use of com.intellij.lang.javascript.psi.JSFunction in project intellij-plugins by JetBrains.
the class FlexMoveClassProcessor method detectConflicts.
private MultiMap<PsiElement, String> detectConflicts(UsageInfo[] usages) {
MultiMap<PsiElement, String> conflicts = new MultiMap<>();
final Collection<PsiElement> filesToMove = Arrays.asList(myElementsToMove);
JSVisibilityUtil.Options options = new JSVisibilityUtil.Options();
for (PsiElement file : filesToMove) {
options.overridePackage(file, myTargetPackage);
}
for (UsageInfo usage : usages) {
final PsiElement element = usage.getElement();
if (!(element instanceof JSReferenceExpression)) {
continue;
}
if (CommonRefactoringUtil.isAncestor(element, filesToMove)) {
continue;
}
JSReferenceExpression refExpr = (JSReferenceExpression) element;
final PsiElement resolved = refExpr.resolve();
if (!(resolved instanceof JSQualifiedNamedElement)) {
continue;
}
PsiElement containingClass = null;
if (resolved instanceof JSFunction && ((JSFunction) resolved).isConstructor() && myElements.contains(containingClass = resolved.getParent()) || myElements.contains(resolved)) {
JSRefactoringConflictsUtil.checkAccessibility((JSAttributeListOwner) resolved, (JSClass) containingClass, null, refExpr, conflicts, true, options);
}
}
for (PsiElement fileToMove : filesToMove) {
JSRefactoringConflictsUtil.checkOutgoingReferencesAccessibility(fileToMove, filesToMove, null, true, conflicts, Conditions.alwaysTrue(), options);
}
//JSRefactoringConflictsUtil.analyzeModuleConflicts(myProject, myElements, usages, myTargetDirectory, conflicts);
return conflicts;
}
use of com.intellij.lang.javascript.psi.JSFunction in project intellij-plugins by JetBrains.
the class FlexMoveInnerClassProcessor method findUsages.
@NotNull
@Override
protected UsageInfo[] findUsages() {
final Collection<UsageInfo> result = Collections.synchronizedCollection(new ArrayList<UsageInfo>());
ReferencesSearch.search(myElement, new LocalSearchScope(myElement.getContainingFile())).forEach(reference -> {
final PsiElement element = reference.getElement();
if (!(element instanceof JSReferenceExpression)) {
return true;
}
if (JSResolveUtil.isSelfReference(element)) {
return true;
}
result.add(new UsageInfo(element));
return true;
});
if (myElement instanceof JSClass) {
final JSFunction constructor = ((JSClass) myElement).getConstructor();
if (constructor != null) {
result.add(new UsageInfo(constructor));
JSRefactoringUtil.addConstructorUsages((JSClass) myElement, result);
}
}
TextOccurrencesUtil.findNonCodeUsages(myElement, myElement.getName(), mySearchInComments, mySearchTextOccurences, StringUtil.getQualifiedName(myPackageName, myClassName), result);
return UsageViewUtil.removeDuplicatedUsages(result.toArray(new UsageInfo[result.size()]));
}
use of com.intellij.lang.javascript.psi.JSFunction in project intellij-plugins by JetBrains.
the class JSChangeSignatureDetector method getRange.
@Nullable
private static TextRange getRange(PsiElement element) {
JSFunction f = PsiTreeUtil.getParentOfType(element, JSFunction.class, false);
if (f == null)
return null;
ASTNode identifier = f.findNameIdentifier();
if (identifier == null) {
return null;
}
PsiElement e = f.getReturnTypeElement();
if (e == null) {
ASTNode colon = f.getNode().findChildByType(JSTokenTypes.COLON);
if (colon != null) {
e = colon.getPsi();
}
}
if (e == null) {
e = f.getParameterList();
}
return new TextRange(identifier.getTextRange().getStartOffset(), e.getTextRange().getEndOffset());
}
Aggregations