Class AbstractEcoreModelQuery<P extends org.eclipse.emf.ecore.EObject,​R>

  • Type Parameters:
    P - the type of the "project", the top-most semantic language unit
    R - IModelQuery search result type
    All Implemented Interfaces:
    IEcoreModelQuery<P,​R>
    Direct Known Subclasses:
    AbstractEcoreModelQuery, EcoreModelQuery

    public abstract class AbstractEcoreModelQuery<P extends org.eclipse.emf.ecore.EObject,​R>
    extends java.lang.Object
    implements IEcoreModelQuery<P,​R>
    An absract implementation of the Ecore model query interface with common helpful functionality.
    Author:
    kroeher, Holger Eichelberger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private CommonXtextEditor<?,​P> currentEditor
      Stores the current XtextEditor from which the XtextResource is used as a basis for parsing the Ecore-model which in turn is used for retrieving elements from.
      private org.eclipse.xtext.resource.XtextResource currentResource
      Stores the current XtextResource that is the basis for parsing the Ecore-model which in turn is used for retrieving elements from.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.eclipse.xtext.nodemodel.ICompositeNode getRootNode​(org.eclipse.xtext.resource.XtextResource resource)
      Returns the ICompositeNode of the Ecore-model that represent the root node.
      protected org.eclipse.xtext.resource.XtextResource getXtextResource​(CommonXtextEditor<?,​P> ivmlEditor)
      Returns the XtextResource currently displayed by the given editor.
      protected static boolean notEmpty​(java.lang.String stringToCheck)
      Checks whether the given String is not null or empty.
      protected static boolean notEmpty​(java.util.List<?> listToCheck)
      Checks whether the given List is not null or empty.
      protected static boolean notEmpty​(org.eclipse.emf.common.util.EList<?> eListToCheck)
      Checks whether the given EList is not null or empty.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • currentResource

        private org.eclipse.xtext.resource.XtextResource currentResource
        Stores the current XtextResource that is the basis for parsing the Ecore-model which in turn is used for retrieving elements from. This attribute is used to avoid parsing the same XtextResource multiple times.
      • currentEditor

        private CommonXtextEditor<?,​P extends org.eclipse.emf.ecore.EObject> currentEditor
        Stores the current XtextEditor from which the XtextResource is used as a basis for parsing the Ecore-model which in turn is used for retrieving elements from. This attribute is used to avoid parsing the same XtextResource multiple times.
    • Constructor Detail

      • AbstractEcoreModelQuery

        public AbstractEcoreModelQuery()
    • Method Detail

      • notEmpty

        protected static boolean notEmpty​(java.lang.String stringToCheck)
        Checks whether the given String is not null or empty.
        Parameters:
        stringToCheck - the String to check
        Returns:
        true if the given String is not null or empty. False otherwise.
      • notEmpty

        protected static boolean notEmpty​(org.eclipse.emf.common.util.EList<?> eListToCheck)
        Checks whether the given EList is not null or empty.
        Parameters:
        eListToCheck - the EList to check
        Returns:
        true if the given EList is not null or empty. False otherwise.
      • notEmpty

        protected static boolean notEmpty​(java.util.List<?> listToCheck)
        Checks whether the given List is not null or empty.
        Parameters:
        listToCheck - the List to check
        Returns:
        true if the given List is not null or empty. False otherwise.
      • getXtextResource

        protected org.eclipse.xtext.resource.XtextResource getXtextResource​(CommonXtextEditor<?,​P> ivmlEditor)
        Returns the XtextResource currently displayed by the given editor. This code for reading the resource is copied from: http://code.google.com/a/eclipselabs.org/p/vclipse/source /browse/trunk/plugins/org.vclipse.base.ui/src/org/vclipse/base/ui/util/EditorUtilsExtensions.java?r=1498
        Parameters:
        ivmlEditor - the XtextEditor from which the resource should be retrieved
        Returns:
        the XtextResource currently displayed by the given editor. May return null if the given editor is null or the resource of that editor cannot be read.
      • getRootNode

        public org.eclipse.xtext.nodemodel.ICompositeNode getRootNode​(org.eclipse.xtext.resource.XtextResource resource)
        Returns the ICompositeNode of the Ecore-model that represent the root node.
        Specified by:
        getRootNode in interface IEcoreModelQuery<P extends org.eclipse.emf.ecore.EObject,​R>
        Parameters:
        resource - the XtextResource from which the root node should be retrieved
        Returns:
        the ICompositeNode of the Ecore-model that represent the root node. May return null if the given resource is null or cannot be parsed