Package de.gebit.integrity.modelsource
Class DefaultModelSourceExplorer
- java.lang.Object
-
- de.gebit.integrity.modelsource.DefaultModelSourceExplorer
-
- All Implemented Interfaces:
ModelSourceExplorer
public class DefaultModelSourceExplorer extends java.lang.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 java.lang.String
determineSourceFilePath(org.eclipse.emf.ecore.EObject aModelElement)
Determines the full path to the source file in which a certain element is defined.protected java.lang.String
determineSourceFilePath(org.eclipse.xtext.nodemodel.ICompositeNode aNode)
Finds the source file path for a givenICompositeNode
and cleans it up, removing Xtext-specific stuff and resulting in a clean absolute path.ModelSourceInformationElement
determineSourceInformation(org.eclipse.emf.ecore.EObject aModelElement)
Determines all information about the source of a model element at once.int
determineSourceLine(org.eclipse.emf.ecore.EObject aModelElement)
Finds the line in the original script file at which a certain element starts.protected int
determineSourceLine(org.eclipse.xtext.nodemodel.ICompositeNode aNode)
Finds the line number in the source file matching a givenICompositeNode
.java.lang.String
determineSourceSnippet(org.eclipse.emf.ecore.EObject aModelElement)
Finds the textual snippet from which a model element was originally parsed.protected java.lang.String
determineSourceSnippet(org.eclipse.xtext.nodemodel.ICompositeNode aNode)
Finds the source snippet matching a givenICompositeNode
.protected org.eclipse.xtext.nodemodel.ICompositeNode
findNode(org.eclipse.emf.ecore.EObject aModelElement)
Finds the node conforming to a given model element.
-
-
-
Method Detail
-
determineSourceFilePath
public java.lang.String determineSourceFilePath(org.eclipse.emf.ecore.EObject aModelElement)
Description copied from interface:ModelSourceExplorer
Determines the full path to the source file in which a certain element is defined.- Specified by:
determineSourceFilePath
in interfaceModelSourceExplorer
- Parameters:
aModelElement
- the element- Returns:
- the file path
-
determineSourceFilePath
protected java.lang.String determineSourceFilePath(org.eclipse.xtext.nodemodel.ICompositeNode aNode)
Finds the source file path for a givenICompositeNode
and 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 java.lang.String determineSourceSnippet(org.eclipse.emf.ecore.EObject aModelElement)
Description copied from interface:ModelSourceExplorer
Finds the textual snippet from which a model element was originally parsed.- Specified by:
determineSourceSnippet
in interfaceModelSourceExplorer
- Parameters:
aModelElement
- the element- Returns:
- the snippet
-
determineSourceSnippet
protected java.lang.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:ModelSourceExplorer
Finds the line in the original script file at which a certain element starts.- Specified by:
determineSourceLine
in 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:ModelSourceExplorer
Determines all information about the source of a model element at once.- Specified by:
determineSourceInformation
in 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 anIllegalArgumentException
instead, if no node could be found.- Parameters:
aModelElement
- the model element to investigate- Returns:
- the node
-
-