Java 类com.intellij.psi.tree.IElementType 实例源码

项目:AppleScript-IDEA    文件:ScopeUtil.java   
@Nullable
public static PsiElement getMaxLocalScopeForTargetOrReference(PsiElement element) {
  if (element == null) {
    return null;
  }
  PsiElement currentScope;
  if (element instanceof AppleScriptTargetVariable
          || element instanceof AppleScriptReferenceElement) {
    //local scope: handler definition, current file, object declaration
    currentScope = element.getContext();
    boolean roofReached = false;
    while (!roofReached && currentScope != null) {
      IElementType elementType = currentScope.getNode().getElementType();
      roofReached = HANDLER_DEFINITIONS.contains(elementType)
              || elementType == AppleScriptParserDefinition.FILE
              || element == AppleScriptTypes.OBJECT_TARGET_PROPERTY_DECLARATION;//todo to check this
      currentScope = roofReached ? currentScope : currentScope.getContext();
    }
    return currentScope;
  }
  return null;
}
项目:AppleScript-IDEA    文件:KeywordCompletionContributor.java   
public KeywordCompletionContributor() {

    extend(CompletionType.BASIC, psiElement().inFile(StandardPatterns.instanceOf(AppleScriptFile.class)),
        new CompletionProvider<CompletionParameters>() {
          @Override
          protected void addCompletions(@NotNull CompletionParameters completionParameters,
                                        ProcessingContext processingContext,
                                        @NotNull CompletionResultSet completionResultSet) {
            PsiFile file = completionParameters.getOriginalFile();
            if (!(file instanceof AppleScriptFile)) return;
            PsiElement position = completionParameters.getPosition();
            if (position instanceof PsiComment) return;

            ASTNode node = position.getNode();
            if (node.getElementType() == AppleScriptTypes.STRING_LITERAL) return;

            for (IElementType kwElem : AppleScriptTokenTypesSets.KEYWORDS.getTypes()) {
              completionResultSet.addElement(LookupElementBuilder
                  .create(kwElem.toString().toLowerCase().replaceAll("_", " ")).bold()
                  .withTypeText("keyword", true));
            }
          }
        });
  }
项目:AppleScript-IDEA    文件:AppleScriptPairedBraceMatcher.java   
@Override
public boolean isRBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  BracePair pair = findPair(false, iterator, fileText, fileType);
  if (pair == null) return false;
  if (pair.getRightBraceType() != AppleScriptTypes.END)
    return super.isRBraceToken(iterator, fileText, fileType);//true;

  boolean result = false;
  int count = 0;
  while (true) {
    iterator.retreat();
    count++;
    if (iterator.atEnd()) break;
    IElementType eType = iterator.getTokenType();
    if (eType == AppleScriptTypes.NLS || eType == AppleScriptTypes.BLOCK_BODY)
      result = true;
    else break;
  }
  while (count-- > 0) iterator.advance();
  return result;
}
项目:reasonml-idea-plugin    文件:CommonParser.java   
@Override
public void parseLight(IElementType elementType, PsiBuilder builder) {
    builder = adapt_builder_(elementType, builder, this, null);
    PsiBuilder.Marker m = enter_section_(builder, 0, _COLLAPSE_, null);


    ParserState parserState = new ParserState(new ParserScope(file, m_types.FILE_MODULE, null));
    parseFile(builder, parserState);

    // if we have a scope at last position in file, without SEMI, we need to handle it here
    if (!parserState.scopes.empty()) {
        ParserScope scope = parserState.scopes.pop();
        while (scope != null) {
            scope.end();
            scope = parserState.scopes.empty() ? null : parserState.scopes.pop();
        }
    }

    new ParserScope(file, m_types.FILE_MODULE, null).end();

    exit_section_(builder, 0, m, elementType, true, true, TRUE_CONDITION);
}
项目:reasonml-idea-plugin    文件:RmlParser.java   
private void parseLt(PsiBuilder builder, ParserState parserState) {
    // Can be a symbol or a JSX tag
    IElementType nextTokenType = builder.rawLookup(1);
    if (nextTokenType == m_types.LIDENT || nextTokenType == m_types.UIDENT) {
        // Surely a tag
        builder.remapCurrentToken(m_types.TAG_LT);
        parserState.currentScope = markScope(builder, parserState.scopes, startTag, m_types.TAG_START, groupExpression, m_types.TAG_LT);
        parserState.currentScope.complete = true;

        builder.advanceLexer();
        parserState.dontMove = true;
        builder.remapCurrentToken(m_types.TAG_NAME);
    } else if (nextTokenType == m_types.SLASH) {
        builder.remapCurrentToken(m_types.TAG_LT);
        parserState.currentScope = markScope(builder, parserState.scopes, closeTag, m_types.TAG_CLOSE, any, m_types.TAG_LT);
        parserState.currentScope.complete = true;
    }
}
项目:reasonml-idea-plugin    文件:FoldingBuilder.java   
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
    List<FoldingDescriptor> descriptors = new ArrayList<>();

    PsiTreeUtil.processElements(root, element -> {
        IElementType elementType = element.getNode().getElementType();
        MlTypes types = elementType.getLanguage() == RmlLanguage.INSTANCE ? RmlTypes.INSTANCE : OclTypes.INSTANCE;
        if (types.COMMENT == elementType) {
            FoldingDescriptor fold = fold(element);
            if (fold != null) {
                descriptors.add(fold);
            }
        } else if (types.TYPE_EXPRESSION == elementType) {
            foldType(descriptors, (PsiType) element);
        } else if (types.LET_EXPRESSION == elementType) {
            foldLet(descriptors, (PsiLet) element);
        } else if (types.MODULE_EXPRESSION == elementType) {
            foldModule(descriptors, (PsiModule) element);
        }
        return true;
    });

    return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
项目:bamboo-soy    文件:SoyLexer.java   
@Override
public MergeFunction getMergeFunction() {
  return ((final IElementType type, final Lexer originalLexer) -> {
    if (type == SoyTypes.OTHER || type == TokenType.WHITE_SPACE) {
      IElementType returnType =  type;
      while (originalLexer.getTokenType() == SoyTypes.OTHER
          || originalLexer.getTokenType() == TokenType.WHITE_SPACE) {
        if (originalLexer.getTokenType() == SoyTypes.OTHER) {
          returnType = SoyTypes.OTHER;
        }
        originalLexer.advance();
      }
      return returnType;
    }

    return type;
  });
}
项目:idea-php-dotenv-plugin    文件:JsPsiHelper.java   
/**
 * @param psiElement checking element
 * @return true if this is process.env.*** variable
 */
public static boolean checkPsiElement(@NotNull PsiElement psiElement) {
    if(!(psiElement instanceof LeafPsiElement)) {
        return false;
    }

    IElementType elementType = ((LeafPsiElement) psiElement).getElementType();
    if(!elementType.toString().equals("JS:IDENTIFIER")) {
        return false;
    }

    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof JSReferenceExpression)) {
        return false;
    }

    return ((JSReferenceExpression) parent).getCanonicalText().startsWith("process.env");
}
项目:intellij-postfix-templates    文件:CptSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (tokenType.equals(CptTypes.SEPARATOR) || tokenType.equals(CptTypes.MAP)) {
        return SEPARATOR_KEYS;
    } else if (tokenType.equals(CptTypes.TEMPLATE_NAME)) {
        return TEMPLATE_NAME_KEYS;
    } else if (tokenType.equals(CptTypes.CLASS_NAME)) {
        return CLASS_NAME_KEYS;
    } else if (tokenType.equals(CptTypes.TEMPLATE_DESCRIPTION)) {
        return TEMPLATE_DESCRIPTION_KEYS;
    } else if (tokenType.equals(CptTypes.TEMPLATE_CODE)) {
        return TEMPLATE_CODE_KEYS;
    } else if (TEMPLATE_VARIABLE_PARTS.contains(tokenType)) {
        return TEMPLATE_VARIABLE_KEYS;
    } else if (tokenType.equals(CptTypes.TEMPLATE_ESCAPE)) {
        return TEMPLATE_ESCAPE_KEYS;
    } else if (tokenType.equals(CptTypes.COMMENT)) {
        return COMMENT_KEYS;
    } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHAR_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:hybris-integration-intellij-idea-plugin    文件:CommonPsiUtils.java   
@NotNull
@Contract(pure = true)
public static List<PsiElement> findChildrenByIElementType(
    @NotNull final PsiElement element,
    @NotNull final IElementType elementType
) {
    Validate.notNull(element);
    Validate.notNull(elementType);

    List<PsiElement> result = Collections.emptyList();
    ASTNode child = element.getNode().getFirstChildNode();

    while (child != null) {
        if (elementType == child.getElementType()) {
            if (result.isEmpty()) {
                result = new ArrayList<PsiElement>();
            }
            result.add(child.getPsi());
        }
        child = child.getTreeNext();
    }

    return result;
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexAnyHeaderParameterNameMixin.java   
@NotNull
@Override
public final PsiReference[] getReferences() {
    final IElementType leafType = Optional.ofNullable(getFirstChild())
                                          .map(PsiElement::getNode)
                                          .map(ASTNode::getElementType)
                                          .orElse(null);

    if (ImpexTypes.MACRO_USAGE.equals(leafType)) {
        return new PsiReference[]{new ImpexMacrosReferenceBase(this)};
    }

    //optimisation: dont even try for macro's and documents
    if (!ImpexTypes.HEADER_PARAMETER_NAME.equals(leafType)) {
        return PsiReference.EMPTY_ARRAY;
    }
    if (myReference == null) {
        myReference = new TypeSystemAttributeReference(this);
    }
    return new PsiReference[]{myReference};
}
项目:sercapnp    文件:CapnpSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (tokenType.equals(CapnpTypes.SEPARATOR)) {
        return SEPARATOR_KEYS;

    } else if (tokenType.equals(CapnpTypes.IDENTIFIER)){
        return IDENTIFIER_KEYS;
    } else if (tokenType.equals(CapnpTypes.KEYWORD)) {
        return KEY_KEYS;
    } else if (tokenType.equals(CapnpTypes.TYPE)) {
        return TYPE_KEYS;
    } else if (tokenType.equals(CapnpTypes.COMMENT)) {
        return COMMENT_KEYS;
    } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHAR_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:AppleScript-IDEA    文件:AppleScriptComponentScopeResolver.java   
@Nullable
private PsiElement getHandlerDefinitionScope(PsiElement scopeElement) {
  PsiElement currentScope = scopeElement;
  while (currentScope != null) {
    IElementType elementType = currentScope.getNode().getElementType();
    if (HANDLER_DEFINITIONS.contains(elementType)) {
      return currentScope;
    }
    currentScope = currentScope.getContext();
  }
  return null;
}
项目:AppleScript-IDEA    文件:AppleScriptComponentScopeResolver.java   
private boolean isInsideHandlerDefinition(PsiElement context) {
  while (context != null) {
    IElementType elementType = context.getNode().getElementType();
    if (HANDLER_DEFINITIONS.contains(elementType)) {
      return true;
    }
    context = context.getContext();
  }
  return false;
}
项目:AppleScript-IDEA    文件:AppleScriptGeneratedParserUtil.java   
/**
 * @return true if this is the application reference of a &lt;tell&gt; or &lt;using terms
 * from&gt; statements
 */
public static boolean isTellStatementStart(PsiBuilder b, int l) {
  if (!isInTellStatement(b, l + 1)) return false;
  int i = -1;
  IElementType prevElem = b.rawLookup(i);
  while (prevElem == com.intellij.psi.TokenType.WHITE_SPACE || prevElem == MY
          || prevElem == APPLICATION || prevElem == STRING_LITERAL || prevElem == null
          || prevElem == ID) {
    prevElem = b.rawLookup(--i);
  }
  return prevElem == TELL
          || (b.getUserData(IS_PARSING_USING_TERMS_FROM_STATEMENT) == Boolean.TRUE)
          && prevElem == FROM;
}
项目: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();
}
项目: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;
}
项目:AppleScript-IDEA    文件:AppleScriptNamesValidator.java   
private IElementType getTokenType(String name) {
  AppleScriptLexerAdapter lexer = new AppleScriptLexerAdapter();
  lexer.start(name);
  IElementType tt = lexer.getTokenType();
  lexer.advance();
  return lexer.getTokenType() == null ? tt : null;
}
项目:AppleScript-IDEA    文件:AppleScriptPsiImplUtil.java   
public static String getSelectorName(AppleScriptArgumentSelector argumentSelector) {
  final StringBuilder result = new StringBuilder();
  ASTNode child = argumentSelector.getNode().getFirstChildNode();
  while (child != null) {
    final IElementType tt = child.getElementType();
    if (tt == AppleScriptTypes.IDENTIFIER || tt == AppleScriptTypes.COLON) {
      result.append(child.getText());
    }
    child = child.getTreeNext();
  }
  return result.toString();
}
项目:AppleScript-IDEA    文件:AppleScriptLexerTest.java   
public void testLexerTest() {
  AppleScriptLexerAdapter lexer = new AppleScriptLexerAdapter();
  CharSequence ch = "the \"My string\"";
  lexer.start(ch);
  IElementType tt = lexer.getTokenType();
  assertTrue(tt == AppleScriptTypes.THE_KW);
  lexer.advance();
  tt = lexer.getTokenType();
  assertTrue(tt == TokenType.WHITE_SPACE);
  lexer.advance();
  tt = lexer.getTokenType();
  assertTrue(tt == AppleScriptTypes.STRING_LITERAL);
}
项目:reasonml-idea-plugin    文件:CommonParser.java   
@Override
@NotNull
public ASTNode parse(@NotNull IElementType elementType, @NotNull PsiBuilder builder) {
    //builder.setDebugMode(true);

    //System.out.println("start parsing");
    //long start = System.currentTimeMillis();

    parseLight(elementType, builder);
    ASTNode treeBuilt = builder.getTreeBuilt();

    //long end = System.currentTimeMillis();
    //System.out.println("end parsing in " + (end - start) + "ms");
    return treeBuilt;
}
项目:reasonml-idea-plugin    文件:RmlParser.java   
private void parseLBracket(PsiBuilder builder, ParserState parserState) {
    IElementType nextTokenType = builder.rawLookup(1);
    if (nextTokenType == m_types.ARROBASE) {
        parserState.currentScope = markScope(builder, parserState.scopes, annotation, m_types.ANNOTATION_EXPRESSION, scopeExpression, m_types.LBRACKET);
    } else if (nextTokenType == m_types.PERCENT) {
        parserState.currentScope = markScope(builder, parserState.scopes, macro, m_types.MACRO_EXPRESSION, scopeExpression, m_types.LBRACKET);
    } else {
        parserState.currentScope = markScope(builder, parserState.scopes, bracket, m_types.SCOPED_EXPR, scopeExpression, m_types.LBRACKET);
    }
}
项目:reasonml-idea-plugin    文件:OclParser.java   
private void parseLBracket(PsiBuilder builder, ParserState parserState) {
    IElementType nextTokenType = builder.rawLookup(1);
    if (nextTokenType == m_types.ARROBASE) {
        // This is an annotation
        parserState.currentScope = markScope(builder, parserState.scopes, annotation, m_types.ANNOTATION_EXPRESSION, scopeExpression, m_types.LBRACKET);
    } else {
        parserState.currentScope = markScope(builder, parserState.scopes, bracket, m_types.SCOPED_EXPR, scopeExpression, m_types.LBRACKET);
    }
}
项目:reasonml-idea-plugin    文件:ParserState.java   
@Nullable
public ParserScope endUntilScopeExpression(IElementType scopeElementType) {
    ParserScope scope = null;

    if (!scopes.empty()) {
        scope = scopes.peek();
        while (scope != null && scope.scopeType != scopeExpression && (scopeElementType == null || scope.scopeElementType != scopeElementType)) {
            scopes.pop().end();
            scope = getLatestScope();
        }
    }

    return scope;
}
项目: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 "{...}";
}
项目: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;
}
项目:Goal-Intellij-Plugin    文件:PrologTypes.java   
public static PsiElement createElement(ASTNode node) {
  IElementType type = node.getElementType();
   if (type == CALLABLE) {
    return new PrologCallableImpl(node);
  }
  else if (type == CLAUSE) {
    return new PrologClauseImpl(node);
  }
  else if (type == DIRECTIVE_CLAUSE) {
    return new PrologDirectiveClauseImpl(node);
  }
  else if (type == LIST) {
    return new PrologListImpl(node);
  }
  else if (type == NUMBER) {
    return new PrologNumberImpl(node);
  }
  else if (type == OPERATOR) {
    return new PrologOperatorImpl(node);
  }
  else if (type == PREDICATE) {
    return new PrologPredicateImpl(node);
  }
  else if (type == PREDICATE_SPEC) {
    return new PrologPredicateSpecImpl(node);
  }
  else if (type == STRING) {
    return new PrologStringImpl(node);
  }
  else if (type == TERM) {
    return new PrologTermImpl(node);
  }
  else if (type == TERM_LIST) {
    return new PrologTermListImpl(node);
  }
  else if (type == VARIABLE_LIST) {
    return new PrologVariableListImpl(node);
  }
  throw new AssertionError("Unknown element type: " + type);
}
项目:bamboo-soy    文件:SoyParserUtil.java   
@Override
public int getEdgePosition(List<IElementType> tokens, boolean atStreamEdge,
    TokenTextGetter getter) {
  int newLinesFound = 0;
  for (int i = tokens.size() - 1; i > 0; i--) {
    if (tokens.get(i) == DOC_COMMENT_BLOCK) {
      return i;
    }
    newLinesFound += countNewlines(getter.get(i));
    if (newLinesFound > 1) {
      break;
    }
  }
  return tokens.size();
}
项目:bamboo-soy    文件:SoyParserUtil.java   
/**
 * Matches a closing tag iff there is frame in the stack which it may close.
 */
public static boolean parseEndOfStatementBlock(PsiBuilder builder, int level) {
  if (!nextTokenIs(builder, "", LBRACE_SLASH, LBRACE_LBRACE_SLASH)) {
    return false;
  }
  Marker marker = enter_section_(builder);
  boolean r = consumeToken(builder, LBRACE_SLASH) || consumeToken(builder, LBRACE_LBRACE_SLASH);

  IElementType block = null;
  for (IElementType token : closingTokenToBlock.keySet()) {
    if (consumeToken(builder, token)) {
      block = closingTokenToBlock.get(token);
      break;
    }
  }
  if (block == null) {
    // None of the expected closing tags found.
    exit_section_(builder, marker, null, false);
    return false;
  }

  Frame frame = ErrorState.get(builder).currentFrame;
  while (frame != null) {
    if (frame.elementType == block) {
      // Found a frame that matches the closing tag.
      exit_section_(builder, marker, null, true);
      return true;
    }
    frame = frame.parentFrame;
  }

  // No matching frame found.
  exit_section_(builder, marker, null, false);
  return false;
}
项目:idea-php-dotenv-plugin    文件:DotEnvTypes.java   
public static PsiElement createElement(ASTNode node) {
  IElementType type = node.getElementType();
   if (type == COMMENT) {
    return new DotEnvCommentImpl(node);
  }
  else if (type == EMPTY_LINE) {
    return new DotEnvEmptyLineImpl(node);
  }
  else if (type == PROPERTY) {
    return new DotEnvPropertyImpl(node);
  }
  throw new AssertionError("Unknown element type: " + type);
}
项目:intellij-csv-validator    文件:CsvStructureViewElement.java   
protected PsiElement createEmptyPsiField() {
    final String text = "<undefined>";
    final IElementType type = CsvTypes.FIELD;
    final Project project = this.element.getProject();
    final PsiManager psiManager = PsiManager.getInstance(project);
    final DummyHolder dummyHolder = DummyHolderFactory.createHolder(psiManager, null);
    final FileElement fileElement = dummyHolder.getTreeElement();
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(CsvLanguage.INSTANCE);
    final Lexer lexer = parserDefinition.createLexer(project);
    final PsiBuilder psiBuilder = PsiBuilderFactory.getInstance().createBuilder(project, fileElement, lexer, CsvLanguage.INSTANCE, text);
    final ASTNode node = parserDefinition.createParser(project).parse(type, psiBuilder);
    fileElement.rawAddChildren((com.intellij.psi.impl.source.tree.TreeElement)node);
    return node.getPsi();
}
项目:EmojiPrefix    文件:EmojiResourceParser.java   
public void parseLight(IElementType t, PsiBuilder b) {
  boolean r;
  b = adapt_builder_(t, b, this, null);
  Marker m = enter_section_(b, 0, _COLLAPSE_, null);
  if (t == PROPERTY) {
    r = property(b, 0);
  }
  else {
    r = parse_root_(t, b, 0);
  }
  exit_section_(b, 0, m, t, r, true, TRUE_CONDITION);
}
项目:EmojiPrefix    文件:EmojiResourceTypes.java   
public static PsiElement createElement(ASTNode node) {
  IElementType type = node.getElementType();
   if (type == PROPERTY) {
    return new EmojiResourcePropertyImpl(node);
  }
  throw new AssertionError("Unknown element type: " + type);
}
项目:EmojiPrefix    文件:EmojiResourceSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType type) {
    if (textAttrMap.containsKey(type)) {
        return textAttrMap.get(type);
    }
    return EMPTY_KEYS;
}
项目:intellij-postfix-templates    文件:CptParser.java   
public void parseLight(IElementType t, PsiBuilder b) {
  boolean r;
  b = adapt_builder_(t, b, this, null);
  Marker m = enter_section_(b, 0, _COLLAPSE_, null);
  if (t == MAPPING) {
    r = mapping(b, 0);
  }
  else if (t == MAPPINGS) {
    r = mappings(b, 0);
  }
  else if (t == REPLACEMENT) {
    r = replacement(b, 0);
  }
  else if (t == TEMPLATE) {
    r = template(b, 0);
  }
  else if (t == TEMPLATE_CODE_G) {
    r = templateCodeG(b, 0);
  }
  else if (t == TEMPLATE_VARIABLE) {
    r = templateVariable(b, 0);
  }
  else if (t == TEMPLATE_VARIABLE_EXPRESSION_G) {
    r = templateVariableExpressionG(b, 0);
  }
  else if (t == TEMPLATE_VARIABLE_NAME_G) {
    r = templateVariableNameG(b, 0);
  }
  else if (t == TEMPLATE_VARIABLE_VALUE_G) {
    r = templateVariableValueG(b, 0);
  }
  else {
    r = parse_root_(t, b, 0);
  }
  exit_section_(b, 0, m, t, r, true, TRUE_CONDITION);
}
项目:intellij-postfix-templates    文件:CptTypes.java   
public static PsiElement createElement(ASTNode node) {
  IElementType type = node.getElementType();
   if (type == MAPPING) {
    return new CptMappingImpl(node);
  }
  else if (type == MAPPINGS) {
    return new CptMappingsImpl(node);
  }
  else if (type == REPLACEMENT) {
    return new CptReplacementImpl(node);
  }
  else if (type == TEMPLATE) {
    return new CptTemplateImpl(node);
  }
  else if (type == TEMPLATE_CODE_G) {
    return new CptTemplateCodeGImpl(node);
  }
  else if (type == TEMPLATE_VARIABLE) {
    return new CptTemplateVariableImpl(node);
  }
  else if (type == TEMPLATE_VARIABLE_EXPRESSION_G) {
    return new CptTemplateVariableExpressionGImpl(node);
  }
  else if (type == TEMPLATE_VARIABLE_NAME_G) {
    return new CptTemplateVariableNameGImpl(node);
  }
  else if (type == TEMPLATE_VARIABLE_VALUE_G) {
    return new CptTemplateVariableValueGImpl(node);
  }
  throw new AssertionError("Unknown element type: " + type);
}
项目:intellij-postfix-templates    文件:CptBlock.java   
@Override
protected List<Block> buildChildren() {
    List<Block> blocks = new ArrayList<>();
    ASTNode child = myNode.getFirstChildNode();
    while (child != null) {
        final IElementType elementType = child.getElementType();

        final Indent indent = elementType == CptTypes.MAPPINGS
            ? Indent.getNormalIndent()
            : Indent.getNoneIndent();

        final Indent childIndent = _Set(CptTypes.TEMPLATE,CptTypes.MAPPINGS, CptTypes.MAPPING, CptTypes.REPLACEMENT,
            CptTypes.TEMPLATE_ESCAPE, CptTypes.TEMPLATE_CODE, CptTypes.TEMPLATE_VARIABLE).contains(elementType)
            ? Indent.getNormalIndent()
            : Indent.getNoneIndent();

        if (elementType != TokenType.WHITE_SPACE) {
            Alignment alignment = null; //Alignment.createAlignment();

            /*
            if (elementType == CptTypes.MAP) {
                alignment = mapAlignment;
            }
            */

            Block block = new CptBlock(child, Wrap.createWrap(WrapType.NONE, false), indent, childIndent, alignment, spacingBuilder);
            blocks.add(block);
        }

        child = child.getTreeNext();
    }
    return blocks;
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    if (KEYWORD_TOKEN_SET.contains(tokenType)) {
        return KEYWORD_KEYS;
    } else if (tokenType.equals(FlexibleSearchTypes.STRING)) {
        return STRING_KEYS;
    } else if (SYMBOL_TOKEN_SET.contains(tokenType)) {
        return SYMBOL_KEYS;
    } else if (COLUMN_TOKEN_SET.contains(tokenType)) {
        return COLUMN_KEYS;
    } else if (TABLE_NAME_TOKEN_SET.contains(tokenType)) {
        return TABLE_KEYS;
    } else if (BRACES_TOKEN_SET.contains(tokenType)) {
        return BRACES_KEYS;
    } else if (BRACKETS_TOKEN_SET.contains(tokenType)) {
        return BRACKETS_KEYS;
    } else if (PARENTHESES_TOKEN_SET.contains(tokenType)) {
        return PARENTHESES_KEYS;
    } else if (tokenType.equals(FlexibleSearchTypes.NUMBER)) {
        return NUMBER_KEYS;
    } else if (tokenType.equals(FlexibleSearchParserDefinition.COMMENT)) {
        return COMMENT_KEYS;
    } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
        return BAD_CHARACTER_KEYS;
    } else {
        return EMPTY_KEYS;
    }
}
项目:intellij-csv-validator    文件:CsvValidationInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new PsiElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (element == null || !holder.getFile().getLanguage().isKindOf(CsvLanguage.INSTANCE)) {
                return;
            }

            IElementType elementType = CsvIntentionHelper.getElementType(element);
            PsiElement firstChild = element.getFirstChild();
            PsiElement nextSibling = element.getNextSibling();
            if (elementType == TokenType.ERROR_ELEMENT && CsvIntentionHelper.getElementType(firstChild) == TokenType.BAD_CHARACTER) {
                if (firstChild.getText().equals("\"")) {
                    holder.registerProblem(element, UNESCAPED_SEQUENCE, fixUnescapedSequence);
                } else {
                    holder.registerProblem(element, SEPARATOR_MISSING, fixSeparatorMissing);
                    holder.registerProblem(element, UNESCAPED_SEQUENCE, fixUnescapedSequence);
                }
            } else if ((elementType == CsvTypes.TEXT || elementType == CsvTypes.ESCAPED_TEXT)
                    && CsvIntentionHelper.getElementType(nextSibling) == TokenType.ERROR_ELEMENT
                    && nextSibling.getFirstChild() == null) {
                holder.registerProblem(element, CLOSING_QUOTE_MISSING, fixClosingQuoteMissing);
            }
        }
    };
}
项目:intellij-crystal    文件:CrystalTypes.java   
public static PsiElement createElement(ASTNode node) {
  IElementType type = node.getElementType();
   if (type == PROPERTY) {
    return new CrystalPropertyImpl(node);
  }
  throw new AssertionError("Unknown element type: " + type);
}