Class JavaScriptAstParser
java.lang.Object
org.fife.rsta.ac.js.ast.parser.JavaScriptParser
org.fife.rsta.ac.js.ast.parser.JavaScriptAstParser
- Direct Known Subclasses:
RhinoJavaScriptAstParser
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class JavaScriptParser
dot, options, provider -
Constructor Summary
ConstructorsConstructorDescriptionJavaScriptAstParser(SourceCompletionProvider provider, int dot, TypeDeclarationOptions options) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddCodeBlock(org.mozilla.javascript.Node parent, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock codeBlock, int offset) for each child of parent AstNode add a new code block and add completions for each block of codeprivate voidaddVariableToResolver(org.mozilla.javascript.ast.AstNode name, org.mozilla.javascript.ast.AstNode target, CodeBlock block, int offset) private booleancanAddVariable(CodeBlock block) private booleancanProcessNode(org.mozilla.javascript.ast.AstNode node) convertAstNodeToCodeBlock(org.mozilla.javascript.ast.AstRoot root, Set<org.fife.ui.autocomplete.Completion> set, String entered) Converts AstRoot to CodeBlockprivate JavaScriptFunctionDeclarationcreateJavaScriptFunction(String lookupName, int offset, CodeBlock block, TypeDeclaration returnType, org.mozilla.javascript.ast.FunctionNode fn) private voidextractVariableForForEach(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode iteratedObject) Extract variable for each in loop.private voidextractVariableForForIn(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode iteratedObject) Extract variable for in loop.private JavaScriptVariableDeclarationextractVariableFromNode(org.mozilla.javascript.ast.AstNode node, CodeBlock block, int offset) Extract the variable from the Rhino node and add to the CodeBlockprivate JavaScriptVariableDeclarationextractVariableFromNode(org.mozilla.javascript.ast.AstNode node, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode initializer) Extract the variable from the Rhino node and add to the CodeBlockprivate voidextractVariableFromNode(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset) Extract the variable from the Variable initializer and set the TypeintgetDot()private TypeDeclarationgetFunctionType(org.mozilla.javascript.ast.FunctionNode fn) protected voiditerateNode(org.mozilla.javascript.ast.AstNode child, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock block, int offset) private voidprocessCaseNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) private voidprocessDoNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract while loop from node and add new code blockprivate voidprocessExpressionNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract completions from expression nodeprivate voidprocessExpressionStatement(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) private voidprocessForNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract code fromToken.FORand add completions, then parse body of for-loop.private voidprocessFunctionNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Add function to completions set and extract local variables to add to code block TODO: functions can have local scope, so add function to it's own codeblock when applicableprivate voidprocessIfThenElse(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract variables from if/else node(s)private voidprocessInfix(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract variable from binary operator e.g.private voidprocessSwitchNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract local variables from switch node*private voidprocessTryCatchNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract variables from try/catch node(s)private voidprocessVariableNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract variable from node and add to code blockprivate voidprocessWhileNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Extract while loop from node and add new code blockprivate voidreassignVariable(org.mozilla.javascript.ast.AstNode assign, CodeBlock block, int locationOffSet) private voidMethods inherited from class JavaScriptParser
isPreProcessing
-
Field Details
-
functions
-
-
Constructor Details
-
JavaScriptAstParser
public JavaScriptAstParser(SourceCompletionProvider provider, int dot, TypeDeclarationOptions options)
-
-
Method Details
-
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- Specified by:
convertAstNodeToCodeBlockin classJavaScriptParser- Parameters:
root- AstRoot to iterateset- completions setentered- text entered by user- Returns:
- CodeBlock tree
-
setFunctionValues
private void setFunctionValues() -
addCodeBlock
private void addCodeBlock(org.mozilla.javascript.Node parent, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock codeBlock, int offset) for each child of parent AstNode add a new code block and add completions for each block of code- Parameters:
parent- AstNode to iterate childrenset- completions set to add toentered- Text enteredcodeBlock- parent CodeBlockoffset- codeblock offset
-
iterateNode
-
processExpressionStatement
-
reassignVariable
private void reassignVariable(org.mozilla.javascript.ast.AstNode assign, CodeBlock block, int locationOffSet) -
addVariableToResolver
private void addVariableToResolver(org.mozilla.javascript.ast.AstNode name, org.mozilla.javascript.ast.AstNode target, CodeBlock block, int offset) -
processCaseNode
-
processSwitchNode
-
processTryCatchNode
-
processIfThenElse
-
processExpressionNode
-
processWhileNode
-
processDoNode
-
processInfix
-
processFunctionNode
private void processFunctionNode(org.mozilla.javascript.Node child, CodeBlock block, Set<org.fife.ui.autocomplete.Completion> set, String entered, int offset) Add function to completions set and extract local variables to add to code block TODO: functions can have local scope, so add function to it's own codeblock when applicable -
createJavaScriptFunction
private JavaScriptFunctionDeclaration createJavaScriptFunction(String lookupName, int offset, CodeBlock block, TypeDeclaration returnType, org.mozilla.javascript.ast.FunctionNode fn) -
canProcessNode
private boolean canProcessNode(org.mozilla.javascript.ast.AstNode node) -
getFunctionType
-
processVariableNode
-
processForNode
-
extractVariableFromNode
private void extractVariableFromNode(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset) Extract the variable from the Variable initializer and set the Type- Parameters:
initializer- AstNode from which to extract the variableblock- code block to add the variable toooffset- position of the variable in code
-
extractVariableForForEach
private void extractVariableForForEach(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode iteratedObject) Extract variable for each in loop. If the iteratedObject is an Array, then resolve the variable to the array type otherwise set to iterator object type- Parameters:
initializer-block-offset-iteratedObject-
-
extractVariableForForIn
private void extractVariableForForIn(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode iteratedObject) Extract variable for in loop. If the iteratedObject is an Array, then assume the variable to be a number otherwise do not attempt to resolve- Parameters:
initializer-block-offset-iteratedObject-
-
canAddVariable
-
extractVariableFromNode
private JavaScriptVariableDeclaration extractVariableFromNode(org.mozilla.javascript.ast.AstNode node, CodeBlock block, int offset) Extract the variable from the Rhino node and add to the CodeBlock- Parameters:
node- AstNode node from which to extract the variableblock- code block to add the variable toooffset- position of the variable in code
-
extractVariableFromNode
private JavaScriptVariableDeclaration extractVariableFromNode(org.mozilla.javascript.ast.AstNode node, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode initializer) Extract the variable from the Rhino node and add to the CodeBlock- Parameters:
node- AstNode node from which to extract the variableblock- code block to add the variable toooffset- position of the variable in codeinitializer- node associated with variable
-
getProvider
-
getDot
public int getDot()
-