Package org.fife.rsta.ac.js
Class SourceCompletionProvider
java.lang.Object
org.fife.ui.autocomplete.CompletionProviderBase
org.fife.ui.autocomplete.AbstractCompletionProvider
org.fife.ui.autocomplete.DefaultCompletionProvider
org.fife.rsta.ac.js.SourceCompletionProvider
- All Implemented Interfaces:
org.fife.ui.autocomplete.CompletionProvider
public class SourceCompletionProvider
extends org.fife.ui.autocomplete.DefaultCompletionProvider
Completion provider for JavaScript source code (not comments or strings).
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.fife.ui.autocomplete.AbstractCompletionProvider
org.fife.ui.autocomplete.AbstractCompletionProvider.CaseInsensitiveComparator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate JavaScriptEngineprivate JarManagerprivate JavaScriptTypesFactoryprivate Stringprivate List<org.fife.ui.autocomplete.Completion> private JavaScriptCompletionProviderprivate PreProcessingScriptsprivate Stringprivate ShorthandCompletionCacheprivate TypeDeclarationOptionsprivate VariableResolverprivate booleanFields inherited from class org.fife.ui.autocomplete.DefaultCompletionProvider
segFields inherited from class org.fife.ui.autocomplete.AbstractCompletionProvider
comparator, completionsFields inherited from class org.fife.ui.autocomplete.CompletionProviderBase
EMPTY_STRING -
Constructor Summary
ConstructorsConstructorDescriptionSourceCompletionProvider(boolean xmlSupported) SourceCompletionProvider(String javaScriptEngine, boolean xmlSupported) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddShorthandCompletions(Set<org.fife.ui.autocomplete.Completion> set) Adds simple shorthand completions relevant to JavaScript from the shorthand template.voiddebugCodeBlock(CodeBlock block, int tab) findDeclaration(String name) Convenience method to call variable resolverConvenience method to call variable resolver for non-local variables i.e.List<org.fife.ui.autocomplete.Completion> getCompletionsAt(JTextComponent tc, Point p) protected List<org.fife.ui.autocomplete.Completion> getSelf()returns the Base class for the source completion provider.getSourceLocForClass(String className) private List<org.fife.ui.autocomplete.Completion> handleNewFilter(Set<org.fife.ui.autocomplete.Completion> set, String text) protected booleanisValidChar(char ch) booleanprotected CodeBlockiterateAstRoot(org.mozilla.javascript.ast.AstRoot root, Set<org.fife.ui.autocomplete.Completion> set, String entered, int dot, TypeDeclarationOptions options) Iterates through AstRoot to extract all code blocks, functions, variables etc...private voidloadECMAClasses(Set<org.fife.ui.autocomplete.Completion> set, String text) Load ECMA JavaScript class completionsvoidparseDocument(int dot) private voidparseTextAndResolve(Set<org.fife.ui.autocomplete.Completion> set, String text) Parse Text and add completions to setprivate booleanpopulateCompletionsFromType(JavaScriptType type, Set<org.fife.ui.autocomplete.Completion> set) Populate Set of completions if JavaScriptType is not null and return true, otherwise return falseprotected voidrecursivelyAddLocalVars(Set<org.fife.ui.autocomplete.Completion> completions, CodeBlock block, int dot, String text, boolean findMatch, boolean isPreprocessing) Iterate though the CodeBlock and extract all variables within scopeprivate List<org.fife.ui.autocomplete.Completion> resolveCompletions(String text, Set<org.fife.ui.autocomplete.Completion> set) resolveTypeDeclation(String name) Convenience method to call variable resolverresolveTypeFromFunctionNode(org.mozilla.javascript.ast.AstNode functionNode) Get the source of the node and try to resolve function node:voidsetJarManager(JarManager jarManager) The jar manager is used to parse the JS API for function completionsvoidsetJavaScriptEngine(JavaScriptEngine engine) void(package private) voidvoidsetPreProcessingScripts(PreProcessingScripts preProcessing) voidvoidsetShorthandCache(ShorthandCompletionCache shorthandCache) Set template completion cache for source completion provider.voidsetTypeDeclationOptions(TypeDeclarationOptions typeDeclarationOptions) Set type declaration options for parservoidsetXMLSupported(boolean xmlSupported) private booleanMethods inherited from class org.fife.ui.autocomplete.DefaultCompletionProvider
getParameterizedCompletions, init, loadFromXML, loadFromXML, loadFromXML, loadFromXMLMethods inherited from class org.fife.ui.autocomplete.AbstractCompletionProvider
addCompletion, addCompletions, addWordCompletions, checkProviderAndAdd, clear, getCompletionByInputText, removeCompletionMethods inherited from class org.fife.ui.autocomplete.CompletionProviderBase
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, isAutoActivateOkay, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParent
-
Field Details
-
parent
-
jarManager
-
dot
private int dot -
engine
-
javaScriptTypesFactory
-
variableResolver
-
preProcessing
-
shorthandCache
-
xmlSupported
private boolean xmlSupported -
self
-
typeDeclarationOptions
-
lastCompletionsAtText
-
lastParameterizedCompletionsAt
-
-
Constructor Details
-
SourceCompletionProvider
public SourceCompletionProvider(boolean xmlSupported) -
SourceCompletionProvider
-
-
Method Details
-
addShorthandCompletions
Adds simple shorthand completions relevant to JavaScript from the shorthand template.- Parameters:
set- The set to add to.- See Also:
-
setShorthandCache
Set template completion cache for source completion provider.- Parameters:
shorthandCache- The cache to use.
-
getCompletionsAt
- Specified by:
getCompletionsAtin interfaceorg.fife.ui.autocomplete.CompletionProvider- Overrides:
getCompletionsAtin classorg.fife.ui.autocomplete.DefaultCompletionProvider
-
getCompletionsImpl
- Overrides:
getCompletionsImplin classorg.fife.ui.autocomplete.AbstractCompletionProvider
-
handleNewFilter
-
resolveCompletions
-
loadECMAClasses
Load ECMA JavaScript class completions- Parameters:
set- completion settext-
-
getSelf
returns the Base class for the source completion provider. This is represented by a class name or ECMA lookup name e.g. set to 'Global' for server side or 'Window' for client JavaScript support- Returns:
- base class for the completion provider
-
parseTextAndResolve
Parse Text and add completions to set -
populateCompletionsFromType
private boolean populateCompletionsFromType(JavaScriptType type, Set<org.fife.ui.autocomplete.Completion> set) Populate Set of completions if JavaScriptType is not null and return true, otherwise return false -
getAlreadyEnteredText
- Specified by:
getAlreadyEnteredTextin interfaceorg.fife.ui.autocomplete.CompletionProvider- Overrides:
getAlreadyEnteredTextin classorg.fife.ui.autocomplete.DefaultCompletionProvider
-
iterateAstRoot
protected CodeBlock iterateAstRoot(org.mozilla.javascript.ast.AstRoot root, Set<org.fife.ui.autocomplete.Completion> set, String entered, int dot, TypeDeclarationOptions options) Iterates through AstRoot to extract all code blocks, functions, variables etc... e.g. functions, if statements, variables- Parameters:
root- AstRoot to iterateset- add add completions to set (functions only TODO remove this and do elsewhere)entered- already entered textdot- position in codeoptions- Options for the parsing.- Returns:
-
resolveTypeDeclation
Convenience method to call variable resolver- Parameters:
name-- Returns:
-
findDeclaration
Convenience method to call variable resolver- Parameters:
name-- Returns:
- JavaScript variable declaration
-
findNonLocalDeclaration
Convenience method to call variable resolver for non-local variables i.e. does NOT try to resolve name to any local variables (just pre-processed or system)- Parameters:
name-- Returns:
- JavaScript variable declaration
-
resolveTypeFromFunctionNode
Get the source of the node and try to resolve function node:- Parameters:
functionNode-- Returns:
- a.toString().getCharAt(1); returns String TypeDeclaration
-
setParent
-
setJavaScriptTypesFactory
-
getJavaScriptTypesFactory
-
recursivelyAddLocalVars
protected void recursivelyAddLocalVars(Set<org.fife.ui.autocomplete.Completion> completions, CodeBlock block, int dot, String text, boolean findMatch, boolean isPreprocessing) Iterate though the CodeBlock and extract all variables within scope- Parameters:
completions-block-dot-text-findMatch-
-
isValidChar
protected boolean isValidChar(char ch) - Overrides:
isValidCharin classorg.fife.ui.autocomplete.DefaultCompletionProvider
-
setJarManager
The jar manager is used to parse the JS API for function completions- Parameters:
jarManager-
-
getJarManager
-
getVariableResolver
-
getLanguageSupport
-
setPreProcessingScripts
-
getPreProcessingScripts
-
supportsPreProcessingScripts
private boolean supportsPreProcessingScripts() -
getJavaScriptEngine
-
setJavaScriptEngine
-
getSourceLocForClass
-
isXMLSupported
public boolean isXMLSupported() -
setXMLSupported
public void setXMLSupported(boolean xmlSupported) -
setSelf
-
parseDocument
public void parseDocument(int dot) -
getTypesFactory
-
setTypeDeclationOptions
Set type declaration options for parser- Parameters:
typeDeclarationOptions-
-
debugCodeBlock
-