org.eclipse.mtl.ide.ui.editors.template
Class MTLSourceContent

java.lang.Object
  extended by org.eclipse.mtl.ide.ui.editors.template.MTLSourceContent

public class MTLSourceContent
extends java.lang.Object

The source content (i.e the semantic content for the template editor). It can create a CST model and it is able to do an incremental parsing of the text. You have to initialize the content with the method init.


Constructor Summary
MTLSourceContent()
          Constructor.
 
Method Summary
 void createCST()
          Creates a CST model.
 java.util.List<org.eclipse.emf.common.util.URI> getAccessibleOutputFiles()
          Gets all the accessible output files (EMTL) of this project.
 Module getCST()
          Gets the current CST model.
 CSTNode getCSTNode(int posBegin, int posEnd)
          Gets the nearest CST node at the given position.
 CSTNode getCSTParent(CSTNode node, java.lang.Class c)
          Gets the CST parent of the given type.
 org.eclipse.core.resources.IFile getFile()
          Gets the MTL file.
 java.util.List<org.eclipse.ocl.helper.Choice> getSyntaxHelp(java.lang.String text, int offset)
          Obtains syntax completion choices for the specified fragment of an OCL expression.
 java.lang.String getText()
          Returns the text of the source.
 java.util.List<org.eclipse.emf.ecore.EClassifier> getTypes()
          Gets the meta-model types.
 void init(java.lang.StringBuffer text)
          It initializes the template content with the given text.
 void init(java.lang.StringBuffer text, org.eclipse.core.resources.IFile aFile)
          It initializes the template content with the given text and the corresponding file.
 CSTNode updateCST(int posBegin, int posEnd, java.lang.String newText)
          Computes a delta version of the CST model, and returns the modified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MTLSourceContent

public MTLSourceContent()
Constructor.

Method Detail

getCST

public Module getCST()
Gets the current CST model. It returns 'null', if createCST hasn't been called.

Returns:
the current CST model

getFile

public org.eclipse.core.resources.IFile getFile()
Gets the MTL file. It can be null if the file hasn't been specified.

Returns:
the MTL file, or null

init

public void init(java.lang.StringBuffer text)
It initializes the template content with the given text. The file and the project won't be specified.

Parameters:
text - is the content of the document

init

public void init(java.lang.StringBuffer text,
                 org.eclipse.core.resources.IFile aFile)
It initializes the template content with the given text and the corresponding file.

Parameters:
text - is the content of the document
aFile - is a file, can be null

createCST

public void createCST()
Creates a CST model. You can get it with the method getCST.


updateCST

public CSTNode updateCST(int posBegin,
                         int posEnd,
                         java.lang.String newText)
Computes a delta version of the CST model, and returns the modified object. This object will be refreshed in the outline view.

Parameters:
posBegin - the beginning index, inclusive
posEnd - the ending index, exclusive
newText - the string that will replace previous contents
Returns:
the modified object

getCSTNode

public CSTNode getCSTNode(int posBegin,
                          int posEnd)
Gets the nearest CST node at the given position.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
Returns:
the nearest CST node

getCSTParent

public CSTNode getCSTParent(CSTNode node,
                            java.lang.Class c)
Gets the CST parent of the given type. It browses the ancestors of the given node and returns the nearest valid parent if it exists.

Parameters:
node - is the current node
c - is the class which represents the type of the parent to search
Returns:
the CST parent, or null if it doesn't exist

getSyntaxHelp

public java.util.List<org.eclipse.ocl.helper.Choice> getSyntaxHelp(java.lang.String text,
                                                                   int offset)
Obtains syntax completion choices for the specified fragment of an OCL expression.

Parameters:
text - a partial OCL expression for which to seek choices that could be appended to it
offset - is the current offset in the text
Returns:
a list of Choices, possibly empty. The ordering of the list may or may not indicate relative relevance or frequency of a choice

getTypes

public java.util.List<org.eclipse.emf.ecore.EClassifier> getTypes()
Gets the meta-model types.

Returns:
the meta-model objects, or an empty list

getAccessibleOutputFiles

public java.util.List<org.eclipse.emf.common.util.URI> getAccessibleOutputFiles()
Gets all the accessible output files (EMTL) of this project. It means the files of the project and the files of the required plugins.

Returns:
the URIs of the output files, there are 'plugin' URIs and 'workspace' URIs...

getText

public java.lang.String getText()
Returns the text of the source.

Returns:
the text of the source

Copyright 2008 Obeo
All Rights Reserved.