Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into develar/is
Browse files Browse the repository at this point in the history
# Conflicts:
#	platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
  • Loading branch information
develar committed Jul 20, 2016
2 parents 4ab9c06 + 83e579c commit 7958abe
Show file tree
Hide file tree
Showing 172 changed files with 3,193 additions and 2,700 deletions.
49 changes: 24 additions & 25 deletions bin/scripts/win/idea.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,33 @@ SET IDE_HOME=%IDE_BIN_DIR%\..
:: Try (in order): @@product_uc@@_JDK, @@vm_options@@.jdk, ..\jre, JDK_HOME, JAVA_HOME.
:: ---------------------------------------------------------------------
SET JDK=
IF EXIST "%@@product_uc@@_JDK%" (
SET JDK=%@@product_uc@@_JDK%
)
IF "%JDK%" == "" (
SET BITS=64
SET USER_JDK64_FILE=%USERPROFILE%\.@@system_selector@@\config\@@vm_options@@.jdk
SET BITS=
SET USER_JDK_FILE=%USERPROFILE%\.@@system_selector@@\config\@@vm_options@@.jdk
IF EXIST "%USER_JDK64_FILE%" (
SET /P JDK=<%USER_JDK64_FILE%
IF NOT EXIST "%JDK%" SET JDK=%IDE_HOME%\%JDK%
) ELSE (
IF EXIST "%USER_JDK_FILE%" (
SET /P JDK=<%USER_JDK_FILE%
IF NOT EXIST "%JDK%" SET JDK=%IDE_HOME%\%JDK%
)
)
)
IF "%JDK%" == "" (
IF EXIST "%IDE_HOME%\jre" SET JDK=%IDE_HOME%\jre
)
IF "%JDK%" == "" (
IF EXIST "%JDK_HOME%" SET JDK=%JDK_HOME%

IF EXIST "%@@product_uc@@_JDK%" SET JDK=%@@product_uc@@_JDK%
IF NOT "%JDK%" == "" GOTO check

SET BITS=64
SET USER_JDK64_FILE=%USERPROFILE%\.@@system_selector@@\config\@@vm_options@@.jdk
SET BITS=
SET USER_JDK_FILE=%USERPROFILE%\.@@system_selector@@\config\@@vm_options@@.jdk
IF EXIST "%USER_JDK64_FILE%" (
SET /P JDK=<%USER_JDK64_FILE%
) ELSE (
IF EXIST "%USER_JDK_FILE%" SET /P JDK=<%USER_JDK_FILE%
)
IF "%JDK%" == "" (
IF EXIST "%JAVA_HOME%" SET JDK=%JAVA_HOME%
IF NOT "%JDK%" == "" (
IF NOT EXIST "%JDK%" SET JDK=%IDE_HOME%\%JDK%
GOTO check
)

IF EXIST "%IDE_HOME%\jre" SET JDK=%IDE_HOME%\jre
IF NOT "%JDK%" == "" GOTO check

IF EXIST "%JDK_HOME%" SET JDK=%JDK_HOME%
IF NOT "%JDK%" == "" GOTO check

IF EXIST "%JAVA_HOME%" SET JDK=%JAVA_HOME%

:check
SET JAVA_EXE=%JDK%\bin\java.exe
IF NOT EXIST "%JAVA_EXE%" SET JAVA_EXE=%JDK%\jre\bin\java.exe
IF NOT EXIST "%JAVA_EXE%" (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import com.intellij.debugger.engine.JVMNameUtil;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.psi.CommonClassNames;
import com.intellij.psi.PsiPrimitiveType;
import com.intellij.psi.impl.PsiJavaParserFacadeImpl;
import com.sun.jdi.*;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.List;
Expand All @@ -43,29 +43,12 @@ public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
return result;
}

if (result instanceof BooleanValue) {
return convertToWrapper(context, (BooleanValue)result, CommonClassNames.JAVA_LANG_BOOLEAN);
}
if (result instanceof ByteValue) {
return convertToWrapper(context, (ByteValue)result, CommonClassNames.JAVA_LANG_BYTE);
}
if (result instanceof CharValue) {
return convertToWrapper(context, (CharValue)result, CommonClassNames.JAVA_LANG_CHARACTER);
}
if (result instanceof ShortValue) {
return convertToWrapper(context, (ShortValue)result, CommonClassNames.JAVA_LANG_SHORT);
}
if (result instanceof IntegerValue) {
return convertToWrapper(context, (IntegerValue)result, CommonClassNames.JAVA_LANG_INTEGER);
}
if (result instanceof LongValue) {
return convertToWrapper(context, (LongValue)result, CommonClassNames.JAVA_LANG_LONG);
}
if (result instanceof FloatValue) {
return convertToWrapper(context, (FloatValue)result, CommonClassNames.JAVA_LANG_FLOAT);
}
if (result instanceof DoubleValue) {
return convertToWrapper(context, (DoubleValue)result, CommonClassNames.JAVA_LANG_DOUBLE);
if (result instanceof PrimitiveValue) {
PrimitiveValue primitiveValue = (PrimitiveValue)result;
PsiPrimitiveType primitiveType = PsiJavaParserFacadeImpl.getPrimitiveType(primitiveValue.type().name());
if (primitiveType != null) {
return convertToWrapper(context, primitiveValue, primitiveType.getBoxedTypeName());
}
}
throw new EvaluateException("Cannot perform boxing conversion for a value of type " + ((Value)result).type().name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.intellij.debugger.jdi;

import com.intellij.util.ReflectionUtil;
import com.intellij.util.ThrowableConsumer;
import com.sun.jdi.*;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -52,13 +53,23 @@ public static void visit(ReferenceType classType, Method method, long maxOffset,
visit(classType, method, bytecodes, methodVisitor);
}

public static byte[] getConstantPool(ReferenceType type) {
try {
return type.constantPool();
}
catch (NullPointerException e) { // workaround for JDK bug 6822627
ReflectionUtil.resetField(type, "constantPoolInfoGotten");
return type.constantPool();
}
}

private static void visit(ReferenceType type, Method method, byte[] bytecodes, MethodVisitor methodVisitor) {
try {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos)) {
dos.writeInt(0xCAFEBABE); // magic
dos.writeInt(Opcodes.V1_8); // version
dos.writeShort(type.constantPoolCount()); // constant_pool_count
dos.write(type.constantPool()); // constant_pool
dos.write(getConstantPool(type)); // constant_pool
dos.writeShort(0); // access_flags;
dos.writeShort(0); // this_class;
dos.writeShort(0); // super_class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiJavaParserFacadeImpl;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.reference.SoftReference;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -65,14 +66,24 @@ public void clear() {
protected Cache initEvaluatorAndChildrenExpression(final Project project) {
final Cache cache = new Cache();
try {
PsiClass contextClass = DebuggerUtils.findClass(getClassName(), project, GlobalSearchScope.allScope(project));
if (contextClass instanceof PsiCompiledElement) {
contextClass = (PsiClass)((PsiCompiledElement)contextClass).getMirror();
String className = getClassName();
PsiClass contextClass;
PsiType contextType;
PsiPrimitiveType primitiveType = PsiJavaParserFacadeImpl.getPrimitiveType(className);
if (primitiveType != null) {
contextClass = JavaPsiFacade.getInstance(project).findClass(primitiveType.getBoxedTypeName(), GlobalSearchScope.allScope(project));
contextType = primitiveType;
}
if(contextClass == null) {
throw EvaluateExceptionUtil.CANNOT_FIND_SOURCE_CLASS;
else {
contextClass = DebuggerUtils.findClass(className, project, GlobalSearchScope.allScope(project));
if (contextClass instanceof PsiCompiledElement) {
contextClass = (PsiClass)((PsiCompiledElement)contextClass).getMirror();
}
if (contextClass == null) {
throw EvaluateExceptionUtil.CANNOT_FIND_SOURCE_CLASS;
}
contextType = DebuggerUtils.getType(className, project);
}
final PsiType contextType = DebuggerUtils.getType(getClassName(), project);
cache.myPsiChildrenExpression = null;
JavaCodeFragment codeFragment = myDefaultFragmentFactory.createCodeFragment(myReferenceExpression, contextClass, project);
codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.intellij.psi.util.ClassUtil;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiTypesUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.ContainerUtil;
Expand Down Expand Up @@ -266,10 +267,14 @@ else if (nodeClass.dims > rendererClass.dims) {
}

public static boolean instanceOf(@Nullable Type subType, @NotNull String superType) {
if (subType == null || subType instanceof PrimitiveType || subType instanceof VoidType) {
if (subType == null || subType instanceof VoidType) {
return false;
}

if (subType instanceof PrimitiveType) {
return superType.equals(subType.name());
}

if (CommonClassNames.JAVA_LANG_OBJECT.equals(superType)) {
return true;
}
Expand Down Expand Up @@ -389,18 +394,16 @@ public static PsiClass findClass(@NotNull final String className, @NotNull Proje
public static PsiType getType(@NotNull String className, @NotNull Project project) {
ApplicationManager.getApplication().assertReadAccessAllowed();

final PsiManager psiManager = PsiManager.getInstance(project);
try {
if (getArrayClass(className) != null) {
return JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createTypeFromText(className, null);
return JavaPsiFacade.getInstance(project).getElementFactory().createTypeFromText(className, null);
}
if(project.isDefault()) {
if (project.isDefault()) {
return null;
}
final PsiClass aClass =
JavaPsiFacade.getInstance(psiManager.getProject()).findClass(className.replace('$', '.'), GlobalSearchScope.allScope(project));
PsiClass aClass = findClass(className, project, GlobalSearchScope.allScope(project));
if (aClass != null) {
return JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createType(aClass);
return PsiTypesUtil.getClassType(aClass);
}
}
catch (IncorrectOperationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction;
import com.intellij.codeInsight.intention.QuickFixFactory;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.module.impl.scopes.ModulesScope;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
Expand Down Expand Up @@ -75,21 +76,18 @@ static HighlightInfo checkModuleDuplicates(@NotNull PsiJavaModule element, @NotN

@Nullable
static HighlightInfo checkFileDuplicates(@NotNull PsiJavaModule element, @NotNull PsiFile file) {
VirtualFile vFile = file.getVirtualFile();
if (vFile != null) {
Module module = ModuleUtilCore.findModuleForPsiElement(element);
if (module != null) {
Project project = file.getProject();
Module module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(vFile);
if (module != null) {
Collection<VirtualFile> others =
FilenameIndex.getVirtualFilesByName(project, MODULE_INFO_FILE, new ModulesScope(Collections.singleton(module), project));
if (others.size() > 1) {
String message = JavaErrorMessages.message("module.file.duplicate");
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(element)).description(message).create();
others.stream().map(f -> PsiManager.getInstance(project).findFile(f)).filter(f -> f != file).findFirst().ifPresent(
duplicate -> QuickFixAction.registerQuickFixAction(info, new GoToSymbolFix(duplicate, JavaErrorMessages.message("module.open.duplicate.text")))
);
return info;
}
Collection<VirtualFile> others =
FilenameIndex.getVirtualFilesByName(project, MODULE_INFO_FILE, new ModulesScope(Collections.singleton(module), project));
if (others.size() > 1) {
String message = JavaErrorMessages.message("module.file.duplicate");
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(element)).description(message).create();
others.stream().map(f -> PsiManager.getInstance(project).findFile(f)).filter(f -> f != file).findFirst().ifPresent(
duplicate -> QuickFixAction.registerQuickFixAction(info, new GoToSymbolFix(duplicate, JavaErrorMessages.message("module.open.duplicate.text")))
);
return info;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class UnusedSymbolLocalInspectionBase extends BaseJavaLocalInspectionTool
@NonNls public static final String SHORT_NAME = HighlightInfoType.UNUSED_SYMBOL_SHORT_NAME;
@NonNls public static final String DISPLAY_NAME = HighlightInfoType.UNUSED_SYMBOL_DISPLAY_NAME;
@NonNls public static final String UNUSED_PARAMETERS_SHORT_NAME = "UnusedParameters";
@NonNls public static final String UNUSED_ID = "unused";

public boolean LOCAL_VARIABLE = true;
public boolean FIELD = true;
Expand Down Expand Up @@ -126,7 +127,7 @@ public String getShortName() {
@NotNull
@NonNls
public String getID() {
return "unused";
return UNUSED_ID;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/
package com.intellij.codeInspection.deadCode;

import com.intellij.codeInspection.ex.InspectionElementsMerger;
import com.intellij.codeInspection.ex.InspectionElementsMergerBase;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.util.WriteExternalException;
import org.jdom.Element;

public class UnusedDeclarationInspectionMerger extends InspectionElementsMerger {
public class UnusedDeclarationInspectionMerger extends InspectionElementsMergerBase {
private static final String UNUSED_SYMBOL = "UNUSED_SYMBOL";
private static final String UNUSED_DECLARATION = "UnusedDeclaration";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static ArrayList<RefParameter> getUnusedParameters(RefMethod refMethod) {
clearUsedParameters(refMethod, result, checkDeep);

for (RefParameter parameter : result) {
if (parameter != null && !((RefElementImpl)parameter).isSuppressed(UnusedSymbolLocalInspectionBase.UNUSED_PARAMETERS_SHORT_NAME)) {
if (parameter != null && !((RefElementImpl)parameter).isSuppressed(UnusedSymbolLocalInspectionBase.UNUSED_PARAMETERS_SHORT_NAME, UnusedSymbolLocalInspectionBase.UNUSED_ID)) {
res.add(parameter);
}
}
Expand Down Expand Up @@ -315,6 +315,6 @@ private static void removeUnusedParameterViaChangeSignature(final PsiMethod psiM
@Nullable
@Override
public String getAlternativeID() {
return "unused";
return UnusedSymbolLocalInspectionBase.UNUSED_ID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ private static Indent getDefaultSubtreeIndent(@NotNull ASTNode child, @NotNull C
if (parent != null) {
final Indent defaultChildIndent = getChildIndent(parent, indentOptions);
if (defaultChildIndent != null) return defaultChildIndent;
}
if (child.getTreeParent() instanceof PsiLambdaExpression && child instanceof PsiCodeBlock) {
return Indent.getNoneIndent();
if (parent.getPsi() instanceof PsiLambdaExpression && child instanceof PsiCodeBlock) {
return Indent.getNoneIndent();
}
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,28 @@ Import[] readImports(UnitInputStream in) throws IOException {
}

private static void writeImport(@NotNull DataOutput out, IndexTree.Import anImport) throws IOException {
SerializedUnit.writeQualifiedName(out, anImport.myFullname);
boolean hasAlias = anImport.myAlias != 0;
out.writeInt(NameEnvironment.fromString(anImport.myQualifier));
boolean hasAlias = anImport.myAlias != null;
int flags = 0;
flags = BitUtil.set(flags, IS_STATIC, anImport.myStaticImport);
flags = BitUtil.set(flags, IS_ON_DEMAND, anImport.myOnDemand);
flags = BitUtil.set(flags, HAS_ALIAS, hasAlias);
out.writeByte(flags);
if (anImport.myImportedName != null) {
out.writeInt(NameEnvironment.hashIdentifier(anImport.myImportedName));
}
if (hasAlias) {
out.writeInt(anImport.myAlias);
out.writeInt(NameEnvironment.hashIdentifier(anImport.myAlias));
}
}

private Import readImport(UnitInputStream in) throws IOException {
int qualifier = 0;
int len = DataInputOutputUtil.readINT(in);
for (int i = 0; i < len - 1; i++) {
qualifier = in.names.qualifiedName(qualifier, in.readInt());
}
int lastId = in.readInt();
int qualifier = in.readInt();
int flags = in.readByte();
int shortName = BitUtil.isSet(flags, IS_ON_DEMAND) ? 0 : in.readInt();
int alias = BitUtil.isSet(flags, HAS_ALIAS) ? in.readInt() : 0;

boolean onDemand = BitUtil.isSet(flags, IS_ON_DEMAND);
boolean isStatic = BitUtil.isSet(flags, IS_STATIC);

int shortName;
if (onDemand) {
shortName = 0;
qualifier = in.names.qualifiedName(qualifier, lastId);
} else {
shortName = lastId;
}

return obtainImport(qualifier, shortName, alias, isStatic);
return obtainImport(qualifier, shortName, alias, BitUtil.isSet(flags, IS_STATIC));
}

private Import obtainImport(int qualifier, int shortName, int alias, boolean isStatic) {
Expand Down
Loading

0 comments on commit 7958abe

Please sign in to comment.