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 @@ -19,11 +19,9 @@
import com.intellij.java.language.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.java.language.psi.util.InheritanceUtil;
import consulo.java.analysis.impl.JavaQuickFixBundle;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.psi.PsiElement;
import consulo.language.util.IncorrectOperationException;
import consulo.project.Project;

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

Expand Down Expand Up @@ -83,8 +81,7 @@ protected PsiExpression getModifiedArgument(final PsiExpression expression,

@Nullable
private static PsiClass getJavaUtilList(final PsiElement context) {
return JavaPsiFacade.getInstance(context.getProject()).findClass(JavaClassNames.JAVA_UTIL_LIST,
context.getResolveScope());
return JavaPsiFacade.getInstance(context.getProject()).findClass(CommonClassNames.JAVA_UTIL_LIST, context.getResolveScope());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import consulo.annotation.access.RequiredReadAction;
import consulo.codeEditor.Editor;
import consulo.java.analysis.impl.localize.JavaQuickFixLocalize;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.editor.inspection.LocalQuickFixAndIntentionActionOnPsiElement;
import consulo.language.editor.intention.BaseIntentionAction;
import consulo.language.editor.intention.HighPriorityAction;
Expand Down Expand Up @@ -149,7 +148,7 @@ private static boolean areConvertible(@Nullable PsiType exprType, @Nullable PsiT
}
PsiClassType.ClassResolveResult resolve = ((PsiClassType)parameterType).resolveGenerics();
PsiClass resolvedClass = resolve.getElement();
if (resolvedClass == null || !JavaClassNames.JAVA_UTIL_OPTIONAL.equals(resolvedClass.getQualifiedName())) {
if (resolvedClass == null || !CommonClassNames.JAVA_UTIL_OPTIONAL.equals(resolvedClass.getQualifiedName())) {
return false;
}

Expand All @@ -170,7 +169,7 @@ private static PsiExpression getModifiedExpression(PsiExpression expression) {
Project project = expression.getProject();
Nullability nullability = NullabilityUtil.getExpressionNullability(expression, true);
String methodName = nullability == Nullability.NOT_NULL ? "of" : "ofNullable";
String newExpressionText = JavaClassNames.JAVA_UTIL_OPTIONAL + "." + methodName + "(" + expression.getText() + ")";
String newExpressionText = CommonClassNames.JAVA_UTIL_OPTIONAL + "." + methodName + "(" + expression.getText() + ")";
return JavaPsiFacade.getElementFactory(project).createExpressionFromText(newExpressionText, expression);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
import com.intellij.java.language.psi.util.PsiUtil;
import consulo.codeEditor.Editor;
import consulo.java.analysis.impl.JavaQuickFixBundle;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.editor.inspection.LocalQuickFixAndIntentionActionOnPsiElement;
import consulo.language.editor.intention.HighPriorityAction;
import consulo.language.psi.PsiElement;
import consulo.language.psi.PsiFile;
import consulo.language.util.IncorrectOperationException;
import consulo.project.Project;
import org.jetbrains.annotations.Nls;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import org.jetbrains.annotations.Nls;

public class WrapStringWithFileFix extends LocalQuickFixAndIntentionActionOnPsiElement implements HighPriorityAction {
public final static MyMethodArgumentFixerFactory REGISTAR = new MyMethodArgumentFixerFactory();
Expand Down Expand Up @@ -59,7 +57,7 @@ public String getFamilyName() {

@Override
public boolean isAvailable(@Nonnull Project project, @Nonnull PsiFile file, @Nonnull PsiElement startElement, @Nonnull PsiElement endElement) {
return myType != null && myType.isValid() && myType.equalsToText(JavaClassNames.JAVA_IO_FILE) && startElement.isValid() && startElement.getManager().isInProject(startElement) &&
return myType != null && myType.isValid() && myType.equalsToText(CommonClassNames.JAVA_IO_FILE) && startElement.isValid() && startElement.getManager().isInProject(startElement) &&
isStringType(startElement);
}

Expand All @@ -76,11 +74,11 @@ private static boolean isStringType(@Nonnull PsiElement expression) {
if (type == null) {
return false;
}
return type.equalsToText(JavaClassNames.JAVA_LANG_STRING);
return type.equalsToText(CommonClassNames.JAVA_LANG_STRING);
}

private static PsiElement getModifiedExpression(@Nonnull PsiElement expression) {
return JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(PsiKeyword.NEW + " " + JavaClassNames.JAVA_IO_FILE + "(" + expression.getText() + ")", expression);
return JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(PsiKeyword.NEW + " " + CommonClassNames.JAVA_IO_FILE + "(" + expression.getText() + ")", expression);
}

private static class MyMethodArgumentFix extends MethodArgumentFix implements HighPriorityAction {
Expand Down Expand Up @@ -108,12 +106,12 @@ public static class MyMethodArgumentFixerFactory extends ArgumentFixerActionFact
@Nullable
@Override
protected PsiExpression getModifiedArgument(final PsiExpression expression, final PsiType toType) throws IncorrectOperationException {
return isStringType(expression) && toType.equalsToText(JavaClassNames.JAVA_IO_FILE) ? (PsiExpression) getModifiedExpression(expression) : null;
return isStringType(expression) && toType.equalsToText(CommonClassNames.JAVA_IO_FILE) ? (PsiExpression) getModifiedExpression(expression) : null;
}

@Override
public boolean areTypesConvertible(@Nonnull final PsiType exprType, @Nonnull final PsiType parameterType, @Nonnull final PsiElement context) {
return parameterType.isConvertibleFrom(exprType) || (parameterType.equalsToText(JavaClassNames.JAVA_IO_FILE) && exprType.equalsToText(JavaClassNames.JAVA_LANG_STRING));
return parameterType.isConvertibleFrom(exprType) || (parameterType.equalsToText(CommonClassNames.JAVA_IO_FILE) && exprType.equalsToText(CommonClassNames.JAVA_LANG_STRING));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import com.intellij.java.language.psi.util.PsiTypesUtil;
import com.intellij.java.language.psi.util.TypeConversionUtil;
import consulo.annotation.access.RequiredReadAction;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.psi.PsiManager;
import consulo.project.Project;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.Contract;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.Contract;

import java.util.*;

Expand Down Expand Up @@ -119,12 +117,12 @@ public TypeConstraint notInstanceOf() {

@Override
public String toString() {
return JavaClassNames.JAVA_LANG_OBJECT;
return CommonClassNames.JAVA_LANG_OBJECT;
}

@Override
public PsiType getPsiType(Project project) {
return JavaPsiFacade.getElementFactory(project).createTypeByFQClassName(JavaClassNames.JAVA_LANG_OBJECT);
return JavaPsiFacade.getElementFactory(project).createTypeByFQClassName(CommonClassNames.JAVA_LANG_OBJECT);
}
};

Expand Down Expand Up @@ -255,11 +253,11 @@ private static TypeConstraint.Exact exactClass(@Nonnull PsiClass psiClass) {
String name = psiClass.getQualifiedName();
if (name != null) {
switch (name) {
case JavaClassNames.JAVA_LANG_OBJECT:
case CommonClassNames.JAVA_LANG_OBJECT:
return EXACTLY_OBJECT;
case JavaClassNames.JAVA_LANG_CLONEABLE:
case CommonClassNames.JAVA_LANG_CLONEABLE:
return ArraySuperInterface.CLONEABLE;
case JavaClassNames.JAVA_IO_SERIALIZABLE:
case CommonClassNames.JAVA_IO_SERIALIZABLE:
return ArraySuperInterface.SERIALIZABLE;
}
}
Expand Down Expand Up @@ -319,8 +317,8 @@ public boolean isConvertibleFrom(@Nonnull Exact other) {
}

private enum ArraySuperInterface implements TypeConstraint.Exact {
CLONEABLE(JavaClassNames.JAVA_LANG_CLONEABLE),
SERIALIZABLE(JavaClassNames.JAVA_IO_SERIALIZABLE);
CLONEABLE(CommonClassNames.JAVA_LANG_CLONEABLE),
SERIALIZABLE(CommonClassNames.JAVA_IO_SERIALIZABLE);
@Nonnull
private final String myReference;

Expand Down Expand Up @@ -403,13 +401,13 @@ public boolean canBeInstantiated() {
// Abstract final type is incorrect. We, however, assume that final wins: it can be instantiated
// otherwise TypeConstraints.instanceOf(type) would return impossible type
return (myClass.isFinal() || !myClass.isAbstract())
&& !JavaClassNames.JAVA_LANG_VOID.equals(myClass.getQualifiedName());
&& !CommonClassNames.JAVA_LANG_VOID.equals(myClass.getQualifiedName());
}

@Override
public boolean isComparedByEquals() {
String name = myClass.getQualifiedName();
return name != null && (JavaClassNames.JAVA_LANG_STRING.equals(name) || TypeConversionUtil.isPrimitiveWrapper(name));
return name != null && (CommonClassNames.JAVA_LANG_STRING.equals(name) || TypeConversionUtil.isPrimitiveWrapper(name));
}

@Nonnull
Expand Down Expand Up @@ -548,7 +546,7 @@ public boolean isConvertibleFrom(@Nonnull Exact other) {
}
//noinspection SimplifiableIfStatement
if (other instanceof ExactClass exactClass) {
return JavaClassNames.JAVA_LANG_OBJECT.equals(exactClass.myClass.getQualifiedName());
return CommonClassNames.JAVA_LANG_OBJECT.equals(exactClass.myClass.getQualifiedName());
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
package com.intellij.java.analysis.impl.codeInspection.dataFlow.inliner;

import com.intellij.java.analysis.impl.codeInspection.dataFlow.CFGBuilder;
import com.intellij.java.language.psi.CommonClassNames;
import com.intellij.java.language.psi.PsiExpression;
import com.intellij.java.language.psi.PsiMethodCallExpression;
import com.siyeh.ig.callMatcher.CallMatcher;
import consulo.java.language.module.util.JavaClassNames;
import jakarta.annotation.Nonnull;

public class TransformInliner implements CallInliner {
Expand All @@ -23,7 +23,7 @@ public class TransformInliner implements CallInliner {
CallMatcher.instanceCall("io.reactivex.rxjava3.core.Maybe", "to").parameterCount(1),
CallMatcher.instanceCall("io.reactivex.rxjava3.core.Observable", "to").parameterCount(1),
CallMatcher.instanceCall("io.reactivex.rxjava3.core.Single", "to").parameterCount(1),
CallMatcher.instanceCall(JavaClassNames.JAVA_LANG_STRING, "transform").parameterCount(1),
CallMatcher.instanceCall(CommonClassNames.JAVA_LANG_STRING, "transform").parameterCount(1),
CallMatcher.instanceCall("one.util.streamex.BaseStreamEx", "chain").parameterCount(1)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
import consulo.application.Application;
import consulo.application.progress.ProgressManager;
import consulo.java.deadCodeNotWorking.OldStyleInspection;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.Language;
import consulo.language.editor.ImplicitUsageProvider;
import consulo.language.editor.impl.inspection.reference.RefElementImpl;
import consulo.language.editor.inspection.*;
import consulo.language.editor.inspection.GlobalInspectionContext;
import consulo.language.editor.inspection.GlobalInspectionTool;
import consulo.language.editor.inspection.InspectionToolState;
import consulo.language.editor.inspection.ProblemDescriptionsProcessor;
import consulo.language.editor.inspection.localize.InspectionLocalize;
import consulo.language.editor.inspection.reference.RefElement;
import consulo.language.editor.inspection.reference.RefEntity;
Expand Down Expand Up @@ -219,7 +221,7 @@ private static boolean isWriteReplaceMethod(@Nonnull PsiMethod method, RefClass
if (parameters.length != 0) {
return false;
}
if (!method.getReturnType().equalsToText(JavaClassNames.JAVA_LANG_OBJECT)) {
if (!method.getReturnType().equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
return false;
}
if (method.hasModifierProperty(PsiModifier.STATIC)) {
Expand All @@ -238,7 +240,7 @@ private static boolean isReadResolveMethod(@Nonnull PsiMethod method, RefClass r
if (parameters.length != 0) {
return false;
}
if (!method.getReturnType().equalsToText(JavaClassNames.JAVA_LANG_OBJECT)) {
if (!method.getReturnType().equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
return false;
}
if (method.hasModifierProperty(PsiModifier.STATIC)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
import com.intellij.java.language.psi.util.InheritanceUtil;
import com.intellij.java.language.psi.util.PsiUtil;
import com.intellij.java.language.psi.util.TypeConversionUtil;
import consulo.java.language.module.util.JavaClassNames;
import consulo.language.psi.PsiElement;
import consulo.language.psi.scope.GlobalSearchScope;
import consulo.project.Project;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -65,11 +64,11 @@ public static PsiClassType getType(@Nonnull PsiClass aClass) {
}

public static PsiClassType getObjectType(@Nonnull PsiElement context) {
return getType(JavaClassNames.JAVA_LANG_OBJECT, context);
return getType(CommonClassNames.JAVA_LANG_OBJECT, context);
}

public static PsiClassType getStringType(@Nonnull PsiElement context) {
return getType(JavaClassNames.JAVA_LANG_STRING, context);
return getType(CommonClassNames.JAVA_LANG_STRING, context);
}

/**
Expand All @@ -83,12 +82,12 @@ public static boolean isNarrowingConversion(@Nullable PsiType sourceType, @Nulla

@Contract("null -> false")
public static boolean isJavaLangObject(@Nullable PsiType targetType) {
return typeEquals(JavaClassNames.JAVA_LANG_OBJECT, targetType);
return typeEquals(CommonClassNames.JAVA_LANG_OBJECT, targetType);
}

@Contract("null -> false")
public static boolean isJavaLangString(@Nullable PsiType targetType) {
return typeEquals(JavaClassNames.JAVA_LANG_STRING, targetType);
return typeEquals(CommonClassNames.JAVA_LANG_STRING, targetType);
}

public static boolean isOptional(@Nullable PsiType type) {
Expand All @@ -101,7 +100,7 @@ public static boolean isOptional(PsiClass aClass) {
return false;
}
final String qualifiedName = aClass.getQualifiedName();
return JavaClassNames.JAVA_UTIL_OPTIONAL.equals(qualifiedName) || "java.util.OptionalDouble".equals(qualifiedName) || "java.util.OptionalInt".equals(qualifiedName) || ("java.util" +
return CommonClassNames.JAVA_UTIL_OPTIONAL.equals(qualifiedName) || "java.util.OptionalDouble".equals(qualifiedName) || "java.util.OptionalInt".equals(qualifiedName) || ("java.util" +
".OptionalLong").equals(qualifiedName) || "com.google.common.base.Optional".equals(qualifiedName);
}

Expand Down Expand Up @@ -245,19 +244,19 @@ public static PsiType unaryNumericPromotion(PsiType type) {
if (type == null) {
return null;
}
if (type.equalsToText(JavaClassNames.JAVA_LANG_BYTE)
|| type.equalsToText(JavaClassNames.JAVA_LANG_SHORT)
|| type.equalsToText(JavaClassNames.JAVA_LANG_CHARACTER)
|| type.equalsToText(JavaClassNames.JAVA_LANG_INTEGER)
if (type.equalsToText(CommonClassNames.JAVA_LANG_BYTE)
|| type.equalsToText(CommonClassNames.JAVA_LANG_SHORT)
|| type.equalsToText(CommonClassNames.JAVA_LANG_CHARACTER)
|| type.equalsToText(CommonClassNames.JAVA_LANG_INTEGER)
|| type.equals(PsiType.BYTE)
|| type.equals(PsiType.SHORT)
|| type.equals(PsiType.CHAR)) {
return PsiType.INT;
} else if (type.equalsToText(JavaClassNames.JAVA_LANG_LONG)) {
} else if (type.equalsToText(CommonClassNames.JAVA_LANG_LONG)) {
return PsiType.LONG;
} else if (type.equalsToText(JavaClassNames.JAVA_LANG_FLOAT)) {
} else if (type.equalsToText(CommonClassNames.JAVA_LANG_FLOAT)) {
return PsiType.FLOAT;
} else if (type.equalsToText(JavaClassNames.JAVA_LANG_DOUBLE)) {
} else if (type.equalsToText(CommonClassNames.JAVA_LANG_DOUBLE)) {
return PsiType.DOUBLE;
}
return type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,20 @@
*/
package com.intellij.java.debugger.impl.engine.evaluation.expression;

import java.util.Collections;
import java.util.Map;

import com.intellij.java.debugger.engine.evaluation.EvaluateException;
import com.intellij.java.debugger.impl.engine.evaluation.EvaluationContextImpl;
import com.intellij.java.language.impl.psi.impl.PsiJavaParserFacadeImpl;
import com.intellij.java.language.psi.CommonClassNames;
import consulo.internal.com.sun.jdi.*;
import consulo.logging.Logger;
import consulo.util.lang.Couple;
import consulo.java.language.module.util.JavaClassNames;
import com.intellij.java.language.impl.psi.impl.PsiJavaParserFacadeImpl;
import java.util.HashMap;
import consulo.internal.com.sun.jdi.ClassType;
import consulo.internal.com.sun.jdi.Field;
import consulo.internal.com.sun.jdi.Method;
import consulo.internal.com.sun.jdi.ObjectReference;
import consulo.internal.com.sun.jdi.PrimitiveValue;
import consulo.internal.com.sun.jdi.ReferenceType;
import consulo.internal.com.sun.jdi.Value;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* @author Eugene Zhuravlev
* Date: Feb 8, 2010
Expand All @@ -48,14 +42,14 @@ public class UnBoxingEvaluator implements Evaluator

static
{
TYPES_TO_CONVERSION_METHOD_MAP.put(JavaClassNames.JAVA_LANG_BOOLEAN, Couple.of("booleanValue", "()Z"));
TYPES_TO_CONVERSION_METHOD_MAP.put(JavaClassNames.JAVA_LANG_BYTE, Couple.of("byteValue", "()B"));
TYPES_TO_CONVERSION_METHOD_MAP.put(JavaClassNames.JAVA_LANG_CHARACTER, Couple.of("charValue", "()C"));
TYPES_TO_CONVERSION_METHOD_MAP.put(JavaClassNames.JAVA_LANG_SHORT, Couple.of("shortValue", "()S"));
TYPES_TO_CONVERSION_METHOD_MAP.put(JavaClassNames.JAVA_LANG_INTEGER, Couple.of("intValue", "()I"));
TYPES_TO_CONVERSION_METHOD_MAP.put(JavaClassNames.JAVA_LANG_LONG, Couple.of("longValue", "()J"));
TYPES_TO_CONVERSION_METHOD_MAP.put(JavaClassNames.JAVA_LANG_FLOAT, Couple.of("floatValue", "()F"));
TYPES_TO_CONVERSION_METHOD_MAP.put(JavaClassNames.JAVA_LANG_DOUBLE, Couple.of("doubleValue", "()D"));
TYPES_TO_CONVERSION_METHOD_MAP.put(CommonClassNames.JAVA_LANG_BOOLEAN, Couple.of("booleanValue", "()Z"));
TYPES_TO_CONVERSION_METHOD_MAP.put(CommonClassNames.JAVA_LANG_BYTE, Couple.of("byteValue", "()B"));
TYPES_TO_CONVERSION_METHOD_MAP.put(CommonClassNames.JAVA_LANG_CHARACTER, Couple.of("charValue", "()C"));
TYPES_TO_CONVERSION_METHOD_MAP.put(CommonClassNames.JAVA_LANG_SHORT, Couple.of("shortValue", "()S"));
TYPES_TO_CONVERSION_METHOD_MAP.put(CommonClassNames.JAVA_LANG_INTEGER, Couple.of("intValue", "()I"));
TYPES_TO_CONVERSION_METHOD_MAP.put(CommonClassNames.JAVA_LANG_LONG, Couple.of("longValue", "()J"));
TYPES_TO_CONVERSION_METHOD_MAP.put(CommonClassNames.JAVA_LANG_FLOAT, Couple.of("floatValue", "()F"));
TYPES_TO_CONVERSION_METHOD_MAP.put(CommonClassNames.JAVA_LANG_DOUBLE, Couple.of("doubleValue", "()D"));
}

public static boolean isTypeUnboxable(String typeName)
Expand Down
Loading
Loading