Class JavaScriptCompletionResolver
java.lang.Object
org.fife.rsta.ac.js.resolver.JavaScriptResolver
org.fife.rsta.ac.js.resolver.JavaScriptCompletionResolver
- Direct Known Subclasses:
JSR223JavaScriptCompletionResolver
Compiles the entered text using Rhino and tries to resolve the JavaScriptType
from the AstRoot e.g.
var a = ""; "" --> String JavaScriptType var b =
a.toString() a.toString --> String JavaScriptType
etc.
Note, will resolve any type added to JavaScriptTypesFactory
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate static classVisit all nodes in the AstNode tree and all to a single list -
Field Summary
FieldsFields inherited from class JavaScriptResolver
provider -
Constructor Summary
ConstructorsConstructorDescriptionStandard ECMA JavaScript resolver -
Method Summary
Modifier and TypeMethodDescriptioncompileText(String text) Compiles Text and resolves the type.private JavaScriptTypecreateNewTypeDeclaration(SourceCompletionProvider provider, String type, String text) Creates a new JavaScriptType based on the String typeprotected TypeDeclarationfindJavaStaticType(org.mozilla.javascript.ast.AstNode node) Try to resolve the Token.NAME AstNode and return a TypeDeclarationgetFunctionNameLookup(org.mozilla.javascript.ast.FunctionCall call, SourceCompletionProvider provider) Returns same string format asJavaScriptResolver.getLookupText(JSMethodData, String)but from AstNode FunctiongetLookupText(JSMethodData method, String name) Get lookup string for function completionsprotected JavaScriptTypelookupFromName(org.mozilla.javascript.ast.AstNode node, JavaScriptType lastJavaScriptType) Lookup the name of the node within the last JavaScript type.protected JavaScriptTypelookupFunctionCompletion(org.mozilla.javascript.ast.AstNode node, JavaScriptType lastJavaScriptType) Lookup the function name of the node within the last JavaScript type.private JavaScriptTypelookupJavaScriptType(JavaScriptType lastJavaScriptType, String lookupText) protected TypeDeclarationresolveNativeType(org.mozilla.javascript.ast.AstNode node) Resolve node type to TypeDeclaration N.B called fromCompilerNodeVisitor.visit()resolveNode(org.mozilla.javascript.ast.AstNode node) Resolve node type to TypeDeclaration.resolveParamNode(String text) Resolve node type to TypeDeclaration.protected TypeDeclarationresolveTypeFromLastJavaScriptType(org.mozilla.javascript.ast.AstNode node) Method called if the lastJavaScriptType is not null.protected TypeDeclarationtestJavaStaticType(org.mozilla.javascript.ast.AstNode node) Test whether the node can be resolved as a static Java class.
-
Field Details
-
lastJavaScriptType
-
lastLookupName
-
-
Constructor Details
-
JavaScriptCompletionResolver
Standard ECMA JavaScript resolver- Parameters:
provider-
-
-
Method Details
-
compileText
Compiles Text and resolves the type. e.g. "Hello World".length; //resolve as a Number- Specified by:
compileTextin classJavaScriptResolver- Parameters:
text- to compile and resolve
-
resolveParamNode
Resolve node type to TypeDeclaration. Called instead of #compileText(String text) when document is already parsed- Specified by:
resolveParamNodein classJavaScriptResolver- Parameters:
text- The node to resolve- Returns:
- TypeDeclaration for node or null if not found.
-
resolveNode
Resolve node type to TypeDeclaration. Called instead of #compileText(String text) when document is already parsed- Specified by:
resolveNodein classJavaScriptResolver- Parameters:
node- AstNode to resolve- Returns:
- TypeDeclaration for node or null if not found.
-
resolveNativeType
Resolve node type to TypeDeclaration N.B called fromCompilerNodeVisitor.visit()- Specified by:
resolveNativeTypein classJavaScriptResolver- Parameters:
node- AstNode to resolve- Returns:
- TypeDeclaration for node or null if not found.
-
testJavaStaticType
Test whether the node can be resolved as a static Java class. Only looks for Token.NAME nodes to test- Parameters:
node- node to test- Returns:
- The type declaration.
-
findJavaStaticType
Try to resolve the Token.NAME AstNode and return a TypeDeclaration- Parameters:
node- node to resolve- Returns:
- TypeDeclaration if the name can be resolved as a Java Class else null
-
lookupFromName
protected JavaScriptType lookupFromName(org.mozilla.javascript.ast.AstNode node, JavaScriptType lastJavaScriptType) Lookup the name of the node within the last JavaScript type. e.g. var a = 1; var b = a.MAX_VALUE; looks up MAX_VALUE within NumberLiteral a where a is resolve before as a JavaScript Number;- Parameters:
node-lastJavaScriptType-- Returns:
- The type.
-
lookupFunctionCompletion
protected JavaScriptType lookupFunctionCompletion(org.mozilla.javascript.ast.AstNode node, JavaScriptType lastJavaScriptType) Lookup the function name of the node within the last JavaScript type. e.g. var a = ""; var b = a.toString(); looks up toString() within StringLiteral a where a is resolve before as a JavaScript String;- Parameters:
node-lastJavaScriptType-- Returns:
- The type.
-
getLookupText
Description copied from class:JavaScriptResolverGet lookup string for function completions- Specified by:
getLookupTextin classJavaScriptResolver- Parameters:
method- JSMethodData holding method informationname- name of method- Returns:
- The lookup text.
-
getFunctionNameLookup
public String getFunctionNameLookup(org.mozilla.javascript.ast.FunctionCall call, SourceCompletionProvider provider) Description copied from class:JavaScriptResolverReturns same string format asJavaScriptResolver.getLookupText(JSMethodData, String)but from AstNode Function- Specified by:
getFunctionNameLookupin classJavaScriptResolver- Parameters:
call-provider-- Returns:
- The function name.
-
lookupJavaScriptType
-
createNewTypeDeclaration
private JavaScriptType createNewTypeDeclaration(SourceCompletionProvider provider, String type, String text) Creates a new JavaScriptType based on the String type- Parameters:
provider- SourceCompletionProvidertype- type of JavaScript type to create e.g. java.sql.Connectiontext- Text entered from the user to resolve the node. This will be null if resolveNode(AstNode node) is called- Returns:
-
resolveTypeFromLastJavaScriptType
protected TypeDeclaration resolveTypeFromLastJavaScriptType(org.mozilla.javascript.ast.AstNode node) Method called if the lastJavaScriptType is not null. i.e. has gone through one iteration at least. Resolves TypeDeclaration for parts of a variable past the first part. e.g. "".toString() //resolve toString() In some circumstances this is useful to resolve this. e.g. for Custom Object completions- Parameters:
node- Node to resolve- Returns:
- Type Declaration
-