Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,18 @@
*/
package com.intellij.java.analysis.impl.codeInspection.dataFlow.fix;

import jakarta.annotation.Nonnull;

import org.jetbrains.annotations.Nls;

import jakarta.annotation.Nullable;
import com.intellij.java.language.LanguageLevel;
import com.intellij.java.language.psi.*;
import com.intellij.java.language.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.java.language.psi.util.PsiUtil;
import consulo.language.editor.inspection.LocalQuickFix;
import consulo.language.editor.inspection.ProblemDescriptor;
import consulo.project.Project;
import com.intellij.java.language.LanguageLevel;
import consulo.java.language.module.util.JavaClassNames;
import com.intellij.java.language.psi.JavaPsiFacade;
import consulo.language.psi.PsiElement;
import com.intellij.java.language.psi.PsiExpression;
import com.intellij.java.language.psi.PsiMethod;
import com.intellij.java.language.psi.PsiMethodCallExpression;
import com.intellij.java.language.psi.PsiReferenceExpression;
import com.intellij.java.language.psi.codeStyle.JavaCodeStyleManager;
import consulo.language.psi.util.PsiTreeUtil;
import com.intellij.java.language.psi.util.PsiUtil;
import consulo.project.Project;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import org.jetbrains.annotations.Nls;

/**
* @author peter
Expand Down Expand Up @@ -101,7 +94,8 @@ public static ReplaceWithObjectsEqualsFix createFix(@Nonnull PsiMethodCallExpres
}

PsiMethod method = call.resolveMethod();
if(method != null && method.getParameterList().getParametersCount() == 1 && method.getParameterList().getParameters()[0].getType().equalsToText(JavaClassNames.JAVA_LANG_OBJECT))
if(method != null && method.getParameterList().getParametersCount() == 1
&& method.getParameterList().getParameters()[0].getType().equalsToText(CommonClassNames.JAVA_LANG_OBJECT))
{
return new ReplaceWithObjectsEqualsFix(qualifier.getText(), noParens.getText());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.intellij.java.language.psi.*;
import com.intellij.java.language.psi.util.PsiUtil;
import consulo.annotation.access.RequiredReadAction;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.psi.PsiElement;
import consulo.language.psi.PsiReference;
import consulo.language.psi.scope.LocalSearchScope;
Expand Down Expand Up @@ -87,7 +86,7 @@ else if (psiCall instanceof PsiNewExpression newExpr && psiCall.getArgumentList(
if (classOrAnonymousClassReference != null
&& classOrAnonymousClassReference.resolve() instanceof PsiClass psiClass) {
PsiClass superClass = psiClass.getSuperClass();
return superClass == null || JavaClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName());
return superClass == null || CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.intellij.java.language.psi.util.PropertyUtil;
import com.intellij.java.language.psi.util.PsiUtil;
import consulo.annotation.access.RequiredReadAction;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.ast.IElementType;
import consulo.language.psi.PsiDirectory;
import consulo.language.psi.PsiElement;
Expand Down Expand Up @@ -347,9 +346,9 @@ private static boolean isSideEffectFreeConstructor(@Nonnull PsiNewExpression new
String packageName = classPackage == null ? null : classPackage.getQualifiedName();

// all Throwable descendants from java.lang are side effects free
if (JavaClassNames.DEFAULT_PACKAGE.equals(packageName) || "java.io".equals(packageName)) {
if (CommonClassNames.DEFAULT_PACKAGE.equals(packageName) || "java.io".equals(packageName)) {
PsiClass throwableClass =
JavaPsiFacade.getInstance(aClass.getProject()).findClass(JavaClassNames.JAVA_LANG_THROWABLE, aClass.getResolveScope());
JavaPsiFacade.getInstance(aClass.getProject()).findClass(CommonClassNames.JAVA_LANG_THROWABLE, aClass.getResolveScope());
if (throwableClass != null && InheritanceUtil.isInheritorOrSelf(aClass, throwableClass, true)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import consulo.internal.com.sun.jdi.InterfaceType;
import consulo.internal.com.sun.jdi.Type;
import consulo.internal.com.sun.jdi.Value;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.psi.PsiElement;
import consulo.project.Project;
import jakarta.annotation.Nonnull;
Expand Down Expand Up @@ -109,7 +108,7 @@ public static PsiType getCastableRuntimeType(Project project, Value value)
if(type instanceof ClassType)
{
ClassType superclass = ((ClassType) type).superclass();
if(superclass != null && !JavaClassNames.JAVA_LANG_OBJECT.equals(superclass.name()))
if(superclass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(superclass.name()))
{
psiType = findPsiType(project, superclass);
if(psiType != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
import consulo.application.ApplicationManager;
import consulo.codeEditor.EditorFactory;
import consulo.document.Document;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.ast.IElementType;
import consulo.language.psi.PsiElement;
import consulo.module.content.ProjectFileIndex;
import consulo.module.content.ProjectRootManager;
import consulo.project.Project;
import consulo.util.lang.Comparing;
import consulo.virtualFileSystem.VirtualFile;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

Expand Down Expand Up @@ -93,9 +91,9 @@ public static boolean isString(@Nonnull PsiType type) {
if (type instanceof PsiClassType) {
// optimization. doesn't require resolve
final String shortName = ((PsiClassType)type).getClassName();
if (!Comparing.equal(shortName, JavaClassNames.JAVA_LANG_STRING_SHORT)) return false;
if (!Comparing.equal(shortName, CommonClassNames.JAVA_LANG_STRING_SHORT)) return false;
}
return JavaClassNames.JAVA_LANG_STRING.equals(type.getCanonicalText());
return CommonClassNames.JAVA_LANG_STRING.equals(type.getCanonicalText());
}

public static boolean isStringOrStringArray(@Nonnull PsiType type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.intellij.java.language.jvm.types.JvmReferenceType;
import com.intellij.java.language.jvm.types.JvmSubstitutor;
import com.intellij.java.language.jvm.types.JvmType;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.psi.PsiElement;
import consulo.logging.Logger;
import consulo.logging.attachment.AttachmentFactory;
Expand Down Expand Up @@ -91,7 +90,7 @@ static JvmReferenceType getClassSuperType(@Nonnull PsiClass psiClass) {
return null;
}
if (psiClass.isEnum()) {
return getTypeByName(JavaClassNames.JAVA_LANG_ENUM, psiClass.getProject(), psiClass.getResolveScope());
return getTypeByName(CommonClassNames.JAVA_LANG_ENUM, psiClass.getProject(), psiClass.getResolveScope());
}
if (psiClass instanceof PsiAnonymousClass) {
PsiClassType baseClassType = ((PsiAnonymousClass) psiClass).getBaseClassType();
Expand All @@ -102,7 +101,7 @@ static JvmReferenceType getClassSuperType(@Nonnull PsiClass psiClass) {
return getJavaLangObject(psiClass.getManager(), psiClass.getResolveScope());
}
}
if (JavaClassNames.JAVA_LANG_OBJECT.equals(psiClass.getQualifiedName())) {
if (CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass.getQualifiedName())) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

import com.intellij.java.language.jvm.types.JvmType;
import com.intellij.java.language.psi.util.TypeConversionUtil;
import consulo.project.Project;
import consulo.language.psi.PsiManager;
import consulo.language.psi.scope.GlobalSearchScope;
import consulo.java.language.module.util.JavaClassNames;
import consulo.project.Project;
import consulo.util.collection.ArrayFactory;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

Expand All @@ -31,23 +29,23 @@
*/
public abstract class PsiType implements PsiAnnotationOwner, Cloneable, JvmType {
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType BYTE = new PsiPrimitiveType("byte", JavaClassNames.JAVA_LANG_BYTE);
public static final PsiPrimitiveType BYTE = new PsiPrimitiveType("byte", CommonClassNames.JAVA_LANG_BYTE);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType CHAR = new PsiPrimitiveType("char", JavaClassNames.JAVA_LANG_CHARACTER);
public static final PsiPrimitiveType CHAR = new PsiPrimitiveType("char", CommonClassNames.JAVA_LANG_CHARACTER);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType DOUBLE = new PsiPrimitiveType("double", JavaClassNames.JAVA_LANG_DOUBLE);
public static final PsiPrimitiveType DOUBLE = new PsiPrimitiveType("double", CommonClassNames.JAVA_LANG_DOUBLE);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType FLOAT = new PsiPrimitiveType("float", JavaClassNames.JAVA_LANG_FLOAT);
public static final PsiPrimitiveType FLOAT = new PsiPrimitiveType("float", CommonClassNames.JAVA_LANG_FLOAT);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType INT = new PsiPrimitiveType("int", JavaClassNames.JAVA_LANG_INTEGER);
public static final PsiPrimitiveType INT = new PsiPrimitiveType("int", CommonClassNames.JAVA_LANG_INTEGER);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType LONG = new PsiPrimitiveType("long", JavaClassNames.JAVA_LANG_LONG);
public static final PsiPrimitiveType LONG = new PsiPrimitiveType("long", CommonClassNames.JAVA_LANG_LONG);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType SHORT = new PsiPrimitiveType("short", JavaClassNames.JAVA_LANG_SHORT);
public static final PsiPrimitiveType SHORT = new PsiPrimitiveType("short", CommonClassNames.JAVA_LANG_SHORT);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType BOOLEAN = new PsiPrimitiveType("boolean", JavaClassNames.JAVA_LANG_BOOLEAN);
public static final PsiPrimitiveType BOOLEAN = new PsiPrimitiveType("boolean", CommonClassNames.JAVA_LANG_BOOLEAN);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType VOID = new PsiPrimitiveType("void", JavaClassNames.JAVA_LANG_VOID);
public static final PsiPrimitiveType VOID = new PsiPrimitiveType("void", CommonClassNames.JAVA_LANG_VOID);
@SuppressWarnings("StaticInitializerReferencesSubClass")
public static final PsiPrimitiveType NULL = new PsiPrimitiveType("null", (String) null);

Expand Down Expand Up @@ -194,7 +192,7 @@ public static PsiClassType getTypeByName(String qName, Project project, GlobalSe
*/
@Nonnull
public static PsiClassType getJavaLangObject(@Nonnull PsiManager manager, @Nonnull GlobalSearchScope resolveScope) {
return getTypeByName(JavaClassNames.JAVA_LANG_OBJECT, manager.getProject(), resolveScope);
return getTypeByName(CommonClassNames.JAVA_LANG_OBJECT, manager.getProject(), resolveScope);
}

/**
Expand All @@ -206,7 +204,7 @@ public static PsiClassType getJavaLangObject(@Nonnull PsiManager manager, @Nonnu
*/
@Nonnull
public static PsiClassType getJavaLangClass(@Nonnull PsiManager manager, @Nonnull GlobalSearchScope resolveScope) {
return getTypeByName(JavaClassNames.JAVA_LANG_CLASS, manager.getProject(), resolveScope);
return getTypeByName(CommonClassNames.JAVA_LANG_CLASS, manager.getProject(), resolveScope);
}

/**
Expand All @@ -218,7 +216,7 @@ public static PsiClassType getJavaLangClass(@Nonnull PsiManager manager, @Nonnul
*/
@Nonnull
public static PsiClassType getJavaLangThrowable(@Nonnull PsiManager manager, @Nonnull GlobalSearchScope resolveScope) {
return getTypeByName(JavaClassNames.JAVA_LANG_THROWABLE, manager.getProject(), resolveScope);
return getTypeByName(CommonClassNames.JAVA_LANG_THROWABLE, manager.getProject(), resolveScope);
}

/**
Expand All @@ -230,7 +228,7 @@ public static PsiClassType getJavaLangThrowable(@Nonnull PsiManager manager, @No
*/
@Nonnull
public static PsiClassType getJavaLangString(@Nonnull PsiManager manager, @Nonnull GlobalSearchScope resolveScope) {
return getTypeByName(JavaClassNames.JAVA_LANG_STRING, manager.getProject(), resolveScope);
return getTypeByName(CommonClassNames.JAVA_LANG_STRING, manager.getProject(), resolveScope);
}

/**
Expand All @@ -242,7 +240,7 @@ public static PsiClassType getJavaLangString(@Nonnull PsiManager manager, @Nonnu
*/
@Nonnull
public static PsiClassType getJavaLangError(@Nonnull PsiManager manager, @Nonnull GlobalSearchScope resolveScope) {
return getTypeByName(JavaClassNames.JAVA_LANG_ERROR, manager.getProject(), resolveScope);
return getTypeByName(CommonClassNames.JAVA_LANG_ERROR, manager.getProject(), resolveScope);
}

/**
Expand All @@ -254,7 +252,7 @@ public static PsiClassType getJavaLangError(@Nonnull PsiManager manager, @Nonnul
*/
@Nonnull
public static PsiClassType getJavaLangRuntimeException(@Nonnull PsiManager manager, @Nonnull GlobalSearchScope resolveScope) {
return getTypeByName(JavaClassNames.JAVA_LANG_RUNTIME_EXCEPTION, manager.getProject(), resolveScope);
return getTypeByName(CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION, manager.getProject(), resolveScope);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
*/
package com.intellij.java.language.psi;

import consulo.util.lang.Comparing;
import consulo.language.psi.PsiManager;
import consulo.language.psi.scope.GlobalSearchScope;
import consulo.java.language.module.util.JavaClassNames;
import consulo.logging.Logger;
import consulo.util.dataholder.Key;

import consulo.util.lang.Comparing;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

Expand Down Expand Up @@ -163,9 +161,9 @@ public boolean equals(Object o) {

PsiWildcardType that = (PsiWildcardType) o;
if (myBound == null && that.myBound != null) {
return that.isExtends() && that.myBound.equalsToText(JavaClassNames.JAVA_LANG_OBJECT);
return that.isExtends() && that.myBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
} else if (myBound != null && that.myBound == null) {
return isExtends() && myBound.equalsToText(JavaClassNames.JAVA_LANG_OBJECT);
return isExtends() && myBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
}
return myIsExtending == that.myIsExtending && Comparing.equal(myBound, that.myBound);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.intellij.java.language.codeInsight.runner.JavaMainMethodProvider;
import com.intellij.java.language.psi.*;
import consulo.java.language.module.util.JavaClassNames;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

Expand Down Expand Up @@ -84,7 +83,7 @@ public static boolean isMainMethod(PsiMethod method) {
return false;
}
PsiType componentType = arrayType.getComponentType();
return componentType.equalsToText(JavaClassNames.JAVA_LANG_STRING);
return componentType.equalsToText(CommonClassNames.JAVA_LANG_STRING);
}

public static boolean hasMainMethod(PsiClass psiClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package com.intellij.java.language.psi.util;

import com.intellij.java.language.psi.*;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.ast.IElementType;
import consulo.language.psi.PsiElement;
import consulo.language.psi.util.PsiTreeUtil;
Expand Down Expand Up @@ -69,7 +68,7 @@ public static boolean isCommutativeOperation(PsiPolyadicExpression expression) {
return false;
}
PsiType type = expression.getType();
return type != null && !type.equalsToText(JavaClassNames.JAVA_LANG_STRING);
return type != null && !type.equalsToText(CommonClassNames.JAVA_LANG_STRING);
}

public static boolean isAssociativeOperation(PsiPolyadicExpression expression) {
Expand Down Expand Up @@ -208,7 +207,7 @@ else if (expression instanceof PsiInstanceOfExpression) {
if (!parentType.equals(childType)) {
return true;
}
if (childType.equalsToText(JavaClassNames.JAVA_LANG_STRING)
if (childType.equalsToText(CommonClassNames.JAVA_LANG_STRING)
&& !PsiTreeUtil.isAncestor(parentPolyadic.getOperands()[0], childPolyadic, true)) {
PsiExpression[] operands = childPolyadic.getOperands();
for (PsiExpression operand : operands) {
Expand Down
Loading
Loading