@Override public PsiParser createParser(Project project) { return new PsiParser() { @NotNull @Override public ASTNode parse(IElementType root, PsiBuilder builder) { final PsiBuilder.Marker rootMarker = builder.mark(); final PsiBuilder.Marker propertiesList = builder.mark(); while (!builder.eof()) { parseProvider(builder); } propertiesList.done(SPIElementTypes.PROVIDERS_LIST); rootMarker.done(root); return builder.getTreeBuilt(); } }; }
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); }
@NotNull @Override public PsiParser createParser(Project project) { return new PsiParser() { @NotNull @Override public ASTNode parse(IElementType root, PsiBuilder builder) { return new DtdParsing(root, XmlEntityDecl.EntityContextType.GENERIC_XML, builder).parse(); } }; }
@Override public PsiParser createParser(Project project) { return (root, builder) -> { PsiBuilder.Marker rootMarker = builder.mark(); new ProjectViewPsiParser(builder).parseFile(); rootMarker.done(root); return builder.getTreeBuilt(); }; }
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; }
@NotNull public PsiParser createParser(final Project project) { if(project != null) { project.putUserData(JSGRAPHQL_ACTIVATED, true); } return new JSGraphQLParser(); }
@NotNull public PsiParser createParser(final Project project) { //return new MultiMarkdownParser(); return MultiMarkdownGlobalSettings.getInstance().lightParserFailedBuild.runBuild(new FailedBuildRunnable<PsiParser>() { @Nullable @Override public PsiParser runCanFail() throws Throwable { return new MultiMarkdownLightParser(); } @Nullable @Override public PsiParser run() { return new MultiMarkdownParser(); } }); }
/** * Called when the parser gets confused from layout rules. * * Increases the debt of rbraces in the token remapper in * HaskellParserWrapper. When the remapper is in debt it will swallow * (=remap them to TokenType.WHITE_SPACE) synthetic rbraces until no debt * remains. */ public static boolean stateHackMess(@NotNull PsiBuilder builder, int level) { if (!(builder instanceof Builder)) return false; PsiParser wrapper = ((Builder) builder).parser; if (!(wrapper instanceof HaskellParserWrapper)) return false; // IElementType tok = builder.getTokenType(); int offs = builder.getCurrentOffset(); int line = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs); int lineStart = StringUtil.lineColToOffset(builder.getOriginalText(), line, 1); Pair<Integer, Integer> p = ((HaskellParserWrapper) wrapper).debtPoints.get(offs); if (p != null && p.getSecond() == 0 && !((HaskellParserWrapper) wrapper).regressed) { ((HaskellParserWrapper) wrapper).maxRbraceDebt = ((HaskellParserWrapper) wrapper).debtPoints.get(offs).getFirst(); ((HaskellParserWrapper) wrapper).rbraceDebt = ((HaskellParserWrapper) wrapper).rbraceDebt - ((HaskellParserWrapper) wrapper).maxRbraceDebt; ((HaskellParserWrapper) wrapper).debtPoints.put(offs, Pair.create(((HaskellParserWrapper) wrapper).maxRbraceDebt, ((HaskellParserWrapper) wrapper).maxRbraceDebt)); } else if (((HaskellParserWrapper) wrapper).maxRbraceDebt == -1) { int numOpen = findBraces(((HaskellParserWrapper) wrapper).lexer.openBraces, offs, line, lineStart); ((HaskellParserWrapper) wrapper).maxRbraceDebt = numOpen; } // System.out.println("Confused at: " + offs + " line " + line + " on token " + tok // + " regressed: " + ((HaskellParserWrapper) wrapper).regressed + " max: " // + ((HaskellParserWrapper) wrapper).maxRbraceDebt); boolean ret = ((HaskellParserWrapper) wrapper).increaseRbraceDebt(builder.getCurrentOffset()); if (((HaskellParserWrapper) wrapper).maxRbraceDebt == 0) ((HaskellParserWrapper) wrapper).maxRbraceDebt = -1; return ret; }
public static boolean indented(@NotNull PsiBuilder builder, int level, Parser geq) { if (!(builder instanceof Builder)) return false; PsiParser wrapper = ((Builder) builder).parser; if (!(wrapper instanceof HaskellParserWrapper)) return false; if (builder.eof()) return false; // IElementType currtok = builder.getTokenType(); Pair<Integer, IElementType> prevtok = previousElem(builder); if (prevtok == null) return true; int offs = builder.getCurrentOffset(); int line = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs); int prevline = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs + prevtok.getFirst()); if (prevline == line) return true; int thisLineStart = StringUtil.lineColToOffset(builder.getOriginalText(), line, 0); int prevLineStart = StringUtil.lineColToOffset(builder.getOriginalText(), prevline, 0); // CharSequence lineStuff = builder.getOriginalText().subSequence(thisLineStart, offs); CharSequence prevLineStuff = builder.getOriginalText().subSequence(prevLineStart, thisLineStart - 1); int indentation = indentationLevel(prevLineStuff); int myindentation = offs - thisLineStart; // String tokName = builder.getTokenText(); boolean geqVal = geq.parse(builder, level); if (geqVal && myindentation >= indentation || !geqVal && myindentation > indentation) return true; return false; }
@Override protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi) { final Project project = psi.getProject(); final Language languageForParser = getLanguageForParser(psi); final LanguageVersion tempLanguageVersion = chameleon.getUserData(LanguageVersion.KEY); final LanguageVersion languageVersion = tempLanguageVersion == null ? psi.getLanguageVersion() : tempLanguageVersion; final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new _CSharpMacroLexer(), languageForParser, languageVersion, chameleon.getChars()); final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(languageForParser).createParser(languageVersion); return parser.parse(this, builder, languageVersion).getFirstChildNode(); }
@Override @RequiredReadAction protected ASTNode doParseContents(@NotNull final ASTNode chameleon, @NotNull final PsiElement psi) { final Project project = psi.getProject(); CSharpDocLanguage docLanguage = CSharpDocLanguage.INSTANCE; final LanguageVersion languageVersion = LanguageVersionUtil.findDefaultVersion(docLanguage); DeprecatedCSharpDocLexer docLexer = new DeprecatedCSharpDocLexer(); final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, docLexer, docLanguage, languageVersion, chameleon.getChars()); final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(docLanguage).createParser(languageVersion); return parser.parse(this, builder, languageVersion).getFirstChildNode(); }
@NotNull private PsiBuilder doParse(@NotNull ASTNode chameleon, Project project, LanguageVersion languageVersion) { LanguageLevel languageLevel = LanguageLevel.HIGHEST; PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new JspJavaLexer(languageLevel), JavaLanguage.INSTANCE, languageVersion, chameleon.getChars()); JavaParserUtil.setLanguageLevel(builder, languageLevel); PsiParser parser = new JavaInJspParser(); parser.parse(this, builder, languageVersion); return builder; }
@NotNull @Override public PsiParser createParser() { if(myExpressionElementType == null) { myExpressionElementType = createExpressionElementType(); } return new CfsParser(myExpressionElementType); }
@Nonnull @Override public PsiParser createParser(@Nonnull LanguageVersion languageVersion) { if(languageVersion instanceof LanguageVersionWithParsing) { return ((LanguageVersionWithParsing)languageVersion).createParser(); } throw new IllegalArgumentException("'createParser' need override for language version '" + languageVersion + "'"); }
@Override public PsiParser createParser(Project project) { return new TSParser(); }
@NotNull public PsiParser createParser(final Project project) { return new AppleScriptParser(); }
@NotNull public PsiParser createParser(final Project project) { return new RmlParser(); }
@NotNull public PsiParser createParser(final Project project) { return new OclParser(); }
@NotNull public PsiParser createParser(final Project project) { return new GCMParser(); }
@NotNull public PsiParser createParser(final Project project) { return new SoyParser(); }
@Override public PsiParser createParser(Project project) { return new EmojiResourceParser(); }
@NotNull public PsiParser createParser(final Project project) { return new FlexibleSearchParser(); }
@NotNull @Override public PsiParser createParser(final Project project) { return new ImpexParser(); }
@Override public PsiParser createParser(Project project) { return new OneScriptParser(); }
@Override @NotNull public PsiParser createParser(final Project project) { return new CsvParser(); }
@Override public PsiParser createParser(Project project) { return new ActionSpecParser(); }
@Override public PsiParser createParser(Project project) { return new PrologParser(); }
@Override public PsiParser createParser(Project project) { return new ModuleParser(); }
@Override public PsiParser createParser(Project project) { return new MasParser(); }
@Override public PsiParser createParser(Project project) { return new TestParser(); }
@Nullable public PsiParser createParser(final Project project) { return new YAMLParser(); }
@Override public PsiParser createParser(Project project) { return new MelParser(); }
@Override public PsiParser createParser(Project project) { return new WeaveParser(); }
@NotNull public PsiParser createParser(final Project project) { return new NixParser(); }
@Override public PsiParser createParser(final Project project) { return new SutrParser(); }
@Override public PsiParser createParser(final Project project) { return new UtrParser(); }
@NotNull public PsiParser createParser(final Project project) { return new SmcParser(); }