本文整理汇总了Java中com.intellij.psi.search.searches.ReferencesSearch.SearchParameters方法的典型用法代码示例。如果您正苦于以下问题:Java ReferencesSearch.SearchParameters方法的具体用法?Java ReferencesSearch.SearchParameters怎么用?Java ReferencesSearch.SearchParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.search.searches.ReferencesSearch
的用法示例。
在下文中一共展示了ReferencesSearch.SearchParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的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: should_process_reference
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Test
public void should_process_reference() throws Exception {
// given
PsiReference reference1 = mock(PsiReference.class);
PsiReference reference2 = mock(PsiReference.class);
PsiField field = mock(PsiField.class);
ReferencesSearch.SearchParameters searchParameters = mock(ReferencesSearch.SearchParameters.class);
when(searchParameters.getElementToSearch()).thenReturn(field);
when(searchParameters.getEffectiveSearchScope()).thenReturn(mock(GlobalSearchScope.class));
when(scenarioStateReferenceProvider.findReferences(field)).thenReturn(Arrays.asList(reference1, reference2));
when(scenarioStateProvider.isJGivenScenarioState(field)).thenReturn(true);
// when
referenceProvider.processQuery(searchParameters, processor);
// then
verify(processor).process(reference1);
verify(processor).process(reference2);
}
示例3: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public void processQuery(@NotNull final ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
new ReadAction() {
@Override
protected void run(@NotNull final Result result) throws Throwable {
final PsiElement refElement = queryParameters.getElementToSearch();
if (PyMagicLiteralTools.isMagicLiteral(refElement)) {
final String refText = ((StringLiteralExpression)refElement).getStringValue();
if (!StringUtil.isEmpty(refText)) {
final SearchScope searchScope = queryParameters.getEffectiveSearchScope();
queryParameters.getOptimizer().searchWord(refText, searchScope, true, refElement);
}
}
}
}.execute();
}
示例4: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
public void processQuery(@NotNull final ReferencesSearch.SearchParameters params,
@NotNull final Processor<PsiReference> consumer) {
final PsiElement element = params.getElementToSearch();
if (!(element instanceof PyElement) && !(element instanceof PsiDirectory)) {
return;
}
SearchScope searchScope = params.getEffectiveSearchScope();
if (searchScope instanceof GlobalSearchScope) {
searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope)searchScope, PythonFileType.INSTANCE);
}
String name = PyUtil.computeElementNameForStringSearch(element);
if (StringUtil.isEmpty(name)) {
return;
}
params.getOptimizer().searchWord(name, searchScope, UsageSearchContext.IN_STRINGS, true, element);
}
示例5: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters params, @NotNull Processor<PsiReference> consumer) {
final PsiElement refElement = params.getElementToSearch();
if (!(refElement instanceof PsiFile)) {
return;
}
final VirtualFile vFile = ((PsiFile)refElement).getVirtualFile();
if (vFile == null) {
return;
}
LocalResourceManager manager = LocalResourceManager.getInstance(refElement);
if (manager == null) {
return;
}
String resType = manager.getFileResourceType((PsiFile)refElement);
if (resType != null) {
String resName = AndroidCommonUtils.getResourceName(resType, vFile.getName());
// unless references can be found by a simple CachedBasedRefSearcher
if (!resName.equals(vFile.getNameWithoutExtension()) && StringUtil.isNotEmpty(resName)) {
params.getOptimizer().searchWord(resName, params.getEffectiveSearchScope(), true, refElement);
}
}
}
示例6: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
final PsiElement element = queryParameters.getElementToSearch();
if (element instanceof PsiMethod) {
final String propertyName = GroovyPropertyUtils.getPropertyName((PsiMethod)element);
if (propertyName == null) return;
queryParameters.getOptimizer().searchWord(propertyName, GroovyScopeUtil
.restrictScopeToGroovyFiles(queryParameters.getEffectiveSearchScope()),
UsageSearchContext.IN_CODE, true, element);
}
else if (element instanceof GrField) {
for (GrAccessorMethod method : ((GrField)element).getGetters()) {
MethodReferencesSearch.search(method, queryParameters.getEffectiveSearchScope(), true).forEach(consumer);
}
final GrAccessorMethod setter = ((GrField)element).getSetter();
if (setter != null) {
MethodReferencesSearch.search(setter, queryParameters.getEffectiveSearchScope(), true).forEach(consumer);
}
}
}
示例7: execute
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters queryParameters, @NotNull final
Processor<PsiReference> consumer) {
return new ReadAction<Boolean>() {
protected void run(@NotNull final Result<Boolean> result) {
result.setResult(doExecute(queryParameters, consumer));
}
}.execute().getResultObject();
}
示例8: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
final PsiElement element = queryParameters.getElementToSearch();
ApplicationManager.getApplication().runReadAction(() -> {
SearchScope scope = queryParameters.getEffectiveSearchScope();
if (!scenarioStateProvider.isJGivenScenarioState(element)
|| !(scope instanceof GlobalSearchScope)) {
return;
}
PsiField field = (PsiField) element;
scenarioStateReferenceProvider.findReferences(field).forEach(consumer::process);
});
}
示例9: should_not_process_reference_if_search_scope_is_not_global
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Test
public void should_not_process_reference_if_search_scope_is_not_global() throws Exception {
// given
PsiField field = mock(PsiField.class);
ReferencesSearch.SearchParameters searchParameters = mock(ReferencesSearch.SearchParameters.class);
when(searchParameters.getElementToSearch()).thenReturn(field);
when(searchParameters.getEffectiveSearchScope()).thenReturn(mock(LocalSearchScope.class));
when(scenarioStateProvider.isJGivenScenarioState(field)).thenReturn(true);
// when
referenceProvider.processQuery(searchParameters, processor);
// then
verifyZeroInteractions(processor);
}
示例10: should_not_process_reference_if_element_is_not_a_JGiven_scenario_state
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Test
public void should_not_process_reference_if_element_is_not_a_JGiven_scenario_state() throws Exception {
// given
PsiField field = mock(PsiField.class);
ReferencesSearch.SearchParameters searchParameters = mock(ReferencesSearch.SearchParameters.class);
when(searchParameters.getElementToSearch()).thenReturn(field);
when(searchParameters.getEffectiveSearchScope()).thenReturn(mock(GlobalSearchScope.class));
when(scenarioStateProvider.isJGivenScenarioState(field)).thenReturn(false);
// when
referenceProvider.processQuery(searchParameters, processor);
// then
verifyZeroInteractions(processor);
}
示例11: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public void processQuery(
@NotNull final ReferencesSearch.SearchParameters queryParameters,
@NotNull final Processor<PsiReference> consumer
) {
final PsiElement elementToSearch = queryParameters.getElementToSearch();
if (!elementToSearch.isValid()) {
return;
}
final SearchScope scope = queryParameters.getEffectiveSearchScope();
if (!(scope instanceof GlobalSearchScope)) {
return;
}
// search macros usage references
if (isMacroUsage(elementToSearch) || isMacroNameDeclaration(elementToSearch)) {
final PsiFile file = elementToSearch.getContainingFile();
final PsiElement[] results = PsiTreeUtil.collectElements(
file,
element -> isMacroUsage(element) && element.textMatches(elementToSearch)
);
stream(results)
.map(ImpexMacrosReferenceBase::new)
.forEach(consumer::process);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:28,代码来源:ImpexReferenceSearcher.java
示例12: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters parameters, @NotNull Processor<PsiReference> consumer) {
final PsiElement target = parameters.getElementToSearch();
if (!(target instanceof PsiNamedElement)) return;
final String name = ((PsiNamedElement)target).getName();
if (name == null || StringUtil.isEmptyOrSpaces(name)) return;
final SearchScope scope = parameters.getEffectiveSearchScope();
final SearchRequestCollector collector = parameters.getOptimizer();
final SearchSession session = collector.getSearchSession();
collector.searchWord(name, scope, UsageSearchContext.IN_CODE, true, new MyProcessor(target, null, session));
}
示例13: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
PsiElement refElement = queryParameters.getElementToSearch();
if (!(refElement instanceof PsiMethod)) return;
addPropertyAccessUsages((PsiMethod)refElement, queryParameters.getEffectiveSearchScope(), queryParameters.getOptimizer());
}
示例14: execute
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters p, @NotNull final Processor<PsiReference> consumer) {
final PsiElement refElement = p.getElementToSearch();
boolean isAnnotation = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return PsiUtil.isAnnotationMethod(refElement);
}
});
if (isAnnotation) {
final PsiMethod method = (PsiMethod)refElement;
PsiClass containingClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
@Override
public PsiClass compute() {
boolean isValueMethod =
PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME.equals(method.getName()) && method.getParameterList().getParametersCount() == 0;
return isValueMethod ? method.getContainingClass() : null;
}
});
if (containingClass != null) {
SearchScope scope = ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
@Override
public SearchScope compute() {
return p.getEffectiveSearchScope();
}
});
final Query<PsiReference> query = ReferencesSearch.search(containingClass, scope, p.isIgnoreAccessScope());
return query.forEach(createImplicitDefaultAnnotationMethodConsumer(consumer));
}
}
return true;
}
示例15: processQuery
import com.intellij.psi.search.searches.ReferencesSearch; //导入方法依赖的package包/类
@Override
public void processQuery(@NotNull final ReferencesSearch.SearchParameters p, @NotNull final Processor<PsiReference> consumer) {
final PsiElement refElement = p.getElementToSearch();
if (!refElement.isValid() || !(refElement instanceof PsiVariable)) return;
final String name = ((PsiVariable)refElement).getName();
if (StringUtil.isEmptyOrSpaces(name)) return;
SearchScope scope = p.getEffectiveSearchScope();
if (!(scope instanceof LocalSearchScope)) {
final PsiFile file = refElement.getContainingFile();
if (file == null) return;
//process incomplete references to the 'field' in the same file only
scope = new LocalSearchScope(file);
}
PsiElement[] elements = ((LocalSearchScope)scope).getScope();
if (elements.length == 0) return;
PsiSearchHelper.SERVICE.getInstance(p.getProject()).processElementsWithWord(new TextOccurenceProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, int offsetInElement) {
for (PsiElement child = element.findElementAt(offsetInElement); child != null; child = child.getParent()) {
if (!name.equals(child.getText())) {
break;
}
if (child instanceof PsiJavaCodeReferenceElement) {
final PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)child;
if (!ref.isQualified() &&
!(ref.getParent() instanceof PsiMethodCallExpression) &&
ref.resolve() == null && ref.advancedResolve(true).getElement() == refElement) {
consumer.process(ref);
}
}
}
return true;
}
}, scope, name, UsageSearchContext.ANY, true);
}