diff --git a/.idea/libraries/asm5.xml b/.idea/libraries/asm5.xml new file mode 100644 index 000000000000..e4873676bb75 --- /dev/null +++ b/.idea/libraries/asm5.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java index f02820fa0f93..15c19335af85 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,17 +16,16 @@ package com.intellij.openapi.compiler; import com.intellij.compiler.CompilerConfiguration; -import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectUtilCore; import com.intellij.openapi.roots.CompilerModuleExtension; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; @@ -38,7 +37,6 @@ import org.jetbrains.jps.model.java.compiler.AnnotationProcessingConfiguration; import java.io.File; import java.util.Arrays; import java.util.Comparator; -import java.util.Locale; /** * A set of utility methods for working with paths @@ -47,16 +45,13 @@ public class CompilerPaths { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.compiler.CompilerPaths"); private static volatile String ourSystemPath; private static final Comparator URLS_COMPARATOR = new Comparator() { + @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } }; - private static final String DEFAULT_GENERATED_DIR_NAME = "generated"; - /** * Returns a directory - * @param project - * @param compiler * @return a directory where compiler may generate files. All generated files are not deleted when the application exits */ public static File getGeneratedDataDirectory(Project project, Compiler compiler) { @@ -65,7 +60,6 @@ public class CompilerPaths { } /** - * @param project * @return a root directory where generated files for various compilers are stored */ public static File getGeneratedDataDirectory(Project project) { @@ -74,7 +68,6 @@ public class CompilerPaths { } /** - * @param project * @return a root directory where compiler caches for the given project are stored */ public static File getCacheStoreDirectory(final Project project) { @@ -92,7 +85,6 @@ public class CompilerPaths { } /** - * @param project * @return a directory under IDEA "system" directory where all files related to compiler subsystem are stored (such as compiler caches or generated files) */ public static File getCompilerSystemDirectory(Project project) { @@ -104,36 +96,7 @@ public class CompilerPaths { } public static String getCompilerSystemDirectoryName(Project project) { - return getPresentableName(project) + "." + project.getLocationHash(); - } - - @Nullable - private static String getPresentableName(final Project project) { - if (project.isDefault()) { - return project.getName(); - } - - String location = project.getPresentableUrl(); - if (location == null) { - return null; - } - - String projectName = FileUtil.toSystemIndependentName(location); - if (projectName.endsWith("/")) { - projectName = projectName.substring(0, projectName.length() - 1); - } - - final int lastSlash = projectName.lastIndexOf('/'); - if (lastSlash >= 0 && lastSlash + 1 < projectName.length()) { - projectName = projectName.substring(lastSlash + 1); - } - - if (StringUtil.endsWithIgnoreCase(projectName, ProjectFileType.DOT_DEFAULT_EXTENSION)) { - projectName = projectName.substring(0, projectName.length() - ProjectFileType.DOT_DEFAULT_EXTENSION.length()); - } - - projectName = projectName.toLowerCase(Locale.US).replace(':', '_'); // replace ':' from windows drive names - return projectName; + return ProjectUtilCore.getPresentableName(project) + "." + project.getLocationHash(); } public static File getCompilerSystemDirectory() { @@ -143,7 +106,6 @@ public class CompilerPaths { } /** - * @param module * @param forTestClasses true if directory for test sources, false - for sources. * @return a directory to which the sources (or test sources depending on the second partameter) should be compiled. * Null is returned if output directory is not specified or is not valid @@ -190,6 +152,7 @@ public class CompilerPaths { } else { outPathUrl = application.runReadAction(new Computable() { + @Override public String compute() { final String url = extension.getCompilerOutputUrlForTests(); return url != null ? url : extension.getCompilerOutputUrl(); @@ -203,6 +166,7 @@ public class CompilerPaths { } else { outPathUrl = application.runReadAction(new Computable() { + @Override public String compute() { return extension.getCompilerOutputUrl(); } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointClassGroup.java b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointClassGroup.java index ca978304202e..477e2d3cfca1 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointClassGroup.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointClassGroup.java @@ -17,6 +17,7 @@ package com.intellij.debugger.ui; import com.intellij.debugger.DebuggerBundle; import com.intellij.util.PlatformIcons; +import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,6 +26,13 @@ import javax.swing.*; public class XBreakpointClassGroup extends XBreakpointGroup { private static final String DEFAULT_PACKAGE_NAME = DebuggerBundle.message("default.package.name"); + public static final XBreakpointClassGroup UNKNOWN = new XBreakpointClassGroup("", "") { + @NotNull + @Override + public String getName() { + return XDebuggerBundle.message("xbreakpoint.group.unknown"); + } + }; private String myPackageName; private String myClassName; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByClassRule.java b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByClassRule.java index fc3a179da2e8..50c70fba17a1 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByClassRule.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByClassRule.java @@ -42,17 +42,18 @@ class XBreakpointGroupingByClassRule extends XBreakpointGroupingRule groups) { if (b instanceof XBreakpoint) { Breakpoint javaBreakpoint = BreakpointManager.findBreakpoint((XBreakpoint)b); if (javaBreakpoint == null) { - return null; + return XBreakpointClassGroup.UNKNOWN; } String className = javaBreakpoint.getShortClassName(); String packageName = javaBreakpoint.getPackageName(); if (className == null) { - return null; + return XBreakpointClassGroup.UNKNOWN; } for (XBreakpointClassGroup group : groups) { if (group.getClassName().equals(className) && group.getPackageName().equals(packageName)) { @@ -61,7 +62,7 @@ class XBreakpointGroupingByClassRule extends XBreakpointGroupingRule extends XBreakpointGroupingRule return XBreakpointsGroupingPriorities.BY_PACKAGE; } + @NotNull @Override public XBreakpointPackageGroup getGroup(@NotNull B breakpoint, @NotNull Collection groups) { String packageName = null; @@ -49,7 +50,7 @@ public class XBreakpointGroupingByPackageRule extends XBreakpointGroupingRule } } if (packageName == null) { - return null; + return XBreakpointPackageGroup.UNKNOWN; } for (XBreakpointPackageGroup group : groups) { if (StringUtil.equals(group.getPackageName(), packageName)) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointPackageGroup.java b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointPackageGroup.java index 0d193a20255b..470d56bfe506 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointPackageGroup.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointPackageGroup.java @@ -18,17 +18,30 @@ package com.intellij.debugger.ui; import com.intellij.debugger.DebuggerBundle; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.PlatformIcons; +import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; public class XBreakpointPackageGroup extends XBreakpointGroup { private static final String DEFAULT_PACKAGE_NAME = DebuggerBundle.message("default.package.name"); + public static final XBreakpointPackageGroup UNKNOWN = new XBreakpointPackageGroup() { + @NotNull + @Override + public String getName() { + return XDebuggerBundle.message("xbreakpoint.group.unknown"); + } + }; private String myPackageName; - public XBreakpointPackageGroup(String packageName) { + private XBreakpointPackageGroup() { + myPackageName = null; + } + + public XBreakpointPackageGroup(@NotNull String packageName) { myPackageName = packageName; } @@ -44,7 +57,7 @@ public class XBreakpointPackageGroup extends XBreakpointGroup { return StringUtil.isEmpty(packageName) ? DEFAULT_PACKAGE_NAME : packageName; } - @NotNull + @Nullable public String getPackageName() { return myPackageName; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/NegationBroadScopeFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/NegationBroadScopeFix.java index b628b9fc5afb..8581de630fb6 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/NegationBroadScopeFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/NegationBroadScopeFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,23 +40,24 @@ public class NegationBroadScopeFix implements IntentionAction { @Override @NotNull public String getText() { - String text = myPrefixExpression.getOperand().getText(); - text += " "; + PsiExpression operand = myPrefixExpression.getOperand(); + String text = operand == null ? "" : operand.getText() + " "; PsiElement parent = myPrefixExpression.getParent(); - String operation = parent instanceof PsiInstanceOfExpression - ? PsiKeyword.INSTANCEOF - : ((PsiBinaryExpression)parent).getOperationSign().getText(); - text += operation + " "; String rop; if (parent instanceof PsiInstanceOfExpression) { + text += PsiKeyword.INSTANCEOF + " "; final PsiTypeElement type = ((PsiInstanceOfExpression)parent).getCheckType(); rop = type == null ? "" : type.getText(); } - else { + else if (parent instanceof PsiBinaryExpression) { + text += ((PsiBinaryExpression)parent).getOperationSign().getText() + " "; final PsiExpression rOperand = ((PsiBinaryExpression)parent).getROperand(); rop = rOperand == null ? "" : rOperand.getText(); } + else { + rop = ""; + } text += rop; return QuickFixBundle.message("negation.broader.scope.text", text); @@ -70,7 +71,7 @@ public class NegationBroadScopeFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - if (!myPrefixExpression.isValid()) return false; + if (!myPrefixExpression.isValid() || myPrefixExpression.getOperand() == null) return false; PsiElement parent = myPrefixExpression.getParent(); if (parent instanceof PsiInstanceOfExpression && ((PsiInstanceOfExpression)parent).getOperand() == myPrefixExpression) { @@ -83,7 +84,7 @@ public class NegationBroadScopeFix implements IntentionAction { @Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { - if (!FileModificationService.getInstance().preparePsiElementForWrite(myPrefixExpression)) return; + if (!isAvailable(project, editor, file) || !FileModificationService.getInstance().preparePsiElementForWrite(myPrefixExpression)) return; PsiExpression operand = myPrefixExpression.getOperand(); PsiElement unnegated = myPrefixExpression.replace(operand); PsiElement parent = unnegated.getParent(); diff --git a/java/java-psi-impl/java-psi-impl.iml b/java/java-psi-impl/java-psi-impl.iml index 89e9dba328f0..70b825d962d4 100644 --- a/java/java-psi-impl/java-psi-impl.iml +++ b/java/java-psi-impl/java-psi-impl.iml @@ -10,7 +10,7 @@ - + diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java index f2a4b48fd780..4f91aea55686 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java @@ -40,7 +40,7 @@ import static com.intellij.psi.compiled.ClassFileDecompilers.Full; public class ClassFileStubBuilder implements BinaryFileStubBuilder { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClassFileStubBuilder"); - public static final int STUB_VERSION = 9; + public static final int STUB_VERSION = 10; @Override public boolean acceptsFile(@NotNull VirtualFile file) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java index ec5fd7c21433..4d3cdbfc3bcc 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java @@ -63,7 +63,7 @@ import com.intellij.util.cls.ClsFormatException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.asm4.ClassReader; +import org.jetbrains.org.objectweb.asm.ClassReader; import java.io.IOException; import java.util.Collections; @@ -537,7 +537,8 @@ public class ClsFileImpl extends ClsRepositoryPsiElement try { PsiJavaFileStubImpl stub = new PsiJavaFileStubImpl("do.not.know.yet", true); - StubBuildingVisitor visitor = new StubBuildingVisitor(file, STRATEGY, stub, 0, file.getNameWithoutExtension()); + String className = file.getNameWithoutExtension(); + StubBuildingVisitor visitor = new StubBuildingVisitor(file, STRATEGY, stub, 0, className); try { new ClassReader(bytes).accept(visitor, ClassReader.SKIP_FRAMES); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/InnerClassSourceStrategy.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/InnerClassSourceStrategy.java index 936269905957..8ebb87d2276d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/InnerClassSourceStrategy.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/InnerClassSourceStrategy.java @@ -20,7 +20,7 @@ package com.intellij.psi.impl.compiled; import org.jetbrains.annotations.Nullable; -import org.jetbrains.asm4.ClassReader; +import org.jetbrains.org.objectweb.asm.ClassReader; public interface InnerClassSourceStrategy { @Nullable diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java index 37a1eb60ca3d..fdc14c8fc637 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java @@ -31,7 +31,7 @@ import com.intellij.util.io.StringRef; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.asm4.*; +import org.jetbrains.org.objectweb.asm.*; import java.lang.reflect.Array; import java.text.CharacterIterator; @@ -56,6 +56,8 @@ public class StubBuildingVisitor extends ClassVisitor { public static final String FLOAT_NEGATIVE_INF = "-1.0f / 0.0"; public static final String FLOAT_NAN = "0.0f / 0.0"; + public static final int ASM_API = Opcodes.ASM5; + @NonNls private static final String SYNTHETIC_CLASS_INIT_METHOD = ""; @NonNls private static final String SYNTHETIC_INIT_METHOD = ""; @@ -68,7 +70,7 @@ public class StubBuildingVisitor extends ClassVisitor { private PsiModifierListStub myModList; public StubBuildingVisitor(T classSource, InnerClassSourceStrategy innersStrategy, StubElement parent, int access, String shortName) { - super(Opcodes.ASM4); + super(ASM_API); mySource = classSource; myInnersStrategy = innersStrategy; myParent = parent; @@ -543,7 +545,7 @@ public class StubBuildingVisitor extends ClassVisitor { private final String myDesc; public AnnotationTextCollector(@Nullable String desc, AnnotationResultCallback callback) { - super(Opcodes.ASM4); + super(ASM_API); myCallback = callback; myDesc = desc; @@ -615,7 +617,7 @@ public class StubBuildingVisitor extends ClassVisitor { private final PsiModifierListStub myModList; private AnnotationCollectingVisitor(final PsiModifierListStub modList) { - super(Opcodes.ASM4); + super(ASM_API); myModList = modList; } @@ -646,7 +648,7 @@ public class StubBuildingVisitor extends ClassVisitor { final int paramIgnoreCount, final int paramCount, final PsiParameterStubImpl[] paramStubs) { - super(Opcodes.ASM4); + super(ASM_API); myOwner = owner; myModList = modList; myIgnoreCount = ignoreCount; diff --git a/java/java-tests/testData/psi/cls/mirror/Class.txt b/java/java-tests/testData/psi/cls/mirror/Class.txt new file mode 100644 index 000000000000..59d7e4d231fe --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/Class.txt @@ -0,0 +1,385 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package java.lang; + +public final class Class implements java.io.Serializable, java.lang.reflect.GenericDeclaration, java.lang.reflect.Type, java.lang.reflect.AnnotatedElement { + private static final int ANNOTATION = 8192; + private static final int ENUM = 16384; + private static final int SYNTHETIC = 4096; + private transient volatile java.lang.reflect.Constructor cachedConstructor; + private transient volatile java.lang.Class newInstanceCallerCache; + private transient java.lang.String name; + private static java.security.ProtectionDomain allPermDomain; + private static boolean useCaches; + private transient volatile java.lang.ref.SoftReference> reflectionData; + private transient volatile int classRedefinedCount; + private transient volatile sun.reflect.generics.repository.ClassRepository genericInfo; + private static final long serialVersionUID = 3206093459760846163L; + private static final java.io.ObjectStreamField[] serialPersistentFields; + private static sun.reflect.ReflectionFactory reflectionFactory; + private static boolean initted; + private transient volatile T[] enumConstants; + private transient volatile java.util.Map enumConstantDirectory; + private transient volatile java.lang.Class.AnnotationData annotationData; + private transient volatile sun.reflect.annotation.AnnotationType annotationType; + transient java.lang.ClassValue.ClassValueMap classValueMap; + + private static native void registerNatives(); + + private Class() { /* compiled code */ } + + public java.lang.String toString() { /* compiled code */ } + + public java.lang.String toGenericString() { /* compiled code */ } + + @sun.reflect.CallerSensitive + public static java.lang.Class forName(java.lang.String s) throws java.lang.ClassNotFoundException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public static java.lang.Class forName(java.lang.String s, boolean b, java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException { /* compiled code */ } + + private static native java.lang.Class forName0(java.lang.String s, boolean b, java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException; + + @sun.reflect.CallerSensitive + public T newInstance() throws java.lang.InstantiationException, java.lang.IllegalAccessException { /* compiled code */ } + + public native boolean isInstance(java.lang.Object o); + + public native boolean isAssignableFrom(java.lang.Class aClass); + + public native boolean isInterface(); + + public native boolean isArray(); + + public native boolean isPrimitive(); + + public boolean isAnnotation() { /* compiled code */ } + + public boolean isSynthetic() { /* compiled code */ } + + public java.lang.String getName() { /* compiled code */ } + + private native java.lang.String getName0(); + + @sun.reflect.CallerSensitive + public java.lang.ClassLoader getClassLoader() { /* compiled code */ } + + native java.lang.ClassLoader getClassLoader0(); + + public java.lang.reflect.TypeVariable>[] getTypeParameters() { /* compiled code */ } + + public native java.lang.Class getSuperclass(); + + public java.lang.reflect.Type getGenericSuperclass() { /* compiled code */ } + + public java.lang.Package getPackage() { /* compiled code */ } + + public java.lang.Class[] getInterfaces() { /* compiled code */ } + + private native java.lang.Class[] getInterfaces0(); + + public java.lang.reflect.Type[] getGenericInterfaces() { /* compiled code */ } + + public native java.lang.Class getComponentType(); + + public native int getModifiers(); + + public native java.lang.Object[] getSigners(); + + native void setSigners(java.lang.Object[] objects); + + @sun.reflect.CallerSensitive + public java.lang.reflect.Method getEnclosingMethod() throws java.lang.SecurityException { /* compiled code */ } + + private native java.lang.Object[] getEnclosingMethod0(); + + private java.lang.Class.EnclosingMethodInfo getEnclosingMethodInfo() { /* compiled code */ } + + private static java.lang.Class toClass(java.lang.reflect.Type type) { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Constructor getEnclosingConstructor() throws java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.Class getDeclaringClass() throws java.lang.SecurityException { /* compiled code */ } + + private native java.lang.Class getDeclaringClass0(); + + @sun.reflect.CallerSensitive + public java.lang.Class getEnclosingClass() throws java.lang.SecurityException { /* compiled code */ } + + public java.lang.String getSimpleName() { /* compiled code */ } + + public java.lang.String getTypeName() { /* compiled code */ } + + private static boolean isAsciiDigit(char c) { /* compiled code */ } + + public java.lang.String getCanonicalName() { /* compiled code */ } + + public boolean isAnonymousClass() { /* compiled code */ } + + public boolean isLocalClass() { /* compiled code */ } + + public boolean isMemberClass() { /* compiled code */ } + + private java.lang.String getSimpleBinaryName() { /* compiled code */ } + + private boolean isLocalOrAnonymousClass() { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.Class[] getClasses() { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Field[] getFields() throws java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Method[] getMethods() throws java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Constructor[] getConstructors() throws java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Field getField(java.lang.String s) throws java.lang.NoSuchFieldException, java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Method getMethod(java.lang.String s, java.lang.Class... classes) throws java.lang.NoSuchMethodException, java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Constructor getConstructor(java.lang.Class... classes) throws java.lang.NoSuchMethodException, java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.Class[] getDeclaredClasses() throws java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Field[] getDeclaredFields() throws java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Method[] getDeclaredMethods() throws java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Constructor[] getDeclaredConstructors() throws java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Field getDeclaredField(java.lang.String s) throws java.lang.NoSuchFieldException, java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Method getDeclaredMethod(java.lang.String s, java.lang.Class... classes) throws java.lang.NoSuchMethodException, java.lang.SecurityException { /* compiled code */ } + + @sun.reflect.CallerSensitive + public java.lang.reflect.Constructor getDeclaredConstructor(java.lang.Class... classes) throws java.lang.NoSuchMethodException, java.lang.SecurityException { /* compiled code */ } + + public java.io.InputStream getResourceAsStream(java.lang.String s) { /* compiled code */ } + + public java.net.URL getResource(java.lang.String s) { /* compiled code */ } + + public java.security.ProtectionDomain getProtectionDomain() { /* compiled code */ } + + private native java.security.ProtectionDomain getProtectionDomain0(); + + static native java.lang.Class getPrimitiveClass(java.lang.String s); + + private void checkMemberAccess(int i, java.lang.Class aClass, boolean b) { /* compiled code */ } + + private void checkPackageAccess(java.lang.ClassLoader classLoader, boolean b) { /* compiled code */ } + + private java.lang.String resolveName(java.lang.String s) { /* compiled code */ } + + private java.lang.Class.ReflectionData reflectionData() { /* compiled code */ } + + private java.lang.Class.ReflectionData newReflectionData(java.lang.ref.SoftReference> softReference, int i) { /* compiled code */ } + + private native java.lang.String getGenericSignature0(); + + private sun.reflect.generics.factory.GenericsFactory getFactory() { /* compiled code */ } + + private sun.reflect.generics.repository.ClassRepository getGenericInfo() { /* compiled code */ } + + native byte[] getRawAnnotations(); + + native byte[] getRawTypeAnnotations(); + + static byte[] getExecutableTypeAnnotationBytes(java.lang.reflect.Executable executable) { /* compiled code */ } + + native sun.reflect.ConstantPool getConstantPool(); + + private java.lang.reflect.Field[] privateGetDeclaredFields(boolean b) { /* compiled code */ } + + private java.lang.reflect.Field[] privateGetPublicFields(java.util.Set> set) { /* compiled code */ } + + private static void addAll(java.util.Collection collection, java.lang.reflect.Field[] fields) { /* compiled code */ } + + private java.lang.reflect.Constructor[] privateGetDeclaredConstructors(boolean b) { /* compiled code */ } + + private java.lang.reflect.Method[] privateGetDeclaredMethods(boolean b) { /* compiled code */ } + + private java.lang.reflect.Method[] privateGetPublicMethods() { /* compiled code */ } + + private static java.lang.reflect.Field searchFields(java.lang.reflect.Field[] fields, java.lang.String s) { /* compiled code */ } + + private java.lang.reflect.Field getField0(java.lang.String s) throws java.lang.NoSuchFieldException { /* compiled code */ } + + private static java.lang.reflect.Method searchMethods(java.lang.reflect.Method[] methods, java.lang.String s, java.lang.Class[] classes) { /* compiled code */ } + + private java.lang.reflect.Method getMethod0(java.lang.String s, java.lang.Class[] classes, boolean b) { /* compiled code */ } + + private java.lang.reflect.Constructor getConstructor0(java.lang.Class[] classes, int i) throws java.lang.NoSuchMethodException { /* compiled code */ } + + private static boolean arrayContentsEq(java.lang.Object[] objects, java.lang.Object[] objects1) { /* compiled code */ } + + private static java.lang.reflect.Field[] copyFields(java.lang.reflect.Field[] fields) { /* compiled code */ } + + private static java.lang.reflect.Method[] copyMethods(java.lang.reflect.Method[] methods) { /* compiled code */ } + + private static java.lang.reflect.Constructor[] copyConstructors(java.lang.reflect.Constructor[] constructors) { /* compiled code */ } + + private native java.lang.reflect.Field[] getDeclaredFields0(boolean b); + + private native java.lang.reflect.Method[] getDeclaredMethods0(boolean b); + + private native java.lang.reflect.Constructor[] getDeclaredConstructors0(boolean b); + + private native java.lang.Class[] getDeclaredClasses0(); + + private static java.lang.String argumentTypesToString(java.lang.Class[] classes) { /* compiled code */ } + + public boolean desiredAssertionStatus() { /* compiled code */ } + + private static native boolean desiredAssertionStatus0(java.lang.Class aClass); + + public boolean isEnum() { /* compiled code */ } + + private static sun.reflect.ReflectionFactory getReflectionFactory() { /* compiled code */ } + + private static void checkInitted() { /* compiled code */ } + + public T[] getEnumConstants() { /* compiled code */ } + + T[] getEnumConstantsShared() { /* compiled code */ } + + java.util.Map enumConstantDirectory() { /* compiled code */ } + + public T cast(java.lang.Object o) { /* compiled code */ } + + private java.lang.String cannotCastMsg(java.lang.Object o) { /* compiled code */ } + + public java.lang.Class asSubclass(java.lang.Class aClass) { /* compiled code */ } + + public A getAnnotation(java.lang.Class aClass) { /* compiled code */ } + + public boolean isAnnotationPresent(java.lang.Class aClass) { /* compiled code */ } + + public A[] getAnnotationsByType(java.lang.Class aClass) { /* compiled code */ } + + public java.lang.annotation.Annotation[] getAnnotations() { /* compiled code */ } + + public A getDeclaredAnnotation(java.lang.Class aClass) { /* compiled code */ } + + public A[] getDeclaredAnnotationsByType(java.lang.Class aClass) { /* compiled code */ } + + public java.lang.annotation.Annotation[] getDeclaredAnnotations() { /* compiled code */ } + + private java.lang.Class.AnnotationData annotationData() { /* compiled code */ } + + private java.lang.Class.AnnotationData createAnnotationData(int i) { /* compiled code */ } + + boolean casAnnotationType(sun.reflect.annotation.AnnotationType annotationType, sun.reflect.annotation.AnnotationType annotationType1) { /* compiled code */ } + + sun.reflect.annotation.AnnotationType getAnnotationType() { /* compiled code */ } + + java.util.Map,java.lang.annotation.Annotation> getDeclaredAnnotationMap() { /* compiled code */ } + + public java.lang.reflect.AnnotatedType getAnnotatedSuperclass() { /* compiled code */ } + + public java.lang.reflect.AnnotatedType[] getAnnotatedInterfaces() { /* compiled code */ } + + private static class AnnotationData { + final java.util.Map,java.lang.annotation.Annotation> annotations; + final java.util.Map,java.lang.annotation.Annotation> declaredAnnotations; + final int redefinedCount; + + AnnotationData(java.util.Map,java.lang.annotation.Annotation> map, java.util.Map,java.lang.annotation.Annotation> map1, int i) { /* compiled code */ } + } + + private static class Atomic { + private static final sun.misc.Unsafe unsafe; + private static final long reflectionDataOffset; + private static final long annotationTypeOffset; + private static final long annotationDataOffset; + + private Atomic() { /* compiled code */ } + + private static long objectFieldOffset(java.lang.reflect.Field[] fields, java.lang.String s) { /* compiled code */ } + + static boolean casReflectionData(java.lang.Class aClass, java.lang.ref.SoftReference> softReference, java.lang.ref.SoftReference> softReference1) { /* compiled code */ } + + static boolean casAnnotationType(java.lang.Class aClass, sun.reflect.annotation.AnnotationType annotationType, sun.reflect.annotation.AnnotationType annotationType1) { /* compiled code */ } + + static boolean casAnnotationData(java.lang.Class aClass, java.lang.Class.AnnotationData annotationData, java.lang.Class.AnnotationData annotationData1) { /* compiled code */ } + } + + private static final class EnclosingMethodInfo { + private java.lang.Class enclosingClass; + private java.lang.String name; + private java.lang.String descriptor; + + private EnclosingMethodInfo(java.lang.Object[] objects) { /* compiled code */ } + + boolean isPartial() { /* compiled code */ } + + boolean isConstructor() { /* compiled code */ } + + boolean isMethod() { /* compiled code */ } + + java.lang.Class getEnclosingClass() { /* compiled code */ } + + java.lang.String getName() { /* compiled code */ } + + java.lang.String getDescriptor() { /* compiled code */ } + } + + static class MethodArray { + private java.lang.reflect.Method[] methods; + private int length; + + MethodArray() { /* compiled code */ } + + void add(java.lang.reflect.Method method) { /* compiled code */ } + + void addAll(java.lang.reflect.Method[] methods) { /* compiled code */ } + + void addAll(java.lang.Class.MethodArray methodArray) { /* compiled code */ } + + void addIfNotPresent(java.lang.reflect.Method method) { /* compiled code */ } + + void addAllIfNotPresent(java.lang.Class.MethodArray methodArray) { /* compiled code */ } + + void addAllNonStatic(java.lang.reflect.Method[] methods) { /* compiled code */ } + + int length() { /* compiled code */ } + + java.lang.reflect.Method get(int i) { /* compiled code */ } + + void removeByNameAndSignature(java.lang.reflect.Method method) { /* compiled code */ } + + void compactAndTrim() { /* compiled code */ } + + java.lang.reflect.Method[] getArray() { /* compiled code */ } + } + + private static class ReflectionData { + volatile java.lang.reflect.Field[] declaredFields; + volatile java.lang.reflect.Field[] publicFields; + volatile java.lang.reflect.Method[] declaredMethods; + volatile java.lang.reflect.Method[] publicMethods; + volatile java.lang.reflect.Constructor[] declaredConstructors; + volatile java.lang.reflect.Constructor[] publicConstructors; + volatile java.lang.reflect.Field[] declaredPublicFields; + volatile java.lang.reflect.Method[] declaredPublicMethods; + volatile java.lang.Class[] interfaces; + final int redefinedCount; + + ReflectionData(int i) { /* compiled code */ } + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java index 7523e5b2dbe0..4ac4bfb055e1 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java @@ -18,8 +18,10 @@ package com.intellij.psi; import com.intellij.JavaTestUtil; import com.intellij.ide.highlighter.JavaFileType; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.impl.compiled.ClsFileImpl; @@ -52,7 +54,7 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { public void testLocalClass() { doTest(); } public void testBounds() { doTest(); } - public void testTextPsiMismatch() throws Exception { + public void testTextPsiMismatch() { CommonCodeStyleSettings.IndentOptions options = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getIndentOptions(JavaFileType.INSTANCE); int indent = options.INDENT_SIZE; @@ -65,22 +67,31 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { } } + public void testJdk8Class() { + String testDir = JavaTestUtil.getJavaTestDataPath(); + String clsPath = testDir + "/../../mockJDK-1.8/jre/lib/rt.jar!/java/lang/Class.class"; + String txtPath = testDir + "/psi/cls/mirror/" + "Class.txt"; + doTest(clsPath, txtPath); + } + private void doTest() { doTest(getTestName(false)); } private static void doTest(String name) { String testDir = JavaTestUtil.getJavaTestDataPath() + "/psi/cls/mirror/"; + doTest(testDir + "pkg/" + name + ".class", testDir + name + ".txt"); + } - String clsPath = testDir + "pkg/" + name + ".class"; - VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(clsPath); + private static void doTest(String clsPath, String txtPath) { + VirtualFileSystem fs = clsPath.contains("!/") ? JarFileSystem.getInstance() : LocalFileSystem.getInstance(); + VirtualFile vFile = fs.findFileByPath(clsPath); assertNotNull(clsPath, vFile); PsiFile clsFile = getPsiManager().findFile(vFile); assertNotNull(vFile.getPath(), clsFile); String expected; try { - String txtPath = testDir + name + ".txt"; expected = StringUtil.trimTrailing(PlatformTestUtil.loadFileText(txtPath)); } catch (IOException e) { diff --git a/lib/src/asm5-src.zip b/lib/src/asm5-src.zip index dedd2c6d8be2..c76977dbe561 100644 Binary files a/lib/src/asm5-src.zip and b/lib/src/asm5-src.zip differ diff --git a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java new file mode 100644 index 000000000000..663cd6f9e0b3 --- /dev/null +++ b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.application.ex; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.Ref; +import org.jetbrains.annotations.NotNull; + +public class ApplicationUtil { + // throws exception if can't grab read action right now + public static T tryRunReadAction(@NotNull final Computable computable) throws CannotRunReadActionException { + final Ref result = new Ref(); + if (((ApplicationEx)ApplicationManager.getApplication()).tryRunReadAction(new Runnable() { + @Override + public void run() { + result.set(computable.compute()); + } + })) { + return result.get(); + } + throw new CannotRunReadActionException(); + } + + public static class CannotRunReadActionException extends RuntimeException{ + @Override + public Throwable fillInStackTrace() { + return this; + } + } +} diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java index 09fdd72f0e4b..4f752daaec09 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -154,7 +154,7 @@ public class LowLevelSearchUtil { int startOffset = scopeStart; int endOffset = range.getEndOffset(); if (endOffset > buffer.length()) { - throw new AssertionError("Range for element: '"+scope+"' = "+range+" is out of file '" + file + "' range: " + file.getTextLength()); + throw new AssertionError("Range for element: '"+scope+"' = "+range+" is out of file '" + file + "' range: " + file.getTextRange()+"; file contents length: "+buffer.length()+"; file provider: "+file.getViewProvider()); } final char[] bufferArray = CharArrayUtil.fromSequenceWithoutCopying(buffer); diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java index b91ac03f53c1..289b31e95e2b 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java @@ -18,12 +18,8 @@ package com.intellij.psi.impl.search; import com.intellij.concurrency.*; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ReadAction; -import com.intellij.openapi.application.Result; -import com.intellij.openapi.application.ex.ApplicationEx; -import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.application.ex.ApplicationUtil; import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.fileEditor.impl.LoadTextUtil; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressIndicatorProvider; @@ -58,13 +54,13 @@ import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; public class PsiSearchHelperImpl implements PsiSearchHelper { - private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.search.PsiSearchHelperImpl"); private final PsiManagerEx myManager; @Override @@ -314,26 +310,6 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { return totalResult; } - private static class CannotRunReadActionException extends RuntimeException{ - @Override - public Throwable fillInStackTrace() { - return this; - } - } - // throws exception if can't grab read action right now - private static T tryRead(final Computable computable) throws CannotRunReadActionException { - final Ref result = new Ref(); - if (((ApplicationEx)ApplicationManager.getApplication()).tryRunReadAction(new Runnable() { - @Override - public void run() { - result.set(computable.compute()); - } - })) { - return result.get(); - } - throw new CannotRunReadActionException(); - } - /** * @param files to scan for references in this pass. * @param totalSize the number of files to scan in both passes. Can be different from files.size() in case of @@ -361,7 +337,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { TooManyUsagesStatus.getFrom(progress).pauseProcessingIfTooManyUsages(); processVirtualFile(vfile, progress, localProcessor, canceled, counter, totalSize); } - catch (CannotRunReadActionException action) { + catch (ApplicationUtil.CannotRunReadActionException action) { failedFiles.add(vfile); } return !canceled.get(); @@ -397,7 +373,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { @NotNull final AtomicBoolean canceled, @NotNull AtomicInteger counter, int totalSize) { - final PsiFile file = tryRead(new Computable() { + final PsiFile file = ApplicationUtil.tryRunReadAction(new Computable() { @Override public PsiFile compute() { return vfile.isValid() ? myManager.findFile(vfile) : null; @@ -406,9 +382,14 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { if (file != null && !(file instanceof PsiBinaryFile)) { // load contents outside read action if (FileDocumentManager.getInstance().getCachedDocument(vfile) == null) { - LoadTextUtil.loadText(vfile); // cache bytes in vfs + // cache bytes in vfs + try { + vfile.contentsToByteArray(); + } + catch (IOException ignored) { + } } - tryRead(new Computable() { + ApplicationUtil.tryRunReadAction(new Computable() { @Override public Void compute() { if (myManager.getProject().isDisposed()) throw new ProcessCanceledException(); @@ -416,8 +397,8 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { Set processed = new THashSet(psiRoots.size() * 2, (float)0.5); for (final PsiFile psiRoot : psiRoots) { checkCanceled(progress); - assert psiRoot != null : "One of the roots of file " + file + " is null. All roots: " + psiRoots + - "; ViewProvider: " + file.getViewProvider() + "; Virtual file: " + file.getViewProvider().getVirtualFile(); + assert psiRoot != null : "One of the roots of file " + file + " is null. All roots: " + psiRoots + "; ViewProvider: " + + file.getViewProvider() + "; Virtual file: " + file.getViewProvider().getVirtualFile(); if (!processed.add(psiRoot)) continue; if (!psiRoot.isValid()) { continue; @@ -541,14 +522,12 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { progress.setText(PsiBundle.message("psi.search.in.non.java.files.progress")); } - final SearchScope useScope = new ReadAction() { + final SearchScope useScope = originalElement == null ? null : ApplicationManager.getApplication().runReadAction(new Computable() { @Override - protected void run(final Result result) { - if (originalElement != null) { - result.setResult(getUseScope(originalElement)); - } + public SearchScope compute() { + return getUseScope(originalElement); } - }.execute().getResultObject(); + }); final Ref cancelled = new Ref(Boolean.FALSE); for (int i = 0; i < files.length; i++) { @@ -826,7 +805,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { return processPsiFileRootsAsync(files, totalSize, alreadyProcessedFiles, progress, new Processor() { @Override public boolean process(final PsiFile psiRoot) { - return tryRead(new Computable() { + return ApplicationUtil.tryRunReadAction(new Computable() { @Override public Boolean compute() { final VirtualFile vfile = psiRoot.getVirtualFile(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index be946e68c7eb..63ed23dc70be 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -172,8 +172,7 @@ public class Messages { public static boolean canShowMacSheetPanel() { return SystemInfo.isMac && !isApplicationInUnitTestOrHeadless() - && Registry.is("ide.mac.message.dialogs.as.sheets") - && !SystemInfo.isJavaVersionAtLeast("1.8"); + && Registry.is("ide.mac.message.dialogs.as.sheets"); //&& !DialogWrapper.isMultipleModalDialogs(); } diff --git a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java index 3d8c4ff9cd3c..dfbf3ddd486b 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java @@ -19,6 +19,7 @@ import com.intellij.openapi.ui.popup.util.PopupUtil; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.ActiveRunnable; import com.intellij.openapi.util.Expirable; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.registry.Registry; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -39,6 +40,16 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable { private boolean myInvalidatesPendingFurtherRequestors = true; private Expirable myExpirable; + public boolean isForced() { + return myForced; + } + + public void setForced(boolean forced) { + myForced = forced; + } + + private boolean myForced; + protected FocusCommand() { saveAllocation(); } @@ -168,7 +179,10 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable { } } else { - if (!myToFocus.requestFocusInWindow()) { + // This change seems reasonable to me. But as far as some implementations + // can ignore the "forced" parameter we can get bad focus behaviour. + // So let's start from mac. + if (!myToFocus.requestFocusInWindow() && (isForced() && SystemInfo.isMac)) { myToFocus.requestFocus(); } } diff --git a/platform/platform-api/src/com/intellij/ui/mac/MacMessages.java b/platform/platform-api/src/com/intellij/ui/mac/MacMessages.java index d0e55fb9b0ed..2c06767b96d9 100644 --- a/platform/platform-api/src/com/intellij/ui/mac/MacMessages.java +++ b/platform/platform-api/src/com/intellij/ui/mac/MacMessages.java @@ -39,7 +39,7 @@ public abstract class MacMessages { @Nullable DialogWrapper.DoNotAskOption doNotAskOption); public static MacMessages getInstance() { - return Registry.is("ide.mac.message.sheets.java.emulation.dialogs") && SystemInfo.isJavaVersionAtLeast("1.7") + return Registry.is("ide.mac.message.sheets.java.emulation.dialogs") ? ServiceManager.getService(MacMessagesEmulation.class) : ServiceManager.getService(MacMessages.class); } diff --git a/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.form b/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.form deleted file mode 100644 index 9dc1d1074339..000000000000 --- a/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.form +++ /dev/null @@ -1,54 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.java b/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.java index a7810c10b435..a9ab36046cc0 100644 --- a/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.java +++ b/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.java @@ -20,6 +20,8 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.wm.impl.FocusRequestInfo; import com.intellij.ui.JBColor; +import com.intellij.ui.JBSplitter; +import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.table.JBTable; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -39,9 +41,8 @@ import java.util.List; * @author Konstantin Bulenkov */ public class FocusTracesDialog extends DialogWrapper { - private JTextPane myStacktrace; - private JBTable myRequestsTable; - private JPanel myRootPanel; + private final JTextPane myStacktrace = new JTextPane(); + private final JBTable myRequestsTable; private final List myRequests; private static final String[] COLUMNS = {"Time", "Forced", "Component"}; @@ -49,19 +50,24 @@ public class FocusTracesDialog extends DialogWrapper { super(project); myRequests = requests; setTitle("Focus Traces"); - init(); final String[][] data = new String[requests.size()][]; for (int i = 0; i < data.length; i++) { final FocusRequestInfo r = requests.get(i); data[i] = new String[]{r.getDate(), String.valueOf(r.isForced()), String.valueOf(r.getComponent())}; } - myRequestsTable.setModel(new DefaultTableModel(data, COLUMNS)); + myRequestsTable = new JBTable(new DefaultTableModel(data, COLUMNS) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }); final ListSelectionListener selectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { final int index = myRequestsTable.getSelectedRow(); if (-1 < index && index < myRequests.size()) { myStacktrace.setText(myRequests.get(index).getStackTrace()); + myStacktrace.setCaretPosition(0); } else { myStacktrace.setText(""); @@ -70,12 +76,15 @@ public class FocusTracesDialog extends DialogWrapper { }; myRequestsTable.getSelectionModel().addListSelectionListener(selectionListener); final TableColumnModel columnModel = myRequestsTable.getColumnModel(); + columnModel.getColumn(0).setMinWidth(120); columnModel.getColumn(0).setMaxWidth(120); + columnModel.getColumn(0).setPreferredWidth(120); + columnModel.getColumn(1).setMinWidth(60); columnModel.getColumn(1).setMaxWidth(60); - columnModel.getSelectionModel().addListSelectionListener(selectionListener); - columnModel.setColumnSelectionAllowed(false); + columnModel.getColumn(1).setPreferredWidth(60); myRequestsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myRequestsTable.changeSelection(0, 0, false, true); + init(); } @Override @@ -85,7 +94,13 @@ public class FocusTracesDialog extends DialogWrapper { @Override protected JComponent createCenterPanel() { - return myRootPanel; + JPanel panel = new JPanel(new BorderLayout()); + JBSplitter splitter = new JBSplitter(true, .5F, .2F, .8F); + splitter.setFirstComponent(new JBScrollPane(myRequestsTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); + splitter.setSecondComponent( + new JBScrollPane(myStacktrace, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); + panel.add(splitter, BorderLayout.CENTER); + return panel; } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java index e6a79dd487b3..947a06e57c5b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java @@ -1283,8 +1283,8 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat } private class MyTimer extends Timer implements ActionListener { - private final List myTimerListeners = Collections.synchronizedList(new ArrayList()); - private final List myTransparentTimerListeners = Collections.synchronizedList(new ArrayList()); + private final List myTimerListeners = ContainerUtil.createLockFreeCopyOnWriteList(); + private final List myTransparentTimerListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private int myLastTimePerformed; MyTimer() { @@ -1312,19 +1312,11 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat } public void addTimerListener(TimerListener listener, boolean transparent){ - if (transparent) { - myTransparentTimerListeners.add(listener); - } else { - myTimerListeners.add(listener); - } + (transparent ? myTransparentTimerListeners : myTimerListeners).add(listener); } public void removeTimerListener(TimerListener listener, boolean transparent){ - if (transparent) { - myTransparentTimerListeners.remove(listener); - } else { - myTimerListeners.remove(listener); - } + (transparent ? myTransparentTimerListeners : myTimerListeners).remove(listener); } @Override @@ -1341,7 +1333,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat boolean transparentOnly = myLastTimePerformed == lastEventCount; try { - HashSet notified = new HashSet(); + Set notified = new HashSet(); myTransparentOnlyUpdate = transparentOnly; notifyListeners(myTransparentTimerListeners, notified); @@ -1357,13 +1349,9 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat } private void notifyListeners(final List timerListeners, final Set notified) { - final TimerListener[] listeners = timerListeners.toArray(new TimerListener[timerListeners.size()]); - for (TimerListener listener : listeners) { - if (timerListeners.contains(listener)) { - if (!notified.contains(listener)) { - notified.add(listener); - runListenerAction(listener); - } + for (TimerListener listener : timerListeners) { + if (notified.add(listener)) { + runListenerAction(listener); } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java index aa548af56b05..106a3e728a89 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java @@ -229,7 +229,8 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, @Override @NotNull public CaretImpl getCurrentCaret() { - return ApplicationManager.getApplication().isDispatchThread() && myCurrentCaret != null ? myCurrentCaret : getPrimaryCaret(); + CaretImpl currentCaret = myCurrentCaret; + return ApplicationManager.getApplication().isDispatchThread() && currentCaret != null ? currentCaret : getPrimaryCaret(); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java index 6daf1ab3f061..b66fcf46abb7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java @@ -298,6 +298,7 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable { revalidateFurtherRequestors(); } + command.setForced(forced); command.run().doWhenDone(new Runnable() { @Override public void run() { diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java index 11d325038ae5..73dedb4e9f3d 100755 --- a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java @@ -20,7 +20,6 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.Gray; import com.intellij.ui.JBColor; -import com.intellij.util.ui.GraphicsUtil; import com.intellij.util.ui.UIUtil; import org.jdesktop.swingx.graphics.GraphicsUtilities; import org.jdesktop.swingx.graphics.ShadowRenderer; diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java index b3e3fce15d35..765d56091fb8 100755 --- a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java @@ -16,17 +16,18 @@ package com.intellij.ui.messages; import com.apple.eawt.FullScreenUtilities; +import com.intellij.openapi.application.impl.LaterInvocator; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.JBColor; import com.intellij.ui.mac.MacMainFrameDecorator; import com.intellij.util.ui.Animator; -import com.intellij.util.ui.UIUtil; import javax.swing.*; import java.awt.*; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; /** @@ -52,13 +53,15 @@ public class SheetMessage { final String focusedButton, final String defaultButton) { - myWindow = new JDialog(owner, "This should not be shown", Dialog.ModalityType.APPLICATION_MODAL) { - @Override - public void paint(Graphics g) { - super.paint(g); + myWindow = new JDialog(owner, "This should not be shown", Dialog.ModalityType.APPLICATION_MODAL); + myWindow.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE); + myWindow.addWindowListener(new WindowAdapter() { + @Override + public void windowActivated(WindowEvent e) { + super.windowActivated(e); } - }; + }); myParent = owner; @@ -68,8 +71,8 @@ public class SheetMessage { imageHeight = 0; registerMoveResizeHandler(); - myWindow.setFocusableWindowState(true); myWindow.setFocusable(true); + myWindow.setFocusableWindowState(true); startAnimation(true); myWindow.setSize(myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT); @@ -78,7 +81,9 @@ public class SheetMessage { FullScreenUtilities.setWindowCanFullScreen(myParent, false); } setPositionRelativeToParent(); + LaterInvocator.enterModal(myWindow); myWindow.setVisible(true); + LaterInvocator.leaveModal(myWindow); } private boolean couldBeInFullScreen() { diff --git a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties index de89eaa7f3b3..63adccb02428 100644 --- a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties +++ b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties @@ -44,6 +44,7 @@ xbreakpoint.master.breakpoint.none= xbreakpoint.master.breakpoint.description=Disabled until selected breakpoint is hit: rule.name.group.by.file=Group by file xbreakpoint.default.display.text=Line {0} in {1} +xbreakpoint.group.unknown=Unknown xbreakpoint.reached.text=Breakpoint reached: diff --git a/platform/projectModel-api/src/com/intellij/openapi/project/ProjectUtilCore.java b/platform/projectModel-api/src/com/intellij/openapi/project/ProjectUtilCore.java index 5dedb2dc093a..120605d93292 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/project/ProjectUtilCore.java +++ b/platform/projectModel-api/src/com/intellij/openapi/project/ProjectUtilCore.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,21 @@ */ package com.intellij.openapi.project; +import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.roots.JdkOrderEntry; import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.roots.libraries.LibraryUtil; import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileProvider; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Locale; public class ProjectUtilCore { public static String displayUrlRelativeToProject(@NotNull VirtualFile file, @@ -64,4 +70,33 @@ public class ProjectUtilCore { url + " - [" + module.getName() + "]" : "[" + module.getName() + "] - " + url; } + + @Nullable + public static String getPresentableName(@NotNull Project project) { + if (project.isDefault()) { + return project.getName(); + } + + String location = project.getPresentableUrl(); + if (location == null) { + return null; + } + + String projectName = FileUtil.toSystemIndependentName(location); + if (projectName.endsWith("/")) { + projectName = projectName.substring(0, projectName.length() - 1); + } + + final int lastSlash = projectName.lastIndexOf('/'); + if (lastSlash >= 0 && lastSlash + 1 < projectName.length()) { + projectName = projectName.substring(lastSlash + 1); + } + + if (StringUtil.endsWithIgnoreCase(projectName, ProjectFileType.DOT_DEFAULT_EXTENSION)) { + projectName = projectName.substring(0, projectName.length() - ProjectFileType.DOT_DEFAULT_EXTENSION.length()); + } + + projectName = projectName.toLowerCase(Locale.US).replace(':', '_'); // replace ':' from windows drive names + return projectName; + } } diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/XBreakpointGroupingRule.java b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/XBreakpointGroupingRule.java index 1038747be2c0..650e295ad087 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/XBreakpointGroupingRule.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/XBreakpointGroupingRule.java @@ -53,7 +53,7 @@ public abstract class XBreakpointGroupingRule { return XBreakpointsGroupingPriorities.DEFAULT; } - @Nullable + @NotNull public abstract G getGroup(@NotNull B breakpoint, @NotNull Collection groups); @Nullable diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroup.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroup.java index f7ae89a202a9..c86b5e30bd28 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroup.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroup.java @@ -15,9 +15,11 @@ */ package com.intellij.xdebugger.impl.breakpoints.ui.grouping; +import com.intellij.icons.AllIcons; import com.intellij.ide.presentation.VirtualFilePresentation; -import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.xdebugger.XDebuggerBundle; +import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,8 +29,26 @@ import javax.swing.*; * @author nik */ public class XBreakpointFileGroup extends XBreakpointGroup { + public static final XBreakpointFileGroup UNKNOWN = new XBreakpointFileGroup() { + @NotNull + @Override + public String getName() { + return XDebuggerBundle.message("xbreakpoint.group.unknown"); + } + + @Nullable + @Override + public Icon getIcon(boolean isOpen) { + return AllIcons.FileTypes.Text; + } + }; + private final VirtualFile myFile; + private XBreakpointFileGroup() { + myFile = null; + } + public XBreakpointFileGroup(@NotNull VirtualFile file) { myFile = file; } @@ -43,6 +63,7 @@ public class XBreakpointFileGroup extends XBreakpointGroup { return myFile.getPresentableUrl(); } + @Nullable public VirtualFile getFile() { return myFile; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroupingRule.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroupingRule.java index b0b5998ef71f..44afa0fe3c88 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroupingRule.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroupingRule.java @@ -16,6 +16,7 @@ package com.intellij.xdebugger.impl.breakpoints.ui.grouping; import com.intellij.icons.AllIcons; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.XSourcePosition; @@ -41,17 +42,20 @@ public class XBreakpointFileGroupingRule extends XBreakpointGroupingRule groups) { if (!(breakpoint instanceof XLineBreakpoint)) { - return null; + return XBreakpointFileGroup.UNKNOWN; } XSourcePosition position = ((XLineBreakpoint)breakpoint).getSourcePosition(); - if (position == null) return null; + if (position == null) { + return XBreakpointFileGroup.UNKNOWN; + } VirtualFile file = position.getFile(); for (XBreakpointFileGroup group : groups) { - if (group.getFile().equals(file)) { + if (Comparing.equal(group.getFile(), file)) { return group; } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointGroupingByTypeRule.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointGroupingByTypeRule.java index 5d1301604f72..19c9018ee270 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointGroupingByTypeRule.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointGroupingByTypeRule.java @@ -45,6 +45,7 @@ public class XBreakpointGroupingByTypeRule extends XBreakpointGroupingRule groups) { if (b instanceof XBreakpoint) { @@ -56,6 +57,6 @@ public class XBreakpointGroupingByTypeRule extends XBreakpointGroupingRule" + + "" + + "" + + " " + condition + "" + + " url" + + " " + logExpression + "" + + "" + + "" + + "