本文整理汇总了Java中com.intellij.lang.parser.GeneratedParserUtilBase类的典型用法代码示例。如果您正苦于以下问题:Java GeneratedParserUtilBase类的具体用法?Java GeneratedParserUtilBase怎么用?Java GeneratedParserUtilBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeneratedParserUtilBase类属于com.intellij.lang.parser包,在下文中一共展示了GeneratedParserUtilBase类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: suggestKeywords
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
private static Collection<String> suggestKeywords(PsiElement position) {
TextRange posRange = position.getTextRange();
CupFile posFile = (CupFile) position.getContainingFile();
TextRange range = new TextRange(0, posRange.getStartOffset());
String text = range.isEmpty() ? CompletionInitializationContext.DUMMY_IDENTIFIER : range.substring(posFile.getText());
int completionOffset = posRange.getStartOffset() - range.getStartOffset(); // = posRange.getStartOffset() ...
PsiFile file = PsiFileFactory.getInstance(posFile.getProject()).createFileFromText("a.cup", CupLanguage.INSTANCE, text, true, false);
GeneratedParserUtilBase.CompletionState state = new GeneratedParserUtilBase.CompletionState(completionOffset) {
@Nullable
@Override
public String convertItem(Object o) {
if (o == CupTypes.IDENTIFIER) {
return null;
}
return o.toString();
}
};
file.putUserData(GeneratedParserUtilBase.COMPLETION_STATE_KEY, state);
TreeUtil.ensureParsed(file.getNode());
return state.items;
}
示例2: addCompletions
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext processingContext, @NotNull CompletionResultSet resultSet) {
PsiElement position = parameters.getPosition();
PsiElement parent = position.getParent();
PsiElement grandParent = Optional.ofNullable(parent)
.map(PsiElement::getParent)
.orElse(null);
if (parent instanceof ElmFile || parent instanceof GeneratedParserUtilBase.DummyBlock) {
addCompletionsInInvalidExpression(position, resultSet);
} else if (grandParent instanceof ElmLowerCasePath) {
this.addValueOrFieldCompletions((ElmLowerCaseId) parent, resultSet);
} else if (grandParent instanceof ElmMixedCasePath
|| grandParent instanceof ElmUpperCasePath) {
addTypeOrModuleCompletions(parent, resultSet);
} else if (grandParent instanceof ElmExposingClause) {
this.addExposedValuesCompletion((ElmExposingClause)grandParent, resultSet);
} else if (parent instanceof ElmUpperCaseId) {
this.addExposedValuesCompletion((ElmUpperCaseId)parent, resultSet);
} else if (parent instanceof ElmLowerCaseId && grandParent instanceof ElmModuleDeclaration) {
this.singleModuleValueProvider.addCompletions((ElmFile)grandParent.getContainingFile(), resultSet);
}
}
示例3: CaseOfParser
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
public CaseOfParser(
GeneratedParserUtilBase.Parser header,
GeneratedParserUtilBase.Parser branch,
GeneratedParserUtilBase.Parser oneOrMoreSeparations
) {
this.header = header;
this.branch = branch;
this.oneOrMoreSeparations = oneOrMoreSeparations;
}
示例4: current_position_
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
/**
* Returns current position in the {@link PsiBuilder}.
*
* @param builder_ builder
* @return current position
*/
public static int current_position_(PsiBuilder builder_) {
try {
if (GeneratedParserUtilBase.class.getMethod("current_position_", PsiBuilder.class) != null) {
return GeneratedParserUtilBase.current_position_(builder_);
}
} catch (NoSuchMethodException ignored) {
}
return 0;
}
示例5: nextTokenIs
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
/**
* Checks if next token of {@link PsiBuilder} is in the given tokens list.
*
* @param builder_ builder
* @param frameName frame name
* @param tokens tokens list
* @return builder is in the tokens list
*/
public static boolean nextTokenIs(PsiBuilder builder_, String frameName, IElementType... tokens) {
try {
if (GeneratedParserUtilBase.class.getMethod("nextTokenIs", PsiBuilder.class, String.class, IElementType.class) != null) {
return GeneratedParserUtilBase.nextTokenIs(builder_, frameName, tokens);
}
} catch (NoSuchMethodException ignored) {
}
return true;
}
示例6: empty_element_parsed_guard_
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
/**
* Checks if at the given position there is empty element.
*
* @param builder_ builder
* @param funcName_ function name
* @param prev_position_ previous position
* @return empty element at the given position
*/
public static boolean empty_element_parsed_guard_(PsiBuilder builder_, String funcName_, int prev_position_) {
try {
if (GeneratedParserUtilBase.class.getMethod("nextTokenIs", PsiBuilder.class, String.class, int.class) != null) {
return GeneratedParserUtilBase.empty_element_parsed_guard_(builder_, funcName_, prev_position_);
}
} catch (NoSuchMethodException ignored) {
}
return true;
}
示例7: suggestKeywords
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
private Collection<String> suggestKeywords(@NotNull PsiElement position)
{
PsiFile psiFile = position.getContainingFile();
PsiElement topLevelElement = position;
while(!(topLevelElement.getParent() instanceof PsiFile))
{
topLevelElement = topLevelElement.getParent();
}
PsiFile file = PsiFileFactory.getInstance(psiFile.getProject()).createFileFromText("a.thrift", ThriftLanguage.INSTANCE, topLevelElement.getText(), true, false);
GeneratedParserUtilBase.CompletionState state = new GeneratedParserUtilBase.CompletionState(position.getTextOffset() - topLevelElement.getTextOffset());
file.putUserData(GeneratedParserUtilBase.COMPLETION_STATE_KEY, state);
TreeUtil.ensureParsed(file.getNode());
return state.items;
}
示例8: suggestKeywords
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
private Collection<String> suggestKeywords(@NotNull PsiElement position) {
PsiFile psiFile = position.getContainingFile();
PsiElement topLevelElement = position;
while (!(topLevelElement.getParent() instanceof PsiFile)) {
topLevelElement = topLevelElement.getParent();
}
PsiFile file = PsiFileFactory.getInstance(psiFile.getProject())
.createFileFromText("a.thrift", ThriftLanguage.INSTANCE, topLevelElement.getText(), true, false);
GeneratedParserUtilBase.CompletionState state =
new GeneratedParserUtilBase.CompletionState(position.getTextOffset() - topLevelElement.getTextOffset());
file.putUserData(GeneratedParserUtilBase.COMPLETION_STATE_KEY, state);
TreeUtil.ensureParsed(file.getNode());
return state.items;
}
示例9: adapt_builder_
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
public static PsiBuilder adapt_builder_(IElementType root, PsiBuilder builder, PsiParser parser, TokenSet[] tokenSets) {
PsiBuilder result = GeneratedParserUtilBase.adapt_builder_(root, builder, parser, tokenSets);
ErrorState.get(result).altMode = true;
return result;
}
示例10: DummyRoot
import com.intellij.lang.parser.GeneratedParserUtilBase; //导入依赖的package包/类
public DummyRoot(PsiElement child) {
super(GeneratedParserUtilBase.DUMMY_BLOCK);
this.child = child;
}