Package com.intellij.lang

Examples of com.intellij.lang.ASTNode


    return newStep;
  }

  @Override
  public String getName() {
    final ASTNode keyword = getKeyword();
    final int keywordLength = keyword != null ? keyword.getTextLength() : 0;
    return getText().substring(keywordLength).trim();
  }
View Full Code Here


    if (provider instanceof HbFileViewProvider) {
      if (HbConfig.isAutocompleteMustachesEnabled() && c == '}' && !previousChar.equals("}")) {
        // we may be able to complete the second brace
        PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
        PsiElement elementAt = provider.findElementAt(offset - 1, provider.getBaseLanguage());
        ASTNode node = elementAt != null ? elementAt.getNode() : null;
        if (node != null && node.getElementType() == HbTokenTypes.INVALID) {
          // we should be looking at the beginning of a close brace.  Find its matching open brace and auto-complete based on its type
          PsiElement mustache = PsiTreeUtil.findFirstParent(elementAt, new Condition<PsiElement>() {
            @Override
            public boolean value(PsiElement psiElement) {
              return psiElement instanceof HbMustache;
View Full Code Here

    super(node);
  }

  @NotNull
  protected String getElementText() {
    final ASTNode node = getNode();
    final ASTNode[] children = node.getChildren(TEXT_FILTER);
    return StringUtil.join(children, new Function<ASTNode, String>() {
      public String fun(ASTNode astNode) {
        return astNode.getText();
      }
    }, " ").trim();
View Full Code Here

    }, " ").trim();
  }

  @Nullable
  public PsiElement getShortDescriptionText() {
    final ASTNode node = getNode();
    final ASTNode[] children = node.getChildren(TEXT_FILTER);
    return children.length > 0 ? children[0].getPsi() : null;
  }
View Full Code Here

    }

    final PsiFile file = element.getContainingFile();
    Block rootBlock;

    ASTNode node = element.getNode();

    if (node.getElementType() == HbTokenTypes.OUTER_ELEMENT_TYPE) {
      // If we're looking at a HbTokenTypes.OUTER_ELEMENT_TYPE element, then we've been invoked by our templated
      // language.  Make a dummy block to allow that formatter to continue
      return new SimpleTemplateLanguageFormattingModelBuilder().createModel(element, settings);
    }
    else {
View Full Code Here

             protected void addCompletions(@NotNull CompletionParameters parameters,
                                           ProcessingContext context,
                                           @NotNull CompletionResultSet result) {
               PsiElement position = PsiTreeUtil.getParentOfType(parameters.getPosition(), HbMustacheName.class);
               PsiElement prevSibling = position != null ? position.getPrevSibling() : null;
               ASTNode prevSiblingNode = prevSibling != null ? prevSibling.getNode() : null;
               if (prevSiblingNode != null && prevSiblingNode.getElementType() == HbTokenTypes.OPEN_BLOCK) {
                 result.addElement(LookupElementBuilder.create("if"));
                 result.addElement(LookupElementBuilder.create("each"));
                 result.addElement(LookupElementBuilder.create("unless"));
                 result.addElement(LookupElementBuilder.create("with"));
               }
View Full Code Here

    if (isSingleLine(psi, document)) {
      return;
    }

    if (HbTokenTypes.COMMENT == psi.getNode().getElementType()) {
      ASTNode commentNode = psi.getNode();
      String commentText = commentNode.getText();

      // comment might be unclosed or too short (a one character fold triggers an invalid range assertion error),
      // so do a bit of sanity checking on its length and whether or not it's got the requisite open/close
      // tags before we allow folding
      if (commentText.length() > 6
          && commentText.substring(0, 3).equals("{{!")
          && commentText.substring(commentText.length() - 2, commentText.length()).equals("}}")) {
        TextRange range = new TextRange(commentNode.getTextRange().getStartOffset() + 3, commentNode.getTextRange().getEndOffset() - 2);
        descriptors.add(new FoldingDescriptor(commentNode, range));
      }
    }

    if (psi instanceof HbBlockWrapper) {
View Full Code Here

  private void appendDescriptors(ASTNode node, List<FoldingDescriptor> descriptors) {
    if (BLOCKS_TO_FOLD.contains(node.getElementType()) && node.getTextRange().getLength() >= 2) {
      descriptors.add(new FoldingDescriptor(node, node.getTextRange()));
    }
    ASTNode child = node.getFirstChildNode();
    while (child != null) {
      appendDescriptors(child, descriptors);
      child = child.getTreeNext();
    }
  }
View Full Code Here

public class GherkinSpellcheckerStrategy extends SpellcheckingStrategy {
  @NotNull
  @Override
  public Tokenizer getTokenizer(final PsiElement element) {
    if (element instanceof LeafElement) {
      final ASTNode node = element.getNode();
      if (node != null && node.getElementType() instanceof GherkinElementType){
        return SpellcheckingStrategy.TEXT_TOKENIZER;
      }
    }
    return super.getTokenizer(element);
  }
View Full Code Here

          }
        }
      }
      buildAdditionalRanges(result, editorText);
    } else if (parent instanceof GherkinStepsHolder) {
      final ASTNode stepHolderNode = parent.getNode();
      if (stepHolderNode != null) {
        final ASTNode keyword = stepHolderNode.findChildByType(GherkinTokenTypes.KEYWORDS);
        if (keyword != null) {
          result.add(TextRange.create(keyword.getTextRange().getStartOffset(), parent.getTextRange().getEndOffset()));
        }
      }
      result.add(parent.getTextRange());
    }
   
View Full Code Here

TOP

Related Classes of com.intellij.lang.ASTNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.