cleanup: rename file to psiFile to distinguish from VirtualFile

GitOrigin-RevId: e718eac8ba2d2177787ae941d8525b3c154d10fc
This commit is contained in:
Alexey Kudravtsev
2025-05-16 00:11:36 +02:00
committed by intellij-monorepo-bot
parent 3edf733f03
commit 6d1f55f160
585 changed files with 2380 additions and 2379 deletions

View File

@@ -681,8 +681,8 @@ public final class HighlightFixUtil {
if (DumbService.getInstance(variable.getProject()).isDumb()) return;
String shortName = classType.getClassName();
PsiFile file = parameterList.getContainingFile();
Project project = file.getProject();
PsiFile psiFile = parameterList.getContainingFile();
Project project = psiFile.getProject();
JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
PsiShortNamesCache shortNamesCache = PsiShortNamesCache.getInstance(project);
PsiClass[] classes = shortNamesCache.getClassesByName(shortName, GlobalSearchScope.allScope(project));
@@ -848,11 +848,11 @@ public final class HighlightFixUtil {
registerChangeParameterClassFix(sink, lType, rType);
}
private static @NotNull LanguageLevel getApplicableLevel(@NotNull PsiFile file, @NotNull JavaFeature feature) {
private static @NotNull LanguageLevel getApplicableLevel(@NotNull PsiFile psiFile, @NotNull JavaFeature feature) {
LanguageLevel standardLevel = feature.getStandardLevel();
LanguageLevel featureLevel = feature.getMinimumLevel();
if (featureLevel.isPreview()) {
JavaSdkVersion sdkVersion = JavaSdkVersionUtil.getJavaSdkVersion(file);
JavaSdkVersion sdkVersion = JavaSdkVersionUtil.getJavaSdkVersion(psiFile);
if (sdkVersion != null) {
if (standardLevel != null && sdkVersion.isAtLeast(JavaSdkVersion.fromLanguageLevel(standardLevel))) {
return standardLevel;

View File

@@ -45,10 +45,10 @@ public final class HighlightNamesUtil {
highlight(containingFile, holder, visitor -> psiElement.accept(visitor));
}
public static void highlight(@NotNull PsiFile file, @NotNull HighlightInfoHolder holder, @NotNull Consumer<? super @NotNull JavaElementVisitor> consumer) {
public static void highlight(@NotNull PsiFile psiFile, @NotNull HighlightInfoHolder holder, @NotNull Consumer<? super @NotNull JavaElementVisitor> consumer) {
JavaNamesHighlightVisitor visitor = new JavaNamesHighlightVisitor();
if (!visitor.suitableForFile(file)) return;
visitor.analyze(file, false, holder, () -> consumer.accept(visitor));
if (!visitor.suitableForFile(psiFile)) return;
visitor.analyze(psiFile, false, holder, () -> consumer.accept(visitor));
}
static @Nullable HighlightInfo highlightMethodName(@NotNull PsiMember methodOrClass,
@@ -263,10 +263,10 @@ public final class HighlightNamesUtil {
}
private static TextAttributes getScopeAttributes(@NotNull PsiElement element, @NotNull TextAttributesScheme colorsScheme) {
PsiFile file = element.getContainingFile();
if (file == null) return null;
PsiFile psiFile = element.getContainingFile();
if (psiFile == null) return null;
TextAttributes result = null;
DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl)DependencyValidationManager.getInstance(file.getProject());
DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl)DependencyValidationManager.getInstance(psiFile.getProject());
List<Pair<NamedScope,NamedScopesHolder>> scopes = validationManager.getScopeBasedHighlightingCachedScopes();
for (Pair<NamedScope, NamedScopesHolder> scope : scopes) {
NamedScope namedScope = scope.getFirst();
@@ -276,7 +276,7 @@ public final class HighlightNamesUtil {
continue;
}
PackageSet packageSet = namedScope.getValue();
if (packageSet != null && packageSet.contains(file, scope.getSecond())) {
if (packageSet != null && packageSet.contains(psiFile, scope.getSecond())) {
result = TextAttributes.merge(attributes, result);
}
}

View File

@@ -79,14 +79,14 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
}
@Override
public boolean suitableForFile(@NotNull PsiFile file) {
HighlightingLevelManager highlightingLevelManager = HighlightingLevelManager.getInstance(file.getProject());
if (highlightingLevelManager.runEssentialHighlightingOnly(file)) {
public boolean suitableForFile(@NotNull PsiFile psiFile) {
HighlightingLevelManager highlightingLevelManager = HighlightingLevelManager.getInstance(psiFile.getProject());
if (highlightingLevelManager.runEssentialHighlightingOnly(psiFile)) {
return false;
}
// both PsiJavaFile and PsiCodeFragment must match
return file instanceof PsiImportHolder && !InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file);
return psiFile instanceof PsiImportHolder && !InjectedLanguageManager.getInstance(psiFile.getProject()).isInjectedFragment(psiFile);
}
@Override
@@ -100,17 +100,17 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
}
@Override
public boolean analyze(@NotNull PsiFile file, boolean updateWholeFile, @NotNull HighlightInfoHolder holder, @NotNull Runnable highlight) {
public boolean analyze(@NotNull PsiFile psiFile, boolean updateWholeFile, @NotNull HighlightInfoHolder holder, @NotNull Runnable highlight) {
try {
prepare(holder, file);
prepare(holder, psiFile);
if (updateWholeFile) {
GlobalInspectionContextBase.assertUnderDaemonProgress();
Project project = file.getProject();
Document document = PsiDocumentManager.getInstance(project).getDocument(file);
Project project = psiFile.getProject();
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
highlight.run();
ProgressManager.checkCanceled();
if (document != null) {
new UnusedImportsVisitor(file, document).collectHighlights(holder);
new UnusedImportsVisitor(psiFile, document).collectHighlights(holder);
}
}
else {
@@ -124,8 +124,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
return true;
}
private void prepare(@NotNull HighlightInfoHolder holder, @NotNull PsiFile file) {
myCollector = new JavaErrorCollector(file, error -> reportError(error, holder));
private void prepare(@NotNull HighlightInfoHolder holder, @NotNull PsiFile psiFile) {
myCollector = new JavaErrorCollector(psiFile, error -> reportError(error, holder));
}
private void reportError(@NotNull JavaCompilationError<?, ?> error, @NotNull HighlightInfoHolder holder) {

View File

@@ -28,7 +28,7 @@ import java.util.function.Supplier;
*/
final class JavaNamesHighlightVisitor extends JavaElementVisitor implements HighlightVisitor, DumbAware {
private HighlightInfoHolder myHolder;
private PsiFile myFile;
private PsiFile myPsiFile;
private LanguageLevel myLanguageLevel;
private boolean shouldHighlightSoftKeywords;
private boolean isClassFile;
@@ -40,9 +40,9 @@ final class JavaNamesHighlightVisitor extends JavaElementVisitor implements High
}
@Override
public boolean suitableForFile(@NotNull PsiFile file) {
public boolean suitableForFile(@NotNull PsiFile psiFile) {
// both PsiJavaFile and PsiCodeFragment must match
return file instanceof PsiImportHolder;
return psiFile instanceof PsiImportHolder;
}
@Override
@@ -51,26 +51,26 @@ final class JavaNamesHighlightVisitor extends JavaElementVisitor implements High
}
@Override
public boolean analyze(@NotNull PsiFile file, boolean updateWholeFile, @NotNull HighlightInfoHolder holder, @NotNull Runnable highlight) {
public boolean analyze(@NotNull PsiFile psiFile, boolean updateWholeFile, @NotNull HighlightInfoHolder holder, @NotNull Runnable highlight) {
try {
prepare(holder, file);
prepare(holder, psiFile);
highlight.run();
}
finally {
myFile = null;
myPsiFile = null;
myHolder = null;
}
return true;
}
private void prepare(@NotNull HighlightInfoHolder holder, @NotNull PsiFile file) {
private void prepare(@NotNull HighlightInfoHolder holder, @NotNull PsiFile psiFile) {
myHolder = holder;
myFile = file;
myLanguageLevel = PsiUtil.getLanguageLevel(file);
shouldHighlightSoftKeywords = PsiJavaModule.MODULE_INFO_FILE.equals(file.getName()) ||
myPsiFile = psiFile;
myLanguageLevel = PsiUtil.getLanguageLevel(psiFile);
shouldHighlightSoftKeywords = PsiJavaModule.MODULE_INFO_FILE.equals(psiFile.getName()) ||
myLanguageLevel.isAtLeast(LanguageLevel.JDK_10);
isClassFile = file.getOriginalFile() instanceof PsiCompiledFile;
isClassFile = psiFile.getOriginalFile() instanceof PsiCompiledFile;
}
@Override
@@ -188,7 +188,7 @@ final class JavaNamesHighlightVisitor extends JavaElementVisitor implements High
}
private void doVisitReferenceElement(@NotNull PsiJavaCodeReferenceElement ref) {
JavaResolveResult result = LocalRefUseInfo.resolveOptimised(ref, myFile);
JavaResolveResult result = LocalRefUseInfo.resolveOptimised(ref, myPsiFile);
PsiElement resolved = result != null ? result.getElement() : null;
if (resolved instanceof PsiVariable variable) {
@@ -219,7 +219,7 @@ final class JavaNamesHighlightVisitor extends JavaElementVisitor implements High
private void highlightReferencedMethodOrClassName(@NotNull PsiJavaCodeReferenceElement element, @Nullable PsiElement resolved) {
PsiElement parent = element.getParent();
TextAttributesScheme colorsScheme = myHolder.getColorsScheme();
DumbService dumbService = DumbService.getInstance(myFile.getProject());
DumbService dumbService = DumbService.getInstance(myPsiFile.getProject());
if (parent instanceof PsiMethodCallExpression methodCall) {
PsiMethod method = dumbService.computeWithAlternativeResolveEnabled(() -> methodCall.resolveMethod());
PsiElement methodNameElement = element.getReferenceNameElement();
@@ -266,7 +266,7 @@ final class JavaNamesHighlightVisitor extends JavaElementVisitor implements High
JavaResolveResult result;
JavaResolveResult[] results;
try {
results = computeIfSmartMode(myFile.getProject(), () -> expression.multiResolve(true));
results = computeIfSmartMode(myPsiFile.getProject(), () -> expression.multiResolve(true));
result = results != null && results.length == 1 ? results[0] : JavaResolveResult.EMPTY;
}
catch (IndexNotReadyException e) {

View File

@@ -39,13 +39,13 @@ public final class LocalRefUseInfo {
private final @NotNull Set<PsiImportStatementBase> myUsedImports;
/**
* @param file Java/JSP file to get local reference use info for.
* @param psiFileRoot Java/JSP file to get local reference use info for.
* @return LocalRefUseInfo container (compute if it was not ready yet)
*/
public static @NotNull LocalRefUseInfo forFile(@NotNull PsiFile file) {
return CachedValuesManager.getCachedValue(file, () -> {
Builder builder = new Builder(file);
for (PsiFile psiFile : file.getViewProvider().getAllFiles()) {
public static @NotNull LocalRefUseInfo forFile(@NotNull PsiFile psiFileRoot) {
return CachedValuesManager.getCachedValue(psiFileRoot, () -> {
Builder builder = new Builder(psiFileRoot);
for (PsiFile psiFile : psiFileRoot.getViewProvider().getAllFiles()) {
psiFile.accept(builder);
}
LocalRefUseInfo result = builder.build();
@@ -61,9 +61,9 @@ public final class LocalRefUseInfo {
this.myUsedImports = myImportStatements;
}
public @NotNull GlobalUsageHelper getGlobalUsageHelper(@NotNull PsiFile file, @Nullable UnusedDeclarationInspectionBase deadCodeInspection) {
FileViewProvider viewProvider = file.getViewProvider();
Project project = file.getProject();
public @NotNull GlobalUsageHelper getGlobalUsageHelper(@NotNull PsiFile psiFile, @Nullable UnusedDeclarationInspectionBase deadCodeInspection) {
FileViewProvider viewProvider = psiFile.getViewProvider();
Project project = psiFile.getProject();
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
VirtualFile virtualFile = viewProvider.getVirtualFile();
@@ -262,15 +262,15 @@ public final class LocalRefUseInfo {
}
private static class Builder extends JavaRecursiveElementWalkingVisitor {
private final @NotNull PsiFile myFile;
private final @NotNull PsiFile myPsiFile;
private final @NotNull Set<PsiAnchor> myDclsUsedMap;
private final @NotNull MultiMap<PsiElement, PsiReference> myLocalRefsMap;
private final @NotNull Set<PsiImportStatementBase> myImportStatements;
Builder(@NotNull PsiFile file) {
Builder(@NotNull PsiFile psiFile) {
myImportStatements = new HashSet<>();
myDclsUsedMap = new HashSet<>();
myFile = file;
myPsiFile = psiFile;
myLocalRefsMap = MultiMap.createLinkedSet();
}
@@ -308,7 +308,7 @@ public final class LocalRefUseInfo {
@Override
public void visitElement(@NotNull PsiElement element) {
super.visitElement(element);
if(myFile instanceof ServerPageFile) {
if(myPsiFile instanceof ServerPageFile) {
// in JSP, XmlAttributeValue may contain java references
try {
for (PsiReference reference : element.getReferences()) {
@@ -323,8 +323,8 @@ public final class LocalRefUseInfo {
}
private void registerReferencesFromInjectedFragments(@NotNull PsiElement element) {
InjectedLanguageManager manager = InjectedLanguageManager.getInstance(myFile.getProject());
manager.enumerateEx(element, myFile, false, (injectedPsi, places) -> {
InjectedLanguageManager manager = InjectedLanguageManager.getInstance(myPsiFile.getProject());
manager.enumerateEx(element, myPsiFile, false, (injectedPsi, places) -> {
if (InjectedLanguageJavaReferenceSupplier.containsPsiMemberReferences(injectedPsi.getLanguage().getID())) {
injectedPsi.accept(new PsiRecursiveElementWalkingVisitor() {
@Override
@@ -366,7 +366,7 @@ public final class LocalRefUseInfo {
PsiElement refElement = resolveResult.getElement();
PsiFile psiFile = refElement == null ? null : refElement.getContainingFile();
if (psiFile != null) psiFile = (PsiFile)psiFile.getNavigationElement(); // look at navigation elements because all references resolve into Cls elements when highlighting library source
if (refElement != null && psiFile != null && myFile.getViewProvider().equals(psiFile.getViewProvider())) {
if (refElement != null && psiFile != null && myPsiFile.getViewProvider().equals(psiFile.getViewProvider())) {
registerLocalRef(ref, refElement.getNavigationElement());
}
@@ -420,7 +420,7 @@ public final class LocalRefUseInfo {
public void visitReferenceElement(@NotNull PsiJavaCodeReferenceElement ref) {
super.visitReferenceElement(ref);
if (!(ref instanceof PsiImportStaticReferenceElement)) {
JavaResolveResult result = resolveOptimised(ref, myFile);
JavaResolveResult result = resolveOptimised(ref, myPsiFile);
if (result != null) {
registerReference(ref, result);
}
@@ -430,7 +430,7 @@ public final class LocalRefUseInfo {
@Override
public void visitReferenceExpression(@NotNull PsiReferenceExpression ref) {
super.visitReferenceExpression(ref);
JavaResolveResult result = resolveOptimised(ref, myFile);
JavaResolveResult result = resolveOptimised(ref, myPsiFile);
if (result != null) {
registerReference(ref, result);
}

View File

@@ -43,28 +43,28 @@ import java.util.function.Function;
class UnusedImportsVisitor extends JavaElementVisitor {
private final LocalRefUseInfo myRefCountHolder;
private final @NotNull Project myProject;
private final PsiFile myFile;
private final PsiFile myPsiFile;
private final @NotNull Document myDocument;
private final @NotNull CodeInsightContext myContext;
private boolean requiresFix = false;
private int myCurrentEntryIndex = -1;
private boolean errorFound;
UnusedImportsVisitor(@NotNull PsiFile file, @NotNull Document document) throws ProcessCanceledException {
UnusedImportsVisitor(@NotNull PsiFile psiFile, @NotNull Document document) throws ProcessCanceledException {
ApplicationManager.getApplication().assertIsNonDispatchThread();
ApplicationManager.getApplication().assertReadAccessAllowed();
myProject = file.getProject();
myFile = file;
myProject = psiFile.getProject();
myPsiFile = psiFile;
myDocument = document;
myRefCountHolder = LocalRefUseInfo.forFile(file);
myContext = FileViewProviderUtil.getCodeInsightContext(file);
myRefCountHolder = LocalRefUseInfo.forFile(psiFile);
myContext = FileViewProviderUtil.getCodeInsightContext(psiFile);
}
void collectHighlights(@NotNull HighlightInfoHolder holder) {
ApplicationManager.getApplication().assertIsNonDispatchThread();
HighlightDisplayKey unusedImportKey = HighlightDisplayKey.find(UnusedImportInspection.SHORT_NAME);
PsiJavaFile javaFile = ObjectUtils.tryCast(myFile, PsiJavaFile.class);
PsiJavaFile javaFile = ObjectUtils.tryCast(myPsiFile, PsiJavaFile.class);
PsiImportList importList = javaFile == null ? null : javaFile.getImportList();
if (unusedImportKey != null && isUnusedImportEnabled(unusedImportKey) && importList != null) {
PsiImportStatementBase[] imports = importList.getAllImportStatements();
@@ -81,9 +81,9 @@ class UnusedImportsVisitor extends JavaElementVisitor {
}
ModCommandAction fixNotOnFly = null;
if (requiresFix) {
ModCommandAction fix = QuickFixFactory.getInstance().createOptimizeImportsFix(true, myFile);
OptimizeImportRestarter.getInstance(myProject).scheduleOnDaemonFinish(myFile, fix);
fixNotOnFly = QuickFixFactory.getInstance().createOptimizeImportsFix(false, myFile);
ModCommandAction fix = QuickFixFactory.getInstance().createOptimizeImportsFix(true, myPsiFile);
OptimizeImportRestarter.getInstance(myProject).scheduleOnDaemonFinish(myPsiFile, fix);
fixNotOnFly = QuickFixFactory.getInstance().createOptimizeImportsFix(false, myPsiFile);
}
HighlightDisplayKey misSortedKey = HighlightDisplayKey.find(MissortedImportsInspection.SHORT_NAME);
if (misSortedKey != null && isToolEnabled(misSortedKey) && fixNotOnFly != null && importList != null) {
@@ -105,24 +105,24 @@ class UnusedImportsVisitor extends JavaElementVisitor {
private boolean isUnusedImportEnabled(@NotNull HighlightDisplayKey unusedImportKey) {
if (isToolEnabled(unusedImportKey)) return true;
for (ImplicitUsageProvider provider : ImplicitUsageProvider.EP_NAME.getExtensionList()) {
if (provider instanceof UnusedImportProvider uip && uip.isUnusedImportEnabled(myFile)) return true;
if (provider instanceof UnusedImportProvider uip && uip.isUnusedImportEnabled(myPsiFile)) return true;
}
return false;
}
private boolean isToolEnabled(@NotNull HighlightDisplayKey displayKey) {
if (!(myFile instanceof PsiJavaFile)) {
if (!(myPsiFile instanceof PsiJavaFile)) {
return false;
}
InspectionProfile profile = getCurrentProfile(myFile);
return profile.isToolEnabled(displayKey, myFile) &&
HighlightingLevelManager.getInstance(myProject).shouldInspect(myFile) &&
!HighlightingLevelManager.getInstance(myProject).runEssentialHighlightingOnly(myFile);
InspectionProfile profile = getCurrentProfile(myPsiFile);
return profile.isToolEnabled(displayKey, myPsiFile) &&
HighlightingLevelManager.getInstance(myProject).shouldInspect(myPsiFile) &&
!HighlightingLevelManager.getInstance(myProject).runEssentialHighlightingOnly(myPsiFile);
}
private static @NotNull InspectionProfile getCurrentProfile(@NotNull PsiFile file) {
Function<? super InspectionProfile, ? extends InspectionProfileWrapper> custom = InspectionProfileWrapper.getCustomInspectionProfileWrapper(file);
InspectionProfileImpl currentProfile = InspectionProjectProfileManager.getInstance(file.getProject()).getCurrentProfile();
private static @NotNull InspectionProfile getCurrentProfile(@NotNull PsiFile psiFile) {
Function<? super InspectionProfile, ? extends InspectionProfileWrapper> custom = InspectionProfileWrapper.getCustomInspectionProfileWrapper(psiFile);
InspectionProfileImpl currentProfile = InspectionProjectProfileManager.getInstance(psiFile.getProject()).getCurrentProfile();
return custom != null ? custom.apply(currentProfile).getInspectionProfile() : currentProfile;
}
@@ -181,16 +181,16 @@ class UnusedImportsVisitor extends JavaElementVisitor {
private void registerRedundantImport(@NotNull HighlightInfoHolder holder,
@NotNull PsiImportStatementBase importStatement, @NotNull HighlightDisplayKey unusedImportKey) {
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(myFile);
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(myPsiFile);
Set<String> imports = virtualFile != null ? virtualFile.getCopyableUserData(ImportsHighlightUtil.IMPORTS_FROM_TEMPLATE) : null;
boolean predefinedImport = imports != null && imports.contains(importStatement.getText());
String description = !predefinedImport ? JavaAnalysisBundle.message("unused.import.statement") :
JavaAnalysisBundle.message("text.unused.import.in.template");
InspectionProfile profile = getCurrentProfile(myFile);
TextAttributesKey key = ObjectUtils.notNull(profile.getEditorAttributes(unusedImportKey.getShortName(), myFile),
InspectionProfile profile = getCurrentProfile(myPsiFile);
TextAttributesKey key = ObjectUtils.notNull(profile.getEditorAttributes(unusedImportKey.getShortName(), myPsiFile),
JavaHighlightInfoTypes.UNUSED_IMPORT.getAttributesKey());
HighlightInfoType.HighlightInfoTypeImpl configHighlightType =
new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(unusedImportKey, myFile).getSeverity(), key);
new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(unusedImportKey, myPsiFile).getSeverity(), key);
ProblemGroup problemGroup = new ExternalSourceProblemGroup() {
@Override

View File

@@ -72,7 +72,7 @@ public class ExtendsListFix extends LocalQuickFixAndIntentionActionOnPsiElement
@Override
public boolean isAvailable(@NotNull Project project,
@NotNull PsiFile file,
@NotNull PsiFile psiFile,
@NotNull PsiElement startElement,
@NotNull PsiElement endElement) {
if (!myTypeToExtendFrom.isValid()) return false;
@@ -92,7 +92,7 @@ public class ExtendsListFix extends LocalQuickFixAndIntentionActionOnPsiElement
@Override
public void invoke(@NotNull Project project,
@NotNull PsiFile file,
@NotNull PsiFile psiFile,
@Nullable Editor editor,
@NotNull PsiElement startElement,
@NotNull PsiElement endElement) {

View File

@@ -50,16 +50,16 @@ public class AddAnnotationFix extends AddAnnotationPsiFix implements IntentionAc
}
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (InjectedLanguageManager.getInstance(project).isInjectedFragment(file)) {
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile psiFile) {
if (InjectedLanguageManager.getInstance(project).isInjectedFragment(psiFile)) {
PsiElement psiElement = getStartElement();
if (psiElement == null || psiElement.getContainingFile() != file) return false;
if (psiElement == null || psiElement.getContainingFile() != psiFile) return false;
}
return isAvailable();
}
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) throws IncorrectOperationException {
applyFix();
}
}

View File

@@ -141,7 +141,7 @@ public class AddAnnotationPsiFix extends LocalQuickFixOnPsiElement implements Lo
@Override
public boolean isAvailable(@NotNull Project project,
@NotNull PsiFile file,
@NotNull PsiFile psiFile,
@NotNull PsiElement startElement,
@NotNull PsiElement endElement) {
return isAvailable((PsiModifierListOwner)startElement, myAnnotation);
@@ -186,11 +186,11 @@ public class AddAnnotationPsiFix extends LocalQuickFixOnPsiElement implements Lo
@Override
public void invoke(@NotNull Project project,
@NotNull PsiFile file,
@NotNull PsiFile psiFile,
@NotNull PsiElement startElement,
@NotNull PsiElement endElement) {
final PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)startElement;
ActionContext context = ActionContext.from(null, file);
ActionContext context = ActionContext.from(null, psiFile);
AddAnnotationModCommandAction delegate = new AddAnnotationModCommandAction(
myAnnotation, modifierListOwner, myPairs, myAnnotationPlace, myAnnotationsToRemove);
if (delegate.getPresentation(context) == null) return;

View File

@@ -25,13 +25,13 @@ public class AddNullableNotNullAnnotationFix extends AddAnnotationPsiFix {
@Override
public boolean isAvailable(@NotNull Project project,
@NotNull PsiFile file,
@NotNull PsiFile psiFile,
@NotNull PsiElement startElement,
@NotNull PsiElement endElement) {
if (!super.isAvailable(project, file, startElement, endElement)) {
if (!super.isAvailable(project, psiFile, startElement, endElement)) {
return false;
}
PsiModifierListOwner owner = getContainer(file, startElement.getTextRange().getStartOffset());
PsiModifierListOwner owner = getContainer(psiFile, startElement.getTextRange().getStartOffset());
return owner != null &&
!AnnotationUtil.isAnnotated(owner, getAnnotationsToRemove()[0], CHECK_EXTERNAL | CHECK_TYPE) &&
isNullabilityAnnotationApplicable(owner);

View File

@@ -163,16 +163,16 @@ public class UnusedDeclarationInspectionBase extends GlobalInspectionTool {
}
@Override
public void checkFile(@NotNull PsiFile file,
public void checkFile(@NotNull PsiFile psiFile,
@NotNull InspectionManager manager,
@NotNull ProblemsHolder ignored,
@NotNull GlobalInspectionContext globalContext,
@NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
if (!file.getLanguage().isKindOf("JAVA")) return;
if (!psiFile.getLanguage().isKindOf("JAVA")) return;
// don't use supplied problems holder to get nice warnings attached to members instead of anchored at the file level
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, false);
ProblemsHolder problemsHolder = new ProblemsHolder(manager, psiFile, false);
PsiElementVisitor visitor = localInspectionBase.buildVisitor(problemsHolder, false);
file.accept(new PsiRecursiveElementWalkingVisitor() {
psiFile.accept(new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(@NotNull PsiElement element) {
element.accept(visitor);

View File

@@ -142,11 +142,11 @@ class ImplicitSubclassInspection : LocalInspectionTool() {
override fun getFamilyName(): String = QuickFixBundle.message("fix.modifiers.family")
override fun invoke(project: Project, file: PsiFile, startElement: PsiElement, endElement: PsiElement) {
override fun invoke(project: Project, psiFile: PsiFile, startElement: PsiElement, endElement: PsiElement) {
try {
for (intentionAction in actionsToPerform) {
if (intentionAction.isAvailable(project, null, file))
intentionAction.invoke(project, null, file)
if (intentionAction.isAvailable(project, null, psiFile))
intentionAction.invoke(project, null, psiFile)
}
}
catch (e: IncorrectOperationException) {

View File

@@ -34,12 +34,12 @@ public final class MissortedImportsInspection extends GlobalSimpleInspectionTool
public static final @NonNls String SHORT_NAME = "MISSORTED_IMPORTS";
@Override
public void checkFile(@NotNull PsiFile file,
public void checkFile(@NotNull PsiFile psiFile,
@NotNull InspectionManager manager,
@NotNull ProblemsHolder problemsHolder,
@NotNull GlobalInspectionContext globalContext,
@NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
if (!(file instanceof PsiJavaFile javaFile) || FileTypeUtils.isInServerPageFile(file)) return;
if (!(psiFile instanceof PsiJavaFile javaFile) || FileTypeUtils.isInServerPageFile(psiFile)) return;
PsiImportList importList = javaFile.getImportList();
if (importList == null) return;
PsiImportStatementBase[] imports = importList.getAllImportStatements();

View File

@@ -30,12 +30,12 @@ public final class UnusedImportInspection extends GlobalSimpleInspectionTool {
public static final @NonNls String SHORT_NAME = "UNUSED_IMPORT";
@Override
public void checkFile(@NotNull PsiFile file,
public void checkFile(@NotNull PsiFile psiFile,
@NotNull InspectionManager manager,
@NotNull ProblemsHolder problemsHolder,
@NotNull GlobalInspectionContext globalContext,
@NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
if (!(file instanceof PsiJavaFile javaFile) || FileTypeUtils.isInServerPageFile(file)) return;
if (!(psiFile instanceof PsiJavaFile javaFile) || FileTypeUtils.isInServerPageFile(psiFile)) return;
final ImportsAreUsedVisitor visitor = new ImportsAreUsedVisitor(javaFile);
javaFile.accept(visitor);
PsiPolyVariantReference reference;

View File

@@ -95,18 +95,18 @@ public final class UnnecessaryUnicodeEscapeInspection extends BaseInspection {
private static class UnnecessaryUnicodeEscapeVisitor extends BaseInspectionVisitor {
@Override
public void visitFile(@NotNull PsiFile file) {
super.visitFile(file);
if (InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file) || !file.isPhysical()) {
public void visitFile(@NotNull PsiFile psiFile) {
super.visitFile(psiFile);
if (InjectedLanguageManager.getInstance(psiFile.getProject()).isInjectedFragment(psiFile) || !psiFile.isPhysical()) {
return;
}
final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
final Document document = PsiDocumentManager.getInstance(psiFile.getProject()).getDocument(psiFile);
if (document == null) {
return;
}
final VirtualFile virtualFile = file.getVirtualFile();
final String text = file.getText();
final Charset charset = LoadTextUtil.extractCharsetFromFileContent(file.getProject(), virtualFile, text);
final VirtualFile virtualFile = psiFile.getVirtualFile();
final String text = psiFile.getText();
final Charset charset = LoadTextUtil.extractCharsetFromFileContent(psiFile.getProject(), virtualFile, text);
final CharsetEncoder encoder = charset.newEncoder().onUnmappableCharacter(CodingErrorAction.REPORT);
final CharBuffer charBuffer = CharBuffer.allocate(1);
final ByteBuffer byteBuffer = ByteBuffer.allocate(10);
@@ -165,7 +165,7 @@ public final class UnnecessaryUnicodeEscapeInspection extends BaseInspection {
if (coderResult.isError()) {
continue;
}
PsiElement element = file.findElementAt(i);
PsiElement element = psiFile.findElementAt(i);
if (element == null) {
return;
}

View File

@@ -32,8 +32,8 @@ class VariableAssignedFromVisitor extends JavaRecursiveElementWalkingVisitor {
}
@Override
public void visitFile(@NotNull PsiFile file) {
LOG.error("Unexpectedly visited PsiFile "+file+" when tracing variable "+variable);
public void visitFile(@NotNull PsiFile psiFile) {
LOG.error("Unexpectedly visited PsiFile " + psiFile + " when tracing variable " + variable);
stopWalking();
}

View File

@@ -96,9 +96,9 @@ public final class UnnecessarySemicolonInspection extends BaseInspection impleme
private class UnnecessarySemicolonVisitor extends BaseInspectionVisitor {
@Override
public void visitFile(@NotNull PsiFile file) {
checkTopLevelSemicolons(file);
super.visitFile(file);
public void visitFile(@NotNull PsiFile psiFile) {
checkTopLevelSemicolons(psiFile);
super.visitFile(psiFile);
}
@Override