本文整理汇总了Java中com.intellij.psi.search.PsiSearchHelper类的典型用法代码示例。如果您正苦于以下问题:Java PsiSearchHelper类的具体用法?Java PsiSearchHelper怎么用?Java PsiSearchHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiSearchHelper类属于com.intellij.psi.search包,在下文中一共展示了PsiSearchHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
private Boolean doExecute(ReferencesSearch.SearchParameters queryParameters, final Processor<PsiReference> consumer) {
final PsiElement element = queryParameters.getElementToSearch(); //was selector_identifier->redefined in
DictionaryComponent dictionaryComponent = null;
if (element instanceof DictionaryComponent) {
dictionaryComponent = (DictionaryComponent) element;
}
if (dictionaryComponent == null) return true;
final List<String> parts = dictionaryComponent.getNameIdentifiers();
if (parts.isEmpty())
return true;
final String componentName = dictionaryComponent.getName(); //or just getName()...
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
String searchWord = parts.get(0);
return searchWord.isEmpty() || helper.processElementsWithWord(new MyOccurrenceProcessor(dictionaryComponent, componentName, consumer),
queryParameters.getScopeDeterminedByUser(), searchWord, UsageSearchContext.IN_CODE, true);
}
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:21,代码来源:AppleScriptDictionaryComponentReferencesSearch.java
示例2: mayRenameInplace
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
public static boolean mayRenameInplace(PsiElement elementToRename, final PsiElement nameSuggestionContext) {
if (nameSuggestionContext != null && nameSuggestionContext.getContainingFile() != elementToRename.getContainingFile()) return false;
if (!(elementToRename instanceof PsiLocalVariable) &&
!(elementToRename instanceof PsiParameter) &&
!(elementToRename instanceof PsiLabeledStatement)) {
return false;
}
SearchScope useScope = PsiSearchHelper.SERVICE.getInstance(elementToRename.getProject()).getUseScope(elementToRename);
if (!(useScope instanceof LocalSearchScope)) return false;
PsiElement[] scopeElements = ((LocalSearchScope)useScope).getScope();
if (scopeElements.length > 1 && // assume there are no elements with use scopes with holes in them
!isElementWithComment(scopeElements) && // ... except a case of element and it's doc comment
!isResourceVariable(scopeElements)) {
return false; // ... and badly scoped resource variables
}
PsiFile containingFile = elementToRename.getContainingFile();
return PsiTreeUtil.isAncestor(containingFile, scopeElements[0], false);
}
示例3: getUsageClass
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
/**
* @return the class the specified method is used from, or null if it is
* used from 0 or more than 1 other classes.
*/
@Nullable
public PsiClass getUsageClass(final PsiMethod method) {
final ProgressManager progressManager = ProgressManager.getInstance();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(method.getProject());
final String name = method.getName();
final GlobalSearchScope scope = GlobalSearchScope.allScope(method.getProject());
if (searchHelper.isCheapEnoughToSearch(name, scope, null, progressManager.getProgressIndicator())
== PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) {
return null;
}
progressManager.runProcess(new Runnable() {
@Override
public void run() {
final Query<PsiReference> query = MethodReferencesSearch.search(method);
if (!query.forEach(UsageProcessor.this)) {
foundClass.set(null);
}
}
}, null);
return foundClass.get();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:StaticMethodOnlyUsedInOneClassInspectionBase.java
示例4: processTextUsages
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
private static void processTextUsages(final Map<String, Set<PsiFile>> processedTextToFiles,
final String text,
final Map<String, Set<PsiFile>> processedFoundTextToFiles,
final PsiSearchHelper searchHelper,
final GlobalSearchScope scope) {
if (!processedTextToFiles.containsKey(text)) {
if (processedFoundTextToFiles.containsKey(text)) {
final Set<PsiFile> filesWithValue = processedFoundTextToFiles.get(text);
processedTextToFiles.put(text, filesWithValue);
}
else {
final Set<PsiFile> resultFiles = new HashSet<PsiFile>();
findFilesWithText(text, searchHelper, scope, resultFiles);
if (resultFiles.isEmpty()) return;
processedTextToFiles.put(text, resultFiles);
}
}
}
示例5: findFilesWithText
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
private static void findFilesWithText(String stringToFind,
PsiSearchHelper searchHelper,
GlobalSearchScope scope,
final Set<PsiFile> resultFiles) {
final List<String> words = StringUtil.getWordsIn(stringToFind);
if (words.isEmpty()) return;
Collections.sort(words, new Comparator<String>() {
@Override
public int compare(final String o1, final String o2) {
return o2.length() - o1.length();
}
});
for (String word : words) {
final Set<PsiFile> files = new THashSet<PsiFile>();
searchHelper.processAllFilesWithWord(word, scope, new CommonProcessors.CollectProcessor<PsiFile>(files), true);
if (resultFiles.isEmpty()) {
resultFiles.addAll(files);
}
else {
resultFiles.retainAll(files);
}
if (resultFiles.isEmpty()) return;
}
}
示例6: findExtensionPointCandidates
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
private static void findExtensionPointCandidates(PsiClass psiClass, final List<ExtensionPointCandidate> list) {
String name = psiClass.getQualifiedName();
if (name == null) {
return;
}
final Project project = psiClass.getProject();
final Collection<VirtualFile> candidates = DomService.getInstance().getDomFileCandidates(IdeaPlugin.class, project, GlobalSearchScope.allScope(project));
GlobalSearchScope scope = GlobalSearchScope.filesScope(project, candidates);
PsiSearchHelper.SERVICE.getInstance(project).processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() {
@Override
public boolean process(PsiFile file, int startOffset, int endOffset) {
PsiElement element = file.findElementAt(startOffset);
processExtensionPointCandidate(element, list);
return true;
}
}, scope);
}
示例7: isInplaceRenameAvailable
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
@Override
public boolean isInplaceRenameAvailable(@NotNull PsiElement elementToRename, PsiElement nameSuggestionContext) {
//local vars & params renames GrVariableInplaceRenameHandler
if (nameSuggestionContext != null && nameSuggestionContext.getContainingFile() != elementToRename.getContainingFile()) return false;
if (!(elementToRename instanceof GrLabeledStatement)) {
return false;
}
SearchScope useScope = PsiSearchHelper.SERVICE.getInstance(elementToRename.getProject()).getUseScope(elementToRename);
if (!(useScope instanceof LocalSearchScope)) return false;
PsiElement[] scopeElements = ((LocalSearchScope)useScope).getScope();
if (scopeElements.length > 1) {
return false;
}
PsiFile containingFile = elementToRename.getContainingFile();
return PsiTreeUtil.isAncestor(containingFile, scopeElements[0], false);
}
示例8: getKnownFragmentDefinitions
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
/**
* Finds all fragment definition across files in the project
*
* @return a list of known fragment definitions, or an empty list if the index is not yet ready
*/
public List<JSGraphQLFragmentDefinitionPsiElement> getKnownFragmentDefinitions() {
try {
final List<JSGraphQLFragmentDefinitionPsiElement> fragmentDefinitions = Lists.newArrayList();
PsiSearchHelper.SERVICE.getInstance(myProject).processElementsWithWord((psiElement, offsetInElement) -> {
if (psiElement.getNode().getElementType() == JSGraphQLTokenTypes.KEYWORD && psiElement.getParent() instanceof JSGraphQLFragmentDefinitionPsiElement) {
final JSGraphQLFragmentDefinitionPsiElement fragmentDefinition = (JSGraphQLFragmentDefinitionPsiElement) psiElement.getParent();
final String fragmentName = fragmentDefinition.getName();
if (fragmentName != null) {
fragmentDefinitions.add(fragmentDefinition);
}
}
return true;
}, searchScope, "fragment", UsageSearchContext.IN_CODE, true, true);
return fragmentDefinitions;
} catch (IndexNotReadyException e) {
// can't search yet (e.g. during project startup)
}
return Collections.emptyList();
}
示例9: isInplaceRenameAvailable
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
@Override
public boolean isInplaceRenameAvailable(PsiElement elementToRename, PsiElement nameSuggestionContext) {
//local vars & params renames GrVariableInplaceRenameHandler
if (nameSuggestionContext != null && nameSuggestionContext.getContainingFile() != elementToRename.getContainingFile()) return false;
if (!(elementToRename instanceof GrLabeledStatement)) {
return false;
}
SearchScope useScope = PsiSearchHelper.SERVICE.getInstance(elementToRename.getProject()).getUseScope(elementToRename);
if (!(useScope instanceof LocalSearchScope)) return false;
PsiElement[] scopeElements = ((LocalSearchScope)useScope).getScope();
if (scopeElements.length > 1) {
return false;
}
PsiFile containingFile = elementToRename.getContainingFile();
return PsiTreeUtil.isAncestor(containingFile, scopeElements[0], false);
}
示例10: isTooExpensiveToSearch
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
public static boolean isTooExpensiveToSearch(PsiNamedElement element, boolean zeroResult)
{
final String name = element.getName();
if(name == null)
{
return true;
}
final ProgressManager progressManager = ProgressManager.getInstance();
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
final SearchScope useScope = element.getUseScope();
if(!(useScope instanceof GlobalSearchScope))
{
return zeroResult;
}
final PsiSearchHelper.SearchCostResult cost = searchHelper.isCheapEnoughToSearch(name, (GlobalSearchScope) useScope, null, progressManager.getProgressIndicator());
if(cost == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES)
{
return zeroResult;
}
return cost == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
}
示例11: invoke
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
final TypeMigrationRules rules = new TypeMigrationRules(TypeMigrationLabeler.getElementType(myVar));
rules.setMigrationRootType(myExpressionType);
rules.setBoundScope(PsiSearchHelper.SERVICE.getInstance(project).getUseScope(myVar));
TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, rules, myVar);
}
示例12: TurnRefsToSuperProcessorBase
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
protected TurnRefsToSuperProcessorBase(Project project, boolean replaceInstanceOf, String superClassName) {
super(project);
mySuperClassName = superClassName;
myManager = PsiManager.getInstance(project);
mySearchHelper = PsiSearchHelper.SERVICE.getInstance(myManager.getProject());
myManager = PsiManager.getInstance(myProject);
myReplaceInstanceOf = replaceInstanceOf;
}
示例13: getScope
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
private static SearchScope getScope(final PsiSearchHelper helper, final PsiElement element) {
SearchScope scope = helper.getUseScope(element);
if (scope instanceof GlobalSearchScope) {
scope =
GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)scope, StdFileTypes.JAVA, StdFileTypes.JSP, StdFileTypes.JSPX);
}
return scope;
}
示例14: getScope
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
@NotNull
public SearchScope getScope() {
return ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
@Override
public SearchScope compute() {
return myScope.intersectWith(PsiSearchHelper.SERVICE.getInstance(myElement.getProject()).getUseScope(myElement));
}
});
}
示例15: getSearchScope
import com.intellij.psi.search.PsiSearchHelper; //导入依赖的package包/类
@Override
@NotNull
public SearchScope getSearchScope(Editor editor, @NotNull PsiElement element) {
TargetElementEvaluatorEx2 evaluator = getElementEvaluatorsEx2(element.getLanguage());
SearchScope result = evaluator != null ? evaluator.getSearchScope(editor, element) : null;
return result != null ? result : PsiSearchHelper.SERVICE.getInstance(element.getProject()).getUseScope(element);
}