use of org.apache.flex.compiler.scopes.IASScope in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method classDefinitionToConstructor.
private IFunctionDefinition classDefinitionToConstructor(IClassDefinition definition) {
IASScope scope = definition.getContainedScope();
Collection<IDefinition> definitions = scope.getAllLocalDefinitions();
for (IDefinition localDefinition : definitions) {
if (localDefinition instanceof IFunctionDefinition) {
IFunctionDefinition functionDefinition = (IFunctionDefinition) localDefinition;
if (functionDefinition.isConstructor()) {
return functionDefinition;
}
}
}
return null;
}
use of org.apache.flex.compiler.scopes.IASScope in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method documentSymbol.
/**
* Searches by name for a symbol in a specific document (not the whole
* workspace)
*/
@Override
public CompletableFuture<List<? extends SymbolInformation>> documentSymbol(DocumentSymbolParams params) {
TextDocumentIdentifier textDocument = params.getTextDocument();
Path path = LanguageServerUtils.getPathFromLanguageServerURI(textDocument.getUri());
if (path == null) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
ICompilationUnit unit = getCompilationUnit(path);
if (unit == null) {
//we couldn't find a compilation unit with the specified path
return CompletableFuture.completedFuture(Collections.emptyList());
}
IASScope[] scopes;
try {
scopes = unit.getFileScopeRequest().get().getScopes();
} catch (Exception e) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
List<SymbolInformation> result = new ArrayList<>();
for (IASScope scope : scopes) {
scopeToSymbols(scope, result);
}
return CompletableFuture.completedFuture(result);
}
use of org.apache.flex.compiler.scopes.IASScope in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method workspaceSymbol.
/**
* Searches by name for a symbol in the workspace.
*/
public CompletableFuture<List<? extends SymbolInformation>> workspaceSymbol(WorkspaceSymbolParams params) {
if (compilationUnits == null) {
//if we haven't successfully compiled the project, we can't do this
return CompletableFuture.completedFuture(Collections.emptyList());
}
List<SymbolInformation> result = new ArrayList<>();
String query = params.getQuery();
for (ICompilationUnit unit : compilationUnits) {
if (unit == null || unit instanceof SWCCompilationUnit) {
continue;
}
IASScope[] scopes;
try {
scopes = unit.getFileScopeRequest().get().getScopes();
} catch (Exception e) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
for (IASScope scope : scopes) {
querySymbolsInScope(query, scope, result);
}
}
return CompletableFuture.completedFuture(result);
}
use of org.apache.flex.compiler.scopes.IASScope in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method addMembersForMXMLTypeToAutoComplete.
private void addMembersForMXMLTypeToAutoComplete(IClassDefinition definition, IMXMLTagData offsetTag, boolean includePrefix, CompletionList result) {
ICompilationUnit unit = getCompilationUnit(Paths.get(offsetTag.getSourcePath()));
if (unit == null) {
return;
}
IASScope[] scopes;
try {
scopes = unit.getFileScopeRequest().get().getScopes();
} catch (Exception e) {
return;
}
if (scopes != null && scopes.length > 0) {
String propertyElementPrefix = null;
if (includePrefix) {
String prefix = offsetTag.getPrefix();
if (prefix.length() > 0) {
propertyElementPrefix = prefix;
}
}
TypeScope typeScope = (TypeScope) definition.getContainedScope();
ASScope scope = (ASScope) scopes[0];
addDefinitionsInTypeScopeToAutoCompleteMXML(typeScope, scope, propertyElementPrefix, result);
addStyleMetadataToAutoCompleteMXML(typeScope, propertyElementPrefix, result);
addEventMetadataToAutoCompleteMXML(typeScope, propertyElementPrefix, result);
}
}
Aggregations