Java 类com.intellij.lang.ASTNode 实例源码

项目:greycat-idea-plugin    文件:GCMFoldingBuilder.java   
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();
    }
}
项目:AppleScript-IDEA    文件:AppleScriptHandlerSelectorPartImpl.java   
@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();
}
项目:TS-IJ    文件:TSClassNameAnnotator.java   
@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);
    }
}
项目:TS-IJ    文件:TSPsiImplUtil.java   
public static String getArgList(TSFnDeclStmt element) {
    ASTNode argNode = element.getNode().findChildByType(TSTypes.VAR_LIST);

    if (argNode != null) {
        return "(" + argNode.getText() + ")";
    } else {
        return "()";
    }
}
项目:intellij-csv-validator    文件:CsvBlockField.java   
@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;
}
项目:reasonml-idea-plugin    文件:FoldingBuilder.java   
@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 "{...}";
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexFoldingBuilder.java   
@Nullable
@Override
public String getPlaceholderText(@NotNull final ASTNode node) {
    Validate.notNull(node);

    return ImpexFoldingPlaceholderBuilderFactory.getPlaceholderBuilder().getPlaceholder(node.getPsi());
}
项目:AppleScript-IDEA    文件:AppleScriptIndentProcessor.java   
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();
}
项目:intellij-crystal    文件:CrystalPsiImplUtil.java   
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;
}
项目:intellij-crystal    文件:CrystalPsiImplUtil.java   
public static String getValue(CrystalProperty element) {
    ASTNode valueNode = element.getNode().findChildByType(CrystalTypes.VALUE);
    if (valueNode != null) {
        return valueNode.getText();
    } else {
        return null;
    }
}
项目:AppleScript-IDEA    文件:AppleScriptWrappingProcessor.java   
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;
}
项目:intellij-postfix-templates    文件:CptPsiImplUtil.java   
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;
    }
}
项目:intellij-csv-validator    文件:CsvBlock.java   
@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;
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchBlock.java   
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;
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexModifiersImpl.java   
public ImpexModifiersImpl(ASTNode node) {
  super(node);
}
项目:greycat-idea-plugin    文件:GCMAttributeDefaultImpl.java   
public GCMAttributeDefaultImpl(ASTNode node) {
  super(node);
}
项目:Goal-Intellij-Plugin    文件:MasUseClauseImpl.java   
public MasUseClauseImpl(ASTNode node) {
  super(node);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchCommonValueExpressionImpl.java   
public FlexibleSearchCommonValueExpressionImpl(ASTNode node) {
  super(node);
}
项目:AppleScript-IDEA    文件:AppleScriptHandlerInterleavedParametersSelectorPartImpl.java   
public AppleScriptHandlerInterleavedParametersSelectorPartImpl(ASTNode node) {
  super(node);
}
项目:TS-IJ    文件:TSParserDefinition.java   
@Override
public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode astNode, ASTNode astNode1) {
    return SpaceRequirements.MAY;
}
项目:Goal-Intellij-Plugin    文件:ActionSpecIdentifierImpl.java   
public ActionSpecIdentifierImpl(ASTNode node) {
  super(node);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchBooleanPrimaryImpl.java   
public FlexibleSearchBooleanPrimaryImpl(ASTNode node) {
  super(node);
}
项目:TS-IJ    文件:TSNamedElementImpl.java   
public TSNamedElementImpl(@NotNull ASTNode node) {
    super(node);
}
项目:reasonml-idea-plugin    文件:PsiTypeImpl.java   
public PsiTypeImpl(@NotNull MlTypes types, @NotNull ASTNode node) {
    super(node);
    m_types = types;
}
项目:AppleScript-IDEA    文件:AppleScriptLabeledParameterDeclarationListImpl.java   
public AppleScriptLabeledParameterDeclarationListImpl(ASTNode node) {
  super(node);
}
项目:Goal-Intellij-Plugin    文件:ActionSpecParserDefinition.java   
@NotNull
@Override
public PsiElement createElement(ASTNode node) {
    return ActionSpecTypes.Factory.createElement(node);
}
项目:intellij-postfix-templates    文件:CptTemplateVariableValueGImpl.java   
public CptTemplateVariableValueGImpl(ASTNode node) {
  super(node);
}
项目:Goal-Intellij-Plugin    文件:ModuleTermImpl.java   
public ModuleTermImpl(ASTNode node) {
  super(node);
}
项目:Goal-Intellij-Plugin    文件:TestEventuallyRuleImpl.java   
public TestEventuallyRuleImpl(ASTNode node) {
  super(node);
}
项目:AppleScript-IDEA    文件:AppleScriptLogicalOrExpressionImpl.java   
public AppleScriptLogicalOrExpressionImpl(ASTNode node) {
  super(node);
}
项目:Goal-Intellij-Plugin    文件:ModuleUseClauseImpl.java   
public ModuleUseClauseImpl(ASTNode node) {
  super(node);
}
项目:bamboo-soy    文件:NamespaceDeclarationMixin.java   
public NamespaceDeclarationMixin(NamespaceDeclarationStub stub, IElementType type, ASTNode node) {
  super(stub, type, node);
}
项目:bamboo-soy    文件:SoyStubBasedPsiElementBase.java   
public SoyStubBasedPsiElementBase(T stub, IElementType nodeType, ASTNode node) {
  super(stub, nodeType, node);
}
项目:reasonml-idea-plugin    文件:OclParserDefinition.java   
@NotNull
public PsiElement createElement(ASTNode node) {
    return PsiElementFactory.createElement(OclTypes.INSTANCE, node);
}
项目:AppleScript-IDEA    文件:AppleScriptSpacingProcessor.java   
private static boolean isWhiteSpace(final ASTNode node) {
  return node != null && (AppleScriptPsiImplUtil.isWhiteSpaceOrNls(node) || node.getTextLength() == 0);
}
项目:AppleScript-IDEA    文件:AppleScriptDictionaryCommandNameImpl.java   
public AppleScriptDictionaryCommandNameImpl(ASTNode node) {
  super(node);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchSelectListImpl.java   
public FlexibleSearchSelectListImpl(ASTNode node) {
  super(node);
}
项目:reasonml-idea-plugin    文件:OclP4ParserDefinition.java   
@NotNull
public PsiElement createElement(ASTNode node) {
    return PsiElementFactory.createElement(OclTypes.INSTANCE, node);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchCharacterValueFunctionImpl.java   
public FlexibleSearchCharacterValueFunctionImpl(ASTNode node) {
  super(node);
}
项目:Goal-Intellij-Plugin    文件:ModuleDropActionImpl.java   
public ModuleDropActionImpl(ASTNode node) {
  super(node);
}