org.eclipse.wst.jsdt.web.core.javascript
Class JsTranslation

java.lang.Object
  extended by org.eclipse.wst.jsdt.web.core.javascript.JsTranslation
All Implemented Interfaces:
IJsTranslation

public class JsTranslation
extends java.lang.Object
implements IJsTranslation

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.


Constructor Summary
JsTranslation()
           
 
Method Summary
 void classpathChange()
          notify the translation to update any external dependancies that are created during translation
 java.lang.String fixupMangledName(java.lang.String displayString)
          fixes a mangled html--> pure js name.
 IJavaScriptElement[] getAllElementsInJsRange(int javaPositionStart, int javaPositionEnd)
           
 IJavaScriptUnit getCompilationUnit()
           
 java.lang.String getDirectoryUnderRoot()
           
 IJavaScriptElement[] getElementsFromJsRange(int javaPositionStart, int javaPositionEnd)
           
 IFile getFile()
           
 IDocument getHtmlDocument()
           
 java.lang.String getHtmlText()
           
 IJsTranslation getInstance(IStructuredDocument htmlDocument, IJavaScriptProject javaProj, boolean listenForChanges)
           
 java.lang.String getJavaPath()
           
 IJavaScriptProject getJavaProject()
           
 IJavaScriptElement getJsElementAtOffset(int jsOffset)
           
 java.lang.String getJsText()
           
 java.lang.String getMangledName()
           
 int getMissingTagStart()
           
 java.util.List getProblems()
           
 Position[] getScriptPositions()
           
 IJsTranslator getTranslator()
           
 WorkingCopyOwner getWorkingCopyOwner()
           
 boolean ifOffsetInImportNode(int offset)
           
 void insertInFirstScriptRegion(java.lang.String text)
           
 void insertScript(int offset, java.lang.String text)
          insert javascript at the given offset.
 void reconcileCompilationUnit()
          checks the CU for errors/consistancy.
 void release()
          release the translation.
 void setProblemCollectingActive(boolean collect)
          start/stop collecting problems within the javascript unit.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsTranslation

public JsTranslation()
Method Detail

getTranslator

public IJsTranslator getTranslator()

getInstance

public IJsTranslation getInstance(IStructuredDocument htmlDocument,
                                  IJavaScriptProject javaProj,
                                  boolean listenForChanges)
Specified by:
getInstance in interface IJsTranslation
Returns:

getJavaProject

public IJavaScriptProject getJavaProject()
Specified by:
getJavaProject in interface IJsTranslation
Returns:
IJavaScriptProject that this translation belongs to

getFile

public IFile getFile()

getHtmlDocument

public IDocument getHtmlDocument()
Specified by:
getHtmlDocument in interface IJsTranslation
Returns:
Original HTML document from the translation.

getMissingTagStart

public int getMissingTagStart()
Specified by:
getMissingTagStart in interface IJsTranslation
Returns:
integer position of a missing tag (the document isn't well formed and resulted in translation error.).

getDirectoryUnderRoot

public java.lang.String getDirectoryUnderRoot()

fixupMangledName

public java.lang.String fixupMangledName(java.lang.String displayString)
Description copied from interface: IJsTranslation
fixes a mangled html--> pure js name.

Specified by:
fixupMangledName in interface IJsTranslation
Returns:

getAllElementsInJsRange

public IJavaScriptElement[] getAllElementsInJsRange(int javaPositionStart,
                                                    int javaPositionEnd)
Specified by:
getAllElementsInJsRange in interface IJsTranslation
Returns:
all javascript elements within the given range

getCompilationUnit

public IJavaScriptUnit getCompilationUnit()
Specified by:
getCompilationUnit in interface IJsTranslation
Returns:
the javascript unit from the jsdt.core

getElementsFromJsRange

public IJavaScriptElement[] getElementsFromJsRange(int javaPositionStart,
                                                   int javaPositionEnd)
Specified by:
getElementsFromJsRange in interface IJsTranslation
Returns:

getHtmlText

public java.lang.String getHtmlText()
Specified by:
getHtmlText in interface IJsTranslation
Returns:
string of the document.

getJavaPath

public java.lang.String getJavaPath()
Specified by:
getJavaPath in interface IJsTranslation
Returns:

getJsElementAtOffset

public IJavaScriptElement getJsElementAtOffset(int jsOffset)
Specified by:
getJsElementAtOffset in interface IJsTranslation
Returns:
a single javascript element at the given offset.

getJsText

public java.lang.String getJsText()
Specified by:
getJsText in interface IJsTranslation
Returns:
only the translated javascript text

getScriptPositions

public Position[] getScriptPositions()
Specified by:
getScriptPositions in interface IJsTranslation
Returns:
a list of the script regions within the translation.

insertInFirstScriptRegion

public void insertInFirstScriptRegion(java.lang.String text)
Specified by:
insertInFirstScriptRegion in interface IJsTranslation

insertScript

public void insertScript(int offset,
                         java.lang.String text)
Description copied from interface: IJsTranslation
insert javascript at the given offset. method should ensure the documents well-formedness and proper script region.

Specified by:
insertScript in interface IJsTranslation

getMangledName

public java.lang.String getMangledName()

getProblems

public java.util.List getProblems()
Specified by:
getProblems in interface IJsTranslation
Returns:
a list of javascript errors

getWorkingCopyOwner

public WorkingCopyOwner getWorkingCopyOwner()

ifOffsetInImportNode

public boolean ifOffsetInImportNode(int offset)
Specified by:
ifOffsetInImportNode in interface IJsTranslation
Returns:
if the offset is within a script import node.

reconcileCompilationUnit

public void reconcileCompilationUnit()
Description copied from interface: IJsTranslation
checks the CU for errors/consistancy.

Specified by:
reconcileCompilationUnit in interface IJsTranslation

release

public void release()
Description copied from interface: IJsTranslation
release the translation. always a good idea to do when you're done. you may notice document and model locks if not.

Specified by:
release in interface IJsTranslation

setProblemCollectingActive

public void setProblemCollectingActive(boolean collect)
Description copied from interface: IJsTranslation
start/stop collecting problems within the javascript unit.

Specified by:
setProblemCollectingActive in interface IJsTranslation

classpathChange

public void classpathChange()
Description copied from interface: IJsTranslation
notify the translation to update any external dependancies that are created during translation

Specified by:
classpathChange in interface IJsTranslation