Search in sources :

Example 1 with TypeScope

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);
    }
}
Also used : IInterfaceDefinition(org.apache.flex.compiler.definitions.IInterfaceDefinition) TypeScope(org.apache.flex.compiler.internal.scopes.TypeScope)

Example 2 with TypeScope

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;
        }
    }
}
Also used : IASScope(org.apache.flex.compiler.scopes.IASScope) ASScope(org.apache.flex.compiler.internal.scopes.ASScope) ITypeDefinition(org.apache.flex.compiler.definitions.ITypeDefinition) TypeScope(org.apache.flex.compiler.internal.scopes.TypeScope) IExpressionNode(org.apache.flex.compiler.tree.as.IExpressionNode) IDefinition(org.apache.flex.compiler.definitions.IDefinition) IMemberAccessExpressionNode(org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode)

Example 3 with TypeScope

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();
    }
}
Also used : IScopedNode(org.apache.flex.compiler.tree.as.IScopedNode) IASScope(org.apache.flex.compiler.scopes.IASScope) IASScope(org.apache.flex.compiler.scopes.IASScope) ASScope(org.apache.flex.compiler.internal.scopes.ASScope) ITypeDefinition(org.apache.flex.compiler.definitions.ITypeDefinition) ISetterDefinition(org.apache.flex.compiler.definitions.ISetterDefinition) IGetterDefinition(org.apache.flex.compiler.definitions.IGetterDefinition) TypeScope(org.apache.flex.compiler.internal.scopes.TypeScope) IDefinition(org.apache.flex.compiler.definitions.IDefinition)

Example 4 with TypeScope

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);
    }
}
Also used : ICompilationUnit(org.apache.flex.compiler.units.ICompilationUnit) IASScope(org.apache.flex.compiler.scopes.IASScope) IASScope(org.apache.flex.compiler.scopes.IASScope) ASScope(org.apache.flex.compiler.internal.scopes.ASScope) TypeScope(org.apache.flex.compiler.internal.scopes.TypeScope) ConcurrentModificationException(java.util.ConcurrentModificationException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

TypeScope (org.apache.flex.compiler.internal.scopes.TypeScope)4 ASScope (org.apache.flex.compiler.internal.scopes.ASScope)3 IASScope (org.apache.flex.compiler.scopes.IASScope)3 IDefinition (org.apache.flex.compiler.definitions.IDefinition)2 ITypeDefinition (org.apache.flex.compiler.definitions.ITypeDefinition)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1 IGetterDefinition (org.apache.flex.compiler.definitions.IGetterDefinition)1 IInterfaceDefinition (org.apache.flex.compiler.definitions.IInterfaceDefinition)1 ISetterDefinition (org.apache.flex.compiler.definitions.ISetterDefinition)1 IExpressionNode (org.apache.flex.compiler.tree.as.IExpressionNode)1 IMemberAccessExpressionNode (org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode)1 IScopedNode (org.apache.flex.compiler.tree.as.IScopedNode)1 ICompilationUnit (org.apache.flex.compiler.units.ICompilationUnit)1