Class AtlOccurrencesFinder

java.lang.Object
org.eclipse.m2m.atl.adt.ui.editor.AtlOccurrencesFinder
All Implemented Interfaces:
IOccurrencesFinder

public class AtlOccurrencesFinder extends Object implements IOccurrencesFinder
This class allows us to look into the model for the occurrence of the selected word (if there are). Several problems are encountered:
  • while the model isn't saved, the finder looks into the old model
  • if there is an error in the model, the finder cannot go through it, and can only find occurrences before the error
  • see also the query todo
  • Constructor Details

    • AtlOccurrencesFinder

      public AtlOccurrencesFinder(AtlEditor editor, org.eclipse.jface.text.IDocument document)
  • Method Details

    • initialize

      public String initialize(org.eclipse.jface.text.IRegion selection)
      Initialization of the finder, with a text selection.
      Parameters:
      selection - the current text selection
      Returns:
      always null (this is not used here)
    • getJobLabel

      public String getJobLabel()
      Specified by:
      getJobLabel in interface IOccurrencesFinder
    • getUnformattedPluralLabel

      public String getUnformattedPluralLabel()
      Description copied from interface: IOccurrencesFinder
      Returns the plural label for this finder with 3 placeholders:
      • {0} for the element name
      • {1} for the number of results found
      • {2} for the scope (name of the compilation unit)
      Specified by:
      getUnformattedPluralLabel in interface IOccurrencesFinder
      Returns:
      the unformatted label
    • getUnformattedSingularLabel

      public String getUnformattedSingularLabel()
      Description copied from interface: IOccurrencesFinder
      Returns the singular label for this finder with 2 placeholders:
      • {0} for the element name
      • {1} for the scope (name of the compilation unit)
      Specified by:
      getUnformattedSingularLabel in interface IOccurrencesFinder
      Returns:
      the unformatted label
    • getElementName

      public String getElementName()
      Description copied from interface: IOccurrencesFinder
      Returns the name of the element to look for or null if the finder hasn't been initialized yet.
      Specified by:
      getElementName in interface IOccurrencesFinder
      Returns:
      the name of the element
    • getOccurrences

      public IOccurrencesFinder.OccurrenceLocation[] getOccurrences()
      Returns the occurrences
      Specified by:
      getOccurrences in interface IOccurrencesFinder
      Returns:
      the occurrences
      See Also:
    • eGet

      public static Object eGet(org.eclipse.emf.ecore.EObject self, String featureName)
      Returns the value of a feature on an EObject.
      Parameters:
      self - the EObject
      featureName - the feature name
      Returns:
      the feature value
    • oclIsKindOf

      public static boolean oclIsKindOf(org.eclipse.emf.ecore.EObject element, String testedElementName)
      Equivalent of ASMOclAny oclIsKindOf method for EObjects.
      Parameters:
      element - the tested element
      testedElementName - the type name
      Returns:
      True element has testedElementName in its superTypes, False else.
    • getRegionFromElement

      public org.eclipse.jface.text.IRegion getRegionFromElement(org.eclipse.emf.ecore.EObject element) throws org.eclipse.jface.text.BadLocationException
      Gets the region of the element (actually, it gives the region of the word that is interesting for us in the expression given by the element.
      Parameters:
      element - the expression we want to extract the word
      Returns:
      the region of the interesting word of the given element
      Throws:
      org.eclipse.jface.text.BadLocationException
    • browseModel

      public void browseModel(org.eclipse.emf.ecore.EObject element, String name, String featureName, String declarationType, String useType, String displayType) throws org.eclipse.jface.text.BadLocationException
      Browses the model in order to find occurrences of an element and add it to the result list.
      Parameters:
      element - the element we want the occurrences from
      name - the name of the element we are looking for
      featureName - the name of the feature that allows us to find the name of the current navigated element
      declarationType - the type of the element that will be considered as "declaration" (different highlighting)
      useType - the type of the element that will be considered as "occurrence" (different highlighting)
      displayType - the type that is going to be displayed in the eclipse marker
      Throws:
      org.eclipse.jface.text.BadLocationException
    • browseModelForType

      public void browseModelForType(org.eclipse.emf.ecore.EObject element, String name) throws org.eclipse.jface.text.BadLocationException
      Browses the model in order to find occurrences of a type and add it to the result list.
      Parameters:
      element - the type
      name - the name of the type
      Throws:
      org.eclipse.jface.text.BadLocationException
    • getSearchKind

      public int getSearchKind()
      Specified by:
      getSearchKind in interface IOccurrencesFinder
    • getID

      public String getID()
      Description copied from interface: IOccurrencesFinder
      Returns the id of this finder.
      Specified by:
      getID in interface IOccurrencesFinder
      Returns:
      returns the id of this finder.