@NotNull @Override public SearchScope getUseScope() { if (this instanceof GoVarDefinition || this instanceof GoConstDefinition || this instanceof GoLabelDefinition) { GoBlock block = PsiTreeUtil.getParentOfType(this, GoBlock.class); if (block != null) return new LocalSearchScope(block); } if (!isPublic()) { return GoPackageUtil.packageScope(getContainingFile()); } GoSpecType parentType = PsiTreeUtil.getStubOrPsiParentOfType(this, GoSpecType.class); if (parentType != null) { GoTypeSpec typeSpec = GoPsiImplUtil.getTypeSpecSafe(parentType); if (typeSpec != null && !StringUtil.isCapitalized(typeSpec.getName())) { return GoPackageUtil.packageScope(getContainingFile()); } } return GoUtil.goPathUseScope(this, !(this instanceof GoMethodDeclaration)); }
public void testUseScope() { myFixture.configureByFiles("get_use_scope.ex"); PsiElement callable = myFixture .getFile() .findElementAt(myFixture.getCaretOffset()) .getPrevSibling() .getLastChild() .getLastChild() .getLastChild() .getLastChild() .getLastChild(); assertInstanceOf(callable, Call.class); SearchScope useScope = callable.getUseScope(); assertInstanceOf(useScope, LocalSearchScope.class); LocalSearchScope localSearchScope = (LocalSearchScope) useScope; PsiElement[] scope = localSearchScope.getScope(); assertEquals(1, scope.length); PsiElement singleScope = scope[0]; assertTrue( "Use Scope is not the surrounding if", singleScope.getText().startsWith("if auth == ") ); }
@NotNull @Override public SearchScope getUseScope() { return new LocalSearchScope(getContainingFile()); }
@Override public boolean isInplaceRenameAvailable(@NotNull PsiElement element, PsiElement context) { SearchScope useScope = element.getUseScope(); return useScope instanceof LocalSearchScope && element instanceof PsiNameIdentifierOwner && !(element instanceof PerlRenameUsagesHelper) && isInplaceAllowed(element, context) && !(((PsiNameIdentifierOwner)element).getNameIdentifier() instanceof PerlStringContentElement) && element.getContainingFile().getLanguage() == PerlLanguage.INSTANCE && !(((LocalSearchScope)useScope).getScope()[0] instanceof PsiFile) ; }
@NotNull @Override public SearchScope getUseScope() { return new LocalSearchScope(getContainingFile()); }
@NotNull @Override public SearchScope getUseScope() { return new LocalSearchScope(getContainingFile()); }
@NotNull @Override public SearchScope getUseScope() { return new LocalSearchScope(getContainingFile()); }
@NotNull @Override public SearchScope getUseScope() { return new LocalSearchScope(getContainingFile()); } }
@NotNull @Override public SearchScope getUseScope() { if (isLexicalDeclaration()) { PerlLexicalScope lexicalScope = getVariable().getLexicalScope(); if (lexicalScope != null) { return new LocalSearchScope(lexicalScope); } } return super.getUseScope(); }
final FindUsagesHandler findUsagesHandler = findUsagesManager.getFindUsagesHandler(target, true); final LocalSearchScope scope = new LocalSearchScope(psiElement); Collection<PsiReference> refs = findUsagesHandler != null ? findUsagesHandler.findReferencesToHighlight(target,
TargetElementUtil.getInstance().getNamedElement(myElement, myAdjustedOffset - myElement.getNode().getStartOffset()); if (namedElement != null) { PsiReference reference = ReferencesSearch.search(namedElement, new LocalSearchScope(myFile)).findFirst(); if (reference instanceof PsiPolyVariantReference) { List<PsiElement> result = new ArrayList<>();
@Override public void computeUsages(List<PsiElement> targets) { if (targets == null) { return; } for (PsiElement target : targets) { if (myFile.equals(target.getContainingFile()) && target instanceof PsiNameIdentifierOwner) { PsiElement nameIdentifier = ((PsiNameIdentifierOwner)target).getNameIdentifier(); if (nameIdentifier != null) { TextRange rangeInIdentifier = target instanceof PerlIdentifierRangeProvider ? ((PerlIdentifierRangeProvider)target).getRangeInIdentifier() : ElementManipulators.getValueTextRange(nameIdentifier); myWriteUsages.add(rangeInIdentifier.shiftRight(nameIdentifier.getNode().getStartOffset())); } } for (PsiReference reference : ReferencesSearch.search(target, new LocalSearchScope(myFile)).findAll()) { myReadUsages.add(reference.getRangeInElement().shiftRight(reference.getElement().getNode().getStartOffset())); } } } }
.first(); if (state != null) { SearchScope scope = queryParameters.getEffectiveSearchScope().intersectWith(new LocalSearchScope(file)); queryParameters.getOptimizer().searchWord(state.getName(), scope, true, state); .find(o -> name.equals(o.getName())); if (field != null) { SearchScope scope = queryParameters.getEffectiveSearchScope().intersectWith(new LocalSearchScope(javaFile)); queryParameters.getOptimizer().searchWord(name, scope, true, field);