com.intellij.lang.ASTNode Java Examples
The following examples show how to use
com.intellij.lang.ASTNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: consulo Author: consulo File: CompositeElement.java License: Apache License 2.0 | 5 votes |
@Override public boolean textContains(char c) { for (ASTNode child = getFirstChildNode(); child != null; child = child.getTreeNext()) { if (child.textContains(c)) return true; } return false; }
Example #2
Source Project: intellij-haxe Author: HaxeFoundation File: HXMLPsiImplUtil.java License: Apache License 2.0 | 5 votes |
public static String getValue(HXMLLib lib) { ASTNode node = lib.getNode().findChildByType(HXMLTypes.VALUE); if (node != null) { return node.getText(); } else { return null; } }
Example #3
Source Project: intellij-haxe Author: HaxeFoundation File: HaxeFoldingBuilder.java License: Apache License 2.0 | 5 votes |
private static TextRange buildImportsFoldingTextRange(ASTNode firstNode, ASTNode lastNode) { ASTNode nodeStartFrom = UsefulPsiTreeUtil.getNextSiblingSkipWhiteSpacesAndComments(firstNode.getFirstChildNode()); if (nodeStartFrom == null) { nodeStartFrom = firstNode; } return new TextRange(nodeStartFrom.getStartOffset(), lastNode.getTextRange().getEndOffset()); }
Example #4
Source Project: consulo Author: consulo File: PsiEquivalenceUtil.java License: Apache License 2.0 | 5 votes |
public static PsiElement[] getFilteredChildren(@Nonnull final PsiElement element, @Nullable Condition<PsiElement> isElementSignificantCondition, boolean areCommentsSignificant) { ASTNode[] children1 = element.getNode().getChildren(null); ArrayList<PsiElement> array = new ArrayList<PsiElement>(); for (ASTNode node : children1) { final PsiElement child = node.getPsi(); if (!(child instanceof PsiWhiteSpace) && (areCommentsSignificant || !(child instanceof PsiComment)) && (isElementSignificantCondition == null || isElementSignificantCondition.value(child))) { array.add(child); } } return PsiUtilCore.toPsiElementArray(array); }
Example #5
Source Project: intellij Author: bazelbuild File: FuncallExpression.java License: Apache License 2.0 | 5 votes |
/** The function name */ @Nullable public ASTNode getFunctionNameNode() { PsiElement argList = getArgList(); if (argList != null) { // We want the reference expr directly prior to the open parenthesis. // This accounts for Skylark native.rule calls. PsiElement prev = argList.getPrevSibling(); if (prev instanceof ReferenceExpression) { return prev.getNode(); } } return getNode().findChildByType(BuildElementTypes.REFERENCE_EXPRESSION); }
Example #6
Source Project: intellij-plugin-v4 Author: antlr File: ANTLRv4FoldingBuilder.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@SuppressWarnings("SimplifiableIfStatement") @Override protected boolean isRegionCollapsedByDefault(@NotNull ASTNode node) { final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(node); if (element == null) return false; ANTLRv4FoldingSettings settings = ANTLRv4FoldingSettings.getInstance(); if (RULE_BLOCKS.contains(node.getElementType())) return settings.isCollapseRuleBlocks(); if (node.getElementType() == TOKENSSPEC) return settings.isCollapseTokens(); if (element instanceof AtAction) return settings.isCollapseActions(); if (element instanceof ANTLRv4FileRoot) { return settings.isCollapseFileHeader(); } if (node.getElementType() == DOC_COMMENT_TOKEN) { PsiElement parent = element.getParent(); if (parent instanceof ANTLRv4FileRoot) { PsiElement firstChild = parent.getFirstChild(); if (firstChild instanceof PsiWhiteSpace) { firstChild = firstChild.getNextSibling(); } if (element.equals(firstChild)) { return settings.isCollapseFileHeader(); } } return settings.isCollapseDocComments(); } if (isComment(element)) { return settings.isCollapseComments(); } return false; }
Example #7
Source Project: consulo Author: consulo File: PsiViewerDialog.java License: Apache License 2.0 | 5 votes |
@Override public Object getData(@Nonnull @NonNls Key<?> dataId) { if (PlatformDataKeys.NAVIGATABLE == dataId) { String fqn = null; if (myPsiTree.hasFocus()) { final TreePath path = myPsiTree.getSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (!(node.getUserObject() instanceof ViewerNodeDescriptor)) return null; ViewerNodeDescriptor descriptor = (ViewerNodeDescriptor)node.getUserObject(); Object elementObject = descriptor.getElement(); final PsiElement element = elementObject instanceof PsiElement ? (PsiElement)elementObject : elementObject instanceof ASTNode ? ((ASTNode)elementObject).getPsi() : null; if (element != null) { fqn = element.getClass().getName(); } } } else if (myRefs.hasFocus()) { final Object value = myRefs.getSelectedValue(); if (value instanceof String) { fqn = (String)value; } } if (fqn != null) { return getContainingFileForClass(fqn); } } return null; }
Example #8
Source Project: jenkinsfile-idea-plugin Author: oliverlockwood File: JenkinsTypes.java License: Apache License 2.0 | 5 votes |
public static PsiElement createElement(ASTNode node) { IElementType type = node.getElementType(); if (type == STEP) { return new JenkinsStepImpl(node); } throw new AssertionError("Unknown element type: " + type); }
Example #9
Source Project: intellij-latte Author: nette-intellij File: LattePsiImplUtil.java License: MIT License | 5 votes |
public static @NotNull String getMacroName(LatteMacroTag element) { ASTNode nameNode = getMacroNameNode(element); if (nameNode != null) { return nameNode.getText(); } return createMacroName(element); }
Example #10
Source Project: consulo Author: consulo File: ASTShallowComparator.java License: Apache License 2.0 | 5 votes |
private ThreeState textMatches(ASTNode oldNode, ASTNode newNode) { myIndicator.checkCanceled(); String oldText = TreeUtil.isCollapsedChameleon(oldNode) ? oldNode.getText() : null; String newText = TreeUtil.isCollapsedChameleon(newNode) ? newNode.getText() : null; if (oldText != null && newText != null) return oldText.equals(newText) ? ThreeState.YES : ThreeState.UNSURE; if (oldText != null) { return compareTreeToText((TreeElement)newNode, oldText) ? ThreeState.YES : ThreeState.UNSURE; } if (newText != null) { return compareTreeToText((TreeElement)oldNode, newText) ? ThreeState.YES : ThreeState.UNSURE; } if (oldNode instanceof ForeignLeafPsiElement) { return newNode instanceof ForeignLeafPsiElement && oldNode.getText().equals(newNode.getText()) ? ThreeState.YES : ThreeState.NO; } if (newNode instanceof ForeignLeafPsiElement) return ThreeState.NO; if (oldNode instanceof LeafElement) { return ((LeafElement)oldNode).textMatches(newNode.getText()) ? ThreeState.YES : ThreeState.NO; } if (newNode instanceof LeafElement) { return ((LeafElement)newNode).textMatches(oldNode.getText()) ? ThreeState.YES : ThreeState.NO; } if (oldNode instanceof PsiErrorElement && newNode instanceof PsiErrorElement) { final PsiErrorElement e1 = (PsiErrorElement)oldNode; final PsiErrorElement e2 = (PsiErrorElement)newNode; if (!Comparing.equal(e1.getErrorDescription(), e2.getErrorDescription())) return ThreeState.NO; } return ThreeState.UNSURE; }
Example #11
Source Project: glsl4idea Author: Darkyenus File: GLSLParserDefinition.java License: GNU Lesser General Public License v3.0 | 5 votes |
@NotNull public PsiElement createElement(ASTNode node) { GLSLElement elt = psiFactory.create(node); if (elt != null) { return elt; } else { //Logger.getInstance(GLSLParserDefinition.class).warn("Creating default GLSLElementImpl for "+node); return new GLSLElementImpl(node); } }
Example #12
Source Project: intellij-haxe Author: HaxeFoundation File: AbstractHaxeNamedComponent.java License: Apache License 2.0 | 5 votes |
@Nullable public ASTNode findChildByRole(int role) { // assert ChildRole.isUnique(role); PsiElement firstChild = getFirstChild(); if (firstChild == null) return null; for (ASTNode child = firstChild.getNode(); child != null; child = child.getTreeNext()) { if (getChildRole(child) == role) return child; } return null; }
Example #13
Source Project: consulo-csharp Author: consulo File: CSharpFileStubElementType.java License: Apache License 2.0 | 5 votes |
@Override public StubBuilder getBuilder() { return new DefaultStubBuilder() { @Nonnull @Override protected StubElement createStubForFile(@Nonnull PsiFile file) { if(file instanceof CSharpFileImpl) { return new CSharpFileStub((CSharpFileImpl) file); } return super.createStubForFile(file); } @Override public boolean skipChildProcessingWhenBuildingStubs(@Nonnull ASTNode parent, @Nonnull ASTNode node) { // skip any lazy parseable elements, like preprocessors or code blocks etc if(node.getElementType() instanceof ILazyParseableElementType) { return true; } return false; } }; }
Example #14
Source Project: intellij-xquery Author: ligasgr File: XQueryModuleDeclImpl.java License: Apache License 2.0 | 4 votes |
public XQueryModuleDeclImpl(ASTNode node) { super(node); }
Example #15
Source Project: consulo Author: consulo File: AnnotationHolderImpl.java License: Apache License 2.0 | 4 votes |
@Override public Annotation createInfoAnnotation(@Nonnull ASTNode node, String message) { assertMyFile(node.getPsi()); return createAnnotation(HighlightSeverity.INFORMATION, node.getTextRange(), message); }
Example #16
Source Project: consulo Author: consulo File: AstBufferUtil.java License: Apache License 2.0 | 4 votes |
public static String getTextSkippingWhitespaceComments(@Nonnull ASTNode element) { int length = toBuffer(element, null, 0, true); char[] buffer = new char[length]; toBuffer(element, buffer, 0, true); return StringFactory.createShared(buffer); }
Example #17
Source Project: BashSupport Author: BashSupport File: BashAssignmentListImpl.java License: Apache License 2.0 | 4 votes |
public BashAssignmentListImpl(ASTNode node) { super(node, "assignment list"); }
Example #18
Source Project: Intellij-Plugin Author: getgauge File: GaugeFoldingBuilder.java License: Apache License 2.0 | 4 votes |
@Nullable @Override public String getPlaceholderText(@NotNull ASTNode astNode) { return " ..."; }
Example #19
Source Project: idea-php-typo3-plugin Author: cedricziel File: FluidBlockWithInjection.java License: MIT License | 4 votes |
protected FluidBlockWithInjection(AbstractXmlTemplateFormattingModelBuilder builder, @NotNull ASTNode node, @Nullable Wrap wrap, @Nullable Alignment alignment, CodeStyleSettings settings, XmlFormattingPolicy xmlFormattingPolicy, Indent indent) { super(builder, node, wrap, alignment, settings, xmlFormattingPolicy, indent); this.myInjectedBlockBuilder = new FluidBlockWithInjectionBuilder(settings); }
Example #20
Source Project: protobuf-jetbrains-plugin Author: protostuff File: FieldNode.java License: Apache License 2.0 | 4 votes |
public FieldNode(@NotNull ASTNode node) { super(node); }
Example #21
Source Project: jetbrains-plugin-graph-database-support Author: neueda File: CypherPatternElementImpl.java License: Apache License 2.0 | 4 votes |
public CypherPatternElementImpl(@NotNull ASTNode node) { super(node); }
Example #22
Source Project: jetbrains-plugin-graph-database-support Author: neueda File: CypherQueryOptionsImpl.java License: Apache License 2.0 | 4 votes |
public CypherQueryOptionsImpl(@NotNull ASTNode node) { super(node); }
Example #23
Source Project: bamboo-soy Author: google File: AtInjectMixin.java License: Apache License 2.0 | 4 votes |
public AtInjectMixin(@NotNull ASTNode node) { super(node); }
Example #24
Source Project: js-graphql-intellij-plugin Author: jimkyndemeyer File: GraphQLInlineFragmentImpl.java License: MIT License | 4 votes |
public GraphQLInlineFragmentImpl(ASTNode node) { super(node); }
Example #25
Source Project: consulo-csharp Author: consulo File: CSharpTupleElementImpl.java License: Apache License 2.0 | 4 votes |
public CSharpTupleElementImpl(@Nonnull ASTNode node) { super(node); }
Example #26
Source Project: JetBrains-NASM-Language Author: ajkhoury File: NASMBitShiftRExprImpl.java License: MIT License | 4 votes |
public NASMBitShiftRExprImpl(@NotNull ASTNode node) { super(node); }
Example #27
Source Project: JetBrains-NASM-Language Author: ajkhoury File: NASMDataElementImpl.java License: MIT License | 4 votes |
public NASMDataElementImpl(@NotNull ASTNode node) { super(node); }
Example #28
Source Project: js-graphql-intellij-plugin Author: jimkyndemeyer File: JSGraphQLEndpointPropertyPsiElement.java License: MIT License | 4 votes |
public JSGraphQLEndpointPropertyPsiElement(@NotNull ASTNode node) { super(node); }
Example #29
Source Project: bamboo-soy Author: google File: IdentifierDefinitionMixin.java License: Apache License 2.0 | 4 votes |
IdentifierDefinitionMixin(@NotNull ASTNode node) { super(node); }
Example #30
Source Project: jetbrains-plugin-graph-database-support Author: neueda File: CypherPropertyExpressionImpl.java License: Apache License 2.0 | 4 votes |
public CypherPropertyExpressionImpl(@NotNull ASTNode node) { super(node); }