com.intellij.lang.PsiBuilderFactory Java Examples
The following examples show how to use
com.intellij.lang.PsiBuilderFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSharpFileFactory.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Nonnull private static IElementType createElementType(String id, BiConsumer<PsiBuilder, LanguageVersion> consumer) { return new IFileElementType(id, CSharpLanguage.INSTANCE) { @Override protected ASTNode doParseContents(@Nonnull ASTNode chameleon, @Nonnull 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, null, languageForParser, languageVersion, chameleon.getChars()); consumer.accept(builder, languageVersion); while(!builder.eof()) { builder.advanceLexer(); } return builder.getTreeBuilt(); } }; }
Example #2
Source File: CSharpFileStubElementType.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction @Override protected ASTNode doParseContents(@Nonnull ASTNode chameleon, @Nonnull PsiElement psi) { final Project project = psi.getProject(); final Language languageForParser = getLanguageForParser(psi); final LanguageVersion tempLanguageVersion = chameleon.getUserData(LanguageVersion.KEY); final CSharpLanguageVersionWrapper languageVersion = (CSharpLanguageVersionWrapper) (tempLanguageVersion == null ? psi.getLanguageVersion() : tempLanguageVersion); Set<String> defVariables = getStableDefines((PsiFile) psi); final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, languageForParser, languageVersion, chameleon.getChars()); builder.putUserData(PREPROCESSOR_VARIABLES, defVariables); final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(languageForParser).createParser(languageVersion); return parser.parse(this, builder, languageVersion).getFirstChildNode(); }
Example #3
Source File: LightApplicationBuilder.java From consulo with Apache License 2.0 | 6 votes |
@Override public void registerServices(@Nonnull InjectingContainerBuilder builder) { builder.bind(PsiBuilderFactory.class).to(PsiBuilderFactoryImpl.class); builder.bind(FileTypeRegistry.class).to(LightFileTypeRegistry.class); builder.bind(FileDocumentManager.class).to(LightFileDocumentManager.class); builder.bind(JobLauncher.class).to(LightJobLauncher.class); builder.bind(EncodingManager.class).to(LightEncodingManager.class); builder.bind(PathMacrosService.class).to(LightPathMacrosService.class); builder.bind(PathMacros.class).to(LightPathMacros.class); builder.bind(UISettings.class); builder.bind(ExpandableItemsHandlerFactory.class).to(LightExpandableItemsHandlerFactory.class); builder.bind(TreeUIHelper.class).to(LightTreeUIHelper.class); builder.bind(UiActivityMonitor.class).to(LightUiActivityMonitor.class); builder.bind(TreeAnchorizer.class).to(TreeAnchorizer.class); builder.bind(ProgressManager.class).to(CoreProgressManager.class); }
Example #4
Source File: OclParser.java From reasonml-idea-plugin with MIT License | 5 votes |
public static ASTNode parseOcamlNode(@NotNull ILazyParseableElementType root, @NotNull ASTNode chameleon) { PsiElement parentElement = chameleon.getTreeParent().getPsi(); Project project = parentElement.getProject(); PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new OclLexer(), root.getLanguage(), chameleon.getText()); //builder.setDebugMode(true); OclParser parser = new OclParser(); return parser.parse(root, builder).getFirstChildNode(); }
Example #5
Source File: CSharpPreprocessorElements.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override protected ASTNode doParseContents(@Nonnull ASTNode chameleon, @Nonnull 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(); }
Example #6
Source File: CSharpFragmentFactory.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override protected ASTNode doParseContents(@Nonnull final ASTNode chameleon, @Nonnull final 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, null, languageForParser, languageVersion, chameleon.getChars()); return ourExpressionParser.parse(this, builder, languageVersion).getFirstChildNode(); }
Example #7
Source File: CSharpFragmentFactory.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override protected ASTNode doParseContents(@Nonnull final ASTNode chameleon, @Nonnull final 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, null, languageForParser, languageVersion, chameleon.getChars()); return ourTypeParser.parse(this, builder, languageVersion).getFirstChildNode(); }
Example #8
Source File: BaseMethodBodyLazyElementType.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override @RequiredReadAction protected ASTNode doParseContents(@Nonnull ASTNode chameleon, @Nonnull 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, null, languageForParser, languageVersion, chameleon.getChars()); builder.putUserData(CSharpFileStubElementType.PREPROCESSOR_VARIABLES, collectVariableFor(psi)); CSharpBuilderWrapper wrapper = new CSharpBuilderWrapper(builder, languageVersion); PsiBuilder.Marker mark = wrapper.mark(); ModifierSet modifierSet = ModifierSet.EMPTY; if(psi instanceof DotNetModifierListOwner) { CSharpModifierList modifierList = (CSharpModifierList) ((DotNetModifierListOwner) psi).getModifierList(); if(modifierList != null && modifierList.hasModifierInTree(CSharpModifier.ASYNC)) { modifierSet = ModifierSet.create(CSharpSoftTokens.ASYNC_KEYWORD); } } parse(wrapper, modifierSet); while(!wrapper.eof()) { PsiBuilder.Marker er = wrapper.mark(); wrapper.advanceLexer(); er.error("Unexpected token"); } mark.done(this); return wrapper.getTreeBuilt().getFirstChildNode(); }
Example #9
Source File: CSharpDocElements.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override @RequiredReadAction protected ASTNode doParseContents(@Nonnull final ASTNode chameleon, @Nonnull 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(); }
Example #10
Source File: CSharpDocElements.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override protected ASTNode doParseContents(@Nonnull final ASTNode chameleon, @Nonnull final PsiElement psi) { Project project = psi.getProject(); Language languageForParser = getLanguageForParser(psi); CSharpReferenceLexer lexer = new CSharpReferenceLexer(); PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, lexer, languageForParser, languageForParser.getVersions()[0], chameleon.getChars()); return myParser.parse(this, builder, languageForParser.getVersions()[0]).getFirstChildNode(); }
Example #11
Source File: HaxeExpressionCodeFragmentImpl.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Override protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi) { final PsiBuilderFactory factory = PsiBuilderFactory.getInstance(); final PsiBuilder psiBuilder = factory.createBuilder(getProject(), chameleon); final PsiBuilder builder = adapt_builder_(HaxeTokenTypes.EXPRESSION, psiBuilder, new HaxeParser()); final PsiBuilder.Marker marker = enter_section_(builder, 0, _NONE_, "<code fragment>"); HaxeParser.expression(builder, 1); while (builder.getTokenType() != null) { builder.advanceLexer(); } marker.done(HaxeTokenTypes.EXPRESSION); return builder.getTreeBuilt(); }
Example #12
Source File: PsiManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Inject public PsiManagerImpl(@Nonnull Project project, @Nonnull Provider<FileIndexFacade> fileIndexFacadeProvider, @Nonnull PsiModificationTracker modificationTracker) { // we need to initialize PsiBuilderFactory service so it won't initialize under PsiLock from ChameleonTransform PsiBuilderFactory.getInstance(); myProject = project; myFileIndex = fileIndexFacadeProvider; myModificationTracker = modificationTracker; myFileManager = new FileManagerImpl(this, fileIndexFacadeProvider); myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)myModificationTracker); Disposer.register(project, () -> myIsDisposed = true); }