use of org.apache.flex.compiler.internal.scopes.TypeScope in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method collectInterfaceNamespaces.
private void collectInterfaceNamespaces(IInterfaceDefinition interfaceDefinition, Set<INamespaceDefinition> namespaceSet) {
TypeScope typeScope = (TypeScope) interfaceDefinition.getContainedScope();
namespaceSet.addAll(typeScope.getNamespaceSet(currentProject));
IInterfaceDefinition[] interfaceDefinitions = interfaceDefinition.resolveExtendedInterfaces(currentProject);
for (IInterfaceDefinition extendedInterface : interfaceDefinitions) {
collectInterfaceNamespaces(extendedInterface, namespaceSet);
}
}
use of org.apache.flex.compiler.internal.scopes.TypeScope in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method autoCompleteMemberAccess.
private void autoCompleteMemberAccess(IMemberAccessExpressionNode node, CompletionList result) {
ASScope scope = (ASScope) node.getContainingScope().getScope();
IExpressionNode leftOperand = node.getLeftOperandNode();
IDefinition leftDefinition = leftOperand.resolve(currentProject);
if (leftDefinition != null && leftDefinition instanceof ITypeDefinition) {
ITypeDefinition typeDefinition = (ITypeDefinition) leftDefinition;
TypeScope typeScope = (TypeScope) typeDefinition.getContainedScope();
addDefinitionsInTypeScopeToAutoCompleteActionScript(typeScope, scope, true, result);
return;
}
ITypeDefinition leftType = leftOperand.resolveType(currentProject);
if (leftType != null) {
TypeScope typeScope = (TypeScope) leftType.getContainedScope();
addDefinitionsInTypeScopeToAutoCompleteActionScript(typeScope, scope, false, result);
return;
}
if (leftOperand instanceof IMemberAccessExpressionNode) {
IMemberAccessExpressionNode memberAccess = (IMemberAccessExpressionNode) leftOperand;
String packageName = memberAccessToPackageName(memberAccess);
if (packageName != null) {
autoCompleteDefinitions(result, false, false, packageName, null);
return;
}
}
}
use of org.apache.flex.compiler.internal.scopes.TypeScope in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method autoCompleteScope.
private void autoCompleteScope(IScopedNode node, boolean typesOnly, CompletionList result) {
IScopedNode currentNode = node;
ASScope scope = (ASScope) node.getScope();
while (currentNode != null) {
IASScope currentScope = currentNode.getScope();
boolean isType = currentScope instanceof TypeScope;
boolean staticOnly = currentNode == node && isType;
if (currentScope instanceof TypeScope && !typesOnly) {
TypeScope typeScope = (TypeScope) currentScope;
addDefinitionsInTypeScopeToAutoComplete(typeScope, scope, true, true, false, null, result);
if (!staticOnly) {
addDefinitionsInTypeScopeToAutoCompleteActionScript(typeScope, scope, false, result);
}
} else {
for (IDefinition localDefinition : currentScope.getAllLocalDefinitions()) {
if (localDefinition.getBaseName().length() == 0) {
continue;
}
if (typesOnly && !(localDefinition instanceof ITypeDefinition)) {
continue;
}
if (!staticOnly || localDefinition.isStatic()) {
if (localDefinition instanceof ISetterDefinition) {
ISetterDefinition setter = (ISetterDefinition) localDefinition;
IGetterDefinition getter = setter.resolveGetter(currentProject);
if (getter != null) {
//it would add a duplicate entry
continue;
}
}
addDefinitionAutoCompleteActionScript(localDefinition, result);
}
}
}
currentNode = currentNode.getContainingScope();
}
}
use of org.apache.flex.compiler.internal.scopes.TypeScope 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