当前位置: 首页>>代码示例>>Java>>正文


Java PsiRecursiveElementVisitor类代码示例

本文整理汇总了Java中com.intellij.psi.PsiRecursiveElementVisitor的典型用法代码示例。如果您正苦于以下问题:Java PsiRecursiveElementVisitor类的具体用法?Java PsiRecursiveElementVisitor怎么用?Java PsiRecursiveElementVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PsiRecursiveElementVisitor类属于com.intellij.psi包,在下文中一共展示了PsiRecursiveElementVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCssClass

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
/**
 * Gets the CssClass PSI element whose name matches the specified cssClassName
 *
 * @param stylesheetFile the PSI style sheet file to visit
 * @param cssClass       the class to find, including the leading ".", e.g. ".my-class-name"
 * @return the matching class or <code>null</code> if no matches are found
 */
public static CssClass getCssClass(StylesheetFile stylesheetFile, String cssClass) {
    final Ref<CssClass> cssClassRef = new Ref<>();
    stylesheetFile.accept(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (cssClassRef.get() != null) {
                return;
            }
            if (element instanceof CssClass) {
                if (cssClass.equals(element.getText()) && isCssModuleClass((CssClass) element)) {
                    cssClassRef.set((CssClass) element);
                    return;
                }
            }
            super.visitElement(element);
        }
    });
    return cssClassRef.get();
}
 
开发者ID:jimkyndemeyer,项目名称:react-css-modules-intellij-plugin,代码行数:27,代码来源:CssModulesUtil.java

示例2: getImportedStyleSheetFile

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
/**
 * Visits the containing file of the specified element to find a require to a style sheet file
 *
 * @param cssReferencingElement starting point for finding an imported style sheet file
 * @return the PSI file for the first imported style sheet file
 */
public static StylesheetFile getImportedStyleSheetFile(PsiElement cssReferencingElement) {
    final Ref<StylesheetFile> file = new Ref<>();
    cssReferencingElement.getContainingFile().accept(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (file.get() != null) {
                return;
            }
            if (element instanceof JSLiteralExpression) {
                if (resolveStyleSheetFile(element, file)) return;
            }
            if(element instanceof ES6FromClause) {
                if (resolveStyleSheetFile(element, file)) return;
            }
            super.visitElement(element);
        }
    });
    return file.get();
}
 
开发者ID:jimkyndemeyer,项目名称:react-css-modules-intellij-plugin,代码行数:26,代码来源:CssModulesUtil.java

示例3: resolveStyleSheetFile

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
/**
 * Resolves the style sheet PSI file that backs a require("./stylesheet.css").
 *
 * @param cssFileNameLiteralParent parent element to a file name string literal that points to a style sheet file
 * @return the matching style sheet PSI file, or <code>null</code> if the file can't be resolved
 */
public static StylesheetFile resolveStyleSheetFile(PsiElement cssFileNameLiteralParent) {
    final Ref<StylesheetFile> stylesheetFileRef = new Ref<>();
    cssFileNameLiteralParent.accept(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (stylesheetFileRef.get() != null) {
                return;
            }
            if (element instanceof JSLiteralExpression) {
                if (resolveStyleSheetFile(element, stylesheetFileRef)) return;
            }
            if(element instanceof ES6FromClause) {
                if (resolveStyleSheetFile(element, stylesheetFileRef)) return;
            }
            super.visitElement(element);
        }
    });
    return stylesheetFileRef.get();
}
 
开发者ID:jimkyndemeyer,项目名称:react-css-modules-intellij-plugin,代码行数:26,代码来源:CssModulesUtil.java

示例4: findDotIds

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
/**
 * Utility method returning all DotIDs with corresponding id the project.
 *
 * @param project - project for searching
 * @param id_     - DotId id for searching
 * @return iterable set of DotIds naming as id
 */
public static Iterable<DotId> findDotIds(Project project, String id_) {
    Set<DotId> ids = new HashSet<>();
    PsiRecursiveElementVisitor psiRecursiveElementVisitor = new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (element instanceof DotId && element.getText().equals(id_)) {
                ids.add(((DotId) element));
            }
            super.visitElement(element);
        }
    };
    Collection<VirtualFile> virtualFiles =
            FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, DotFileType.INSTANCE,
                    GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        DotFile dotFile = (DotFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (dotFile != null) {
            for (PsiElement e : dotFile.getChildren()) {
                psiRecursiveElementVisitor.visitElement(e);
            }
        }
    }
    return ids;
}
 
开发者ID:bzixilu,项目名称:dotplugin,代码行数:32,代码来源:DotPSITreeUtil.java

示例5: getEnvironment

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
public static String getEnvironment(PsiFile file) {
    if (file instanceof JSFile) {
        // for JS Files we have to check the kind of environment being used
        final Ref<String> envRef = new Ref<>();
        file.accept(new PsiRecursiveElementVisitor() {
            @Override
            public void visitElement(PsiElement element) {
                if (!isJSGraphQLLanguageInjectionTarget(element, envRef)) {
                    // no match yet, so keep visiting
                    super.visitElement(element);
                }
            }
        });
        final String environment = envRef.get();
        if (environment != null) {
            return environment;
        }
    } else if (file instanceof JSGraphQLFile) {
        final Ref<String> tag = new Ref<>();
        if (file.getContext() != null && isJSGraphQLLanguageInjectionTarget(file.getContext(), tag)) {
            return tag.get();
        }
    }
    // fallback is traditional GraphQL
    return GRAPHQL_ENVIRONMENT;
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:27,代码来源:JSGraphQLLanguageInjectionUtil.java

示例6: findUnresolvedPrefixes

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
private Set<String> findUnresolvedPrefixes() {
    final Set<String> prefixes = new HashSet<String>();

    myXPathFile.accept(new PsiRecursiveElementVisitor(){
        public void visitElement(PsiElement element) {
            if (element instanceof QNameElement) {
                final PsiReference[] references = element.getReferences();
                for (PsiReference reference : references) {
                    if (reference instanceof PrefixReference) {
                        final PrefixReference prefixReference = (PrefixReference)reference;
                        if (prefixReference.isUnresolved()) {
                            prefixes.add(prefixReference.getPrefix());
                        }
                    }
                }
            }
            super.visitElement(element);
        }
    });
    return prefixes;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:InputExpressionDialog.java

示例7: phpVisitor

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
private void phpVisitor(final @NotNull ProblemsHolder holder, @NotNull PsiFile psiFile) {

        psiFile.acceptChildren(new PsiRecursiveElementVisitor() {
            @Override
            public void visitElement(PsiElement element) {
                PsiElement parent = element.getParent();
                if(!(parent instanceof StringLiteralExpression)) {
                    super.visitElement(element);
                    return;
                }

                MethodReference methodReference = PsiElementUtils.getMethodReferenceWithFirstStringParameter(element);
                if (methodReference != null && PhpElementsUtil.isMethodReferenceInstanceOf(methodReference, ServiceContainerUtil.SERVICE_GET_SIGNATURES)) {
                    String serviceName = ((StringLiteralExpression) parent).getContents();
                    if(StringUtils.isNotBlank(serviceName) && !serviceName.equals(serviceName.toLowerCase())) {
                        holder.registerProblem(element, SYMFONY_LOWERCASE_LETTERS_FOR_SERVICE, ProblemHighlightType.WEAK_WARNING);
                    }
                }

                super.visitElement(element);
            }
        });
    }
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:24,代码来源:CaseSensitivityServiceInspection.java

示例8: yamlVisitor

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
private void yamlVisitor(@NotNull ProblemsHolder holder, @NotNull PsiFile psiFile) {
    psiFile.acceptChildren(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement psiElement) {
            if(psiElement instanceof YAMLScalar) {
                String textValue = ((YAMLScalar) psiElement).getTextValue();
                if(textValue.length() > 0 && textValue.startsWith("!php/const:")) {
                    String constantName = textValue.substring(11);
                    if(StringUtils.isNotBlank(constantName) && ServiceContainerUtil.getTargetsForConstant(psiElement.getProject(), constantName).size() == 0) {
                        holder.registerProblem(psiElement, MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
                    }
                }
            }

            super.visitElement(psiElement);
        }
    });
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:19,代码来源:ContainerConstantInspection.java

示例9: getQualifiedNames

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
@NotNull
@Override
public Set<String> getQualifiedNames(@NotNull final PsiFile sourceFile)
{
	return ApplicationManager.getApplication().runReadAction(new Computable<Set<String>>()
	{
		@Override
		public Set<String> compute()
		{
			final Set<String> set = new THashSet<String>();
			sourceFile.accept(new PsiRecursiveElementVisitor()
			{
				@Override
				public void visitElement(PsiElement element)
				{
					super.visitElement(element);
					if(element instanceof DotNetTypeDeclaration)
					{
						set.add(((DotNetTypeDeclaration) element).getVmQName());
					}
				}
			});
			return set;
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-dotnet,代码行数:27,代码来源:DotNetCoverageEngine.java

示例10: createAllMacrosProvider

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
CachedValueProvider<Map<String, Set<VtlMacro>>> createAllMacrosProvider()
{
	return new CachedValueProvider<Map<String, Set<VtlMacro>>>()
	{
		public CachedValueProvider.Result<Map<String, Set<VtlMacro>>> compute()
		{
			final Map<String, Set<VtlMacro>> result = new THashMap<String, Set<VtlMacro>>();
			myFile.accept(new PsiRecursiveElementVisitor()
			{
				@Override
				public void visitElement(PsiElement element)
				{
					super.visitElement(element);
					if(element instanceof VtlMacro)
					{
						registerMacro((VtlMacro) element, result);
					}
				}
			});
			return CachedValueProvider.Result.create(result, myFile);
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-apache-velocity,代码行数:24,代码来源:ProviderBuilder.java

示例11: collectPsiElementsRecursive

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
@NotNull
private List<PsiElement> collectPsiElementsRecursive(@NotNull PsiElement psiElement) {
    final List<PsiElement> elements = new ArrayList<PsiElement>();
    elements.add(psiElement.getContainingFile());

    psiElement.acceptChildren(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            elements.add(element);
            super.visitElement(element);
        }
    });
    return elements;
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:15,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例12: getNotMentionedNodeIds

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
/**
 * Utility method returning all children nodes which have are mentioned in
 * edge statements but not mentioned in node statements.
 * Case when node is used in edge but not initialized earlier
 *
 * @param e - PSI element (root element for sub tree for searching nodes)
 * @return - iterable entity containing used but mentioned nodes
 */
// TODO: probably it makes sense to change PsiElement to GraphStmt
public static Iterable<DotId> getNotMentionedNodeIds(PsiElement e) {
    Set<DotId> nodeIds = new HashSet<>();
    Set<DotId> edgeIds = new HashSet<>();
    Set<DotId> result = new HashSet<>();
    PsiRecursiveElementVisitor psiRecursiveElementVisitor = new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (element instanceof DotNodeStmt) {
                nodeIds.add(((DotNodeStmt) element).getNodeId().getId());
            } else if (element instanceof DotEdgeStmt) {
                edgeIds.add(((DotEdgeStmt) element).getNodeId().getId());
                edgeIds.add(((DotEdgeStmt) element).getEdgeRHS().getNodeId().getId());
            }
            super.visitElement(element);
        }
    };
    psiRecursiveElementVisitor.visitElement(e);

    for (DotId edgeId : edgeIds) {
        if (nodeIds.stream().noneMatch((i) -> edgeId.getText().equals(i.getText()))) {
            result.add(edgeId);
        }
    }
    return result;
}
 
开发者ID:bzixilu,项目名称:dotplugin,代码行数:35,代码来源:DotPSITreeUtil.java

示例13: getFragmentDefinitions

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
private List<JSGraphQLFragmentDefinitionPsiElement> getFragmentDefinitions(PsiFile file) {
    List<JSGraphQLFragmentDefinitionPsiElement> ret = Lists.newArrayList();
    file.accept(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if(element instanceof JSGraphQLFragmentDefinitionPsiElement) {
                ret.add((JSGraphQLFragmentDefinitionPsiElement) element);
            } else {
                super.visitElement(element);
            }
        }
    });
    return ret;
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:15,代码来源:JSGraphQLCompletionContributor.java

示例14: hasSameSignature

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
/**
 * Compares the signatures of two fields, ignoring comments, whitespace, and annotations
 */
private boolean hasSameSignature(JSGraphQLEndpointFieldDefinition override, JSGraphQLEndpointFieldDefinition toImplement) {
	final StringBuilder toImplementSignature = new StringBuilder();
	final StringBuilder overrideSignature = new StringBuilder();

	final Ref<StringBuilder> sb = new Ref<>();
	final PsiElementVisitor visitor = new PsiRecursiveElementVisitor() {
		@Override
		public void visitElement(PsiElement element) {
			if (element instanceof JSGraphQLEndpointAnnotation) {
				return;
			}
			if (element instanceof PsiWhiteSpace) {
				return;
			}
			if (element instanceof PsiComment) {
				return;
			}
			if (element instanceof LeafPsiElement) {
				sb.get().append(element.getText()).append(" ");
			}
			super.visitElement(element);
		}
	};

	sb.set(overrideSignature);
	override.accept(visitor);

	sb.set(toImplementSignature);
	toImplement.accept(visitor);

	return toImplementSignature.toString().equals(overrideSignature.toString());
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:36,代码来源:JSGraphQLEndpointErrorAnnotator.java

示例15: visitRegisterCoreContainerAliases

import com.intellij.psi.PsiRecursiveElementVisitor; //导入依赖的package包/类
public static void visitRegisterCoreContainerAliases(@NotNull Project project, @NotNull DicAliasVisitor visitor) {
    for (PhpClass phpClass : PhpElementsUtil.getClassesOrInterfaces(project, "Illuminate\\Foundation\\Application")) {
        Method registerMethod = phpClass.findMethodByName("registerCoreContainerAliases");
        if(registerMethod == null) {
            continue;
        }

        final Collection<Variable> aliases = new HashSet<>();
        registerMethod.acceptChildren(new PsiRecursiveElementVisitor() {
            @Override
            public void visitElement(PsiElement element) {
                if(element instanceof Variable && ((Variable) element).isDeclaration() && "aliases".equals(((Variable) element).getName())) {
                    aliases.add((Variable) element);
                }
                super.visitElement(element);
            }
        });

        if(aliases.size() == 0) {
            continue;
        }

        for (Variable alias : aliases) {
            ArrayCreationExpression arrayCreation = PsiTreeUtil.getNextSiblingOfType(alias, ArrayCreationExpression.class);
            if(arrayCreation == null) {
                continue;
            }

            Map<String, PsiElement> arrayCreationKeyMap = PhpElementsUtil.getArrayValueMap(arrayCreation);
            for (Map.Entry<String, PsiElement> entry : arrayCreationKeyMap.entrySet()) {
                PsiElement value = entry.getValue();
                visitor.visit(value, entry.getKey());
            }

        }

    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:39,代码来源:LaravelDicUtil.java


注:本文中的com.intellij.psi.PsiRecursiveElementVisitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。