use of com.perl5.lang.perl.parser.Class.Accessor.psi.impl.PerlClassAccessorMethod in project Perl5-IDEA by Camelcade.
the class ClassAccessorReferencesSearcher method processQuery.
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
PsiElement element = queryParameters.getElementToSearch();
if (element instanceof PerlClassAccessorMethod) {
queryParameters.getOptimizer().searchWord(((PerlClassAccessorMethod) element).getSubName(), queryParameters.getEffectiveSearchScope(), true, element);
PerlClassAccessorMethod pairedMethod = ((PerlClassAccessorMethod) element).getPairedMethod();
if (pairedMethod != null) {
queryParameters.getOptimizer().searchWord(pairedMethod.getSubName(), queryParameters.getEffectiveSearchScope(), true, pairedMethod);
}
}
}
use of com.perl5.lang.perl.parser.Class.Accessor.psi.impl.PerlClassAccessorMethod in project Perl5-IDEA by Camelcade.
the class PerlRenamePolyReferencedElementProcessor method prepareRenaming.
@Override
public void prepareRenaming(PsiElement element, String newName, Map<PsiElement, String> allRenames, SearchScope scope) {
final String currentBaseName = ((PsiNameIdentifierOwner) element).getName();
if (currentBaseName != null && StringUtil.isNotEmpty(newName)) {
boolean globScanned = element instanceof PerlGlobVariable;
for (PsiReference reference : ReferencesSearch.search(element, element.getUseScope()).findAll()) {
if (reference instanceof PsiPolyVariantReference) {
for (ResolveResult resolveResult : ((PsiPolyVariantReference) reference).multiResolve(false)) {
PsiElement resolveResultElement = resolveResult.getElement();
if (!allRenames.containsKey(resolveResultElement)) {
allRenames.put(resolveResultElement, newName);
if (!globScanned && resolveResultElement instanceof PerlGlobVariable) {
globScanned = true;
prepareRenaming(resolveResultElement, newName, allRenames, scope);
}
}
}
}
processDocReference(currentBaseName, newName, reference, allRenames);
}
if (element instanceof PerlSubElement && ((PerlSubElement) element).isMethod()) {
for (PerlSubElement overridingSub : PerlSubUtil.collectOverridingSubs((PerlSubElement) element)) {
allRenames.put(overridingSub, newName);
}
}
// following is the hack until #1730 is fixed
Set<PsiElement> allElements = new THashSet<>(allRenames.keySet());
allElements.stream().filter(e -> e instanceof PerlClassAccessorMethod).forEach(e -> {
PerlClassAccessorMethod pairedMethod = ((PerlClassAccessorMethod) e).getPairedMethod();
if (pairedMethod != null && allRenames.containsKey(e)) {
allRenames.remove(pairedMethod);
}
});
}
}
use of com.perl5.lang.perl.parser.Class.Accessor.psi.impl.PerlClassAccessorMethod in project Perl5-IDEA by Camelcade.
the class PerlClassAccessorWrapper method calcLightElementsFromPsi.
@NotNull
@Override
public List<PerlDelegatingLightNamedElement> calcLightElementsFromPsi() {
String packageName = PerlPackageUtil.getContextPackageName(this);
if (StringUtil.isEmpty(packageName)) {
return Collections.emptyList();
}
List<PsiElement> listElements = getCallArgumentsList();
if (listElements.isEmpty()) {
return Collections.emptyList();
}
List<PerlDelegatingLightNamedElement> result = new ArrayList<>();
for (PsiElement listElement : listElements) {
if (!isAcceptableIdentifierElement(listElement)) {
continue;
}
String baseName = ElementManipulators.getValueText(listElement);
PerlSubAnnotations subAnnotations = computeSubAnnotations(this, listElement);
for (Function<String, String> computation : getNamesComputations()) {
result.add(new PerlClassAccessorMethod(this, baseName, computation, CLASS_ACCESSOR_METHOD, listElement, packageName, subAnnotations));
}
}
return result;
}
Aggregations