本文整理汇总了Java中com.intellij.lang.impl.PsiBuilderImpl类的典型用法代码示例。如果您正苦于以下问题:Java PsiBuilderImpl类的具体用法?Java PsiBuilderImpl怎么用?Java PsiBuilderImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiBuilderImpl类属于com.intellij.lang.impl包,在下文中一共展示了PsiBuilderImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assign_ref_expr
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static boolean assign_ref_expr(PsiBuilder b, int l) {
//So this is rather wonky. What we do here is try to parse the incoming nodes as an expression,
// as assign_ref_expr (and the below rules) need an expression as the first argument, but
// you can chain them together. And calling expr will eat the assign_ref_expr when it parses.
//So to get to the point here:
// We run expr() and then see what it comes up with. If the last node (basically the expression
// that it parsed from the call) is of our type, then we successfully parsed it.
boolean r;
PsiBuilder.Marker m = enter_section_(b);
//Group -1 so we parse whatever expression is next
r = expr(b, l + 1, -1);
if (r) {
//If we parsed an expression, check if we parsed the type we'ere looking for
PsiBuilderImpl.ProductionMarker last = (PsiBuilderImpl.ProductionMarker) b.getLatestDoneMarker();
r = last != null && last.getTokenType().equals(ASSIGN_REF_EXPR);
}
exit_section_(b, m, null, r);
return r;
}
示例2: createBuilder
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static PsiBuilderImpl createBuilder(CharSequence text) {
ParserDefinition parserDefinition = new PlainTextParserDefinition() {
@NotNull
@Override
public Lexer createLexer(Project project) {
return new MyTestLexer();
}
@NotNull
@Override
public TokenSet getWhitespaceTokens() {
return WHITESPACE_SET;
}
@NotNull
@Override
public TokenSet getCommentTokens() {
return COMMENT_SET;
}
};
return new PsiBuilderImpl(getProject(), null, parserDefinition, parserDefinition.createLexer(getProject()), null, text, null, null);
}
示例3: close_marker_impl_
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
if (marker == null) return;
if (result) {
if (elementType != null) {
marker.done(elementType);
}
else {
marker.drop();
}
}
else {
if (frame != null) {
int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartIndex();
if (frame.errorReportedAt > position && frame.parentFrame != null) {
frame.errorReportedAt = frame.parentFrame.errorReportedAt;
}
}
marker.rollbackTo();
}
}
示例4: createAST
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private ASTNode createAST(String text) {
ParserDefinition definition = new BuildParserDefinition();
PsiParser parser = definition.createParser(getProject());
Lexer lexer = definition.createLexer(getProject());
PsiBuilderImpl psiBuilder =
new PsiBuilderImpl(
getProject(), null, definition, lexer, new CharTableImpl(), text, null, null);
PsiBuilderAdapter adapter =
new PsiBuilderAdapter(psiBuilder) {
@Override
public void error(String messageText) {
super.error(messageText);
errors.add(messageText);
}
};
return parser.parse(definition.getFileNodeType(), adapter);
}
示例5: close_marker_impl_
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
if (marker == null) return;
if (result) {
if (elementType != null) {
marker.done(elementType);
}
else {
marker.drop();
}
}
else {
if (frame != null) {
int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartOffset();
if (frame.errorReportedAt > position) {
frame.errorReportedAt = frame.errorReportedAtPrev;
}
}
marker.rollbackTo();
}
}
示例6: close_marker_impl_
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
if (marker == null) return;
if (result) {
if (elementType != null) {
marker.done(elementType);
}
else {
marker.drop();
}
}
else {
if (frame != null) {
int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartIndex();
if (frame.errorReportedAt > position && frame.parentFrame != null) {
frame.errorReportedAt = frame.parentFrame.errorReportedAt;
}
}
marker.rollbackTo();
}
}
示例7: close_marker_impl_
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
if (marker == null) return;
if (result) {
if (elementType != null) {
marker.done(elementType);
}
else {
marker.drop();
}
}
else {
if (frame != null) {
int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartIndex();
if (frame.errorReportedAt > position && frame.parentFrame != null) {
frame.errorReportedAt = frame.parentFrame.errorReportedAt;
}
}
marker.rollbackTo();
}
}
示例8: assign_ref_index_expr
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static boolean assign_ref_index_expr(PsiBuilder b, int l) {
//See assign_ref_expr for explanation
boolean r;
PsiBuilder.Marker m = enter_section_(b);
r = expr(b, l + 1, -1);
if (r) {
PsiBuilderImpl.ProductionMarker last = (PsiBuilderImpl.ProductionMarker)b.getLatestDoneMarker();
r = last != null && last.getTokenType().equals(ASSIGN_REF_INDEX_EXPR);
}
exit_section_(b, m, null, r);
return r;
}
示例9: call_method_expr
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static boolean call_method_expr(PsiBuilder b, int l) {
//See assign_ref_expr for explanation
boolean r;
PsiBuilder.Marker m = enter_section_(b);
r = expr(b, l + 1, -1);
if (r) {
PsiBuilderImpl.ProductionMarker last = (PsiBuilderImpl.ProductionMarker)b.getLatestDoneMarker();
r = last != null && last.getTokenType().equals(CALL_METHOD_EXPR);
}
exit_section_(b, m, null, r);
return r;
}
示例10: parse
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
@Override
@NotNull
public ASTNode parse(final IElementType root, final PsiBuilder builder) {
builder.enforceCommentTokens(TokenSet.EMPTY);
builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, REPARSE_XML_TAG_BY_NAME);
final PsiBuilder.Marker file = builder.mark();
new XmlParsing(builder).parseDocument();
file.done(root);
return builder.getTreeBuilt();
}
示例11: createBuilder
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static PsiBuilderImpl createBuilder(final String text, ASTNode originalTree) {
final Language lang = StdFileTypes.JAVA.getLanguage();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
assertNotNull(parserDefinition);
PsiFile psiFile = createFile("x.java", text);
return new PsiBuilderImpl(getProject(), psiFile, parserDefinition, JavaParserDefinition.createLexer(LanguageLevel.JDK_1_5),
SharedImplUtil.findCharTableByTree(psiFile.getNode()), text, originalTree, null);
}
示例12: reportError
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
private static boolean reportError(PsiBuilder builder,
ErrorState state,
Frame frame,
IElementType elementType,
boolean force,
boolean advance) {
String expectedText = state.getExpectedText(builder);
boolean notEmpty = StringUtil.isNotEmpty(expectedText);
if (!(force || notEmpty || advance)) return false;
String gotText = builder.eof() ? "unexpected end of file" :
notEmpty? "got '" + builder.getTokenText() +"'" :
"'" + builder.getTokenText() +"' unexpected";
String message = expectedText + gotText;
if (advance) {
PsiBuilder.Marker mark = builder.mark();
builder.advanceLexer();
mark.error(message);
}
else if (!force) {
PsiBuilder.Marker extensionMarker = null;
IElementType extensionTokenType = null;
PsiBuilderImpl.ProductionMarker latestDoneMarker = elementType == null ? null : (PsiBuilderImpl.ProductionMarker)builder.getLatestDoneMarker();
if (latestDoneMarker != null &&
frame.position >= latestDoneMarker.getStartIndex() &&
frame.position <= latestDoneMarker.getEndIndex()) {
extensionMarker = ((PsiBuilder.Marker)latestDoneMarker).precede();
extensionTokenType = latestDoneMarker.getTokenType();
((PsiBuilder.Marker)latestDoneMarker).drop();
}
builder.error(message);
if (extensionMarker != null) extensionMarker.done(extensionTokenType);
}
else {
builder.error(message);
}
builder.eof(); // skip whitespaces
frame.errorReportedAt = builder.rawTokenIndex();
return true;
}
示例13: MasqueradingPsiBuilderAdapter
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
public MasqueradingPsiBuilderAdapter(@NotNull final Project project,
@NotNull final ParserDefinition parserDefinition,
@NotNull final MasqueradingLexer lexer,
@NotNull final ASTNode chameleon,
@NotNull final CharSequence text) {
this(new PsiBuilderImpl(project, parserDefinition, lexer, chameleon, text));
}
示例14: doParse
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
public void doParse(IElementType root, PsiBuilder builder) {
builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, MATCH_BY_KEY);
final PsiBuilder.Marker rootMarker = builder.mark();
final PsiBuilder.Marker propertiesList = builder.mark();
while (!builder.eof()) {
Parsing.parseProperty(builder);
}
propertiesList.done(PropertiesElementTypes.PROPERTIES_LIST);
rootMarker.done(root);
}
示例15: parseText
import com.intellij.lang.impl.PsiBuilderImpl; //导入依赖的package包/类
public static @NotNull <T extends PsiElement> T parseText(
@NotNull String text,
@NotNull IElementType rootElementType,
@NotNull Class<T> rootElementClass,
@NotNull ParserDefinition parserDefinition,
@Nullable ErrorProcessor errorProcessor) {
LanguageParserDefinitions.INSTANCE.addExplicitExtension(
parserDefinition.getFileNodeType().getLanguage(),
parserDefinition
);
PsiParser parser = parserDefinition.createParser(model.first);
Lexer lexer = parserDefinition.createLexer(model.first);
PsiBuilderImpl psiBuilder = new PsiBuilderImpl(
model.first,
null,
parserDefinition,
lexer,
new CharTableImpl(),
text,
null,
null
);
ASTNode astNode = parser.parse(rootElementType, psiBuilder);
T res = astNode.getPsi(rootElementClass);
collectErrors(res, errorProcessor);
return res;
}