Package org.fife.rsta.ac.js.ast.parser
Class RhinoJavaScriptAstParser
java.lang.Object
org.fife.rsta.ac.js.ast.parser.JavaScriptParser
org.fife.rsta.ac.js.ast.parser.JavaScriptAstParser
org.fife.rsta.ac.js.ast.parser.RhinoJavaScriptAstParser
Rhino specific JavaScriptAstParser. Reads the importPackage and importClass from the parsed document
and adds to the RhinoJavaScriptTypesFactory.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.fife.rsta.ac.js.ast.parser.JavaScriptAstParser
JavaScriptAstParser.ProcessFunctionType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LinkedHashSet<String> private LinkedHashSet<String> static final StringFields inherited from class org.fife.rsta.ac.js.ast.parser.JavaScriptParser
dot, options, provider -
Constructor Summary
ConstructorsConstructorDescriptionRhinoJavaScriptAstParser(SourceCompletionProvider provider, int dot, TypeDeclarationOptions options) -
Method Summary
Modifier and TypeMethodDescriptionvoidclearImportCache(SourceCompletionProvider provider) Clear the importPackage and importClass cacheconvertAstNodeToCodeBlock(org.mozilla.javascript.ast.AstRoot root, Set<org.fife.ui.autocomplete.Completion> set, String entered) Converts AstRoot to CodeBlockprivate StringextractNameFromSrc(String src) protected voiditerateNode(org.mozilla.javascript.ast.AstNode child, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock block, int offset) Overridden iterateNode to intercept Token.EXPR_RESULT and check for importPackage and importClass named nodes If found, then process them and extract the imports and add them to RhinoJavaScriptTypesFactory then return otherwise call super.iterateNode()private voidmergeImportCache(HashSet<String> packages, HashSet<String> classes) private voidprocessImportClass(String src) Adds class name to RhinoJavaScriptTypesFactoryprivate booleanprocessImportNode(org.mozilla.javascript.ast.AstNode child, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock block, int offset) Look for text importPackage and importClass and add to cacheprivate voidAdds package name to RhinoJavaScriptTypesFactorystatic StringremovePackages(String src) Methods inherited from class org.fife.rsta.ac.js.ast.parser.JavaScriptAstParser
getDot, getProviderMethods inherited from class org.fife.rsta.ac.js.ast.parser.JavaScriptParser
isPreProcessing
-
Field Details
-
PACKAGES
- See Also:
-
importClasses
-
importPackages
-
-
Constructor Details
-
RhinoJavaScriptAstParser
public RhinoJavaScriptAstParser(SourceCompletionProvider provider, int dot, TypeDeclarationOptions options)
-
-
Method Details
-
clearImportCache
Clear the importPackage and importClass cache- Parameters:
provider- SourceCompletionProvider
-
convertAstNodeToCodeBlock
public CodeBlock convertAstNodeToCodeBlock(org.mozilla.javascript.ast.AstRoot root, Set<org.fife.ui.autocomplete.Completion> set, String entered) Description copied from class:JavaScriptParserConverts AstRoot to CodeBlock- Overrides:
convertAstNodeToCodeBlockin classJavaScriptAstParser- Parameters:
root- AstRoot to iterateset- completions setentered- text entered by user- Returns:
- CodeBlock tree
-
mergeImportCache
-
iterateNode
protected void iterateNode(org.mozilla.javascript.ast.AstNode child, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock block, int offset) Overridden iterateNode to intercept Token.EXPR_RESULT and check for importPackage and importClass named nodes If found, then process them and extract the imports and add them to RhinoJavaScriptTypesFactory then return otherwise call super.iterateNode()- Overrides:
iterateNodein classJavaScriptAstParser
-
processImportNode
private boolean processImportNode(org.mozilla.javascript.ast.AstNode child, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock block, int offset) Look for text importPackage and importClass and add to cache- Parameters:
child- AstNode to check. This will always be Token.EXPR_RESULT AstNodeset- Set to add completionsentered- text entered by user if applicableblock- CodeBlockoffset- position of AstNode within document- Returns:
- true if either importPackage or importClass is found
-
removePackages
-
extractNameFromSrc
- Parameters:
src- String to extract name- Returns:
- import statement from withing the ( and ) e.g. importPackage(java.util) importClass(java.util.HashSet) returns java.util or java.util.HashSet respectively
-
processImportPackage
Adds package name to RhinoJavaScriptTypesFactory- Parameters:
src- source text to extract the package
-
processImportClass
Adds class name to RhinoJavaScriptTypesFactory- Parameters:
src- source text to extract the class name
-