org.stjs.generator
Class GenerationContext<JS>

java.lang.Object
  extended by org.stjs.generator.GenerationContext<JS>
All Implemented Interfaces:
TreePathHolder

public class GenerationContext<JS>
extends Object
implements TreePathHolder

This class can resolve an identifier or a method in the given source context. There is one context create for each generation process.

Author:
Alexandru Craciun

Nested Class Summary
static class GenerationContext.AnnotationCacheKey
           
static class GenerationContext.DummyTree
          this is a dummy try just to have the wrapper thing working for cases where only the element is available
 
Constructor Summary
GenerationContext(File inputFile, GeneratorConfiguration configuration, JavaScriptNameProvider names, com.sun.source.util.Trees trees, ClassLoader builtProjectClassLoader, Map<GenerationContext.AnnotationCacheKey,Object> cacheAnnotations, JavaScriptBuilder<JS> javaScriptBuilder)
           
 
Method Summary
 JavascriptFileGenerationException addError(com.sun.source.tree.Tree tree, String message)
           
<T extends Annotation>
T
getAnnotation(Element element, Class<T> annotationType)
           
 ClassLoader getBuiltProjectClassLoader()
           
 Checks getChecks()
           
 com.sun.source.tree.CompilationUnitTree getCompilationUnit()
           
 GeneratorConfiguration getConfiguration()
           
 com.sun.source.util.TreePath getCurrentPath()
           
<T extends com.sun.source.tree.Tree>
TreeWrapper<T,JS>
getCurrentWrapper()
           
 Elements getElements()
           
 File getInputFile()
           
 JavaScriptNameProvider getNames()
           
 int getStartLine(com.sun.source.tree.Tree tree)
           
 com.sun.source.util.Trees getTrees()
           
 Types getTypes()
           
 JavaScriptBuilder<JS> js()
           
 void setCompilationUnit(com.sun.source.tree.CompilationUnitTree compilationUnit)
           
 void setCurrentPath(com.sun.source.util.TreePath currentPath)
           
 void setElements(Elements elements)
           
 void setTrees(com.sun.source.util.Trees trees)
           
 void setTypes(Types types)
           
 JS withPosition(com.sun.source.tree.Tree tree, JS node)
          add the position of the Java original node in the generated node.
<T extends com.sun.source.tree.Tree>
TreeWrapper<T,JS>
wrap(Element enclosingElement)
           
<T extends com.sun.source.tree.Tree>
TreeWrapper<T,JS>
wrap(com.sun.source.util.TreePath path)
           
 void writeJavaScript(JS astRoot, Writer writer)
           
 void writeSourceMap(Writer sourceMapWriter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenerationContext

public GenerationContext(File inputFile,
                         GeneratorConfiguration configuration,
                         JavaScriptNameProvider names,
                         com.sun.source.util.Trees trees,
                         ClassLoader builtProjectClassLoader,
                         Map<GenerationContext.AnnotationCacheKey,Object> cacheAnnotations,
                         JavaScriptBuilder<JS> javaScriptBuilder)
Method Detail

getInputFile

public File getInputFile()

getConfiguration

public GeneratorConfiguration getConfiguration()

getNames

public JavaScriptNameProvider getNames()

getTrees

public com.sun.source.util.Trees getTrees()

setTrees

public void setTrees(com.sun.source.util.Trees trees)

getCurrentPath

public com.sun.source.util.TreePath getCurrentPath()
Specified by:
getCurrentPath in interface TreePathHolder

setCurrentPath

public void setCurrentPath(com.sun.source.util.TreePath currentPath)
Specified by:
setCurrentPath in interface TreePathHolder

getElements

public Elements getElements()

setElements

public void setElements(Elements elements)

getTypes

public Types getTypes()

setTypes

public void setTypes(Types types)

getChecks

public Checks getChecks()

getCompilationUnit

public com.sun.source.tree.CompilationUnitTree getCompilationUnit()

setCompilationUnit

public void setCompilationUnit(com.sun.source.tree.CompilationUnitTree compilationUnit)

addError

public JavascriptFileGenerationException addError(com.sun.source.tree.Tree tree,
                                                  String message)

withPosition

public JS withPosition(com.sun.source.tree.Tree tree,
                       JS node)
add the position of the Java original node in the generated node.

Parameters:
tree -
node -
Returns:

getStartLine

public int getStartLine(com.sun.source.tree.Tree tree)
Parameters:
tree -
Returns:
the starting line of the given tree node

js

public JavaScriptBuilder<JS> js()

writeJavaScript

public void writeJavaScript(JS astRoot,
                            Writer writer)

writeSourceMap

public void writeSourceMap(Writer sourceMapWriter)
                    throws IOException
Throws:
IOException

getCurrentWrapper

public <T extends com.sun.source.tree.Tree> TreeWrapper<T,JS> getCurrentWrapper()

wrap

public <T extends com.sun.source.tree.Tree> TreeWrapper<T,JS> wrap(com.sun.source.util.TreePath path)

wrap

public <T extends com.sun.source.tree.Tree> TreeWrapper<T,JS> wrap(Element enclosingElement)

getBuiltProjectClassLoader

public ClassLoader getBuiltProjectClassLoader()

getAnnotation

public <T extends Annotation> T getAnnotation(Element element,
                                              Class<T> annotationType)


Copyright © 2014. All Rights Reserved.