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);
}
 
Example 41
Project: laravel-insight   File: BladeFoldingBuilder.java   Source Code and License 4 votes vote down vote up
@Override
public boolean isCollapsedByDefault(@NotNull final ASTNode node) {
    return false;
}
 
Example 42
Project: Goal-Intellij-Plugin   File: ModuleSendActionImpl.java   Source Code and License 4 votes vote down vote up
public ModuleSendActionImpl(ASTNode node) {
  super(node);
}
 
Example 43
Project: intellij-csv-validator   File: CsvBlock.java   Source Code and License 4 votes vote down vote up
protected CsvBlock(@NotNull ASTNode node, CsvFormattingInfo formattingInfo) {
    super(node, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment());
    this.formattingInfo = formattingInfo;
}
 
Example 44
Project: reasonml-idea-plugin   File: PsiModuleImpl.java   Source Code and License 4 votes vote down vote up
public PsiModuleImpl(ASTNode node) {
    super(node);
}
 
Example 45
Project: reasonml-idea-plugin   File: PsiModuleNameImpl.java   Source Code and License 4 votes vote down vote up
public PsiModuleNameImpl(@NotNull MlTypes types, @NotNull ASTNode node) {
    super(types, node);
}
 
Example 46
Project: hybris-integration-intellij-idea-plugin   File: ImpexFormattingModelBuilder.java   Source Code and License 4 votes vote down vote up
@Nullable
@Override
public TextRange getRangeAffectingIndent(final PsiFile file, final int offset, final ASTNode elementAtOffset) {
    return null;
}
 
Example 47
Project: hybris-integration-intellij-idea-plugin   File: FlexibleSearchOrderingSpecificationImpl.java   Source Code and License 4 votes vote down vote up
public FlexibleSearchOrderingSpecificationImpl(ASTNode node) {
  super(node);
}
 
Example 48
Project: hybris-integration-intellij-idea-plugin   File: ImpexAnyAttributeNameImpl.java   Source Code and License 4 votes vote down vote up
public ImpexAnyAttributeNameImpl(ASTNode node) {
  super(node);
}
 
Example 49
Project: AppleScript-IDEA   File: DictionaryComponentBase.java   Source Code and License 4 votes vote down vote up
@Nullable
@Override
public ASTNode getNode() {
  return myXmlElement.getNode();
}
 
Example 50
Project: AppleScript-IDEA   File: AbstractAppleScriptScriptObject.java   Source Code and License 4 votes vote down vote up
AbstractAppleScriptScriptObject(@NotNull ASTNode node) {
  super(node);
}
 
Example 51
Project: AppleScript-IDEA   File: AbstractAppleScriptHandlerCall.java   Source Code and License 4 votes vote down vote up
AbstractAppleScriptHandlerCall(ASTNode node) {
  super(node);
  mySelectorReference = new SelectorReference();
}
 
Example 52
Project: AppleScript-IDEA   File: AppleScriptNegationExpressionImpl.java   Source Code and License 4 votes vote down vote up
public AppleScriptNegationExpressionImpl(ASTNode node) {
  super(node);
}
 
Example 53
Project: greycat-idea-plugin   File: GCMToManyDeclarationImpl.java   Source Code and License 4 votes vote down vote up
public GCMToManyDeclarationImpl(ASTNode node) {
  super(node);
}
 
Example 54
Project: AppleScript-IDEA   File: AppleScriptIdReferenceImpl.java   Source Code and License 4 votes vote down vote up
public AppleScriptIdReferenceImpl(ASTNode node) {
  super(node);
}
 
Example 55
Project: hybris-integration-intellij-idea-plugin   File: ImpexBeanShellImpl.java   Source Code and License 4 votes vote down vote up
public ImpexBeanShellImpl(ASTNode node) {
  super(node);
}
 
Example 56
Project: bamboo-soy   File: AtParamMixin.java   Source Code and License 4 votes vote down vote up
public AtParamMixin(AtParamStub stub, IElementType type, ASTNode node) {
  super(stub, type, node);
}
 
Example 57
Project: AppleScript-IDEA   File: AppleScriptPsiImplUtil.java   Source Code and License 4 votes vote down vote up
public static boolean withImportingStdLibrary(AppleScriptUsingTermsFromStatement usingTermsStatement) {
  ASTNode node = usingTermsStatement.getNode();
  return node.findChildByType(AppleScriptTypes.SCRIPTING_ADDITIONS) != null;
}
 
Example 58
Project: greycat-idea-plugin   File: GCMRelationNameImpl.java   Source Code and License 4 votes vote down vote up
public GCMRelationNameImpl(ASTNode node) {
  super(node);
}
 
Example 59
Project: AppleScript-IDEA   File: AppleScriptHandlerInterleavedParameters.java   Source Code and License 4 votes vote down vote up
public AppleScriptHandlerInterleavedParameters(@NotNull ASTNode node) {
  super(node);
}
 
Example 60
Project: hybris-integration-intellij-idea-plugin   File: FlexibleSearchTablePrimaryImpl.java   Source Code and License 4 votes vote down vote up
public FlexibleSearchTablePrimaryImpl(ASTNode node) {
  super(node);
}