Java Code Examples for com.intellij.lang.ASTNode#getUserData()
The following examples show how to use
com.intellij.lang.ASTNode#getUserData() .
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: HaxeFoldingBuilder.java From intellij-haxe with Apache License 2.0 | 6 votes |
@Override public boolean isCollapsedByDefault(@NotNull ASTNode node) { final PsiElement psiElement = node.getPsi(); final CodeFoldingSettings settings = CodeFoldingSettings.getInstance(); final HaxeFoldingSettings haxeSettings = HaxeFoldingSettings.getInstance(); if (psiElement instanceof HaxeImportStatement || psiElement instanceof HaxeUsingStatement) { return settings.COLLAPSE_IMPORTS; } if (isDocComment(node) && !hasRegionMarker(node)) return settings.COLLAPSE_DOC_COMMENTS; RegionDefinition regionType = node.getUserData(REGION_DEFINITION_KEY); if (regionType == C_SHARP_STYLE) return haxeSettings.isCollapseCSharpStyleRegions(); if (regionType == FD_STYLE) return haxeSettings.isCollapseFlashDevelopStyleRegions(); if (regionType == PLUGIN_STYLE) return haxeSettings.isCollapseHaxePluginStyleRegions(); if (regionType == CC_REGION) { return haxeSettings.isCollapseUnusedConditionallyCompiledCode() && isUnusedCCRegion(node); } return false; }
Example 4
Source File: PsiInvalidElementAccessException.java From consulo with Apache License 2.0 | 6 votes |
public static Object findInvalidationTrace(@Nullable ASTNode element) { while (element != null) { Object trace = element.getUserData(INVALIDATION_TRACE); if (trace != null) { return trace; } ASTNode parent = element.getTreeParent(); if (parent == null && element instanceof FileASTNode) { PsiElement psi = element.getPsi(); trace = psi == null ? null : psi.getUserData(INVALIDATION_TRACE); if (trace != null) { return trace; } } element = parent; } return null; }
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: CompositeFoldingBuilder.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction @Override public String getPlaceholderText(@Nonnull ASTNode node, @Nonnull TextRange range) { final FoldingBuilder builder = node.getUserData(FOLDING_BUILDER); return builder == null ? node.getText() : builder instanceof FoldingBuilderEx ? ((FoldingBuilderEx)builder).getPlaceholderText(node, range) : builder.getPlaceholderText(node); }
Example 10
Source File: SharedImplUtil.java From consulo with Apache License 2.0 | 5 votes |
public static CharTable findCharTableByTree(ASTNode tree) { while (tree != null) { final CharTable userData = tree.getUserData(CharTable.CHAR_TABLE_KEY); if (userData != null) return userData; if (tree instanceof FileElement) return ((FileElement)tree).getCharTable(); tree = tree.getTreeParent(); } LOG.error("Invalid root element"); return null; }
Example 11
Source File: TreeUtil.java From consulo with Apache License 2.0 | 5 votes |
private static void initStrongWhitespaceHolder(CommonParentState commonParent, ASTNode start, boolean slopeSide) { if (start instanceof CompositeElement && (isStrongWhitespaceHolder(start.getElementType()) || slopeSide && start.getUserData(UNCLOSED_ELEMENT_PROPERTY) != null)) { commonParent.strongWhiteSpaceHolder = (CompositeElement)start; commonParent.isStrongElementOnRisingSlope = slopeSide; } }
Example 12
Source File: HaxeFoldingBuilder.java From intellij-haxe with Apache License 2.0 | 4 votes |
private boolean hasRegionMarker(@NotNull ASTNode node) { return node.getUserData(REGION_DEFINITION_KEY) != null; }
Example 13
Source File: CompositeFoldingBuilder.java From consulo with Apache License 2.0 | 4 votes |
@RequiredReadAction @Override public String getPlaceholderText(@Nonnull ASTNode node) { final FoldingBuilder builder = node.getUserData(FOLDING_BUILDER); return builder == null ? node.getText() : builder.getPlaceholderText(node); }
Example 14
Source File: CompositeFoldingBuilder.java From consulo with Apache License 2.0 | 4 votes |
@Override @RequiredReadAction public boolean isCollapsedByDefault(@Nonnull ASTNode node) { final FoldingBuilder builder = node.getUserData(FOLDING_BUILDER); return builder != null && builder.isCollapsedByDefault(node); }