本文整理汇总了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;
}
示例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));
}
}
});
}
示例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;
}
示例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);
}
示例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;
}
}
示例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()]);
}
示例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;
});
}
示例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");
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例15: isTellStatementStart
import com.intellij.psi.tree.IElementType; //导入依赖的package包/类
/**
* @return true if this is the application reference of a <tell> or <using terms
* from> 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;
}