Search in sources :

Example 11 with IMXMLTagData

use of org.apache.flex.compiler.mxml.IMXMLTagData in project vscode-nextgenas by BowlerHatLLC.

the class ActionScriptTextDocumentService method getDefinitionForMXMLTag.

private IDefinition getDefinitionForMXMLTag(IMXMLTagData tag) {
    if (tag == null) {
        return null;
    }
    IDefinition offsetDefinition = currentProject.resolveXMLNameToDefinition(tag.getXMLName(), tag.getMXMLDialect());
    if (offsetDefinition != null) {
        return offsetDefinition;
    }
    if (tag.getXMLName().getXMLNamespace().equals(tag.getMXMLDialect().getLanguageNamespace())) {
        for (String typeName : LANGUAGE_TYPE_NAMES) {
            if (tag.getShortName().equals(typeName)) {
                return currentProject.resolveQNameToDefinition(typeName);
            }
        }
    }
    IMXMLTagData parentTag = tag.getParentTag();
    if (parentTag == null) {
        return null;
    }
    IDefinition parentDefinition = currentProject.resolveXMLNameToDefinition(parentTag.getXMLName(), parentTag.getMXMLDialect());
    if (parentDefinition == null || !(parentDefinition instanceof IClassDefinition)) {
        return null;
    }
    IClassDefinition classDefinition = (IClassDefinition) parentDefinition;
    return currentProject.resolveSpecifier(classDefinition, tag.getShortName());
}
Also used : IClassDefinition(org.apache.flex.compiler.definitions.IClassDefinition) IMXMLTagData(org.apache.flex.compiler.mxml.IMXMLTagData) IDefinition(org.apache.flex.compiler.definitions.IDefinition)

Example 12 with IMXMLTagData

use of org.apache.flex.compiler.mxml.IMXMLTagData in project vscode-nextgenas by BowlerHatLLC.

the class ActionScriptTextDocumentService method references.

/**
     * Finds all references of the definition referenced at the current position
     * in a text document. Does not necessarily get called where a definition is
     * defined, but may be at one of the references.
     */
@Override
public CompletableFuture<List<? extends Location>> references(ReferenceParams params) {
    String textDocumentUri = params.getTextDocument().getUri();
    if (!textDocumentUri.endsWith(AS_EXTENSION) && !textDocumentUri.endsWith(MXML_EXTENSION)) {
        return CompletableFuture.completedFuture(Collections.emptyList());
    }
    IMXMLTagData offsetTag = getOffsetMXMLTag(params);
    if (offsetTag != null) {
        IASNode embeddedNode = getEmbeddedActionScriptNodeInMXMLTag(offsetTag, currentOffset, params.getTextDocument(), params.getPosition());
        if (embeddedNode != null) {
            return actionScriptReferencesWithNode(params, embeddedNode);
        }
        //so that's why we call isMXMLTagValidForCompletion()
        if (isMXMLTagValidForCompletion(offsetTag)) {
            return mxmlReferences(params, offsetTag);
        }
    }
    return actionScriptReferences(params);
}
Also used : IASNode(org.apache.flex.compiler.tree.as.IASNode) IMXMLTagData(org.apache.flex.compiler.mxml.IMXMLTagData)

Aggregations

IMXMLTagData (org.apache.flex.compiler.mxml.IMXMLTagData)12 IASNode (org.apache.flex.compiler.tree.as.IASNode)8 IDefinition (org.apache.flex.compiler.definitions.IDefinition)5 IClassDefinition (org.apache.flex.compiler.definitions.IClassDefinition)4 IMXMLTagAttributeData (org.apache.flex.compiler.mxml.IMXMLTagAttributeData)4 ArrayList (java.util.ArrayList)3 MXMLData (org.apache.flex.compiler.internal.mxml.MXMLData)3 IMXMLDataManager (org.apache.flex.compiler.mxml.IMXMLDataManager)3 IIdentifierNode (org.apache.flex.compiler.tree.as.IIdentifierNode)3 ICompilationUnit (org.apache.flex.compiler.units.ICompilationUnit)3 CompletionList (org.eclipse.lsp4j.CompletionList)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ConcurrentModificationException (java.util.ConcurrentModificationException)2 HashMap (java.util.HashMap)2 ISourceLocation (org.apache.flex.compiler.common.ISourceLocation)2 IEventDefinition (org.apache.flex.compiler.definitions.IEventDefinition)2 SWCCompilationUnit (org.apache.flex.compiler.internal.units.SWCCompilationUnit)2 WorkspaceEdit (org.eclipse.lsp4j.WorkspaceEdit)2 StringReader (java.io.StringReader)1