Search in sources :

Example 1 with IDefinitionNode

use of org.apache.flex.compiler.tree.as.IDefinitionNode in project vscode-nextgenas by BowlerHatLLC.

the class ActionScriptTextDocumentService method actionScriptRenameWithNode.

private CompletableFuture<WorkspaceEdit> actionScriptRenameWithNode(RenameParams params, IASNode offsetNode) {
    if (offsetNode == null) {
        //we couldn't find a node at the specified location
        return CompletableFuture.completedFuture(new WorkspaceEdit(new HashMap<>()));
    }
    IDefinition definition = null;
    if (offsetNode instanceof IDefinitionNode) {
        IDefinitionNode definitionNode = (IDefinitionNode) offsetNode;
        IExpressionNode expressionNode = definitionNode.getNameExpressionNode();
        definition = expressionNode.resolve(currentProject);
    } else if (offsetNode instanceof IIdentifierNode) {
        IIdentifierNode identifierNode = (IIdentifierNode) offsetNode;
        definition = identifierNode.resolve(currentProject);
    }
    if (definition == null) {
        if (languageClient != null) {
            MessageParams message = new MessageParams();
            message.setType(MessageType.Info);
            message.setMessage("You cannot rename this element.");
            languageClient.showMessage(message);
        }
        return CompletableFuture.completedFuture(new WorkspaceEdit(new HashMap<>()));
    }
    WorkspaceEdit result = renameDefinition(definition, params.getNewName());
    return CompletableFuture.completedFuture(result);
}
Also used : HashMap(java.util.HashMap) MessageParams(org.eclipse.lsp4j.MessageParams) IIdentifierNode(org.apache.flex.compiler.tree.as.IIdentifierNode) WorkspaceEdit(org.eclipse.lsp4j.WorkspaceEdit) IDefinitionNode(org.apache.flex.compiler.tree.as.IDefinitionNode) IDefinition(org.apache.flex.compiler.definitions.IDefinition) IExpressionNode(org.apache.flex.compiler.tree.as.IExpressionNode)

Aggregations

HashMap (java.util.HashMap)1 IDefinition (org.apache.flex.compiler.definitions.IDefinition)1 IDefinitionNode (org.apache.flex.compiler.tree.as.IDefinitionNode)1 IExpressionNode (org.apache.flex.compiler.tree.as.IExpressionNode)1 IIdentifierNode (org.apache.flex.compiler.tree.as.IIdentifierNode)1 MessageParams (org.eclipse.lsp4j.MessageParams)1 WorkspaceEdit (org.eclipse.lsp4j.WorkspaceEdit)1