diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java index 64bbab269ee6..cff128d2e6a8 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java @@ -255,7 +255,8 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl protected boolean removeLibrary(final Library library) { final LibraryTable table = library.getTable(); if (table != null) { - final Collection usages = myContext.getDaemonAnalyzer().getUsages(new LibraryProjectStructureElement(myContext, library)); + final LibraryProjectStructureElement libraryElement = new LibraryProjectStructureElement(myContext, library); + final Collection usages = new ArrayList(myContext.getDaemonAnalyzer().getUsages(libraryElement)); if (usages.size() > 0) { final MultiMap containerType2Usage = new MultiMap(); for (final ProjectStructureElementUsage usage : usages) { @@ -295,12 +296,12 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl } getModelProvider().getModifiableModel().removeLibrary(library); - myContext.getDaemonAnalyzer().removeElement(new LibraryProjectStructureElement(myContext, library)); + myContext.getDaemonAnalyzer().removeElement(libraryElement); return true; } } else { getModelProvider().getModifiableModel().removeLibrary(library); - myContext.getDaemonAnalyzer().removeElement(new LibraryProjectStructureElement(myContext, library)); + myContext.getDaemonAnalyzer().removeElement(libraryElement); return true; } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java index 640fafc0f609..c2817d2f8672 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java @@ -245,7 +245,7 @@ public class MarkerType { } @Override - public void run(@NotNull ProgressIndicator indicator) { + public void run(@NotNull final ProgressIndicator indicator) { super.run(indicator); ClassInheritorsSearch.search(myClass, ApplicationManager.getApplication().runReadAction(new Computable() { @Override @@ -255,7 +255,10 @@ public class MarkerType { }), true).forEach(new CommonProcessors.CollectProcessor() { @Override public boolean process(final PsiClass o) { - updateComponent(o, myRenderer.getComparator()); + if (!updateComponent(o, myRenderer.getComparator())) { + indicator.cancel(); + } + indicator.checkCanceled(); return super.process(o); } }); @@ -281,13 +284,16 @@ public class MarkerType { } @Override - public void run(@NotNull ProgressIndicator indicator) { + public void run(@NotNull final ProgressIndicator indicator) { super.run(indicator); OverridingMethodsSearch.search(myMethod, true).forEach( new CommonProcessors.CollectProcessor() { @Override public boolean process(PsiMethod psiMethod) { - updateComponent(psiMethod, myRenderer.getComparator()); + if (!updateComponent(psiMethod, myRenderer.getComparator())) { + indicator.cancel(); + } + indicator.checkCanceled(); return super.process(psiMethod); } }); diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/ClassFinderClasspath.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/ClassFinderClasspath.java deleted file mode 100644 index 0cb0b03d91cb..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/ClassFinderClasspath.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright 2000-2012 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 org.jetbrains.jps.incremental.java; - -import com.intellij.openapi.util.io.FileUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; -import sun.misc.Resource; - -import java.io.*; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -class ClassFinderClasspath { - private static final String FILE_PROTOCOL = "file"; - - private final Stack myUrls = new Stack(); - private final List myLoaders = new ArrayList(); - private final Map myLoadersMap = new HashMap(); - - public ClassFinderClasspath(URL[] urls) { - push(urls); - } - - @Nullable - public Resource getResource(String s, boolean flag) { - int i = 0; - for (Loader loader; (loader = getLoader(i)) != null; i++) { - Resource resource = loader.getResource(s, flag); - if (resource != null) { - return resource; - } - } - - return null; - } - - public void releaseResources() { - for (Loader loader : myLoaders) { - loader.releaseResources(); - } - myLoaders.clear(); - myLoadersMap.clear(); - myUrls.clear(); - } - - @Nullable - private synchronized Loader getLoader(int i) { - while (myLoaders.size() < i + 1) { - URL url; - synchronized (myUrls) { - if (myUrls.empty()) { - return null; - } - url = myUrls.pop(); - } - - if (myLoadersMap.containsKey(url)) { - continue; - } - - Loader loader; - try { - loader = getLoader(url, myLoaders.size()); - if (loader == null) { - continue; - } - } - catch (IOException ioexception) { - continue; - } - - myLoaders.add(loader); - myLoadersMap.put(url, loader); - } - - return myLoaders.get(i); - } - - @Nullable - private Loader getLoader(final URL url, int index) throws IOException { - String s; - try { - s = url.toURI().getSchemeSpecificPart(); - } - catch (URISyntaxException thisShouldNotHappen) { - thisShouldNotHappen.printStackTrace(); - s = url.getFile(); - } - - Loader loader = null; - if (s != null && new File(s).isDirectory()) { - if (FILE_PROTOCOL.equals(url.getProtocol())) { - loader = new FileLoader(url, index); - } - } - else { - loader = new JarLoader(url, index); - } - - return loader; - } - - private void push(URL[] urls) { - if (urls.length == 0) return; - synchronized (myUrls) { - for (int i = urls.length - 1; i >= 0; i--) { - myUrls.push(urls[i]); - } - } - } - - - private abstract static class Loader { - protected static final String JAR_PROTOCOL = "jar"; - protected static final String FILE_PROTOCOL = "file"; - - private final URL myURL; - private final int myIndex; - - protected Loader(URL url, int index) { - myURL = url; - myIndex = index; - } - - - protected URL getBaseURL() { - return myURL; - } - - @Nullable - public abstract Resource getResource(final String name, boolean flag); - - public abstract void releaseResources(); - - public int getIndex() { - return myIndex; - } - - } - - private static class FileLoader extends Loader { - private final File myRootDir; - - @SuppressWarnings({"HardCodedStringLiteral"}) - FileLoader(URL url, int index) throws IOException { - super(url, index); - if (!FILE_PROTOCOL.equals(url.getProtocol())) { - throw new IllegalArgumentException("url"); - } - else { - final String s = FileUtil.unquote(url.getFile()); - myRootDir = new File(s); - } - } - - public void releaseResources() { - } - - @Nullable - public Resource getResource(final String name, boolean check) { - URL url = null; - File file = null; - - try { - url = new URL(getBaseURL(), name); - if (!url.getFile().startsWith(getBaseURL().getFile())) { - return null; - } - - file = new File(myRootDir, name.replace('/', File.separatorChar)); - if (!check || file.exists()) { // check means we load or process resource so we check its existence via old way - return new FileResource(name, url, file, !check); - } - } - catch (Exception exception) { - if (!check && file != null && file.exists()) { - try { // we can not open the file if it is directory, Resource still can be created - return new FileResource(name, url, file, false); - } - catch (IOException ex) {} - } - } - return null; - } - - private class FileResource extends Resource { - private final String myName; - private final URL myUrl; - private final File myFile; - - public FileResource(String name, URL url, File file, boolean willLoadBytes) throws IOException { - myName = name; - myUrl = url; - myFile = file; - if (willLoadBytes) getByteBuffer(); // check for existence by creating cached file input stream - } - - public String getName() { - return myName; - } - - public URL getURL() { - return myUrl; - } - - public URL getCodeSourceURL() { - return getBaseURL(); - } - - public InputStream getInputStream() throws IOException { - return new BufferedInputStream(new FileInputStream(myFile)); - } - - public int getContentLength() throws IOException { - return -1; - } - - public String toString() { - return myFile.getAbsolutePath(); - } - } - - @NonNls - public String toString() { - return "FileLoader [" + myRootDir + "]"; - } - } - - private class JarLoader extends Loader { - private final URL myURL; - private ZipFile myZipFile; - - JarLoader(URL url, int index) throws IOException { - super(new URL(JAR_PROTOCOL, "", -1, url + "!/"), index); - myURL = url; - } - - public void releaseResources() { - final ZipFile zipFile = myZipFile; - if (zipFile != null) { - myZipFile = null; - try { - zipFile.close(); - } - catch (IOException e) { - throw new RuntimeException(); - } - } - } - - @Nullable - private ZipFile acquireZipFile() throws IOException { - ZipFile zipFile = myZipFile; - if (zipFile == null) { - zipFile = doGetZipFile(); - myZipFile = zipFile; - } - return zipFile; - } - - @Nullable - private ZipFile doGetZipFile() throws IOException { - if (FILE_PROTOCOL.equals(myURL.getProtocol())) { - String s = FileUtil.unquote(myURL.getFile()); - if (!new File(s).exists()) { - throw new FileNotFoundException(s); - } - else { - return new ZipFile(s); - } - } - - return null; - } - - @Nullable - public Resource getResource(String name, boolean flag) { - try { - final ZipFile file = acquireZipFile(); - if (file != null) { - final ZipEntry entry = file.getEntry(name); - if (entry != null) { - return new JarResource(entry, new URL(getBaseURL(), name)); - } - } - } - catch (Exception e) { - return null; - } - return null; - } - - private class JarResource extends Resource { - private final ZipEntry myEntry; - private final URL myUrl; - - public JarResource(ZipEntry name, URL url) { - myEntry = name; - myUrl = url; - } - - public String getName() { - return myEntry.getName(); - } - - public URL getURL() { - return myUrl; - } - - public URL getCodeSourceURL() { - return myURL; - } - - @Nullable - public InputStream getInputStream() throws IOException { - ZipFile file = null; - try { - file = acquireZipFile(); - if (file == null) { - return null; - } - - final InputStream inputStream = file.getInputStream(myEntry); - if (inputStream == null) { - return null; // if entry was not found - } - return new FilterInputStream(inputStream) {}; - } - catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - public int getContentLength() { - return (int)myEntry.getSize(); - } - } - - @NonNls - public String toString() { - return "JarLoader [" + myURL + "]"; - } - } - - -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/InstrumentationClassFinder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/InstrumentationClassFinder.java index 575d0a475b16..8b2ee439af91 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/InstrumentationClassFinder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/InstrumentationClassFinder.java @@ -1,33 +1,33 @@ package org.jetbrains.jps.incremental.java; -import org.jetbrains.jps.javac.OutputFileObject; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.Opcodes; import org.objectweb.asm.commons.EmptyVisitor; import sun.misc.Resource; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; +import java.net.URISyntaxException; import java.net.URL; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; /** * @author Eugene Zhuravlev * Date: 2/16/12 */ -class InstrumentationClassFinder { +public class InstrumentationClassFinder { private static final PseudoClass[] EMPTY_PSEUDOCLASS_ARRAY = new PseudoClass[0]; private static final String CLASS_RESOURCE_EXTENSION = ".class"; private final Map myLoaded = new HashMap(); // className -> class object private final ClassFinderClasspath myPlatformClasspath; private final ClassFinderClasspath myClasspath; - private final OutputFilesSink myCompiled; - public InstrumentationClassFinder(final URL[] platformClasspath, final URL[] classpath, OutputFilesSink compiled) { - myCompiled = compiled; + public InstrumentationClassFinder(final URL[] platformClasspath, final URL[] classpath) { myPlatformClasspath = new ClassFinderClasspath(platformClasspath); myClasspath = new ClassFinderClasspath(classpath); } @@ -53,10 +53,7 @@ class InstrumentationClassFinder { } // second look into memory and classspath if (is == null) { - final OutputFileObject.Content content = myCompiled.lookupClassBytes(internalName.replace("/", ".")); - if (content != null) { - is = new ByteArrayInputStream(content.getBuffer(), content.getOffset(), content.getLength()); - } + is = lookupClassBeforeClasspath(internalName); } if (is == null) { @@ -65,7 +62,11 @@ class InstrumentationClassFinder { is = resource.getInputStream(); } } - + + if (is == null) { + is = lookupClassAfterClasspath(internalName); + } + if (is == null) { throw new ClassNotFoundException("Class not found: " + internalName); } @@ -80,6 +81,16 @@ class InstrumentationClassFinder { } } + @Nullable + protected InputStream lookupClassBeforeClasspath(final String internalClassName) { + return null; + } + + @Nullable + protected InputStream lookupClassAfterClasspath(final String internalClassName) { + return null; + } + private PseudoClass loadPseudoClass(InputStream is) throws IOException { final ClassReader reader = new ClassReader(is); final V visitor = new V(); @@ -194,4 +205,390 @@ class InstrumentationClassFinder { myIsInterface = (access & Opcodes.ACC_INTERFACE) > 0; } } + + static class ClassFinderClasspath { + private static final String FILE_PROTOCOL = "file"; + + private final Stack myUrls = new Stack(); + private final List myLoaders = new ArrayList(); + private final Map myLoadersMap = new HashMap(); + + public ClassFinderClasspath(URL[] urls) { + if (urls.length > 0) { + for (int i = urls.length - 1; i >= 0; i--) { + myUrls.push(urls[i]); + } + } + } + + @Nullable + public Resource getResource(String s, boolean flag) { + int i = 0; + for (Loader loader; (loader = getLoader(i)) != null; i++) { + Resource resource = loader.getResource(s, flag); + if (resource != null) { + return resource; + } + } + + return null; + } + + public void releaseResources() { + for (Loader loader : myLoaders) { + loader.releaseResources(); + } + myLoaders.clear(); + myLoadersMap.clear(); + } + + @Nullable + private synchronized Loader getLoader(int i) { + while (myLoaders.size() < i + 1) { + URL url; + synchronized (myUrls) { + if (myUrls.empty()) { + return null; + } + url = myUrls.pop(); + } + + if (myLoadersMap.containsKey(url)) { + continue; + } + + Loader loader; + try { + loader = getLoader(url, myLoaders.size()); + if (loader == null) { + continue; + } + } + catch (IOException ioexception) { + continue; + } + + myLoaders.add(loader); + myLoadersMap.put(url, loader); + } + + return myLoaders.get(i); + } + + @Nullable + private Loader getLoader(final URL url, int index) throws IOException { + String s; + try { + s = url.toURI().getSchemeSpecificPart(); + } + catch (URISyntaxException thisShouldNotHappen) { + thisShouldNotHappen.printStackTrace(); + s = url.getFile(); + } + + Loader loader = null; + if (s != null && new File(s).isDirectory()) { + if (FILE_PROTOCOL.equals(url.getProtocol())) { + loader = new FileLoader(url, index); + } + } + else { + loader = new JarLoader(url, index); + } + + return loader; + } + + + private abstract static class Loader { + protected static final String JAR_PROTOCOL = "jar"; + protected static final String FILE_PROTOCOL = "file"; + + private final URL myURL; + private final int myIndex; + + protected Loader(URL url, int index) { + myURL = url; + myIndex = index; + } + + + protected URL getBaseURL() { + return myURL; + } + + @Nullable + public abstract Resource getResource(final String name, boolean flag); + + public abstract void releaseResources(); + + public int getIndex() { + return myIndex; + } + } + + private static class FileLoader extends Loader { + private final File myRootDir; + + @SuppressWarnings({"HardCodedStringLiteral"}) + FileLoader(URL url, int index) throws IOException { + super(url, index); + if (!FILE_PROTOCOL.equals(url.getProtocol())) { + throw new IllegalArgumentException("url"); + } + else { + final String s = unescapePercentSequences(url.getFile().replace('/', File.separatorChar)); + myRootDir = new File(s); + } + } + + public void releaseResources() { + } + + @Nullable + public Resource getResource(final String name, boolean check) { + URL url = null; + File file = null; + + try { + url = new URL(getBaseURL(), name); + if (!url.getFile().startsWith(getBaseURL().getFile())) { + return null; + } + + file = new File(myRootDir, name.replace('/', File.separatorChar)); + if (!check || file.exists()) { // check means we load or process resource so we check its existence via old way + return new FileResource(name, url, file, !check); + } + } + catch (Exception exception) { + if (!check && file != null && file.exists()) { + try { // we can not open the file if it is directory, Resource still can be created + return new FileResource(name, url, file, false); + } + catch (IOException ex) { + } + } + } + return null; + } + + private class FileResource extends Resource { + private final String myName; + private final URL myUrl; + private final File myFile; + + public FileResource(String name, URL url, File file, boolean willLoadBytes) throws IOException { + myName = name; + myUrl = url; + myFile = file; + if (willLoadBytes) getByteBuffer(); // check for existence by creating cached file input stream + } + + public String getName() { + return myName; + } + + public URL getURL() { + return myUrl; + } + + public URL getCodeSourceURL() { + return getBaseURL(); + } + + public InputStream getInputStream() throws IOException { + return new BufferedInputStream(new FileInputStream(myFile)); + } + + public int getContentLength() throws IOException { + return -1; + } + + public String toString() { + return myFile.getAbsolutePath(); + } + } + + @NonNls + public String toString() { + return "FileLoader [" + myRootDir + "]"; + } + } + + private class JarLoader extends Loader { + private final URL myURL; + private ZipFile myZipFile; + + JarLoader(URL url, int index) throws IOException { + super(new URL(JAR_PROTOCOL, "", -1, url + "!/"), index); + myURL = url; + } + + public void releaseResources() { + final ZipFile zipFile = myZipFile; + if (zipFile != null) { + myZipFile = null; + try { + zipFile.close(); + } + catch (IOException e) { + throw new RuntimeException(); + } + } + } + + @Nullable + private ZipFile acquireZipFile() throws IOException { + ZipFile zipFile = myZipFile; + if (zipFile == null) { + zipFile = doGetZipFile(); + myZipFile = zipFile; + } + return zipFile; + } + + @Nullable + private ZipFile doGetZipFile() throws IOException { + if (FILE_PROTOCOL.equals(myURL.getProtocol())) { + String s = unescapePercentSequences(myURL.getFile().replace('/', File.separatorChar)); + if (!new File(s).exists()) { + throw new FileNotFoundException(s); + } + else { + return new ZipFile(s); + } + } + + return null; + } + + @Nullable + public Resource getResource(String name, boolean flag) { + try { + final ZipFile file = acquireZipFile(); + if (file != null) { + final ZipEntry entry = file.getEntry(name); + if (entry != null) { + return new JarResource(entry, new URL(getBaseURL(), name)); + } + } + } + catch (Exception e) { + return null; + } + return null; + } + + private class JarResource extends Resource { + private final ZipEntry myEntry; + private final URL myUrl; + + public JarResource(ZipEntry name, URL url) { + myEntry = name; + myUrl = url; + } + + public String getName() { + return myEntry.getName(); + } + + public URL getURL() { + return myUrl; + } + + public URL getCodeSourceURL() { + return myURL; + } + + @Nullable + public InputStream getInputStream() throws IOException { + ZipFile file = null; + try { + file = acquireZipFile(); + if (file == null) { + return null; + } + + final InputStream inputStream = file.getInputStream(myEntry); + if (inputStream == null) { + return null; // if entry was not found + } + return new FilterInputStream(inputStream) {}; + } + catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + public int getContentLength() { + return (int)myEntry.getSize(); + } + } + + @NonNls + public String toString() { + return "JarLoader [" + myURL + "]"; + } + } + } + + + @NotNull + private static String unescapePercentSequences(@NotNull String s) { + if (s.indexOf('%') == -1) { + return s; + } + StringBuilder decoded = new StringBuilder(); + final int len = s.length(); + int i = 0; + while (i < len) { + char c = s.charAt(i); + if (c == '%') { + List bytes = new ArrayList(); + while (i + 2 < len && s.charAt(i) == '%') { + final int d1 = decode(s.charAt(i + 1)); + final int d2 = decode(s.charAt(i + 2)); + if (d1 != -1 && d2 != -1) { + bytes.add(((d1 & 0xf) << 4 | d2 & 0xf)); + i += 3; + } + else { + break; + } + } + if (!bytes.isEmpty()) { + final byte[] bytesArray = new byte[bytes.size()]; + for (int j = 0; j < bytes.size(); j++) { + bytesArray[j] = (byte)bytes.get(j).intValue(); + } + try { + decoded.append(new String(bytesArray, "UTF-8")); + continue; + } + catch (UnsupportedEncodingException ignored) { + } + } + } + + decoded.append(c); + i++; + } + return decoded.toString(); + } + + private static int decode(char c) { + if ((c >= '0') && (c <= '9')){ + return c - '0'; + } + if ((c >= 'a') && (c <= 'f')){ + return c - 'a' + 10; + } + if ((c >= 'A') && (c <= 'F')){ + return c - 'A' + 10; + } + return -1; + } + } diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index c1d0663e225d..10b03b898693 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -529,7 +529,7 @@ public class JavaBuilder extends ModuleLevelBuilder { private static InstrumentationClassFinder createInstrumentationClassFinder(Collection platformCp, Collection classpath, - OutputFilesSink outputSink) throws MalformedURLException { + final OutputFilesSink outputSink) throws MalformedURLException { final URL[] platformUrls = new URL[platformCp.size()]; int index = 0; for (File file : platformCp) { @@ -544,7 +544,15 @@ public class JavaBuilder extends ModuleLevelBuilder { urls[index++] = getResourcePath(GridConstraints.class).toURI().toURL(); // forms_rt.jar //urls.add(getResourcePath(CellConstraints.class).toURI().toURL()); // jgoodies-forms - return new InstrumentationClassFinder(platformUrls, urls, outputSink); + return new InstrumentationClassFinder(platformUrls, urls) { + protected InputStream lookupClassBeforeClasspath(String internalClassName) { + final OutputFileObject.Content content = outputSink.lookupClassBytes(internalClassName.replace("/", ".")); + if (content != null) { + return new ByteArrayInputStream(content.getBuffer(), content.getOffset(), content.getLength()); + } + return null; + } + }; } private static ClassLoader createInstrumentationClassLoader(Collection platformCp, Collection classpath, diff --git a/jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java b/jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java index 45502bed0f72..63c600a02d41 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java +++ b/jps/jps-builders/src/org/jetbrains/jps/server/ClasspathBootstrap.java @@ -154,15 +154,28 @@ public class ClasspathBootstrap { if (systemCompiler != null) { try { final String localJarPath = FileUtil.toSystemIndependentName(getResourcePath(systemCompiler.getClass()).getPath()); - final String localJavaHome = SystemProperties.getJavaHome(); - String relPath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(localJavaHome), localJarPath, '/'); - if (relPath != null) { - if (relPath.contains("..")) { - relPath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(new File(localJavaHome).getParent()), localJarPath, '/'); + final String localJavaHome = FileUtil.toSystemIndependentName(SystemProperties.getJavaHome()); + if (FileUtil.pathsEqual(localJavaHome, FileUtil.toSystemIndependentName(sdkHome))) { + cp.add(new File(localJarPath)); + } + else { + // sdkHome is not the same as the sdk used to run this process + final File candidate = new File(sdkHome, "lib/tools.jar"); + if (candidate.exists()) { + cp.add(candidate); } - if (relPath != null) { - final File targetFile = new File(sdkHome +"/" +relPath); - cp.add(targetFile); // tools.jar + else { + // last resort + String relPath = FileUtil.getRelativePath(localJavaHome, localJarPath, '/'); + if (relPath != null) { + if (relPath.contains("..")) { + relPath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(new File(localJavaHome).getParent()), localJarPath, '/'); + } + if (relPath != null) { + final File targetFile = new File(sdkHome, relPath); + cp.add(targetFile); // tools.jar + } + } } } } diff --git a/platform/core-api/src/com/intellij/util/IconUtil.java b/platform/core-api/src/com/intellij/util/IconUtil.java index 3be59e668176..95cccedcc9e8 100644 --- a/platform/core-api/src/com/intellij/util/IconUtil.java +++ b/platform/core-api/src/com/intellij/util/IconUtil.java @@ -187,24 +187,35 @@ public class IconUtil { } } - public static Icon getAddRowIcon() { - return SystemInfo.isMac ? PlatformIcons.TABLE_ADD_ROW : PlatformIcons.ADD_ICON; + public static Icon getAddIcon() { + return getToolbarDecoratorIcon("add.png"); } - public static Icon getRemoveRowIcon() { - return SystemInfo.isMac ? PlatformIcons.TABLE_REMOVE_ROW : PlatformIcons.DELETE_ICON; + public static Icon getRemoveIcon() { + return getToolbarDecoratorIcon("remove.png"); } - public static Icon getMoveRowUpIcon() { - return SystemInfo.isMac ? PlatformIcons.TABLE_MOVE_ROW_UP : PlatformIcons.MOVE_UP_ICON; + public static Icon getMoveUpIcon() { + return getToolbarDecoratorIcon("moveUp.png"); } - public static Icon getMoveRowDownIcon() { - return SystemInfo.isMac ? PlatformIcons.TABLE_MOVE_ROW_DOWN : PlatformIcons.MOVE_DOWN_ICON; + public static Icon getMoveDownIcon() { + return getToolbarDecoratorIcon("moveDown.png"); } public static Icon getEditIcon() { - return SystemInfo.isMac ? PlatformIcons.TABLE_EDIT_ROW : PlatformIcons.EDIT; + return getToolbarDecoratorIcon("edit.png"); } + public static Icon getAddClassIcon() { + return getToolbarDecoratorIcon("addClass.png"); + } + + public static Icon getToolbarDecoratorIcon(String name) { + return IconLoader.getIcon(getToolbarDecoratorIconsFolder() + name); + } + + private static String getToolbarDecoratorIconsFolder() { + return "/toolbarDecorator/" + (SystemInfo.isMac ? "mac/" : ""); + } } diff --git a/platform/icons/src/toolbarDecorator/add.png b/platform/icons/src/toolbarDecorator/add.png new file mode 100644 index 000000000000..9f1233e6e6c3 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/add.png differ diff --git a/platform/icons/src/toolbarDecorator/addClass.png b/platform/icons/src/toolbarDecorator/addClass.png new file mode 100644 index 000000000000..56ce420e43fd Binary files /dev/null and b/platform/icons/src/toolbarDecorator/addClass.png differ diff --git a/platform/icons/src/toolbarDecorator/addFolder.png b/platform/icons/src/toolbarDecorator/addFolder.png new file mode 100644 index 000000000000..6186de6cf45f Binary files /dev/null and b/platform/icons/src/toolbarDecorator/addFolder.png differ diff --git a/platform/icons/src/toolbarDecorator/addIcon.png b/platform/icons/src/toolbarDecorator/addIcon.png new file mode 100644 index 000000000000..4116c7eef0f3 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/addIcon.png differ diff --git a/platform/icons/src/toolbarDecorator/addJira.png b/platform/icons/src/toolbarDecorator/addJira.png new file mode 100644 index 000000000000..be1747691fb0 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/addJira.png differ diff --git a/platform/icons/src/toolbarDecorator/addLink.png b/platform/icons/src/toolbarDecorator/addLink.png new file mode 100644 index 000000000000..05e832632317 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/addLink.png differ diff --git a/platform/icons/src/toolbarDecorator/addPackage.png b/platform/icons/src/toolbarDecorator/addPackage.png new file mode 100644 index 000000000000..90f5d053098d Binary files /dev/null and b/platform/icons/src/toolbarDecorator/addPackage.png differ diff --git a/platform/icons/src/toolbarDecorator/addPattern.png b/platform/icons/src/toolbarDecorator/addPattern.png new file mode 100644 index 000000000000..0ddeefda020a Binary files /dev/null and b/platform/icons/src/toolbarDecorator/addPattern.png differ diff --git a/platform/icons/src/toolbarDecorator/addYouTrack.png b/platform/icons/src/toolbarDecorator/addYouTrack.png new file mode 100644 index 000000000000..7ede46dfa541 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/addYouTrack.png differ diff --git a/platform/icons/src/toolbarDecorator/edit.png b/platform/icons/src/toolbarDecorator/edit.png new file mode 100644 index 000000000000..c68452ab50fc Binary files /dev/null and b/platform/icons/src/toolbarDecorator/edit.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/add.png b/platform/icons/src/toolbarDecorator/mac/add.png new file mode 100644 index 000000000000..55f7db18f50d Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/add.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/addClass.png b/platform/icons/src/toolbarDecorator/mac/addClass.png new file mode 100644 index 000000000000..5f27194adf10 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/addClass.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/addFolder.png b/platform/icons/src/toolbarDecorator/mac/addFolder.png new file mode 100644 index 000000000000..6c358ce8cb9a Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/addFolder.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/addIcon.png b/platform/icons/src/toolbarDecorator/mac/addIcon.png new file mode 100644 index 000000000000..ee799035fbc2 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/addIcon.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/addJira.png b/platform/icons/src/toolbarDecorator/mac/addJira.png new file mode 100644 index 000000000000..8ff7e34f81df Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/addJira.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/addLink.png b/platform/icons/src/toolbarDecorator/mac/addLink.png new file mode 100644 index 000000000000..5a7e4ad1e73d Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/addLink.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/addPackage.png b/platform/icons/src/toolbarDecorator/mac/addPackage.png new file mode 100644 index 000000000000..10775b50d88b Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/addPackage.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/addPattern.png b/platform/icons/src/toolbarDecorator/mac/addPattern.png new file mode 100644 index 000000000000..6bf2b9320a31 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/addPattern.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/addYouTrack.png b/platform/icons/src/toolbarDecorator/mac/addYouTrack.png new file mode 100644 index 000000000000..7b18da3ed1a6 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/addYouTrack.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/edit.png b/platform/icons/src/toolbarDecorator/mac/edit.png new file mode 100644 index 000000000000..4c8b67617c37 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/edit.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/moveDown.png b/platform/icons/src/toolbarDecorator/mac/moveDown.png new file mode 100644 index 000000000000..e674a16f6970 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/moveDown.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/moveUp.png b/platform/icons/src/toolbarDecorator/mac/moveUp.png new file mode 100644 index 000000000000..9d03ded56803 Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/moveUp.png differ diff --git a/platform/icons/src/toolbarDecorator/mac/remove.png b/platform/icons/src/toolbarDecorator/mac/remove.png new file mode 100644 index 000000000000..62159bb959fe Binary files /dev/null and b/platform/icons/src/toolbarDecorator/mac/remove.png differ diff --git a/platform/icons/src/toolbarDecorator/moveDown.png b/platform/icons/src/toolbarDecorator/moveDown.png new file mode 100644 index 000000000000..b0782ac407ad Binary files /dev/null and b/platform/icons/src/toolbarDecorator/moveDown.png differ diff --git a/platform/icons/src/toolbarDecorator/moveUp.png b/platform/icons/src/toolbarDecorator/moveUp.png new file mode 100644 index 000000000000..3ab171d9eb5f Binary files /dev/null and b/platform/icons/src/toolbarDecorator/moveUp.png differ diff --git a/platform/icons/src/toolbarDecorator/remove.png b/platform/icons/src/toolbarDecorator/remove.png new file mode 100644 index 000000000000..ee2676e27ebf Binary files /dev/null and b/platform/icons/src/toolbarDecorator/remove.png differ diff --git a/platform/lang-api/src/com/intellij/util/xml/NanoXmlUtil.java b/platform/lang-api/src/com/intellij/util/xml/NanoXmlUtil.java index 69a277574074..05c7a864d9e4 100644 --- a/platform/lang-api/src/com/intellij/util/xml/NanoXmlUtil.java +++ b/platform/lang-api/src/com/intellij/util/xml/NanoXmlUtil.java @@ -98,6 +98,7 @@ public class NanoXmlUtil { } catch (XMLException e) { if (e.getException() instanceof ParserStoppedException) return; + if (e.getException() instanceof ParserStoppedXmlException) return; LOG.debug(e); } } @@ -203,8 +204,8 @@ public class NanoXmlUtil { return null; } - protected static void stop() { - throw new ParserStoppedException(); + protected static void stop() throws ParserStoppedXmlException { + throw ParserStoppedXmlException.INSTANCE; } } @@ -318,6 +319,22 @@ public class NanoXmlUtil { } } + public static class ParserStoppedXmlException extends XMLException { + public static final ParserStoppedException INSTANCE = new ParserStoppedException(); + + private ParserStoppedXmlException() { + super("Parsing stopped"); + } + + @Override + public Throwable fillInStackTrace() { + return this; + } + } + + /** + * @deprecated throw {@link ParserStoppedXmlException#INSTANCE} instead + */ public static class ParserStoppedException extends RuntimeException { @Override public Throwable fillInStackTrace() { @@ -338,7 +355,7 @@ public class NanoXmlUtil { public void startElement(final String name, final String nsPrefix, final String nsURI, final String systemID, final int lineNr) throws Exception { myRootTagName = name; myNamespace = nsURI; - throw new NanoXmlUtil.ParserStoppedException(); + throw ParserStoppedXmlException.INSTANCE; } public void addAttribute(final String key, final String nsPrefix, final String nsURI, final String value, final String type) throws Exception { diff --git a/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java b/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java index baf62a386e5e..3b2352bc3ef8 100644 --- a/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java @@ -29,7 +29,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.util.Disposer; import com.intellij.psi.codeStyle.*; -import com.intellij.ui.components.JBTabbedPane; +import com.intellij.ui.TabbedPaneWrapper; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,7 +50,7 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane private CodeStyleAbstractPanel myActiveTab; private List myTabs; private JPanel myPanel; - private JTabbedPane myTabbedPane; + private TabbedPaneWrapper myTabbedPane; private PredefinedCodeStyle[] myPredefinedCodeStyles; private JPopupMenu myCopyFromMenu; @@ -113,9 +113,9 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane if (myTabs == null) { myPanel = new JPanel(); myPanel.setLayout(new BorderLayout()); - myTabbedPane = new JBTabbedPane(); + myTabbedPane = new TabbedPaneWrapper(this); myTabs = new ArrayList(); - myPanel.add(myTabbedPane); + myPanel.add(myTabbedPane.getComponent()); initTabs(getSettings()); } assert !myTabs.isEmpty(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java index a044b8ae00dd..4d01d1451764 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java @@ -345,7 +345,9 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator extends Task.Backgroundable { return canceled; } - public void updateComponent(PsiElement element, @Nullable final Comparator comparator) { - if (myCanceled) return; - if (myPopup.isDisposed()) return; + public boolean updateComponent(PsiElement element, @Nullable final Comparator comparator) { + if (myCanceled) return false; + if (myPopup.isDisposed()) return false; synchronized (lock) { - if (myData.contains(element)) return; + if (myData.contains(element)) return true; myData.add(element); } @@ -110,6 +110,7 @@ public abstract class BackgroundUpdaterTask extends Task.Backgroundable { myPopup.pack(true, true); } }, 200, ModalityState.stateForComponent(myPopup.getContent())); + return true; } public int getCurrentSize() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoImplementationHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoImplementationHandler.java index 14be963ab4bb..11ee1c156d9e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoImplementationHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoImplementationHandler.java @@ -78,16 +78,21 @@ public class GotoImplementationHandler extends GotoTargetHandler { } @Override - public void run(@NotNull ProgressIndicator indicator) { + public void run(final @NotNull ProgressIndicator indicator) { super.run(indicator); for (PsiElement element : myGotoData.targets) { - updateComponent(element, createComparator(renderers, myGotoData)); + if (!updateComponent(element, createComparator(renderers, myGotoData))) { + return; + } } new ImplementationSearcher.BackgroundableImplementationSearcher() { protected void processElement(PsiElement element) { if (myGotoData.addTarget(element)) { - updateComponent(element, createComparator(renderers, myGotoData)); + if (!updateComponent(element, createComparator(renderers, myGotoData))) { + indicator.cancel(); + } } + indicator.checkCanceled(); } }.searchImplementations(myEditor, myGotoData.source, myOffset); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionAction.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionAction.java index eef5a68fe193..2ffc9489eb08 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionAction.java @@ -19,6 +19,7 @@ import com.intellij.analysis.AnalysisScope; import com.intellij.analysis.AnalysisScopeBundle; import com.intellij.analysis.AnalysisUIOptions; import com.intellij.analysis.BaseAnalysisActionDialog; +import com.intellij.codeInspection.InspectionManager; import com.intellij.codeInspection.InspectionProfileEntry; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.codeInspection.ex.GlobalInspectionContextImpl; @@ -41,6 +42,7 @@ import com.intellij.psi.search.PsiSearchScopeUtil; import com.intellij.psi.search.SearchScope; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Arrays; @@ -62,8 +64,7 @@ public class RunInspectionAction extends GotoActionBase { final PsiElement psiElement = LangDataKeys.PSI_ELEMENT.getData(e.getDataContext()); final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext()); - final VirtualFile virtualFile = LangDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); - if (virtualFile == null) return; + final VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.inspection"); @@ -84,24 +85,27 @@ public class RunInspectionAction extends GotoActionBase { private static void runInspection(@NotNull Project project, @NotNull InspectionProfileEntry profileEntry, - @NotNull VirtualFile virtualFile, + @Nullable VirtualFile virtualFile, PsiElement psiElement, PsiFile psiFile) { - final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManagerEx.getInstance(project); - final Module module = ModuleUtil.findModuleForFile(virtualFile, project); + final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project); + final Module module = virtualFile != null ? ModuleUtil.findModuleForFile(virtualFile, project) : null; AnalysisScope analysisScope = null; if (psiFile != null) { analysisScope = new AnalysisScope(psiFile); } else { - if (virtualFile.isDirectory()) { + if (virtualFile != null && virtualFile.isDirectory()) { final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile); if (psiDirectory != null) { analysisScope = new AnalysisScope(psiDirectory); } } - if (analysisScope == null) { + if (analysisScope == null && virtualFile != null) { analysisScope = new AnalysisScope(project, Arrays.asList(virtualFile)); } + if (analysisScope == null) { + analysisScope = new AnalysisScope(project); + } } final FileFilterPanel fileFilterPanel = new FileFilterPanel(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index c7f968ab97f0..ac35d14d2cc4 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -27,6 +27,7 @@ import com.intellij.codeInspection.reference.*; import com.intellij.codeInspection.ui.InspectionResultsView; import com.intellij.concurrency.JobUtil; import com.intellij.lang.injection.InjectedLanguageManager; +import com.intellij.notification.NotificationGroup; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.PathMacroManager; @@ -42,7 +43,7 @@ import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectUtil; -import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -59,6 +60,7 @@ import com.intellij.ui.content.*; import com.intellij.util.Processor; import com.intellij.util.TripleFunction; import com.intellij.util.containers.HashMap; +import com.intellij.util.ui.UIUtil; import gnu.trove.THashMap; import gnu.trove.THashSet; import org.jdom.Document; @@ -67,7 +69,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -201,12 +202,9 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G }); myView = view; - ContentManager contentManager = getContentManager(); myContent = ContentFactory.SERVICE.getInstance().createContent(view, title, false); myContent.setDisposer(myView); - contentManager.addContent(myContent); - contentManager.setSelectedContent(myContent); ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.INSPECTION).activate(null); } @@ -423,14 +421,14 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G @Override public void onSuccess() { - SwingUtilities.invokeLater(new Runnable() { + UIUtil.invokeLaterIfNeeded(new Runnable() { public void run() { LOG.info("Code inspection finished"); if (myView != null) { if (!myView.update() && !getUIOptions().SHOW_ONLY_DIFF) { - Messages.showMessageDialog(myProject, InspectionsBundle.message("inspection.no.problems.message"), - InspectionsBundle.message("inspection.no.problems.dialog.title"), Messages.getInformationIcon()); + NotificationGroup.toolWindowGroup("Inspection Results", ToolWindowId.INSPECTION, true) + .createNotification(InspectionsBundle.message("inspection.no.problems.message"), MessageType.INFO).notify(myProject); close(true); } else { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index 6da46cf1adec..6cbbba6a4c2b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -426,11 +426,15 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, } public void disableToolByDefault(String toolId) { - getTools(toolId).getDefaultState().setEnabled(false); + getToolDefaultState(toolId).setEnabled(false); + } + + public ScopeToolState getToolDefaultState(String toolId) { + return getTools(toolId).getDefaultState(); } public void enableToolByDefault(String toolId) { - getTools(toolId).getDefaultState().setEnabled(true); + getToolDefaultState(toolId).setEnabled(true); } public boolean wasInitialized() { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java index b92dab9a6384..0dae656923cc 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java @@ -118,7 +118,7 @@ public class ProblemDescriptionNode extends InspectionTreeNode { if (descriptor == null) return ""; PsiElement element = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null; - return renderDescriptionMessage(descriptor, element, true).replaceAll("<[^>]*>", ""); + return renderDescriptionMessage(descriptor, element, true)/*.replaceAll("<[^>]*>", "")*/; } @NotNull diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java index e346f4a120ea..2810d5a32a68 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -181,7 +181,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider { .disableUpAction() .addExtraAction(new DeleteFromFavoritesAction() { { - getTemplatePresentation().setIcon(IconUtil.getRemoveRowIcon()); + getTemplatePresentation().setIcon(IconUtil.getRemoveIcon()); } @Override diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootModelImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootModelImpl.java index 139a086701f0..7978065cd240 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootModelImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootModelImpl.java @@ -82,7 +82,15 @@ public class RootModelImpl implements ModifiableRootModel { @NonNls private static final String ROOT_ELEMENT = "root"; private final ProjectRootManagerImpl myProjectRootManager; // have to register all child disposables using this fake object since all clients call just ModifiableModel.dispose() - private final Disposable myDisposable = Disposer.newDisposable(); + private final List myModelComponents = Collections.synchronizedList(new ArrayList()); + private final Disposable myDisposable = new Disposable() { + @Override + public void dispose() { + for (Disposable component : myModelComponents) { + Disposer.dispose(component); + } + } + }; RootModelImpl(@NotNull ModuleRootManagerImpl moduleRootManager, ProjectRootManagerImpl projectRootManager, VirtualFilePointerManager filePointerManager) { myModuleRootManager = moduleRootManager; @@ -96,7 +104,7 @@ public class RootModelImpl implements ModifiableRootModel { for (ModuleExtension extension : Extensions.getExtensions(ModuleExtension.EP_NAME, moduleRootManager.getModule())) { ModuleExtension model = extension.getModifiableModel(false); - Disposer.register(myDisposable, model); + registerOnDispose(model); myExtensions.add(model); } myConfigurationAccessor = new RootConfigurationAccessor(); @@ -162,7 +170,7 @@ public class RootModelImpl implements ModifiableRootModel { for (ModuleExtension extension : originalRootModel.myExtensions) { ModuleExtension model = extension.getModifiableModel(false); model.readExternal(element); - Disposer.register(myDisposable, model); + registerOnDispose(model); myExtensions.add(model); } myConfigurationAccessor = new RootConfigurationAccessor(); @@ -207,7 +215,7 @@ public class RootModelImpl implements ModifiableRootModel { for (ModuleExtension extension : rootModel.myExtensions) { ModuleExtension model = extension.getModifiableModel(writable); - Disposer.register(myDisposable, model); + registerOnDispose(model); myExtensions.add(model); } } @@ -912,6 +920,7 @@ public class RootModelImpl implements ModifiableRootModel { myExtensions.clear(); myWritable = false; myDisposed = true; + myModelComponents.clear(); } @Override @@ -1139,6 +1148,6 @@ public class RootModelImpl implements ModifiableRootModel { } void registerOnDispose(@NotNull Disposable disposable) { - Disposer.register(myDisposable, disposable); + myModelComponents.add(disposable); } } diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index ba2c682d3ecf..3fd374b320bf 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -1048,29 +1048,13 @@ public class SingleInspectionProfilePanel extends JPanel { for (int i = 0; rows != null && i < rows.length; i++) { final InspectionConfigTreeNode node = (InspectionConfigTreeNode)myTree.getPathForRow(rows[i]).getLastPathComponent(); final InspectionConfigTreeNode parent = (InspectionConfigTreeNode)node.getParent(); - if (node.getUserObject() instanceof Descriptor) { + final Object userObject = node.getUserObject(); + if (userObject instanceof Descriptor && (node.getScopeName() != null || node.isLeaf())) { updateErrorLevel(node, showOptionsAndDescriptorPanels, level); updateUpHierarchy(node, parent); } else { - node.isProperSetting = false; - for (int j = 0; j < node.getChildCount(); j++) { - final InspectionConfigTreeNode child = (InspectionConfigTreeNode)node.getChildAt(j); - if (child.getUserObject() instanceof Descriptor) { //group node - updateErrorLevel(child, showOptionsAndDescriptorPanels, level); - } - else { //root node - child.isProperSetting = false; - for (int k = 0; k < child.getChildCount(); k++) { - final InspectionConfigTreeNode descriptorNode = (InspectionConfigTreeNode)child.getChildAt(k); - if (descriptorNode.getUserObject() instanceof Descriptor) { - updateErrorLevel(descriptorNode, showOptionsAndDescriptorPanels, level); - } - child.isProperSetting |= descriptorNode.isProperSetting; - } - } - node.isProperSetting |= child.isProperSetting; - } + updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, node); updateUpHierarchy(node, parent); } } @@ -1083,6 +1067,23 @@ public class SingleInspectionProfilePanel extends JPanel { repaintTableData(); } + private void updateErrorLevelUpInHierarchy(HighlightDisplayLevel level, + boolean showOptionsAndDescriptorPanels, + InspectionConfigTreeNode node) { + node.isProperSetting = false; + for (int j = 0; j < node.getChildCount(); j++) { + final InspectionConfigTreeNode child = (InspectionConfigTreeNode)node.getChildAt(j); + final Object userObject = child.getUserObject(); + if (userObject instanceof Descriptor && (child.getScopeName() != null || child.isLeaf())) { + updateErrorLevel(child, showOptionsAndDescriptorPanels, level); + } + else { + updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, child); + } + node.isProperSetting |= child.isProperSetting; + } + } + private void updateErrorLevel(final InspectionConfigTreeNode child, final boolean showOptionsAndDescriptorPanels, final HighlightDisplayLevel level) { final HighlightDisplayKey key = child.getDesriptor().getKey(); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/AddScopeAction.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/AddScopeAction.java index ccc3f0817d40..67c9e658c90b 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/AddScopeAction.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/AddScopeAction.java @@ -59,13 +59,11 @@ public abstract class AddScopeAction extends AnAction { if (getSelectedProfile() == null) return; final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); if (project == null) return; - final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null); + final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null); + if (selectedNodes == null) return; final List descriptors = new ArrayList(); - for (InspectionConfigTreeNode node : nodes) { - final Descriptor descriptor = node.getDesriptor(); - if (descriptor != null && node.getScopeName() == null) { - descriptors.add(descriptor); - } + for (InspectionConfigTreeNode node : selectedNodes) { + collect(descriptors, new ArrayList(), node); } presentation.setEnabled(!getAvailableScopes(project, descriptors).isEmpty()); @@ -73,13 +71,13 @@ public abstract class AddScopeAction extends AnAction { @Override public void actionPerformed(AnActionEvent e) { - final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null); - List descriptors = new ArrayList(); - for (InspectionConfigTreeNode node : nodes) { - final Descriptor descriptor = node.getDesriptor(); - if (node.getScopeName() == null && descriptor != null) { - descriptors.add(descriptor); - } + final List descriptors = new ArrayList(); + final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null); + LOG.assertTrue(selectedNodes != null); + + final List nodes = new ArrayList(Arrays.asList(selectedNodes)); + for (InspectionConfigTreeNode node : selectedNodes) { + collect(descriptors, nodes, node); } final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); @@ -97,7 +95,7 @@ public abstract class AddScopeAction extends AnAction { getSelectedProfile().isToolEnabled(descriptor.getKey())); final Descriptor addedDescriptor = new Descriptor(scopeToolState, getSelectedProfile()); if (node.getChildCount() == 0) { - node.add(new InspectionConfigTreeNode(descriptor, scopeToolState, true, true, false)); + node.add(new InspectionConfigTreeNode(descriptor, getSelectedProfile().getToolDefaultState(descriptor.getKey().getID()), true, true, false)); } node.insert(new InspectionConfigTreeNode(addedDescriptor, scopeToolState, false, true, false), 0); node.setInspectionNode(false); @@ -108,6 +106,23 @@ public abstract class AddScopeAction extends AnAction { myTree.revalidate(); } + private static void collect(List descriptors, + List nodes, + InspectionConfigTreeNode node) { + final Descriptor descriptor = node.getDesriptor(); + if (descriptor != null) { + if (node.getScopeName() == null) { + descriptors.add(descriptor); + } + } else if (node.getUserObject() instanceof String) { + for(int i = 0; i < node.getChildCount(); i++) { + final InspectionConfigTreeNode childNode = (InspectionConfigTreeNode)node.getChildAt(i); + nodes.add(childNode); + collect(descriptors, nodes, childNode); + } + } + } + private List getAvailableScopes(Project project, List descriptors) { final ArrayList scopes = new ArrayList(); for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) { diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java index 55269e50ea8b..b21739065b53 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java @@ -53,7 +53,6 @@ import java.util.*; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class AbstractTreeUi { @@ -177,8 +176,7 @@ public class AbstractTreeUi { private SimpleTimerTask myCleanupTask; private final AtomicBoolean myCancelRequest = new AtomicBoolean(); - private final Lock myStateLock = new ReentrantLock(); - private final AtomicBoolean myLockWasAcquired = new AtomicBoolean(); + private final ReentrantLock myStateLock = new ReentrantLock(); private final AtomicBoolean myResettingToReadyNow = new AtomicBoolean(); @@ -1923,7 +1921,7 @@ public class AbstractTreeUi { @Nullable public Boolean _isReady(boolean attempt) { - if (attempt && myLockWasAcquired.get()) return false; + if (attempt && myStateLock.isLocked()) return false; Boolean ready = checkValue(new Computable() { @Override @@ -2414,21 +2412,17 @@ public class AbstractTreeUi { } private boolean attemptLock() throws InterruptedException { - myLockWasAcquired.set(myStateLock.tryLock(Registry.intValue("ide.tree.uiLockAttempt"), TimeUnit.MILLISECONDS)); - return myLockWasAcquired.get(); + return myStateLock.tryLock(Registry.intValue("ide.tree.uiLockAttempt"), TimeUnit.MILLISECONDS); } private void acquireLock() { myStateLock.lock(); - myLockWasAcquired.set(true); } private void releaseLock() { myStateLock.unlock(); - myLockWasAcquired.set(false); } - public ActionCallback batch(final Progressive progressive) { assertIsDispatchThread(); diff --git a/platform/platform-api/src/com/intellij/ui/CommonActionsPanel.java b/platform/platform-api/src/com/intellij/ui/CommonActionsPanel.java index 90ad2778d913..ba0ff5eef1d3 100644 --- a/platform/platform-api/src/com/intellij/ui/CommonActionsPanel.java +++ b/platform/platform-api/src/com/intellij/ui/CommonActionsPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -38,11 +38,11 @@ public class CommonActionsPanel extends JPanel { Icon getIcon() { switch (this) { - case ADD: return IconUtil.getAddRowIcon(); + case ADD: return IconUtil.getAddIcon(); case EDIT: return IconUtil.getEditIcon(); - case REMOVE: return IconUtil.getRemoveRowIcon(); - case UP: return IconUtil.getMoveRowUpIcon(); - case DOWN: return IconUtil.getMoveRowDownIcon(); + case REMOVE: return IconUtil.getRemoveIcon(); + case UP: return IconUtil.getMoveUpIcon(); + case DOWN: return IconUtil.getMoveDownIcon(); } return null; } diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index 99e225686c5b..ed706726980e 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -44,7 +44,6 @@ import com.intellij.util.containers.HashMap; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import sun.awt.event.IgnorePaintEvent; import javax.swing.*; import javax.swing.plaf.basic.ComboPopup; @@ -52,14 +51,10 @@ import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.text.SimpleDateFormat; import java.util.*; -import static java.awt.event.WindowEvent.*; - /** * @author Vladimir Kondratyev diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java index 5a516066e7b7..82fad28a4996 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java @@ -22,10 +22,10 @@ import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; import com.intellij.ide.passwordSafe.impl.providers.EncryptionUtil; import com.intellij.ide.passwordSafe.impl.providers.masterKey.windows.WindowsCryptUtils; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; -import com.intellij.util.WaitForProgressToShow; import java.io.UnsupportedEncodingException; import java.util.HashMap; @@ -182,7 +182,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider { } if (key.get() == null) { final Ref ex = new Ref(); - WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(new Runnable() { + ApplicationManager.getApplication().invokeAndWait(new Runnable() { public void run() { if (key.get() == null) { try { @@ -207,7 +207,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider { } } } - }); + }, ModalityState.NON_MODAL); //noinspection ThrowableResultOfMethodCallIgnored if (ex.get() != null) { throw ex.get(); diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.java index d83651858622..21254efc1ba6 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordSafePromptDialog.java @@ -18,6 +18,8 @@ package com.intellij.ide.passwordSafe.ui; import com.intellij.ide.passwordSafe.PasswordSafe; import com.intellij.ide.passwordSafe.PasswordSafeException; import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; @@ -271,7 +273,7 @@ public class PasswordSafePromptDialog extends DialogWrapper { } } final AtomicReference pw = new AtomicReference(null); - UIUtil.invokeAndWaitIfNeeded(new Runnable() { + ApplicationManager.getApplication().invokeAndWait(new Runnable() { public void run() { final PasswordSafePromptDialog d = new PasswordSafePromptDialog(project, ps, title, message); if (promptLabel != null) { @@ -299,7 +301,7 @@ public class PasswordSafePromptDialog extends DialogWrapper { } } } - }); + }, ModalityState.NON_MODAL); return pw.get(); } } diff --git a/platform/platform-impl/src/com/intellij/internal/tree/ExpandAll.java b/platform/platform-impl/src/com/intellij/internal/tree/ExpandAll.java new file mode 100644 index 000000000000..96de34321f31 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/tree/ExpandAll.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2012 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.internal.tree; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.util.ui.UIUtil; +import com.intellij.util.ui.tree.TreeUtil; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Konstantin Bulenkov + */ +public class ExpandAll extends AnAction { + @Override + public void actionPerformed(AnActionEvent e) { + final Component c = e.getData(PlatformDataKeys.CONTEXT_COMPONENT); + if (c != null) { + final JTree tree = UIUtil.getParentOfType(JTree.class, c); + if (tree != null) { + TreeUtil.expandAll(tree); + } + } + } +} diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java index 150f7bfaef26..7c06e6c39075 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -202,7 +202,7 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT }); - myRemoveButton = new AnActionButton(ApplicationBundle.message("button.remove"), IconUtil.getRemoveRowIcon()) { + myRemoveButton = new AnActionButton(ApplicationBundle.message("button.remove"), IconUtil.getRemoveIcon()) { @Override public void actionPerformed(AnActionEvent e) { removeSelected(); diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 8479f1c58c85..3fff505e0616 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -526,6 +526,7 @@ + diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java b/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java index 804a5b1ce008..2c82e4943aca 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/ShowAllAffectedGenericAction.java @@ -30,6 +30,7 @@ import com.intellij.openapi.vcs.changes.BackgroundFromStartOption; import com.intellij.openapi.vcs.history.ShortVcsRevisionNumber; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; +import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings; import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; @@ -55,11 +56,16 @@ public class ShowAllAffectedGenericAction extends AnAction { final VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION); VirtualFile revisionVirtualFile = e.getData(VcsDataKeys.VCS_VIRTUAL_FILE); if ((revision != null) && (revisionVirtualFile != null)) { - showSubmittedFiles(project, revision.getRevisionNumber(), revisionVirtualFile, vcsKey); + showSubmittedFiles(project, revision.getRevisionNumber(), revisionVirtualFile, vcsKey, revision.getChangedRepositoryPath()); } } public static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile, final VcsKey vcsKey) { + showSubmittedFiles(project, revision, virtualFile, vcsKey, null); + } + + private static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile, + final VcsKey vcsKey, final RepositoryLocation location) { final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName()); if (vcs == null) return; if (! isInLocalFSHack(virtualFile) && ! canPresentNonLocal(project, vcsKey, virtualFile)) return; @@ -81,12 +87,29 @@ public class ShowAllAffectedGenericAction extends AnAction { list[0] = pair.getFirst(); } } else { - final RepositoryLocation local = provider.getForNonLocal(virtualFile); - if (local != null) { - final List changes = provider.getCommittedChanges(provider.createDefaultSettings(), local, 1); + if (location != null) { + final ChangeBrowserSettings settings = provider.createDefaultSettings(); + settings.USE_CHANGE_BEFORE_FILTER = true; + settings.CHANGE_BEFORE = revision.asString(); + final List changes = provider.getCommittedChanges(settings, location, 1); if (changes != null && changes.size() == 1) { list[0] = changes.get(0); } + return; + } else { + final RepositoryLocation local = provider.getForNonLocal(virtualFile); + if (local != null) { + final String number = revision.asString(); + final ChangeBrowserSettings settings = provider.createDefaultSettings(); + final List changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue()); + if (changes != null) { + for (CommittedChangeList change : changes) { + if (number.equals(String.valueOf(change.getNumber()))) { + list[0] = change; + } + } + } + } } } } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/history/CurrentRevision.java b/platform/vcs-api/src/com/intellij/openapi/vcs/history/CurrentRevision.java index 352d86c45119..20e76a4ed96d 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/history/CurrentRevision.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/history/CurrentRevision.java @@ -18,6 +18,7 @@ package com.intellij.openapi.vcs.history; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; @@ -82,4 +83,9 @@ public class CurrentRevision implements VcsFileRevision { public String getBranchName() { return null; } + + @Override + public RepositoryLocation getChangedRepositoryPath() { + return null; // use initial url.. + } } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevision.java b/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevision.java index 22a3421eb897..cde1286f74f5 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevision.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevision.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.vcs.history; +import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.VcsException; import com.intellij.util.ArrayUtil; @@ -43,6 +44,11 @@ public interface VcsFileRevision extends VcsFileContent, VcsRevisionDescription return null; } + @Override + public RepositoryLocation getChangedRepositoryPath() { + return null; + } + public byte[] loadContent() throws IOException, VcsException { return getContent(); } @@ -57,4 +63,6 @@ public interface VcsFileRevision extends VcsFileContent, VcsRevisionDescription }; String getBranchName(); + + RepositoryLocation getChangedRepositoryPath(); } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionEx.java b/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionEx.java index 9a48f438e472..d7ba8e7fb68f 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionEx.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsFileRevisionEx.java @@ -29,5 +29,4 @@ public abstract class VcsFileRevisionEx implements VcsFileRevision { @Nullable public abstract String getCommitterEmail(); - } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/ui/TextFieldAction.java b/platform/vcs-api/src/com/intellij/openapi/vcs/ui/TextFieldAction.java index 51f14588f2c4..befd526c7f13 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/ui/TextFieldAction.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/ui/TextFieldAction.java @@ -34,6 +34,15 @@ public abstract class TextFieldAction extends AnAction implements CustomComponen myDescription = description; myIcon = icon; myField = new JTextField(initSize); + myField.addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + if ('\n' == e.getKeyChar()) { + e.consume(); + actionPerformed(null); + } + } + }); } public JComponent createCustomComponent(Presentation presentation) { @@ -66,29 +75,6 @@ public abstract class TextFieldAction extends AnAction implements CustomComponen actionPerformed(null); } }); - /*myField.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - actionPerformed(null); - } - });*/ - myField.addKeyListener(new KeyAdapter() { - @Override - public void keyTyped(KeyEvent e) { - reaction(e); - } - @Override - public void keyPressed(KeyEvent e) { - reaction(e); - } - }); return panel; } - - private void reaction(KeyEvent e) { - if ((KeyEvent.VK_ENTER == e.getKeyCode()) || ('\n' == e.getKeyChar())) { - e.consume(); - actionPerformed(null); - } - } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/DuringChangeListManagerUpdateTestScheme.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/DuringChangeListManagerUpdateTestScheme.java index fe4295ba504b..578ac75d7999 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/DuringChangeListManagerUpdateTestScheme.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/pending/DuringChangeListManagerUpdateTestScheme.java @@ -129,6 +129,10 @@ public class DuringChangeListManagerUpdateTestScheme { } public static void checkFilesAreInList(final VirtualFile[] files, final String listName, final ChangeListManager manager) { + checkFilesAreInList(listName, manager, files); + } + + public static void checkFilesAreInList(final String listName, final ChangeListManager manager, final VirtualFile... files) { System.out.println("Checking files for list: " + listName); assert manager.findChangeList(listName) != null; final LocalChangeList list = manager.findChangeList(listName); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowser.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowser.java index cb6c61738945..869ce5e21ee3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowser.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowser.java @@ -268,6 +268,10 @@ public class ChangesBrowser extends JPanel implements TypeSafeDataProvider { myViewer.setChangesToDisplay(getCurrentDisplayedChanges(), myToSelect); } + public void setAlwayExpandList(final boolean value) { + myViewer.setAlwaysExpandList(value); + } + private JComponent createToolbar() { DefaultActionGroup toolbarGroups = new DefaultActionGroup(); myToolBarGroup = new DefaultActionGroup(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java index 9afdb600452b..0e2a67525b70 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java @@ -43,6 +43,7 @@ import com.intellij.util.PlatformIcons; import com.intellij.util.containers.Convertor; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; +import gnu.trove.TIntArrayList; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -74,6 +75,7 @@ public abstract class ChangesTreeList extends JPanel { private final Collection myIncludedChanges; private Runnable myDoubleClickHandler = EmptyRunnable.getInstance(); + private boolean myAlwaysExpandList; @NonNls private static final String TREE_CARD = "Tree"; @NonNls private static final String LIST_CARD = "List"; @@ -94,6 +96,7 @@ public abstract class ChangesTreeList extends JPanel { myInclusionListener = inclusionListener; myChangeDecorator = decorator; myIncludedChanges = new HashSet(initiallyIncluded); + myAlwaysExpandList = true; myCards = new CardLayout(); @@ -311,21 +314,24 @@ public abstract class ChangesTreeList extends JPanel { return sortedChanges.get(index); } }); - for (int i = 0; i < sortedChanges.size(); i++) { - T t = sortedChanges.get(i); - if (wasSelected.contains(t)) { - myList.setSelectedIndex(i); - } - } final DefaultTreeModel model = buildTreeModel(changes, myChangeDecorator); TreeState state = null; - if (! wasEmpty) { + if (! myAlwaysExpandList && ! wasEmpty) { state = TreeState.createOn(myTree, (DefaultMutableTreeNode) myTree.getModel().getRoot()); } myTree.setModel(model); - if (! wasEmpty) { + if (! myAlwaysExpandList && ! wasEmpty) { state.applyTo(myTree, (DefaultMutableTreeNode) myTree.getModel().getRoot()); + + final TIntArrayList indices = new TIntArrayList(); + for (int i = 0; i < sortedChanges.size(); i++) { + T t = sortedChanges.get(i); + if (wasSelected.contains(t)) { + indices.add(i); + } + } + myList.setSelectedIndices(indices.toNativeArray()); return; } @@ -857,4 +863,8 @@ public abstract class ChangesTreeList extends JPanel { public void enableSelection(final boolean value) { myTree.setEnabled(value); } + + public void setAlwaysExpandList(boolean alwaysExpandList) { + myAlwaysExpandList = alwaysExpandList; + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 9089fe523273..e0fce56a2897 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -270,6 +270,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } }; myBrowser = browser; + myBrowser.setAlwayExpandList(false); myBrowserExtender = browser.getExtender(); } myDiffDetails.setParent(myBrowser); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index 5b7f7eea5286..97f97876e853 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -1337,6 +1337,11 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { } } + @Override + public RepositoryLocation getChangedRepositoryPath() { + return myRevision.getChangedRepositoryPath(); + } + public VcsFileRevision getRevision() { return myRevision; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index 0a8f5c42d78b..013f1a273a15 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1879,8 +1879,8 @@ unqualified.inner.class.access.option=Ignore references to local inner classes try.with.identical.catches.quickfix=Collapse catch blocks into multi-catch confusing.else.option=Also report when there are no more statements after the 'if' statement html.tag.can.be.javadoc.tag.display.name=... can be replaced with {@code ...} -html.tag.can.be.javadoc.tag.problem.descriptor1=#ref...</code> can be replaced with '{@code ...}' #loc -html.tag.can.be.javadoc.tag.problem.descriptor2=<code>...#ref can be replaced with '{@code ...}' #loc +html.tag.can.be.javadoc.tag.problem.descriptor1=#ref...\\</code\\> can be replaced with '{@code ...}' #loc +html.tag.can.be.javadoc.tag.problem.descriptor2=\\<code\\>...#ref can be replaced with '{@code ...}' #loc html.tag.can.be.javadoc.tag.quickfix=Replace with '{@code ...}' try.finally.can.be.try.with.resources.display.name='try finally' replaceable with 'try' with resources try.finally.can.be.try.with.resources.problem.descriptor=#ref can use automatic resource management #loc diff --git a/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.java b/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.java index 376a1c31d777..7ca98102182b 100644 --- a/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.java +++ b/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -477,7 +477,7 @@ public abstract class AndroidLogcatToolWindowView implements Disposable { private class MyAddFilterAction extends AnAction { private MyAddFilterAction() { - super(CommonBundle.message("button.add"), AndroidBundle.message("android.logcat.add.logcat.filter.button"), IconUtil.getAddRowIcon()); + super(CommonBundle.message("button.add"), AndroidBundle.message("android.logcat.add.logcat.filter.button"), IconUtil.getAddIcon()); } @Override @@ -503,7 +503,7 @@ public abstract class AndroidLogcatToolWindowView implements Disposable { private class MyRemoveFilterAction extends AnAction { private MyRemoveFilterAction() { super(CommonBundle.message("button.delete"), AndroidBundle.message("android.logcat.remove.logcat.filter.button"), - IconUtil.getRemoveRowIcon()); + IconUtil.getRemoveIcon()); } @Override diff --git a/plugins/android/src/org/jetbrains/android/uipreview/LayoutDeviceConfigurationsDialog.java b/plugins/android/src/org/jetbrains/android/uipreview/LayoutDeviceConfigurationsDialog.java index eb15f0aa6630..55f07edac269 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/LayoutDeviceConfigurationsDialog.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/LayoutDeviceConfigurationsDialog.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 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 org.jetbrains.android.uipreview; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -72,7 +87,7 @@ public class LayoutDeviceConfigurationsDialog extends DialogWrapper { AnActionButton addButton = new AnActionButton(AndroidBundle.message("android.layout.preview.device.configurations.dialog.add.button"), null, - IconUtil.getAddRowIcon()) { + IconUtil.getAddIcon()) { @Override public void actionPerformed(AnActionEvent e) { doAdd(); @@ -90,7 +105,7 @@ public class LayoutDeviceConfigurationsDialog extends DialogWrapper { myEditButton.setShortcut(CustomShortcutSet.fromString("alt E")); myRemoveButton = new AnActionButton(AndroidBundle.message("android.layout.preview.device.configurations.dialog.remove.button"), null, - IconUtil.getRemoveRowIcon()) { + IconUtil.getRemoveIcon()) { @Override public void actionPerformed(AnActionEvent e) { doRemove(); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/annotate/CvsAnnotationProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/annotate/CvsAnnotationProvider.java index 9a57ee13d916..e924dd5e9d3c 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/annotate/CvsAnnotationProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/annotate/CvsAnnotationProvider.java @@ -30,6 +30,7 @@ import com.intellij.cvsSupport2.history.CvsRevisionNumber; import com.intellij.openapi.cvsIntegration.CvsResult; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vcs.annotate.AnnotationProvider; @@ -190,6 +191,11 @@ public class CvsAnnotationProvider implements AnnotationProvider{ return null; } + @Override + public RepositoryLocation getChangedRepositoryPath() { + return null; + } + public byte[] loadContent() throws IOException, VcsException { return getContent(); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/ComparableVcsRevisionOnOperation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/ComparableVcsRevisionOnOperation.java index 4ba3860ad1d3..cca941083018 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/ComparableVcsRevisionOnOperation.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/ComparableVcsRevisionOnOperation.java @@ -24,6 +24,7 @@ import com.intellij.openapi.cvsIntegration.CvsResult; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; @@ -102,4 +103,8 @@ public class ComparableVcsRevisionOnOperation implements VcsFileRevision { return null; } + @Override + public RepositoryLocation getChangedRepositoryPath() { + return null; + } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsFileRevisionImpl.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsFileRevisionImpl.java index eb57c5c8d049..85fc97da9bcd 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsFileRevisionImpl.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsFileRevisionImpl.java @@ -20,6 +20,7 @@ import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation import com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import org.netbeans.lib.cvsclient.command.log.LogInformation; import org.netbeans.lib.cvsclient.command.log.Revision; @@ -124,6 +125,11 @@ public class CvsFileRevisionImpl extends CvsFileContent implements CvsFileRevisi return myCvsRevision.getState(); } + @Override + public RepositoryLocation getChangedRepositoryPath() { + return null; + } + public Collection getTags() { if (myTags == null) { myTags = myLogInformation == null ? Collections.emptyList() : collectSymNamesForRevision(); diff --git a/plugins/git4idea/src/git4idea/GitFileRevision.java b/plugins/git4idea/src/git4idea/GitFileRevision.java index a9a6a3e3683b..9b8d05d59974 100644 --- a/plugins/git4idea/src/git4idea/GitFileRevision.java +++ b/plugins/git4idea/src/git4idea/GitFileRevision.java @@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Throwable2Computable; import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsFileRevisionDvcsSpecific; @@ -79,6 +80,11 @@ public class GitFileRevision extends VcsFileRevisionEx implements Comparable repositories = new HashMap(myRepositories); final VirtualFile[] roots = myVcsManager.getRootsUnderVcs(myVcs); // remove repositories that are not in the roots anymore - for (Iterator> iterator = myRepositories.entrySet().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = repositories.entrySet().iterator(); iterator.hasNext(); ) { if (!ArrayUtil.contains(iterator.next().getValue().getRoot(), roots)) { iterator.remove(); } } // add GitRepositories for all roots that don't have correspondent GitRepositories yet. for (VirtualFile root : roots) { - if (!myRepositories.containsKey(root)) { + if (!repositories.containsKey(root)) { if (gitRootOK(root)) { try { GitRepository repository = createGitRepository(root); - myRepositories.put(root, repository); + repositories.put(root, repository); } catch (GitRepoStateException e) { LOG.error("Couldn't initialize GitRepository in " + root.getPresentableUrl(), e); @@ -170,6 +169,11 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement } } } + + REPO_LOCK.writeLock().lock(); + try { + myRepositories.clear(); + myRepositories.putAll(repositories); } finally { REPO_LOCK.writeLock().unlock(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyMarkerTypes.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyMarkerTypes.java index 17858dc94695..2ccadd1a866b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyMarkerTypes.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GroovyMarkerTypes.java @@ -333,14 +333,17 @@ public class GroovyMarkerTypes { } @Override - public void run(@NotNull ProgressIndicator indicator) { + public void run(final @NotNull ProgressIndicator indicator) { super.run(indicator); for (PsiMethod method : PsiImplUtil.getMethodOrReflectedMethods(myMethod)) { OverridingMethodsSearch.search(method, true).forEach( new CommonProcessors.CollectProcessor() { @Override public boolean process(PsiMethod psiMethod) { - updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod), myRenderer.getComparator()); + if (!updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod), myRenderer.getComparator())) { + indicator.cancel(); + } + indicator.checkCanceled(); return true; } }); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java index cf293b66cb19..b42bf1cceec7 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java @@ -43,6 +43,7 @@ import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.psi.GrQualifiedReference; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase; +import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap; import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement; @@ -312,9 +313,10 @@ public class GroovyBlockGenerator implements GroovyElementTypes { } return blockPsi instanceof GrParameterList && mySettings.ALIGN_MULTILINE_PARAMETERS || - blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST || - blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST || - blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION; + blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST || + blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST || + blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION || + blockPsi instanceof GrListOrMap && myGroovySettings.ALIGN_MULTILINE_LIST_OR_MAP; } private static boolean isListLikeClause(PsiElement blockPsi) { @@ -323,7 +325,8 @@ public class GroovyBlockGenerator implements GroovyElementTypes { blockPsi instanceof GrAssignmentExpression || blockPsi instanceof GrConditionalExpression || blockPsi instanceof GrExtendsClause || - blockPsi instanceof GrThrowsClause; + blockPsi instanceof GrThrowsClause || + blockPsi instanceof GrListOrMap; } private static boolean isKeyword(ASTNode node) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyCodeStyleSettings.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyCodeStyleSettings.java index ccdc49a58b69..895f178c762a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyCodeStyleSettings.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyCodeStyleSettings.java @@ -42,6 +42,7 @@ public class GroovyCodeStyleSettings extends CustomCodeStyleSettings { public boolean USE_FLYING_GEESE_BRACES = false; public boolean SPACE_IN_NAMED_ARGUMENT = true; + public boolean ALIGN_MULTILINE_LIST_OR_MAP = false; public GroovyCodeStyleSettings(CodeStyleSettings container) { super("GroovyCodeStyleSettings", container); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyLanguageCodeStyleSettingsProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyLanguageCodeStyleSettingsProvider.java index 828e9939cae2..6cd8df934c1a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyLanguageCodeStyleSettingsProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyLanguageCodeStyleSettingsProvider.java @@ -44,6 +44,7 @@ public class GroovyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSe if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) { consumer.showAllStandardOptions(); consumer.showCustomOption(GroovyCodeStyleSettings.class, "USE_FLYING_GEESE_BRACES", "Use flying geese braces", CodeStyleSettingsCustomizable.WRAPPING_BRACES); + consumer.showCustomOption(GroovyCodeStyleSettings.class, "ALIGN_MULTILINE_LIST_OR_MAP", "Align when multiple", "List and map literals"); return; } if (settingsType == SettingsType.SPACING_SETTINGS) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java index 3272fd5d8b92..a2d41525e024 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java @@ -133,9 +133,14 @@ public abstract class GroovyIndentProcessor implements GroovyElementTypes { // For arguments if (psiParent instanceof GrArgumentList) { - if (child.getElementType() != mLPAREN && - child.getElementType() != mRPAREN) { - return Indent.getContinuationIndent(); + if (child.getElementType() != mLPAREN && child.getElementType() != mRPAREN /*&& child.getElementType() != mCOMMA*/) { + return Indent.getContinuationWithoutFirstIndent(); + } + } + + if (psiParent instanceof GrListOrMap) { + if (child.getElementType() != mLBRACK && child.getElementType() != mRBRACK /*&& child.getElementType() != mCOMMA*/) { + return Indent.getContinuationWithoutFirstIndent(); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/GroovyQuoteHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/GroovyQuoteHandler.java index f9627d34b3f9..aed89f37e90d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/GroovyQuoteHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/editor/GroovyQuoteHandler.java @@ -16,16 +16,19 @@ package org.jetbrains.plugins.groovy.lang.editor; -import com.intellij.codeInsight.editorActions.QuoteHandler; +import com.intellij.codeInsight.editorActions.MultiCharQuoteHandler; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.highlighter.HighlighterIterator; +import com.intellij.openapi.util.TextRange; import com.intellij.psi.tree.IElementType; + import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*; /** * @author ven */ -public class GroovyQuoteHandler implements QuoteHandler { +public class GroovyQuoteHandler implements MultiCharQuoteHandler { public boolean isClosingQuote(HighlighterIterator iterator, int offset) { final IElementType tokenType = iterator.getTokenType(); @@ -42,7 +45,7 @@ public class GroovyQuoteHandler implements QuoteHandler { public boolean isOpeningQuote(HighlighterIterator iterator, int offset) { final IElementType tokenType = iterator.getTokenType(); - if (tokenType== mGSTRING_BEGIN) return true; + if (tokenType == mGSTRING_BEGIN) return true; if (tokenType == mGSTRING_LITERAL || tokenType == mSTRING_LITERAL) { int start = iterator.getStart(); return offset == start; @@ -58,4 +61,16 @@ public class GroovyQuoteHandler implements QuoteHandler { final IElementType tokenType = iterator.getTokenType(); return tokenType == mSTRING_LITERAL || tokenType == mGSTRING_LITERAL; } + + @Override + public CharSequence getClosingQuote(HighlighterIterator iterator, int offset) { + if (offset >= 3) { + Document document = iterator.getDocument(); + if (document == null) return null; + String quote = document.getText(new TextRange(offset - 3, offset)); + if ("'''".equals(quote)) return quote; + if ("\"\"\"".equals(quote)) return quote; + } + return null; + } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java index 284f16b28238..92bf319c941d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java @@ -16,7 +16,6 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic; import com.intellij.navigation.ItemPresentation; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.ElementPresentationUtil; import com.intellij.psi.impl.PsiClassImplUtil; @@ -438,29 +437,6 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod { return copy; } - public static GrLightMethodBuilder wrap(PsiMethod method) { - GrLightMethodBuilder res = new GrLightMethodBuilder(method.getManager(), method.getName()); - - res.setReturnType(method.getReturnType()); - res.setNavigationElement(method.getNavigationElement()); - - res.setContainingClass(method.getContainingClass()); - - res.getModifierList().copyModifiers(method); - - for (PsiParameter parameter : method.getParameterList().getParameters()) { - GrLightParameter p = new GrLightParameter(StringUtil.notNullize(parameter.getName()), parameter.getType(), res); - - if (parameter instanceof GrParameter) { - p.setOptional(((GrParameter)parameter).isOptional()); - } - - res.addParameter(p); - } - - return res; - } - public T getData() { //noinspection unchecked return (T)myData; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java new file mode 100644 index 000000000000..3c69b0a195cd --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2012 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 org.jetbrains.plugins.groovy.lang.psi.impl.synthetic; + +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; + +/** + * @author Sergey Evdokimov + */ +public class GrMethodWrapper extends GrLightMethodBuilder { + + private static PsiType TYPE_MARKER = new PsiPrimitiveType("xxx", PsiAnnotation.EMPTY_ARRAY); + + private volatile boolean myNavigationElementInit; + + private final PsiMethod myWrappedMethod; + + private GrMethodWrapper(PsiMethod method) { + super(method.getManager(), method.getName()); + + myWrappedMethod = method; + + setContainingClass(method.getContainingClass()); + + getModifierList().copyModifiers(method); + + for (PsiParameter parameter : method.getParameterList().getParameters()) { + GrLightParameter p = new GrLightParameter(StringUtil.notNullize(parameter.getName()), parameter.getType(), this); + + if (parameter instanceof GrParameter) { + p.setOptional(((GrParameter)parameter).isOptional()); + } + + addParameter(p); + } + + setReturnType(TYPE_MARKER); + } + + @Override + public void setNavigationElement(@NotNull PsiElement navigationElement) { + myNavigationElementInit = true; + super.setNavigationElement(navigationElement); + } + + @NotNull + @Override + public PsiElement getNavigationElement() { + if (!myNavigationElementInit) { + setNavigationElement(myWrappedMethod.getNavigationElement()); // getNavigationElement() can get long time if wrapped method is a ClsMethod. + } + return super.getNavigationElement(); + } + + @Override + public PsiType getReturnType() { + PsiType type = super.getReturnType(); + if (type == TYPE_MARKER) { + type = myWrappedMethod.getReturnType(); + super.setReturnType(type); + } + + return type; + } + + @Override + public boolean isValid() { + if (myNavigationElementInit) { + return super.isValid(); // This will call isValid() on navigationElement + } + + return myWrappedMethod.isValid(); + } + + public static GrMethodWrapper wrap(@NotNull PsiMethod method) { + return new GrMethodWrapper(method); + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java index 322e4c2a55fe..94a07495c812 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/StubGenerator.java @@ -380,7 +380,11 @@ public class StubGenerator implements ClassItemGenerator { return eval.toString() + "f"; } else if (eval instanceof Character) { - return "'" + ((Character)eval).charValue() + "'"; + StringBuilder buffer = new StringBuilder(); + buffer.append('\''); + StringUtil.escapeStringCharacters(1, Character.toString(((Character)eval).charValue()), buffer); + buffer.append('\''); + return buffer.toString(); } if (eval instanceof Number || eval instanceof Boolean) { return eval.toString(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java index 603676b3e831..b28f22f907b3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java @@ -28,6 +28,7 @@ import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierFlags; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder; +import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrMethodWrapper; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; @@ -169,7 +170,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu private void registerExplicitMethod(String name, String realMethodName) { for (PsiMethod method : mySwingBuilderClass.findMethodsByName(realMethodName, false)) { - add(GrLightMethodBuilder.wrap(method)); + add(GrMethodWrapper.wrap(method)); } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy index 2f13efb141e7..cf6055d4bc69 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy @@ -33,6 +33,8 @@ import com.intellij.debugger.ui.DebuggerPanelsManager import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor import com.intellij.debugger.ui.tree.render.DescriptorLabelListener import com.intellij.execution.executors.DefaultDebugExecutor +import com.intellij.execution.process.OSProcessHandler +import com.intellij.execution.process.OSProcessManager import com.intellij.execution.process.ProcessAdapter import com.intellij.execution.runners.ProgramRunner import com.intellij.openapi.Disposable @@ -47,8 +49,6 @@ import com.intellij.testFramework.builders.JavaModuleFixtureBuilder import com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl import com.intellij.util.SystemProperties import com.intellij.util.concurrency.Semaphore -import com.intellij.execution.process.OSProcessManager -import com.intellij.execution.process.OSProcessHandler /** * @author peter @@ -241,6 +241,23 @@ new Runnable() { } } + void testEvalInStaticMethod() { + myFixture.addFileToProject('Foo.groovy', '''\ +static def foo() { + int x = 5 + print x +} + +foo() + +''') + addBreakpoint 'Foo.groovy', 2 + runDebugger 'Foo', { + waitForBreakpoint() + eval 'x', '5' + } + } + private def addBreakpoint(String fileName, int line) { VirtualFile file = null edt { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyEditingTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyEditingTest.groovy similarity index 75% rename from plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyEditingTest.java rename to plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyEditingTest.groovy index b5770b61e56b..e3363395ef92 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyEditingTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyEditingTest.groovy @@ -15,8 +15,9 @@ */ package org.jetbrains.plugins.groovy.lang; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -import org.jetbrains.plugins.groovy.util.TestUtils; + +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import org.jetbrains.plugins.groovy.util.TestUtils /** * @author peter @@ -24,12 +25,12 @@ import org.jetbrains.plugins.groovy.util.TestUtils; public class GroovyEditingTest extends LightCodeInsightFixtureTestCase { @Override protected String getBasePath() { - return TestUtils.getTestDataPath() + "editing/"; + return TestUtils.testDataPath + "editing/"; } - private void doTest(final char c) throws Throwable { + private void doTest(final String c) { myFixture.configureByFile(getTestName(false) + ".groovy"); - myFixture.type(c); + myFixture.type(c as char); myFixture.checkResultByFile(getTestName(false) + "_after.groovy"); } @@ -43,4 +44,20 @@ public class GroovyEditingTest extends LightCodeInsightFixtureTestCase { public void testPairAngleBracketAfterClassNameOvertype() throws Throwable {doTest('>');} public void testPairAngleBracketAfterClassNameBackspace() throws Throwable {doTest('\b');} public void testNoPairLess() throws Throwable {doTest('<');} + + public void testTripleString() { + myFixture.configureByText('_.groovy', '') + myFixture.type('\'') + myFixture.type('\'') + myFixture.type('\'') + myFixture.checkResult("''''''") + } + + public void testTripleGString() { + myFixture.configureByText('_.groovy', '') + myFixture.type('"') + myFixture.type('"') + myFixture.type('"') + myFixture.checkResult('""""""') + } } \ No newline at end of file diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgFileRevision.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgFileRevision.java index 7da1bf262579..b1d0c085874f 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgFileRevision.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgFileRevision.java @@ -14,6 +14,7 @@ package org.zmlx.hg4idea; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Throwable2Computable; +import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.impl.ContentRevisionCache; @@ -67,6 +68,11 @@ public class HgFileRevision implements VcsFileRevision { return branchName; } + @Override + public RepositoryLocation getChangedRepositoryPath() { + return null; + } + public Date getRevisionDate() { return revisionDate; } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java index abb177cb9160..aa34ea474344 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenExtensionCompletionAndResolutionTest.java @@ -19,6 +19,9 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiReference; import org.jetbrains.idea.maven.indices.MavenIndicesTestFixture; +import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager; + +import java.util.List; public class MavenExtensionCompletionAndResolutionTest extends MavenDomWithIndicesTestCase { @Override @@ -65,7 +68,15 @@ public class MavenExtensionCompletionAndResolutionTest extends MavenDomWithIndic " " + ""); - assertCompletionVariants(myProjectPom, "maven-compiler-plugin", "maven-war-plugin", "maven-eclipse-plugin", "maven-surefire-plugin"); + List actual = getCompletionVariants(myProjectPom); + + if (actual.isEmpty()) { + MavenProjectIndicesManager instance = MavenProjectIndicesManager.getInstance(myProject); + System.out.println("GetArtifacts: " + instance.getArtifactIds("org.apache.maven.plugins")); + System.out.println("Indexes: " + instance.getIndices()); + } + + assertUnorderedElementsAreEqual(actual, "maven-compiler-plugin", "maven-war-plugin", "maven-eclipse-plugin", "maven-surefire-plugin"); } public void testArtifactWithoutGroupCompletion() throws Exception { diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java b/plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java index 6b3bcc3c84ba..ccfd3f9c40ec 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java @@ -32,7 +32,7 @@ import java.util.ArrayList; import java.util.List; public class SpellCheckerSeveritiesProvider extends SeveritiesProvider { - public static final HighlightSeverity TYPO = new HighlightSeverity("TYPO", 10); + public static final HighlightSeverity TYPO = new HighlightSeverity("TYPO", HighlightSeverity.INFORMATION.myVal + 5); public List getSeveritiesHighlightInfoTypes() { final List result = new ArrayList(); diff --git a/plugins/svn4idea/lib/svnkit-javahl.jar b/plugins/svn4idea/lib/svnkit-javahl.jar index a66f21499005..0aabf3462f36 100644 Binary files a/plugins/svn4idea/lib/svnkit-javahl.jar and b/plugins/svn4idea/lib/svnkit-javahl.jar differ diff --git a/plugins/svn4idea/lib/svnkit-javahl16.zip b/plugins/svn4idea/lib/svnkit-javahl16.zip index a193f534b68b..42fc82b86df2 100644 Binary files a/plugins/svn4idea/lib/svnkit-javahl16.zip and b/plugins/svn4idea/lib/svnkit-javahl16.zip differ diff --git a/plugins/svn4idea/lib/svnkit.jar b/plugins/svn4idea/lib/svnkit.jar index 642f90938186..9294dd66d028 100644 Binary files a/plugins/svn4idea/lib/svnkit.jar and b/plugins/svn4idea/lib/svnkit.jar differ diff --git a/plugins/svn4idea/lib/svnkitsrc.zip b/plugins/svn4idea/lib/svnkitsrc.zip index 61576fc60b78..9f52a04c8f0a 100644 Binary files a/plugins/svn4idea/lib/svnkitsrc.zip and b/plugins/svn4idea/lib/svnkitsrc.zip differ diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java index 2ce6697a14fe..e1051620339e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java @@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Throwable2Computable; +import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vcs.history.VcsFileRevision; @@ -115,6 +116,11 @@ public class SvnFileRevision implements VcsFileRevision { return null; } + @Override + public RepositoryLocation getChangedRepositoryPath() { + return new SvnRepositoryLocation(myURL); + } + public Date getRevisionDate() { return myDate; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java index ae4d715969ea..776ab11bef5d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java @@ -58,6 +58,7 @@ import java.nio.charset.Charset; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Map; public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHistorySessionFactory { private final SvnVcs myVcs; @@ -522,7 +523,7 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto private final SVNRevision myPegRevision; protected final String myUrl; private final SvnMergeSourceTracker myTracker; - private SVNURL myRepositoryRoot; + protected SVNURL myRepositoryRoot; public MyLogEntryHandler(SvnVcs vcs, final String url, final SVNRevision pegRevision, @@ -567,9 +568,11 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto } final int mergeLevel = svnLogEntryIntegerPair.getSecond(); - final SvnFileRevision revision = createRevision(logEntry, copyPath); + final SvnFileRevision revision = createRevision(logEntry, copyPath, entryPath); if (copyPath != null) { myLastPath = copyPath; + } else { + myLastPath = correctLastPathAccordingToFolderRenames(myLastPath, logEntry); } if (mergeLevel >= 0) { addToListByLevel((SvnFileRevision) myPrevious, revision, mergeLevel); @@ -578,9 +581,26 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto myPrevious = revision; } } + }); } + private String correctLastPathAccordingToFolderRenames(String lastPath, SVNLogEntry logEntry) { + final Map paths = logEntry.getChangedPaths(); + for (Map.Entry entry : paths.entrySet()) { + final SVNLogEntryPath value = entry.getValue(); + final String copyPath = value.getCopyPath(); + if (copyPath != null) { + final String entryPath = value.getPath(); + if (SVNPathUtil.isAncestor(entryPath, lastPath)) { + final String relativePath = SVNPathUtil.getRelativePath(entryPath, lastPath); + return SVNPathUtil.append(copyPath, relativePath); + } + } + } + return lastPath; + } + public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { myTracker.consume(logEntry); } @@ -599,12 +619,13 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto } } - protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath) throws SVNException { + protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath, SVNLogEntryPath entryPath) throws SVNException { Date date = logEntry.getDate(); String author = logEntry.getAuthor(); String message = logEntry.getMessage(); SVNRevision rev = SVNRevision.create(logEntry.getRevision()); - final SVNURL url = myRepositoryRoot.appendPath(myLastPath, true); +// final SVNURL url = myRepositoryRoot.appendPath(myLastPath, true); + final SVNURL url = myRepositoryRoot.appendPath(entryPath.getPath(), true); return new SvnFileRevision(myVcs, myPegRevision, rev, url.toString(), author, date, message, copyPath, myCharset); } } @@ -619,10 +640,12 @@ public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto super(vcs, url, pegRevision, lastPath, result, repoRootURL, null); } - /*@Override - protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath) { - return new SvnFileRevision(myVcs, SVNRevision.UNDEFINED, logEntry, myUrl, copyPath, null); - }*/ + @Override + protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath, SVNLogEntryPath entryPath) + throws SVNException { + final SVNURL url = myRepositoryRoot.appendPath(entryPath.getPath(), true); + return new SvnFileRevision(myVcs, SVNRevision.UNDEFINED, logEntry, url.toString(), copyPath, null); + } } private class MergeSourceColumnInfo extends ColumnInfo {