Package com.intellij.psi.tree

Examples of com.intellij.psi.tree.IElementType


        return NginxElementTypes.STRINGS;
    }

    @NotNull
    public PsiElement createElement(ASTNode node) {
        IElementType type = node.getElementType();
        if (type == NginxElementTypes.DIRECTIVE) {
            return new NginxDirectiveImpl(node);
        } else if (type == NginxElementTypes.CONTEXT_NAME) {
            return new NginxDirectiveNameImpl(node);
        } else if (type == NginxElementTypes.DIRECTIVE_NAME) {
View Full Code Here


    char ch;
    LineInfo startLine;
    float topWeight;
    float bottomWeight;
    Lexer lexer = hl.getHighlightingLexer();
    IElementType tokenType;

    Graphics2D g = (Graphics2D)img.getGraphics();
    g.setComposite(CLEAR);
    g.fillRect(0, 0, img.getWidth(), img.getHeight());
View Full Code Here

        mergeChildrenTo(parent, cur, list);
      }
      else if (cur instanceof BnfParenOptExpression && isTrivialOrSingular(((BnfParenOptExpression)cur).getExpression())) {
        // currently <expr> + ? expressions are not supported, thus:
        BnfExpression child = ((BnfParenOptExpression)cur).getExpression();
        IElementType type = ParserGeneratorUtil.getEffectiveType(child);
        if (type == BnfTypes.BNF_OP_OPT || type == BnfTypes.BNF_OP_ZEROMORE) {
          list.add(cur.replace(child));
        }
        else if (type == BnfTypes.BNF_OP_ONEMORE) {
          String replacement = ((BnfQuantified)child).getExpression().getText() + "*";
          list.add(cur.replace(BnfElementFactory.createExpressionFromText(element.getProject(), replacement)));
        }
        else {
          String replacement = child.getText() + "?";
          list.add(cur.replace(BnfElementFactory.createExpressionFromText(element.getProject(), replacement)));
        }
      }
      else if (cur instanceof BnfChoice &&
               !(parent instanceof BnfParenthesized) &&
               (parent instanceof BnfSequence || parent instanceof BnfQuantified)) {
        String replacement = "(" + cur.getText() + ")";
        cur.replace(BnfElementFactory.createExpressionFromText(element.getProject(), replacement));
      }
      else if (isOptMany(cur) && isOptMany(PsiTreeUtil.getChildOfType(cur, BnfExpression.class))) {
        BnfExpression child = PsiTreeUtil.getChildOfType(cur, BnfExpression.class);
        IElementType type1 = ParserGeneratorUtil.getEffectiveType(cur);
        IElementType type2 = ParserGeneratorUtil.getEffectiveType(child);
        if (type1 == type2) {
          list.add(cur.replace(child));
        }
        else if (type1 == BnfTypes.BNF_OP_OPT && type2 == BnfTypes.BNF_OP_ONEMORE ||
                 type2 == BnfTypes.BNF_OP_OPT && type1 == BnfTypes.BNF_OP_ONEMORE ||
View Full Code Here

  public Spacing getSpacing(final Block child1, final Block child2) {
    if (!(child1 instanceof AbstractBlock) || !(child2 instanceof AbstractBlock)) {
      return null;
    }

    final IElementType elementType = myNode.getElementType();
    final IElementType parentType = myNode.getTreeParent() == null ? null : myNode.getTreeParent().getElementType();
    final ASTNode node1 = ((AbstractBlock)child1).getNode();
    final IElementType type1 = node1.getElementType();
    final ASTNode node2 = ((AbstractBlock)child2).getNode();
    final IElementType type2 = node2.getElementType();

    if (AT == type1) return Spacing.createSpacing(0, 0, 0, false, 0);
    if (METADATA == type1) return Spacing.createSpacing(1, 1, 0, true, 0);

    if (FUNCTION_DEFINITION.contains(type2)) {
View Full Code Here

    }
    return tlChildren;
  }

  public Wrap createChildWrap(ASTNode child) {
    final IElementType childType = child.getElementType();
    final Wrap wrap = myWrappingProcessor.createChildWrap(child, Wrap.createWrap(WrapType.NONE, false), myChildWrap);

    if (childType == DartTokenTypes.ASSIGNMENT_OPERATOR) {
      myChildWrap = wrap;
    }
View Full Code Here

      prev = (ASTBlock)getSubBlocks().get(index - 1);
      index--;
    }
    while (prev.getNode().getElementType() == DartTokenTypes.SEMICOLON || prev.getNode() instanceof PsiWhiteSpace);

    final IElementType elementType = myNode.getElementType();
    final IElementType prevType = prev == null ? null : prev.getNode().getElementType();
    if (prevType == DartTokenTypes.LBRACE) {
      return new ChildAttributes(Indent.getNormalIndent(), null);
    }
    if (isEndsWithRPAREN(elementType, prevType)) {
      return new ChildAttributes(Indent.getNormalIndent(), null);
View Full Code Here

    myNode = node;
    mySettings = settings;
  }

  Wrap createChildWrap(ASTNode child, Wrap defaultWrap, Wrap childWrap) {
    final IElementType childType = child.getElementType();
    final IElementType elementType = myNode.getElementType();
    if (childType == COMMA || childType == SEMICOLON) return defaultWrap;

    //
    // Function definition/call
    //
View Full Code Here

  private static Wrap createWrap(boolean isNormal) {
    return Wrap.createWrap(isNormal ? WrapType.NORMAL : WrapType.NONE, true);
  }

  private static Wrap createChildWrap(ASTNode child, int parentWrap, boolean newLineAfterLBrace, boolean newLineBeforeRBrace) {
    IElementType childType = child.getElementType();
    if (childType != LPAREN && childType != RPAREN) {
      if (FormatterUtil.isPrecededBy(child, LBRACKET)) {
        if (newLineAfterLBrace) {
          return Wrap.createChildWrap(Wrap.createWrap(parentWrap, true), WrapType.ALWAYS, true);
        }
View Full Code Here

    myBaseAlignment = Alignment.createAlignment();
  }

  @Nullable
  public Alignment createChildAlignment() {
    IElementType elementType = myNode.getElementType();

    if (BINARY_EXPRESSIONS.contains(elementType) && mySettings.ALIGN_MULTILINE_BINARY_OPERATION) {
      return myBaseAlignment;
    }
View Full Code Here

  public DartIndentProcessor(CommonCodeStyleSettings settings) {
    this.settings = settings;
  }

  public Indent getChildIndent(final ASTNode node) {
    final IElementType elementType = node.getElementType();
    final ASTNode prevSibling = UsefulPsiTreeUtil.getPrevSiblingSkipWhiteSpacesAndComments(node);
    final IElementType prevSiblingType = prevSibling == null ? null : prevSibling.getElementType();
    final ASTNode parent = node.getTreeParent();
    final IElementType parentType = parent != null ? parent.getElementType() : null;
    final ASTNode superParent = parent == null ? null : parent.getTreeParent();
    final IElementType superParentType = superParent == null ? null : superParent.getElementType();

    final int braceStyle = superParentType == FUNCTION_BODY ? settings.METHOD_BRACE_STYLE : settings.BRACE_STYLE;

    if (parent == null || parent.getTreeParent() == null || parentType == EMBEDDED_CONTENT) {
      return Indent.getNoneIndent();
View Full Code Here

TOP

Related Classes of com.intellij.psi.tree.IElementType

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.