Package de.gebit.integrity.modelsource
Class DefaultModelSourceExplorer
- java.lang.Object
-
- de.gebit.integrity.modelsource.DefaultModelSourceExplorer
-
- All Implemented Interfaces:
ModelSourceExplorer
public class DefaultModelSourceExplorer extends Object implements ModelSourceExplorer
Default implementation of aModelSourceExplorer.- Author:
- Rene Schneider - initial API and implementation
-
-
Constructor Summary
Constructors Constructor Description DefaultModelSourceExplorer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdetermineSourceFilePath(org.eclipse.emf.ecore.EObject aModelElement)Determines the full path to the source file in which a certain element is defined.protected StringdetermineSourceFilePath(org.eclipse.xtext.nodemodel.ICompositeNode aNode)Finds the source file path for a givenICompositeNodeand cleans it up, removing Xtext-specific stuff and resulting in a clean absolute path.ModelSourceInformationElementdetermineSourceInformation(org.eclipse.emf.ecore.EObject aModelElement)Determines all information about the source of a model element at once.intdetermineSourceLine(org.eclipse.emf.ecore.EObject aModelElement)Finds the line in the original script file at which a certain element starts.protected intdetermineSourceLine(org.eclipse.xtext.nodemodel.ICompositeNode aNode)Finds the line number in the source file matching a givenICompositeNode.StringdetermineSourceSnippet(org.eclipse.emf.ecore.EObject aModelElement)Finds the textual snippet from which a model element was originally parsed.protected StringdetermineSourceSnippet(org.eclipse.xtext.nodemodel.ICompositeNode aNode)Finds the source snippet matching a givenICompositeNode.protected org.eclipse.xtext.nodemodel.ICompositeNodefindNode(org.eclipse.emf.ecore.EObject aModelElement)Finds the node conforming to a given model element.
-
-
-
Method Detail
-
determineSourceFilePath
public String determineSourceFilePath(org.eclipse.emf.ecore.EObject aModelElement)
Description copied from interface:ModelSourceExplorerDetermines the full path to the source file in which a certain element is defined.- Specified by:
determineSourceFilePathin interfaceModelSourceExplorer- Parameters:
aModelElement- the element- Returns:
- the file path
-
determineSourceFilePath
protected String determineSourceFilePath(org.eclipse.xtext.nodemodel.ICompositeNode aNode)
Finds the source file path for a givenICompositeNodeand cleans it up, removing Xtext-specific stuff and resulting in a clean absolute path.- Parameters:
aNode- the node to investigate- Returns:
- the path
-
determineSourceSnippet
public String determineSourceSnippet(org.eclipse.emf.ecore.EObject aModelElement)
Description copied from interface:ModelSourceExplorerFinds the textual snippet from which a model element was originally parsed.- Specified by:
determineSourceSnippetin interfaceModelSourceExplorer- Parameters:
aModelElement- the element- Returns:
- the snippet
-
determineSourceSnippet
protected String determineSourceSnippet(org.eclipse.xtext.nodemodel.ICompositeNode aNode)
Finds the source snippet matching a givenICompositeNode.- Parameters:
aNode- the node to investigate- Returns:
- the source snippet (trimmed)
-
determineSourceLine
public int determineSourceLine(org.eclipse.emf.ecore.EObject aModelElement)
Description copied from interface:ModelSourceExplorerFinds the line in the original script file at which a certain element starts.- Specified by:
determineSourceLinein interfaceModelSourceExplorer- Parameters:
aModelElement- the element- Returns:
- the line number
-
determineSourceLine
protected int determineSourceLine(org.eclipse.xtext.nodemodel.ICompositeNode aNode)
Finds the line number in the source file matching a givenICompositeNode.- Parameters:
aNode- the node to investigate- Returns:
- the line number
-
determineSourceInformation
public ModelSourceInformationElement determineSourceInformation(org.eclipse.emf.ecore.EObject aModelElement)
Description copied from interface:ModelSourceExplorerDetermines all information about the source of a model element at once.- Specified by:
determineSourceInformationin interfaceModelSourceExplorer- Parameters:
aModelElement- the element- Returns:
- the information container
-
findNode
protected org.eclipse.xtext.nodemodel.ICompositeNode findNode(org.eclipse.emf.ecore.EObject aModelElement)
Finds the node conforming to a given model element. This will never return null, but throw anIllegalArgumentExceptioninstead, if no node could be found.- Parameters:
aModelElement- the model element to investigate- Returns:
- the node
-
-