當前位置: 首頁>>代碼示例>>Java>>正文


Java IElementType類代碼示例

本文整理匯總了Java中com.intellij.psi.tree.IElementType的典型用法代碼示例。如果您正苦於以下問題:Java IElementType類的具體用法?Java IElementType怎麽用?Java IElementType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IElementType類屬於com.intellij.psi.tree包,在下文中一共展示了IElementType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMaxLocalScopeForTargetOrReference

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:23,代碼來源:ScopeUtil.java

示例2: KeywordCompletionContributor

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
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));
            }
          }
        });
  }
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:25,代碼來源:KeywordCompletionContributor.java

示例3: isRBraceToken

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:22,代碼來源:AppleScriptPairedBraceMatcher.java

示例4: parseLight

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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);
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:23,代碼來源:CommonParser.java

示例5: parseLt

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
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;
    }
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:19,代碼來源:RmlParser.java

示例6: buildFoldRegions

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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()]);
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:26,代碼來源:FoldingBuilder.java

示例7: getMergeFunction

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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;
  });
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:19,代碼來源:SoyLexer.java

示例8: checkPsiElement

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
/**
 * @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");
}
 
開發者ID:adelf,項目名稱:idea-php-dotenv-plugin,代碼行數:22,代碼來源:JsPsiHelper.java

示例9: getTokenHighlights

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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;
	}
}
 
開發者ID:xylo,項目名稱:intellij-postfix-templates,代碼行數:26,代碼來源:CptSyntaxHighlighter.java

示例10: findChildrenByIElementType

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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;
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:25,代碼來源:CommonPsiUtils.java

示例11: getReferences

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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};
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:22,代碼來源:ImpexAnyHeaderParameterNameMixin.java

示例12: getTokenHighlights

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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;
    }
}
 
開發者ID:xmonader,項目名稱:sercapnp,代碼行數:21,代碼來源:CapnpSyntaxHighlighter.java

示例13: getHandlerDefinitionScope

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
@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;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:13,代碼來源:AppleScriptComponentScopeResolver.java

示例14: isInsideHandlerDefinition

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
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;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:11,代碼來源:AppleScriptComponentScopeResolver.java

示例15: isTellStatementStart

import com.intellij.psi.tree.IElementType; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:18,代碼來源:AppleScriptGeneratedParserUtil.java


注:本文中的com.intellij.psi.tree.IElementType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。