Java Code Examples for com.intellij.lang.ASTNode

The following are top voted examples for showing how to use com.intellij.lang.ASTNode. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: greycat-idea-plugin   File: GCMFoldingBuilder.java   Source Code and License 6 votes vote down vote up
private void appendDescriptors(final ASTNode node, final Document document, final List<FoldingDescriptor> descriptors) {
    if (node.getElementType() == GCMTypes.CLASS_DECLARATION || node.getElementType() == GCMTypes.CUSTOM_TYPE_DECLARATION) {
        TextRange fullRange = node.getTextRange();
        if (fullRange.getEndOffset() - fullRange.getStartOffset() > 0) {

            try {
                int startOffset = fullRange.getStartOffset() + document.getText(fullRange).indexOf("{") + 1;
                int endOffset = fullRange.getEndOffset() - 1;
                if (startOffset < endOffset) {
                    TextRange shortRange = new TextRange(startOffset, fullRange.getEndOffset() - 1);
                    if (shortRange.getEndOffset() - shortRange.getStartOffset() > 1) {
                        descriptors.add(new FoldingDescriptor(node, shortRange));
                    }
                }
            } catch (Throwable e) {

            }
        }
    }
    ASTNode child = node.getFirstChildNode();
    while (child != null) {
        appendDescriptors(child, document, descriptors);
        child = child.getTreeNext();
    }
}
 
Example 2
Project: AppleScript-IDEA   File: AppleScriptHandlerSelectorPartImpl.java   Source Code and License 6 votes vote down vote up
@NotNull
@Override
public String getSelectorPart() {
  StringBuilder builder = new StringBuilder();
  ASTNode child = getNode().getFirstChildNode();
  if (child != null) {
    builder.append(child.getText());
    child = child.getTreeNext();
  }

  while (child != null && AppleScriptTokenTypesSets.COMMENT_OR_WHITE_SPACE.contains(child.getElementType()))
    child = child.getTreeNext();

  if (child != null && child.getElementType() == AppleScriptTypes.COLON) {
    builder.append(child.getText());
  }

  return builder.toString();
}
 
Example 3
Project: TS-IJ   File: TSClassNameAnnotator.java   Source Code and License 5 votes vote down vote up
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
    PsiElement classElement = null;
    if (element instanceof  TSDatablockDecl) {
        TSDatablockDecl db = (TSDatablockDecl) element;

        //Find the first id node, this is kinda wonky since we have to account for whitespace nodes
        //datablock ClassName(...)
        ASTNode node = db.getNode();
        if (node == null) {
            return;
        }
        node = node.findChildByType(TSTypes.ID);
        if (node == null) {
            return;
        }
        classElement = node.getPsi();
    } else if (element instanceof TSObjectExpr) {
        TSObjectExpr obj = (TSObjectExpr) element;

        //Class name should be the second thing in the element:
        // new ClassName(...)
        classElement = PsiTreeUtil.getChildOfType(obj, TSClassNameExpr.class);

        if (classElement == null) {
            return;
        }
        classElement = classElement.getFirstChild();
    }
    if (classElement == null) {
        return;
    }

    //Only annotate if it's an id, can't really tell if it's an expr
    if (classElement.getNode().getElementType().equals(TSTypes.ID)) {
        createSuccessAnnotation(classElement, holder, TSSyntaxHighlighter.CLASSNAME);
    }
}
 
Example 4
Project: TS-IJ   File: TSPsiImplUtil.java   Source Code and License 5 votes vote down vote up
public static String getArgList(TSFnDeclStmt element) {
    ASTNode argNode = element.getNode().findChildByType(TSTypes.VAR_LIST);

    if (argNode != null) {
        return "(" + argNode.getText() + ")";
    } else {
        return "()";
    }
}
 
Example 5
Project: intellij-csv-validator   File: CsvBlockField.java   Source Code and License 5 votes vote down vote up
@Override
protected List<Block> buildChildren() {
    ASTNode node = this.getNode().getFirstChildNode();
    List<Block> blocks = new ArrayList<>();
    while (node != null) {
        if (node.getElementType() != TokenType.WHITE_SPACE) {
            CsvBlockElement block = new CsvBlockElement(node, formattingInfo, this);
            blocks.add(block);
        }
        node = node.getTreeNext();
    }
    return blocks;
}
 
Example 6
Project: reasonml-idea-plugin   File: FoldingBuilder.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public String getPlaceholderText(@NotNull ASTNode node) {
    IElementType elementType = node.getElementType();
    if (elementType == RmlTypes.INSTANCE.COMMENT) {
        return "/*...*/";
    } else if (elementType == OclTypes.INSTANCE.COMMENT) {
        return "(*...*)";
    }

    return "{...}";
}
 
Example 7
Project: hybris-integration-intellij-idea-plugin   File: ImpexFoldingBuilder.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public String getPlaceholderText(@NotNull final ASTNode node) {
    Validate.notNull(node);

    return ImpexFoldingPlaceholderBuilderFactory.getPlaceholderBuilder().getPlaceholder(node.getPsi());
}
 
Example 8
Project: AppleScript-IDEA   File: AppleScriptIndentProcessor.java   Source Code and License 5 votes vote down vote up
Indent getChildIndent(final ASTNode node) {
  final IElementType elementType = node.getElementType();

  if (elementType == BLOCK_BODY || elementType == TOP_BLOCK_BODY || elementType == SCRIPT_BODY) {
    return Indent.getNormalIndent();
  }

  return Indent.getNoneIndent();
}
 
Example 9
Project: intellij-crystal   File: CrystalPsiImplUtil.java   Source Code and License 5 votes vote down vote up
public static PsiElement setName(CrystalProperty element, String newName) {
    ASTNode keyNode = element.getNode().findChildByType(CrystalTypes.KEY);
    if (keyNode != null) {
        CrystalProperty property = CrystalElementFactory.createProperty(element.getProject(), newName);
        ASTNode newKeyNode = property.getFirstChild().getNode();
        element.getNode().replaceChild(keyNode, newKeyNode);
    }
    return element;
}
 
Example 10
Project: intellij-crystal   File: CrystalPsiImplUtil.java   Source Code and License 5 votes vote down vote up
public static String getValue(CrystalProperty element) {
    ASTNode valueNode = element.getNode().findChildByType(CrystalTypes.VALUE);
    if (valueNode != null) {
        return valueNode.getText();
    } else {
        return null;
    }
}
 
Example 11
Project: AppleScript-IDEA   File: AppleScriptWrappingProcessor.java   Source Code and License 5 votes vote down vote up
Wrap createChildWrap(ASTNode child, Wrap defaultWrap, Wrap childWrap) {
  final IElementType childType = child.getElementType();
  final IElementType elementType = myNode.getElementType();

  if (childType == COMMA) return defaultWrap;

  return defaultWrap;
}
 
Example 12
Project: intellij-postfix-templates   File: CptPsiImplUtil.java   Source Code and License 5 votes vote down vote up
public static String getMatchingClassName(CptMapping element) {
	ASTNode keyNode = element.getNode().findChildByType(CptTypes.CLASS_NAME);
	if (keyNode != null) {
		// IMPORTANT: Convert embedded escaped spaces to simple spaces
		return keyNode.getText().replaceAll("\\\\ ", " ");
	} else {
		return null;
	}
}
 
Example 13
Project: intellij-csv-validator   File: CsvBlock.java   Source Code and License 5 votes vote down vote up
@Override
protected List<Block> buildChildren() {
    List<ASTNode> todoNodes = new ArrayList<>();
    List<Block> blocks = new ArrayList<>();
    todoNodes.add(getNode().getFirstChildNode());
    CsvBlockField currentField = null;
    while (todoNodes.size() > 0) {
        ASTNode node = todoNodes.remove(todoNodes.size() - 1);
        if (node == null) {
            continue;
        }
        
        IElementType elementType = node.getElementType();
        todoNodes.add(node.getTreeNext());
        if (elementType == CsvTypes.RECORD) {
            todoNodes.add(node.getFirstChildNode());
        } else if (elementType == CsvTypes.FIELD) {
            currentField = new CsvBlockField(node, formattingInfo);
            if (currentField.getTextLength() > 0) {
                blocks.add(currentField);
            }
        } else if (elementType == CsvTypes.COMMA || elementType == CsvTypes.CRLF) {
            blocks.add(new CsvBlockElement(node, formattingInfo, currentField));
        } else if (elementType != TokenType.WHITE_SPACE && node.getTextLength() > 0) {
            blocks.add(new CsvDummyBlock(node, formattingInfo));
        }
    }
    return blocks;
}
 
Example 14
Project: hybris-integration-intellij-idea-plugin   File: FlexibleSearchBlock.java   Source Code and License 5 votes vote down vote up
protected FlexibleSearchBlock(
    @NotNull final ASTNode node,
    @Nullable final Wrap wrap,
    @Nullable final Alignment alignment,
    @NotNull final SpacingBuilder spacingBuilder
) {

    super(node, wrap, alignment);

    this.spacingBuilder = spacingBuilder;
}
 
Example 15
Project: hybris-integration-intellij-idea-plugin   File: ImpexModifiersImpl.java   Source Code and License 4 votes vote down vote up
public ImpexModifiersImpl(ASTNode node) {
  super(node);
}
 
Example 16
Project: greycat-idea-plugin   File: GCMAttributeDefaultImpl.java   Source Code and License 4 votes vote down vote up
public GCMAttributeDefaultImpl(ASTNode node) {
  super(node);
}
 
Example 17
Project: Goal-Intellij-Plugin   File: MasUseClauseImpl.java   Source Code and License 4 votes vote down vote up
public MasUseClauseImpl(ASTNode node) {
  super(node);
}
 
Example 18
Project: hybris-integration-intellij-idea-plugin   File: FlexibleSearchCommonValueExpressionImpl.java   Source Code and License 4 votes vote down vote up
public FlexibleSearchCommonValueExpressionImpl(ASTNode node) {
  super(node);
}
 
Example 19
Project: AppleScript-IDEA   File: AppleScriptHandlerInterleavedParametersSelectorPartImpl.java   Source Code and License 4 votes vote down vote up
public AppleScriptHandlerInterleavedParametersSelectorPartImpl(ASTNode node) {
  super(node);
}
 
Example 20
Project: TS-IJ   File: TSParserDefinition.java   Source Code and License 4 votes vote down vote up
@Override
public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode astNode, ASTNode astNode1) {
    return SpaceRequirements.MAY;
}
 
Example 21
Project: Goal-Intellij-Plugin   File: ActionSpecIdentifierImpl.java   Source Code and License 4 votes vote down vote up
public ActionSpecIdentifierImpl(ASTNode node) {
  super(node);
}
 
Example 22
Project: hybris-integration-intellij-idea-plugin   File: FlexibleSearchBooleanPrimaryImpl.java   Source Code and License 4 votes vote down vote up
public FlexibleSearchBooleanPrimaryImpl(ASTNode node) {
  super(node);
}
 
Example 23
Project: TS-IJ   File: TSNamedElementImpl.java   Source Code and License 4 votes vote down vote up
public TSNamedElementImpl(@NotNull ASTNode node) {
    super(node);
}
 
Example 24
Project: reasonml-idea-plugin   File: PsiTypeImpl.java   Source Code and License 4 votes vote down vote up
public PsiTypeImpl(@NotNull MlTypes types, @NotNull ASTNode node) {
    super(node);
    m_types = types;
}
 
Example 25
Project: AppleScript-IDEA   File: AppleScriptLabeledParameterDeclarationListImpl.java   Source Code and License 4 votes vote down vote up
public AppleScriptLabeledParameterDeclarationListImpl(ASTNode node) {
  super(node);
}
 
Example 26
Project: Goal-Intellij-Plugin   File: ActionSpecParserDefinition.java   Source Code and License 4 votes vote down vote up
@NotNull
@Override
public PsiElement createElement(ASTNode node) {
    return ActionSpecTypes.Factory.createElement(node);
}
 
Example 27
Project: intellij-postfix-templates   File: CptTemplateVariableValueGImpl.java   Source Code and License 4 votes vote down vote up
public CptTemplateVariableValueGImpl(ASTNode node) {
  super(node);
}
 
Example 28
Project: Goal-Intellij-Plugin   File: ModuleTermImpl.java   Source Code and License 4 votes vote down vote up
public ModuleTermImpl(ASTNode node) {
  super(node);
}
 
Example 29
Project: Goal-Intellij-Plugin   File: TestEventuallyRuleImpl.java   Source Code and License 4 votes vote down vote up
public TestEventuallyRuleImpl(ASTNode node) {
  super(node);
}
 
Example 30
Project: AppleScript-IDEA   File: AppleScriptLogicalOrExpressionImpl.java   Source Code and License 4 votes vote down vote up
public AppleScriptLogicalOrExpressionImpl(ASTNode node) {
  super(node);
}
 
Example 31
Project: Goal-Intellij-Plugin   File: ModuleUseClauseImpl.java   Source Code and License 4 votes vote down vote up
public ModuleUseClauseImpl(ASTNode node) {
  super(node);
}
 
Example 32
Project: bamboo-soy   File: NamespaceDeclarationMixin.java   Source Code and License 4 votes vote down vote up
public NamespaceDeclarationMixin(NamespaceDeclarationStub stub, IElementType type, ASTNode node) {
  super(stub, type, node);
}
 
Example 33
Project: bamboo-soy   File: SoyStubBasedPsiElementBase.java   Source Code and License 4 votes vote down vote up
public SoyStubBasedPsiElementBase(T stub, IElementType nodeType, ASTNode node) {
  super(stub, nodeType, node);
}
 
Example 34
Project: reasonml-idea-plugin   File: OclParserDefinition.java   Source Code and License 4 votes vote down vote up
@NotNull
public PsiElement createElement(ASTNode node) {
    return PsiElementFactory.createElement(OclTypes.INSTANCE, node);
}
 
Example 35
Project: AppleScript-IDEA   File: AppleScriptSpacingProcessor.java   Source Code and License 4 votes vote down vote up
private static boolean isWhiteSpace(final ASTNode node) {
  return node != null && (AppleScriptPsiImplUtil.isWhiteSpaceOrNls(node) || node.getTextLength() == 0);
}
 
Example 36
Project: AppleScript-IDEA   File: AppleScriptDictionaryCommandNameImpl.java   Source Code and License 4 votes vote down vote up
public AppleScriptDictionaryCommandNameImpl(ASTNode node) {
  super(node);
}
 
Example 37
Project: hybris-integration-intellij-idea-plugin   File: FlexibleSearchSelectListImpl.java   Source Code and License 4 votes vote down vote up
public FlexibleSearchSelectListImpl(ASTNode node) {
  super(node);
}
 
Example 38
Project: reasonml-idea-plugin   File: OclP4ParserDefinition.java   Source Code and License 4 votes vote down vote up
@NotNull
public PsiElement createElement(ASTNode node) {
    return PsiElementFactory.createElement(OclTypes.INSTANCE, node);
}
 
Example 39
Project: hybris-integration-intellij-idea-plugin   File: FlexibleSearchCharacterValueFunctionImpl.java   Source Code and License 4 votes vote down vote up
public FlexibleSearchCharacterValueFunctionImpl(ASTNode node) {
  super(node);
}
 
Example 40
Project: Goal-Intellij-Plugin   File: ModuleDropActionImpl.java   Source Code and License 4 votes vote down vote up
public ModuleDropActionImpl(ASTNode node) {
  super(node);
}