diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant index 79a45061194b..e23b893019c4 100644 --- a/build/scripts/layouts.gant +++ b/build/scripts/layouts.gant @@ -62,7 +62,6 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir "remote-servers-api", "remote-servers-java-api", "testFramework-java", - "xml-analysis-api", ].flatten() //noinspection GroovyAssignabilityCheck @@ -78,6 +77,7 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir "java-indexing-impl", "java-impl", "java-psi-impl", + "js-analysis-impl", "jsp-spi", "manifest", "platform-main", @@ -85,7 +85,6 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir "remote-servers-java-impl", "testFramework", "tests_bootstrap", - "xml-analysis-impl", ].flatten() ant.patternset(id: "resources.included") { diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index f49a5676080e..a89c0760ba4f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -2359,6 +2359,9 @@ public class CompileDriver { } private boolean executeCompileTasks(final CompileContext context, final boolean beforeTasks) { + if (myProject.isDisposed()) { + return false; + } final CompilerManager manager = CompilerManager.getInstance(myProject); final ProgressIndicator progressIndicator = context.getProgressIndicator(); progressIndicator.pushState(); diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java index 07fb487dbcba..216f03b750d6 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java @@ -157,7 +157,9 @@ public class ProblemsViewImpl extends ProblemsView{ ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { - ToolWindowManager.getInstance(myProject).getToolWindow(PROBLEMS_TOOLWINDOW_ID).setIcon(active ? myActiveIcon : myPassiveIcon); + final ToolWindowManager twManager = ToolWindowManager.getInstance(myProject); + final ToolWindow tw = twManager.getToolWindow(PROBLEMS_TOOLWINDOW_ID); + tw.setIcon(active ? myActiveIcon : myPassiveIcon); } }, myProject.getDisposed()); } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java index 89db0d034edc..b947271d47e8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/requests/RequestManagerImpl.java @@ -302,7 +302,7 @@ public class RequestManagerImpl extends DebugProcessAdapterImpl implements Reque //there could be no requests after hotswap } else { - LOG.error(e); + LOG.info(e); } } } diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java index 345637ba9efd..55ad817e843c 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java @@ -98,9 +98,21 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy { public List nestedTypes(ReferenceType refType) { List nestedTypes = myNestedClassesCache.get(refType); if (nestedTypes == null) { - final List list = refType.nestedTypes(); - final int size = list.size(); - if (size > 0) { + List list = Collections.emptyList(); + try { + list = refType.nestedTypes(); + } + catch (Throwable e) { + // sometimes some strange errors are thrown from JDI. Do not crash debugger because of this. + // Example: + //java.lang.StringIndexOutOfBoundsException: String index out of range: 487700285 + // at java.lang.String.checkBounds(String.java:375) + // at java.lang.String.(String.java:415) + // at com.sun.tools.jdi.PacketStream.readString(PacketStream.java:392) + // at com.sun.tools.jdi.JDWP$VirtualMachine$AllClassesWithGeneric$ClassInfo.(JDWP.java:1644) + LOG.info(e); + } + if (!list.isEmpty()) { final Set candidates = new HashSet(); final ClassLoaderReference outerLoader = refType.classLoader(); for (ReferenceType nested : list) { diff --git a/java/java-impl/src/com/intellij/lang/java/JavaFindUsagesProvider.java b/java/java-impl/src/com/intellij/lang/java/JavaFindUsagesProvider.java index 2a69d6fdc898..75acbeb25251 100644 --- a/java/java-impl/src/com/intellij/lang/java/JavaFindUsagesProvider.java +++ b/java/java-impl/src/com/intellij/lang/java/JavaFindUsagesProvider.java @@ -1,8 +1,5 @@ /* - -import com.intellij.lang.findUsages.FindUsagesProvider; - -* Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -70,7 +67,7 @@ public class JavaFindUsagesProvider implements FindUsagesProvider { if (ThrowSearchUtil.isSearchable(element)) { return HelpID.FIND_THROW_USAGES; } - return HelpID.FIND_OTHER_USAGES; + return com.intellij.lang.HelpID.FIND_OTHER_USAGES; } @Override diff --git a/java/java-impl/src/com/intellij/psi/impl/source/PsiCodeFragmentImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/PsiCodeFragmentImpl.java index a281f2725bab..c4b4401012a4 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/PsiCodeFragmentImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/PsiCodeFragmentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -283,7 +283,7 @@ public class PsiCodeFragmentImpl extends PsiFileImpl implements JavaCodeFragment } @Override - public void setIntentionActionsFilter(final IntentionActionsFilter filter) { + public void setIntentionActionsFilter(@NotNull final IntentionActionsFilter filter) { myIntentionActionsFilter = filter; } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceParameterTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceParameterTest.java index 5be5dad1c1a1..697b42314e3e 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceParameterTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceParameterTest.java @@ -122,7 +122,7 @@ public class InplaceIntroduceParameterTest extends AbstractJavaInplaceIntroduceT }); } catch (BaseRefactoringProcessor.ConflictsInTestsException e) { - assertEquals("There is already a parameter p. It will conflict with an introduced parameter", e.getMessage()); + assertEquals("There is already a parameter p. It will conflict with the introduced parameter", e.getMessage()); return; } fail("Conflict expected"); diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager.java b/jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager.java index 2408290a3f4a..c63614e17895 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager.java +++ b/jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager.java @@ -44,10 +44,12 @@ class OptimizedFileManager extends DefaultFileManager { private boolean myUseZipFileIndex; private final Map myArchives; private final Map myIsFile = new HashMap(); - private final Map> myContentCache = new HashMap>(); private final Map myDirectoryCache = new HashMap(); public static final File[] NULL_FILE_ARRAY = new File[0]; + private static final boolean ourUseContentCache = Boolean.valueOf(System.getProperty("javac.use.content.cache", "false")); + private final Map> myContentCache = ourUseContentCache? new HashMap>() : Collections.>emptyMap(); + public OptimizedFileManager() throws Throwable { super(new Context(), true, null); final Field archivesField = DefaultFileManager.class.getDeclaredField("archives"); @@ -352,56 +354,36 @@ class OptimizedFileManager extends DefaultFileManager { } public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException { - SoftReference r = myContentCache.get(this); - CharBuffer cb = (r == null ? null : r.get()); - if (cb == null) { - InputStream in = new FileInputStream(f); - try { - final ByteBuffer bb = makeByteBuffer(in); - JavaFileObject prev = log.useSource(this); - try { - cb = decode(bb, ignoreEncodingErrors); - } - finally { - log.useSource(prev); - } - myByteBufferCache.put(bb); // save for next time + CharBuffer cb; + if (ourUseContentCache) { + SoftReference ref = myContentCache.get(this); + cb = (ref != null) ? ref.get() : null; + if (cb == null) { + cb = loadFileContent(ignoreEncodingErrors); if (!ignoreEncodingErrors) { myContentCache.put(this, new SoftReference(cb)); } } - finally { - in.close(); - } + } + else { + cb = loadFileContent(ignoreEncodingErrors); } return cb; } - //public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException { - // final String encodingName = getEncodingName(); - // SoftReference r = myContentCache.get(this); - // CharBuffer cb = (r == null ? null : r.get()); - // if (cb == null) { - // InputStream in = new FileInputStream(f); - // try { - // JavaFileObject prev = log.useSource(this); - // try { - // final char[] chars = FileUtil.loadFileText(f, encodingName); - // cb = CharBuffer.wrap(chars); - // } - // finally { - // log.useSource(prev); - // } - // if (!ignoreEncodingErrors) { - // myContentCache.put(this, new SoftReference(cb)); - // } - // } - // finally { - // in.close(); - // } - // } - // return cb; - //} + private CharBuffer loadFileContent(boolean ignoreEncodingErrors) throws IOException { + final InputStream in = new FileInputStream(f); + final ByteBuffer bb = makeByteBuffer(in); + JavaFileObject prev = log.useSource(this); + try { + return decode(bb, ignoreEncodingErrors); + } + finally { + log.useSource(prev); + myByteBufferCache.put(bb); // save for next time + in.close(); + } + } @Override public boolean equals(Object other) { @@ -540,7 +522,26 @@ class OptimizedFileManager extends DefaultFileManager { void put(ByteBuffer x) { myCached.set(x); } + + void clear() { + myCached.set(null); + } } private final ByteBufferCache myByteBufferCache = new ByteBufferCache(); + + public void close() { + try { + super.close(); + } + finally { + // archives are cleared in super.close() + if (ourUseContentCache) { + myContentCache.clear(); + } + myDirectoryCache.clear(); + myByteBufferCache.clear(); + myIsFile.clear(); + } + } } diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager17.java b/jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager17.java index 4e7b99a82e14..95fcd7d9ffa1 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager17.java +++ b/jps/jps-builders/src/org/jetbrains/jps/javac/OptimizedFileManager17.java @@ -52,7 +52,8 @@ class OptimizedFileManager17 extends com.sun.tools.javac.file.JavacFileManager { private static final boolean isOS2 = _OS_NAME.startsWith("os/2") || _OS_NAME.startsWith("os2"); private static final boolean isMac = _OS_NAME.startsWith("mac"); private static final boolean isFileSystemCaseSensitive = !isWindows && !isOS2 && !isMac; - + private static final boolean ourUseContentCache = Boolean.valueOf(System.getProperty("javac.use.content.cache", "false")); + public OptimizedFileManager17() throws Throwable { super(new Context(), true, null); final Field archivesField = com.sun.tools.javac.file.JavacFileManager.class.getDeclaredField("archives"); @@ -386,22 +387,24 @@ class OptimizedFileManager17 extends com.sun.tools.javac.file.JavacFileManager { } public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException { - CharBuffer cb = fileManager.getCachedContent(this); + CharBuffer cb = ourUseContentCache? fileManager.getCachedContent(this) : null; if (cb == null) { InputStream in = new FileInputStream(file); try { - ByteBuffer bb = fileManager.makeByteBuffer(in); - JavaFileObject prev = fileManager.log.useSource(this); + final ByteBuffer bb = fileManager.makeByteBuffer(in); + final JavaFileObject prev = fileManager.log.useSource(this); try { cb = fileManager.decode(bb, ignoreEncodingErrors); - } finally { + } + finally { fileManager.log.useSource(prev); } fileManager.recycleByteBuffer(bb); - if (!ignoreEncodingErrors) { + if (ourUseContentCache && !ignoreEncodingErrors) { fileManager.cache(this, cb); } - } finally { + } + finally { in.close(); } } @@ -409,5 +412,14 @@ class OptimizedFileManager17 extends com.sun.tools.javac.file.JavacFileManager { } } - + public void close() { + try { + super.close(); + } + finally { + // archives are cleared in super.close() + myDirectoryCache.clear(); + myIsFile.clear(); + } + } } diff --git a/jps/lib/optimizedFileManager.jar b/jps/lib/optimizedFileManager.jar index f7d95998d3c6..55b4e61617f5 100644 Binary files a/jps/lib/optimizedFileManager.jar and b/jps/lib/optimizedFileManager.jar differ diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/ChangeLocalityDetector.java b/platform/analysis-api/src/com/intellij/codeInsight/daemon/ChangeLocalityDetector.java similarity index 95% rename from platform/lang-api/src/com/intellij/codeInsight/daemon/ChangeLocalityDetector.java rename to platform/analysis-api/src/com/intellij/codeInsight/daemon/ChangeLocalityDetector.java index c89666e36d78..18d541ad7d62 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/daemon/ChangeLocalityDetector.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/daemon/ChangeLocalityDetector.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -25,7 +25,6 @@ import org.jetbrains.annotations.Nullable; public interface ChangeLocalityDetector { /** - * @param changedElement * @return the psi element (ancestor of the changedElement) which should be re-highlighted, or null if unsure. * Examples: * - in Java, when the statement has changed, re-highlight the enclosing code block only. diff --git a/platform/lang-api/src/com/intellij/psi/IntentionFilterOwner.java b/platform/analysis-api/src/com/intellij/psi/IntentionFilterOwner.java similarity index 84% rename from platform/lang-api/src/com/intellij/psi/IntentionFilterOwner.java rename to platform/analysis-api/src/com/intellij/psi/IntentionFilterOwner.java index 2970952e96ea..beceae77cdef 100644 --- a/platform/lang-api/src/com/intellij/psi/IntentionFilterOwner.java +++ b/platform/analysis-api/src/com/intellij/psi/IntentionFilterOwner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -17,6 +17,7 @@ package com.intellij.psi; import com.intellij.codeInsight.intention.IntentionAction; +import org.jetbrains.annotations.NotNull; public interface IntentionFilterOwner { /** @@ -24,7 +25,7 @@ public interface IntentionFilterOwner { * * @param filter the intention actions filter instance. */ - void setIntentionActionsFilter(IntentionActionsFilter filter); + void setIntentionActionsFilter(@NotNull IntentionActionsFilter filter); /** * Sets the intention actions filter which is used to determine which intention actions should be available in an editor. @@ -43,14 +44,14 @@ public interface IntentionFilterOwner { * @param intentionAction the intention action to analyze * @return Returns true if the intention action should be available, false otherwise */ - boolean isAvailable(final IntentionAction intentionAction); + boolean isAvailable(@NotNull IntentionAction intentionAction); /** * This filter reports all intentions are available. */ IntentionActionsFilter EVERYTHING_AVAILABLE = new IntentionActionsFilter() { @Override - public boolean isAvailable(final IntentionAction intentionAction) { + public boolean isAvailable(@NotNull final IntentionAction intentionAction) { return true; } }; diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java index 9734068a9dc0..68a9393f9d75 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java @@ -364,6 +364,11 @@ public class VfsUtilCore { }); } + @NotNull + public static String toIdeaUrl(@NotNull String url) { + return toIdeaUrl(url, true); + } + @NotNull public static String toIdeaUrl(@NotNull String url, boolean removeLocalhostPrefix) { int index = url.indexOf(":/"); diff --git a/platform/core-impl/src/com/intellij/lang/HelpID.java b/platform/core-impl/src/com/intellij/lang/HelpID.java new file mode 100644 index 000000000000..acf5b3800dc6 --- /dev/null +++ b/platform/core-impl/src/com/intellij/lang/HelpID.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2013 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.lang; + +import org.jetbrains.annotations.NonNls; + +public class HelpID { + @NonNls public static final String FIND_OTHER_USAGES = "reference.dialogs.findUsages.other"; +} diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index f84130042585..3bd0a48c2eb3 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -625,12 +625,11 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { @Override public int getConsoleFontSize() { String font = getConsoleFontName(); - if (!UISettings.getInstance().PRESENTATION_MODE && myConsoleFontPreferences.hasSize(font)) { + UISettings uiSettings = UISettings.getInstance(); + if ((uiSettings == null || !uiSettings.PRESENTATION_MODE) && myConsoleFontPreferences.hasSize(font)) { return myConsoleFontPreferences.getSize(font); } - else { - return getEditorFontSize(); - } + return getEditorFontSize(); } @Override diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java index 335cbcff6e24..ad37b00fbb2b 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java @@ -15,7 +15,9 @@ import com.intellij.openapi.externalSystem.util.Order; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.util.containers.ContainerUtilRt; @@ -26,6 +28,8 @@ import org.jetbrains.jps.model.java.JavaSourceRootProperties; import org.jetbrains.jps.model.java.JavaSourceRootType; import org.jetbrains.jps.model.module.JpsModuleSourceRootType; +import java.io.File; +import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Map; @@ -92,41 +96,34 @@ public class ContentRootDataService implements ProjectDataService data : datas) { - ContentRootData contentRoot = data.getData(); - ContentEntry contentEntry = findOrCreateContentRoot(model, contentRoot.getRootPath()); + for (final DataNode data : datas) { + final ContentRootData contentRoot = data.getData(); + final ContentEntry contentEntry = findOrCreateContentRoot(model, contentRoot.getRootPath()); + contentEntry.clearExcludeFolders(); + contentEntry.clearSourceFolders(); LOG.info(String.format("Importing content root '%s' for module '%s'", contentRoot.getRootPath(), module.getName())); - final Set retainedPaths = ContainerUtilRt.newHashSet(); for (String path : contentRoot.getPaths(ExternalSystemSourceType.SOURCE)) { createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, false); - retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path)); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.TEST)) { createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, false); - retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path)); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.RESOURCE)) { createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.RESOURCE, false); - retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path)); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.TEST_RESOURCE)) { createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.TEST_RESOURCE, false); - retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path)); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.SOURCE_GENERATED)) { createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, true); - retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path)); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.TEST_GENERATED)) { createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, true); - retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path)); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) { createExcludedRootIfAbsent(contentEntry, path, module.getName()); - retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path)); } contentEntriesMap.remove(contentEntry.getUrl()); - removeOutdatedContentFolders(contentEntry, retainedPaths); } for(ContentEntry contentEntry : contentEntriesMap.values()) { model.removeContentEntry(contentEntry); @@ -139,23 +136,6 @@ public class ContentRootDataService implements ProjectDataService retainedContentFolders) { - final List sourceFolders = ContainerUtilRt.newArrayList(entry.getSourceFolders()); - for(final SourceFolder sourceFolder : sourceFolders) { - final String path = VirtualFileManager.extractPath(sourceFolder.getUrl()); - if(!retainedContentFolders.contains(path)) { - entry.removeSourceFolder(sourceFolder); - } - } - final List excludeFolders = ContainerUtilRt.newArrayList(entry.getExcludeFolders()); - for(final ExcludeFolder excludeFolder : excludeFolders) { - final String path = VirtualFileManager.extractPath(excludeFolder.getUrl()); - if (!retainedContentFolders.contains(path)) { - entry.removeExcludeFolder(excludeFolder); - } - } - } - @NotNull private static ContentEntry findOrCreateContentRoot(@NotNull ModifiableRootModel model, @NotNull String path) { ContentEntry[] entries = model.getContentEntries(); @@ -193,6 +173,12 @@ public class ContentRootDataService implements ProjectDataService> toImport = ContainerUtilRt.newHashSet(); - toImport.add(projectWithResolvedLibraries); - myProjectDataManager.importData(toImport, project, false); + projectWithResolvedLibraries.prepareData(this.getClass().getClassLoader()); + myProjectDataManager.importData(ContainerUtil.>set(projectWithResolvedLibraries), project, false); } }); } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java index 19fd660f180d..a7d09ebc58d9 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java @@ -37,6 +37,7 @@ public abstract class AbstractExternalProjectSettingsControl" + StringUtil.escapeXml(text) + ""; + return StringUtil.htmlEmphasize(text); } public static boolean checkReadOnlyStatus(@NotNull PsiElement element) { diff --git a/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java b/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java index 3c7a8d3f4041..845e5bc96af5 100644 --- a/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java +++ b/platform/lang-api/src/com/intellij/ui/popup/util/DetailView.java @@ -60,7 +60,7 @@ public interface DetailView extends UserDataHolder { } public static PreviewEditorState create(VirtualFile file, int line, TextAttributes attributes) { - return new PreviewEditorState(file, new LogicalPosition(line, 0), attributes); + return new PreviewEditorState(file, line < 0 ? null : new LogicalPosition(line, 0), attributes); } @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java index 693c8ca20a6b..9656cfe55f9e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java @@ -23,6 +23,7 @@ import com.intellij.codeInsight.lookup.Lookup; import com.intellij.codeInsight.lookup.LookupManager; import com.intellij.codeInsight.lookup.impl.LookupImpl; import com.intellij.codeInsight.template.CustomLiveTemplate; +import com.intellij.codeInsight.template.CustomLiveTemplateBase; import com.intellij.codeInsight.template.CustomTemplateCallback; import com.intellij.codeInsight.template.impl.*; import com.intellij.featureStatistics.FeatureUsageTracker; @@ -120,9 +121,12 @@ public abstract class ChooseItemAction extends EditorAction { final CustomTemplateCallback callback = new CustomTemplateCallback(editor, file, false); for (CustomLiveTemplate customLiveTemplate : CustomLiveTemplate.EP_NAME.getExtensions()) { - final int offset = editor.getCaretModel().getOffset(); - if (customLiveTemplate.getShortcut() == shortcutChar && customLiveTemplate.hasCompletionItem(file, offset)) { - return customLiveTemplate.computeTemplateKey(callback) != null; + if (customLiveTemplate instanceof CustomLiveTemplateBase) { + final int offset = editor.getCaretModel().getOffset(); + if (customLiveTemplate.getShortcut() == shortcutChar + && ((CustomLiveTemplateBase)customLiveTemplate).hasCompletionItem(file, offset)) { + return customLiveTemplate.computeTemplateKey(callback) != null; + } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplate.java b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplate.java index a56f5353cba7..77a3370ea2e4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplate.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplate.java @@ -41,10 +41,4 @@ public interface CustomLiveTemplate { String getTitle(); char getShortcut(); - - /** - * Implementation should returns {@code true} if it has own lookup item in completion autopopup - * and it is supposed that template should be expanded while completion auto-popup is active. - */ - boolean hasCompletionItem(@NotNull PsiFile file, int offset); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplateBase.java b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplateBase.java new file mode 100644 index 000000000000..e542ebfe0262 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplateBase.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2013 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.codeInsight.template; + +import com.intellij.psi.PsiFile; +import org.jetbrains.annotations.NotNull; + +abstract public class CustomLiveTemplateBase implements CustomLiveTemplate { + /** + * Implementation should returns {@code true} if it has own lookup item in completion autopopup + * and it is supposed that template should be expanded while completion auto-popup is active. + */ + public boolean hasCompletionItem(@NotNull PsiFile file, int offset) { + return false; + } +} diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleViewImpl.java index 89f6da48b9f7..bb738098f3b8 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleViewImpl.java @@ -41,7 +41,7 @@ public class LanguageConsoleViewImpl extends ConsoleViewImpl implements Language } public LanguageConsoleViewImpl(@NotNull LanguageConsoleImpl console, boolean usePredefinedMessageFilter) { - super(console.getProject(), GlobalSearchScope.allScope(console.getProject()), true, null, usePredefinedMessageFilter); + super(console.getProject(), GlobalSearchScope.allScope(console.getProject()), true, usePredefinedMessageFilter); myConsole = console; Disposer.register(this, myConsole); diff --git a/platform/lang-impl/src/com/intellij/execution/filters/TextConsoleBuilderImpl.java b/platform/lang-impl/src/com/intellij/execution/filters/TextConsoleBuilderImpl.java index dac15cf62bbf..e157726cd1b2 100644 --- a/platform/lang-impl/src/com/intellij/execution/filters/TextConsoleBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/filters/TextConsoleBuilderImpl.java @@ -54,7 +54,7 @@ public class TextConsoleBuilderImpl extends TextConsoleBuilder { } protected ConsoleView createConsole() { - return new ConsoleViewImpl(myProject, myScope, myViewer, null, myUsePredefinedMessageFilter); + return new ConsoleViewImpl(myProject, myScope, myViewer, myUsePredefinedMessageFilter); } @Override diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 817e41f99504..154d1e8a36f3 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -43,21 +43,16 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.editor.ex.MarkupModelEx; -import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.ex.util.EditorUtil; import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.editor.highlighter.HighlighterClient; import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces; -import com.intellij.openapi.editor.markup.HighlighterLayer; -import com.intellij.openapi.editor.markup.HighlighterTargetArea; import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.OpenFileDescriptor; -import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.ide.CopyPasteManager; import com.intellij.openapi.keymap.Keymap; import com.intellij.openapi.keymap.KeymapManager; @@ -67,12 +62,13 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiFileFactory; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.tree.IElementType; import com.intellij.ui.EditorNotificationPanel; -import com.intellij.util.*; +import com.intellij.util.Alarm; +import com.intellij.util.Consumer; +import com.intellij.util.EditorPopupHandler; +import com.intellij.util.SystemProperties; import com.intellij.util.text.CharArrayUtil; import gnu.trove.TIntObjectHashMap; import org.jetbrains.annotations.NonNls; @@ -249,41 +245,15 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo private final Alarm myFoldingAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, this); private final List myPendingFoldRegions = new ArrayList(); - private FileType myFileType; - - /** - * Use it for custom highlighting for user text. - * This will be highlighted as appropriate file to this file type. - * - * @param fileType according to which use highlighting - */ - public void setFileType(FileType fileType) { - myFileType = fileType; - } - public ConsoleViewImpl(final Project project, boolean viewer) { - this(project, viewer, null); - } - - public ConsoleViewImpl(@NotNull final Project project, boolean viewer, @Nullable FileType fileType) { - this(project, GlobalSearchScope.allScope(project), viewer, fileType); + this(project, GlobalSearchScope.allScope(project), viewer, true); } public ConsoleViewImpl(@NotNull final Project project, @NotNull GlobalSearchScope searchScope, boolean viewer, - @Nullable FileType fileType) - { - this(project, searchScope, viewer, fileType, true); - } - - public ConsoleViewImpl(@NotNull final Project project, - @NotNull GlobalSearchScope searchScope, - boolean viewer, - @Nullable FileType fileType, - boolean usePredefinedMessageFilter) - { - this(project, searchScope, viewer, fileType, + boolean usePredefinedMessageFilter) { + this(project, searchScope, viewer, new ConsoleState.NotStartedStated() { @Override public ConsoleState attachTo(ConsoleViewImpl console, ProcessHandler processHandler) { @@ -296,7 +266,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo protected ConsoleViewImpl(@NotNull final Project project, @NotNull GlobalSearchScope searchScope, boolean viewer, - @Nullable FileType fileType, @NotNull final ConsoleState initialState, boolean usePredefinedMessageFilter) { @@ -305,7 +274,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo myState = initialState; myPsiDisposedCheck = new DisposedPsiManagerCheck(project); myProject = project; - myFileType = fileType; myCustomFilter = new CompositeFilter(project); myPredefinedMessageFilter = new CompositeFilter(project); @@ -597,13 +565,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo } } - /** - * todo python plugin compatibility. Remove on the next update. - */ - @Deprecated - protected void beforeExternalAddContentToDocument(int length, ConsoleViewContentType contentType) { - } - private void addToken(int length, @Nullable HyperlinkInfo info, ConsoleViewContentType contentType) { ConsoleUtil.addToken(length, info, contentType, myTokens); } @@ -928,9 +889,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo LOG.warn("unhandled external change: " + event); } } - if (myFileType != null) { - highlightUserTokens(); - } } protected EditorEx createRealEditor() { @@ -941,40 +899,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo return new MyHighlighter(); } - private void highlightUserTokens() { - if (myTokens.isEmpty()) return; - final TokenInfo token = myTokens.get(myTokens.size() - 1); - if (token.contentType == ConsoleViewContentType.USER_INPUT) { - String text = myEditor.getDocument().getText().substring(token.startOffset, token.endOffset); - PsiFile file = PsiFileFactory.getInstance(myProject). - createFileFromText("dummy", myFileType, text, LocalTimeCounter.currentTime(), true); - Document document = PsiDocumentManager.getInstance(myProject).getDocument(file); - assert document != null; - Editor editor = EditorFactory.getInstance().createEditor(document, myProject, myFileType, false); - try { - MarkupModelEx markup = (MarkupModelEx)myEditor.getMarkupModel(); - List list = new ArrayList(); - markup.processRangeHighlightersOutside(0, token.startOffset-1, new CommonProcessors.CollectProcessor(list)); - for (RangeHighlighter highlighter : list) { - if (highlighter.getStartOffset() >= token.startOffset) { - highlighter.dispose(); - } - } - HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(0); - while (!iterator.atEnd()) { - markup - .addRangeHighlighter(iterator.getStart() + token.startOffset, iterator.getEnd() + token.startOffset, HighlighterLayer.SYNTAX, - iterator.getTextAttributes(), - HighlighterTargetArea.EXACT_RANGE); - iterator.advance(); - } - } - finally { - EditorFactory.getInstance().releaseEditor(editor); - } - } - } - private static void registerConsoleEditorActions(Editor editor) { new EnterHandler().registerCustomShortcutSet(CommonShortcuts.ENTER, editor.getContentComponent()); registerActionHandler(editor, IdeActions.ACTION_EDITOR_PASTE, new PasteHandler()); @@ -1212,9 +1136,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo @Override public TextAttributes getTextAttributes() { - if (myFileType != null && getTokenInfo().contentType == ConsoleViewContentType.USER_INPUT) { - return ConsoleViewContentType.NORMAL_OUTPUT.getAttributes(); - } return getTokenInfo() == null ? null : getTokenInfo().attributes; } diff --git a/platform/lang-impl/src/com/intellij/find/impl/HelpID.java b/platform/lang-impl/src/com/intellij/find/impl/HelpID.java index 3e769d2c8f56..0479f91ee38f 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/HelpID.java +++ b/platform/lang-impl/src/com/intellij/find/impl/HelpID.java @@ -1,6 +1,6 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -23,10 +23,8 @@ public interface HelpID { @NonNls String FIND_PACKAGE_USAGES = "reference.dialogs.findUsages.package"; @NonNls String FIND_CLASS_USAGES = "reference.dialogs.findUsages.class"; @NonNls String FIND_METHOD_USAGES = "reference.dialogs.findUsages.method"; - @NonNls String FIND_OTHER_USAGES = "reference.dialogs.findUsages.other"; @NonNls String FIND_THROW_USAGES = "reference.dialogs.findUsages.throwUsages"; - @NonNls String FIND_IN_PROJECT = "find.findInProject"; @NonNls String REPLACE_IN_PROJECT = "find.findInProject"; diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index bc6237fec30f..2c3d3b956b3c 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -973,7 +973,6 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA updatePopup(); } catch (Exception ignore) { - ignore.printStackTrace(); } finally { myList.getEmptyText().setText(StatusText.DEFAULT_EMPTY_TEXT); diff --git a/platform/lang-impl/src/com/intellij/util/download/impl/FileDownloaderImpl.java b/platform/lang-impl/src/com/intellij/util/download/impl/FileDownloaderImpl.java index fece314e67a6..e9be287a24d3 100644 --- a/platform/lang-impl/src/com/intellij/util/download/impl/FileDownloaderImpl.java +++ b/platform/lang-impl/src/com/intellij/util/download/impl/FileDownloaderImpl.java @@ -16,12 +16,13 @@ package com.intellij.util.download.impl; +import com.google.common.base.Throwables; import com.google.common.util.concurrent.AtomicDouble; -import com.intellij.concurrency.JobLauncher; import com.intellij.ide.IdeBundle; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; @@ -37,7 +38,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; -import com.intellij.util.Processor; +import com.intellij.util.concurrency.BoundedTaskExecutor; import com.intellij.util.containers.hash.LinkedHashMap; import com.intellij.util.download.DownloadableFileDescription; import com.intellij.util.download.FileDownloader; @@ -47,6 +48,7 @@ import com.intellij.util.net.NetUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.ide.PooledThreadExecutor; import javax.swing.*; import java.io.*; @@ -54,12 +56,16 @@ import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicLong; /** * @author nik */ public class FileDownloaderImpl implements FileDownloader { + private static final Logger LOG = Logger.getInstance(FileDownloaderImpl.class); private static final int CONNECTION_TIMEOUT = 60*1000; private static final int READ_TIMEOUT = 60*1000; @NonNls private static final String LIB_SCHEMA = "lib://"; @@ -156,58 +162,79 @@ public class FileDownloaderImpl implements FileDownloader { public List> download(@NotNull final File targetDir) throws IOException { final List> downloadedFiles = new ArrayList>(); final List> existingFiles = new ArrayList>(); - final ProgressIndicator parentIndicator = getProgressIndicator(); + ProgressIndicator parentIndicator = ProgressManager.getInstance().getProgressIndicator(); + if (parentIndicator == null) { + parentIndicator = new EmptyProgressIndicator(); + } + try { - final AtomicReference ioException = new AtomicReference(); final ConcurrentTasksProgressManager progressManager = new ConcurrentTasksProgressManager(parentIndicator, myFileDescriptions.size()); parentIndicator.setText(IdeBundle.message("progress.downloading.0.files.text", myFileDescriptions.size())); - boolean finished = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(myFileDescriptions, parentIndicator, false, false, new Processor() { - @Override - public boolean process(DownloadableFileDescription description) { - SubTaskProgressIndicator indicator = progressManager.createSubTaskIndicator(); - indicator.checkCanceled(); + int maxParallelDownloads = Runtime.getRuntime().availableProcessors(); + LOG.debug("Downloading " + myFileDescriptions.size() + " files using " + maxParallelDownloads + " threads"); + long start = System.currentTimeMillis(); + BoundedTaskExecutor executor = new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, maxParallelDownloads); + List> results = new ArrayList>(); + final AtomicLong totalSize = new AtomicLong(); + for (final DownloadableFileDescription description : myFileDescriptions) { + results.add(executor.submit(new Callable() { + @Override + public Void call() throws Exception { + SubTaskProgressIndicator indicator = progressManager.createSubTaskIndicator(); + indicator.checkCanceled(); - final File existing = new File(targetDir, description.getDefaultFileName()); - final String url = description.getDownloadUrl(); - if (url.startsWith(LIB_SCHEMA)) { - final String path = FileUtil.toSystemDependentName(StringUtil.trimStart(url, LIB_SCHEMA)); - final File file = PathManager.findFileInLibDirectory(path); - existingFiles.add(Pair.create(file, description)); - } - else if (url.startsWith(LocalFileSystem.PROTOCOL_PREFIX)) { - String path = FileUtil.toSystemDependentName(StringUtil.trimStart(url, LocalFileSystem.PROTOCOL_PREFIX)); - File file = new File(path); - if (file.exists()) { + final File existing = new File(targetDir, description.getDefaultFileName()); + final String url = description.getDownloadUrl(); + if (url.startsWith(LIB_SCHEMA)) { + final String path = FileUtil.toSystemDependentName(StringUtil.trimStart(url, LIB_SCHEMA)); + final File file = PathManager.findFileInLibDirectory(path); existingFiles.add(Pair.create(file, description)); } - } - else { - File downloaded; - try { - downloaded = downloadFile(description, existing, indicator); - } - catch (IOException e) { - ioException.compareAndSet(null, new IOException(IdeBundle.message("error.file.download.failed", description.getDownloadUrl(), - e.getMessage()), e)); - return false; - } - if (FileUtil.filesEqual(downloaded, existing)) { - existingFiles.add(Pair.create(existing, description)); + else if (url.startsWith(LocalFileSystem.PROTOCOL_PREFIX)) { + String path = FileUtil.toSystemDependentName(StringUtil.trimStart(url, LocalFileSystem.PROTOCOL_PREFIX)); + File file = new File(path); + if (file.exists()) { + existingFiles.add(Pair.create(file, description)); + } } else { - downloadedFiles.add(Pair.create(downloaded, description)); + File downloaded; + try { + downloaded = downloadFile(description, existing, indicator); + } + catch (IOException e) { + throw new IOException(IdeBundle.message("error.file.download.failed", description.getDownloadUrl(), e.getMessage()), e); + } + if (FileUtil.filesEqual(downloaded, existing)) { + existingFiles.add(Pair.create(existing, description)); + } + else { + totalSize.addAndGet(downloaded.length()); + downloadedFiles.add(Pair.create(downloaded, description)); + } } + indicator.finished(); + return null; } - indicator.finished(); - return true; - } - }); - if (!finished) { - if (ioException.get() != null) { - throw ioException.get(); - } - throw new ProcessCanceledException(); + })); } + + for (Future result : results) { + try { + result.get(); + } + catch (InterruptedException e) { + throw new ProcessCanceledException(); + } + catch (ExecutionException e) { + Throwables.propagateIfInstanceOf(e.getCause(), IOException.class); + Throwables.propagateIfInstanceOf(e.getCause(), ProcessCanceledException.class); + LOG.error(e); + } + } + long duration = System.currentTimeMillis() - start; + LOG.debug("Downloaded " + StringUtil.formatFileSize(totalSize.get()) + " in " + StringUtil.formatDuration(duration) + "(" + duration + "ms)"); + List> localFiles = new ArrayList>(); localFiles.addAll(moveToDir(downloadedFiles, targetDir)); localFiles.addAll(existingFiles); @@ -223,12 +250,6 @@ public class FileDownloaderImpl implements FileDownloader { } } - @NotNull - private static ProgressIndicator getProgressIndicator() { - ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); - return indicator == null ? new EmptyProgressIndicator() : indicator; - } - @Nullable private static VirtualFile chooseDirectoryForFiles(Project project, JComponent parentComponent) { final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MessageBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/MessageBuilder.java deleted file mode 100644 index 89c1cb55b880..000000000000 --- a/platform/platform-api/src/com/intellij/openapi/ui/MessageBuilder.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.ui; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.wm.WindowManager; -import com.intellij.ui.mac.MacMessages; -import com.intellij.util.ObjectUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -public final class MessageBuilder { - private final String myMessage; - private final String myTitle; - - private String myYesText; - private String myNoText; - - private Project myProject; - private Icon myIcon; - private DialogWrapper.DoNotAskOption myDoNotAskOption; - - private MessageBuilder(@NotNull String title, @NotNull String message) { - myTitle = title; - myMessage = message; - } - - public static MessageBuilder yesNo(@NotNull String title, @NotNull String message) { - return new MessageBuilder(title, message).icon(Messages.getQuestionIcon()); - } - - public MessageBuilder project(@Nullable Project project) { - myProject = project; - return this; - } - - /** - * @see {@link com.intellij.openapi.ui.Messages#getInformationIcon()} - * @see {@link com.intellij.openapi.ui.Messages#getWarningIcon()} - * @see {@link com.intellij.openapi.ui.Messages#getErrorIcon()} - * @see {@link com.intellij.openapi.ui.Messages#getQuestionIcon()} - */ - public MessageBuilder icon(@Nullable Icon icon) { - myIcon = icon; - return this; - } - - public MessageBuilder doNotAsk(@NotNull DialogWrapper.DoNotAskOption doNotAskOption) { - myDoNotAskOption = doNotAskOption; - return this; - } - - public MessageBuilder yesText(@NotNull String yesText) { - myYesText = yesText; - return this; - } - - public MessageBuilder noText(@NotNull String noText) { - myNoText = noText; - return this; - } - - @Messages.YesNoResult - public int show() { - String yesText = ObjectUtils.chooseNotNull(myYesText, Messages.YES_BUTTON); - String noText = ObjectUtils.chooseNotNull(myNoText, Messages.NO_BUTTON); - if (Messages.canShowMacSheetPanel()) { - return MacMessages.getInstance().showYesNoDialog(myTitle, myMessage, yesText, noText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption); - } - else { - //noinspection MagicConstant - return Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText}, 0, myIcon, myDoNotAskOption); - } - } -} diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java new file mode 100644 index 000000000000..56520d4bf5e8 --- /dev/null +++ b/platform/platform-api/src/com/intellij/openapi/ui/MessageDialogBuilder.java @@ -0,0 +1,138 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.ui; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.wm.WindowManager; +import com.intellij.ui.mac.MacMessages; +import com.intellij.util.ObjectUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +public abstract class MessageDialogBuilder { + protected final String myMessage; + protected final String myTitle; + + protected String myYesText; + protected String myNoText; + + protected Project myProject; + protected Icon myIcon; + protected DialogWrapper.DoNotAskOption myDoNotAskOption; + + private MessageDialogBuilder(@NotNull String title, @NotNull String message) { + myTitle = title; + myMessage = message; + } + + public static YesNo yesNo(@NotNull String title, @NotNull String message) { + return new YesNo(title, message).icon(Messages.getQuestionIcon()); + } + + public static YesNoCancel yesNoCancel(@NotNull String title, @NotNull String message) { + return new YesNoCancel(title, message).icon(Messages.getQuestionIcon()); + } + + protected abstract T getThis(); + + public T project(@Nullable Project project) { + myProject = project; + return getThis(); + } + + /** + * @see {@link com.intellij.openapi.ui.Messages#getInformationIcon()} + * @see {@link com.intellij.openapi.ui.Messages#getWarningIcon()} + * @see {@link com.intellij.openapi.ui.Messages#getErrorIcon()} + * @see {@link com.intellij.openapi.ui.Messages#getQuestionIcon()} + */ + public T icon(@Nullable Icon icon) { + myIcon = icon; + return getThis(); + } + + public T doNotAsk(@NotNull DialogWrapper.DoNotAskOption doNotAskOption) { + myDoNotAskOption = doNotAskOption; + return getThis(); + } + + public T yesText(@NotNull String yesText) { + myYesText = yesText; + return getThis(); + } + + public T noText(@NotNull String noText) { + myNoText = noText; + return getThis(); + } + + public static final class YesNo extends MessageDialogBuilder { + private YesNo(@NotNull String title, @NotNull String message) { + super(title, message); + } + + @Override + protected YesNo getThis() { + return this; + } + + @Messages.YesNoResult + public int show() { + String yesText = ObjectUtils.chooseNotNull(myYesText, Messages.YES_BUTTON); + String noText = ObjectUtils.chooseNotNull(myNoText, Messages.NO_BUTTON); + if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) { + return MacMessages.getInstance().showYesNoDialog(myTitle, myMessage, yesText, noText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption); + } + else { + return Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText}, 0, myIcon, myDoNotAskOption) == 0 ? Messages.YES : Messages.NO; + } + } + } + + public static final class YesNoCancel extends MessageDialogBuilder { + private String myCancelText; + + private YesNoCancel(@NotNull String title, @NotNull String message) { + super(title, message); + } + + public YesNoCancel cancelText(@NotNull String cancelText) { + myCancelText = cancelText; + return getThis(); + } + + @Override + protected YesNoCancel getThis() { + return this; + } + + @Messages.YesNoCancelResult + public int show() { + String yesText = ObjectUtils.chooseNotNull(myYesText, Messages.YES_BUTTON); + String noText = ObjectUtils.chooseNotNull(myNoText, Messages.NO_BUTTON); + String cancelText = ObjectUtils.chooseNotNull(myCancelText, Messages.CANCEL_BUTTON); + if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) { + return MacMessages.getInstance().showYesNoCancelDialog(myTitle, myMessage, yesText, noText, cancelText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption); + } + else { + int buttonNumber = Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText, cancelText}, 0, myIcon, myDoNotAskOption); + return buttonNumber == 0 ? Messages.YES : buttonNumber == 1 ? Messages.NO : Messages.CANCEL; + } + } + } +} diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index fb21fe234a5e..e95efbc12a66 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -201,7 +201,7 @@ public class Messages { return dialog.getExitCode(); } - private static boolean isApplicationInUnitTestOrHeadless(){ + static boolean isApplicationInUnitTestOrHeadless(){ final Application application = ApplicationManager.getApplication(); return application != null && (application.isUnitTestMode() || application.isHeadlessEnvironment()); } diff --git a/platform/platform-impl/src/com/intellij/execution/DelayedDocumentWatcher.java b/platform/platform-impl/src/com/intellij/execution/DelayedDocumentWatcher.java index 7d7cb6aff2df..a62e33d94ff7 100644 --- a/platform/platform-impl/src/com/intellij/execution/DelayedDocumentWatcher.java +++ b/platform/platform-impl/src/com/intellij/execution/DelayedDocumentWatcher.java @@ -15,6 +15,7 @@ */ package com.intellij.execution; +import com.google.common.collect.ImmutableSet; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.event.DocumentAdapter; @@ -23,114 +24,51 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.VirtualFileManager; -import com.intellij.openapi.vfs.newvfs.BulkFileListener; -import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent; -import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.problems.WolfTheProblemSolver; import com.intellij.util.Alarm; import com.intellij.util.Consumer; -import com.intellij.util.messages.MessageBusConnection; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -import java.util.Collections; -import java.util.List; import java.util.Set; -public class DelayedDocumentWatcher implements Runnable { +public class DelayedDocumentWatcher { private final Project myProject; private final Alarm myAlarm; - private final Consumer myConsumer; - private final int myDelay; - + private final int myDelayMillis; + private final Consumer> myConsumer; + private final Condition myChangedFileFilter; private final MyDocumentAdapter myListener; + private final Runnable myAlarmRunnable; private final Set myChangedFiles = new THashSet(); - private boolean myWasRequested; - private final Condition myDocumentChangedFilter; - private MessageBusConnection myMessageBusConnection; - - public DelayedDocumentWatcher(Project project, - Alarm alarm, - int delay, - Consumer consumer, - Condition documentChangedFilter) { + public DelayedDocumentWatcher(@NotNull Project project, + int delayMillis, + @NotNull Consumer> consumer, + @Nullable Condition changedFileFilter) { myProject = project; - myAlarm = alarm; - myDelay = delay; + myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, myProject); + myDelayMillis = delayMillis; myConsumer = consumer; - myDocumentChangedFilter = documentChangedFilter; - + myChangedFileFilter = changedFileFilter; myListener = new MyDocumentAdapter(); + myAlarmRunnable = new MyRunnable(); } - @Override - public void run() { - final VirtualFile[] files; - synchronized (myChangedFiles) { - myWasRequested = false; - files = myChangedFiles.toArray(new VirtualFile[myChangedFiles.size()]); - myChangedFiles.clear(); - } - - final WolfTheProblemSolver problemSolver = WolfTheProblemSolver.getInstance(myProject); - for (VirtualFile file : files) { - if (problemSolver.hasSyntaxErrors(file)) { - // threat any other file in queue as dependency of this file — don't flush if some of the queued file is invalid - // Vladimir.Krivosheev AutoTestManager behavior behavior is preserved. - // LiveEdit version used another strategy (flush all valid files), but now we use AutoTestManager-inspired strategy - synchronized (myChangedFiles) { - Collections.addAll(myChangedFiles, files); - } - - return; - } - } - - myConsumer.consume(files); - } - + @NotNull public Project getProject() { return myProject; } public void activate() { - if (myMessageBusConnection != null) { - return; - } - - myMessageBusConnection = myProject.getMessageBus().connect(myProject); - myMessageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() { - @Override - public void after(@NotNull List events) { - for (VFileEvent event : events) { - if (event instanceof VFileDeleteEvent) { - synchronized (myChangedFiles) { - myChangedFiles.remove(event.getFile()); - } - } - } - } - }); - EditorFactory.getInstance().getEventMulticaster().addDocumentListener(myListener, myProject); } public void deactivate() { - if (myMessageBusConnection == null) { - return; - } - - try { - EditorFactory.getInstance().getEventMulticaster().removeDocumentListener(myListener); - } - finally { - myMessageBusConnection.disconnect(); - myMessageBusConnection = null; - } + EditorFactory.getInstance().getEventMulticaster().removeDocumentListener(myListener); } private class MyDocumentAdapter extends DocumentAdapter { @@ -138,19 +76,35 @@ public class DelayedDocumentWatcher implements Runnable { public void documentChanged(DocumentEvent event) { final Document document = event.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); - if (file == null || !myDocumentChangedFilter.value(file)) { + if (file == null) { return; } + if (!myChangedFiles.contains(file)) { + // optimization: if possible, avoid possible expensive 'myChangedFileFilter.value(file)' call + if (myChangedFileFilter != null && !myChangedFileFilter.value(file)) { + return; + } - synchronized (myChangedFiles) { - // changedFiles contains is not enough, because it can contain not-flushed files from prev request (which are not flushed because some is invalid) - if (!myChangedFiles.add(file) && myWasRequested) { + myChangedFiles.add(file); + } + + myAlarm.cancelRequest(myAlarmRunnable); + myAlarm.addRequest(myAlarmRunnable, myDelayMillis); + } + } + + private class MyRunnable implements Runnable { + @Override + public void run() { + WolfTheProblemSolver problemSolver = WolfTheProblemSolver.getInstance(myProject); + for (VirtualFile file : myChangedFiles) { + if (problemSolver.hasSyntaxErrors(file)) { return; } } - - myAlarm.cancelRequest(DelayedDocumentWatcher.this); - myAlarm.addRequest(DelayedDocumentWatcher.this, myDelay); + Set copy = ImmutableSet.copyOf(myChangedFiles); + myChangedFiles.clear(); + myConsumer.consume(copy); } } diff --git a/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java b/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java index ecd084b4b118..f20a7340edd1 100644 --- a/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java +++ b/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java @@ -15,25 +15,35 @@ */ package com.intellij.execution.impl; +import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.ide.ui.UISettings; +import com.intellij.lexer.Lexer; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.EditorSettings; -import com.intellij.openapi.editor.colors.EditorColors; -import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.EditorFontType; -import com.intellij.openapi.editor.colors.FontPreferences; +import com.intellij.openapi.editor.HighlighterColors; +import com.intellij.openapi.editor.colors.*; import com.intellij.openapi.editor.colors.impl.DelegateColorScheme; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.impl.EditorFactoryImpl; import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.fileTypes.SyntaxHighlighter; +import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; +import com.intellij.psi.tree.IElementType; +import com.intellij.util.containers.FactoryMap; import org.jetbrains.annotations.NotNull; import java.awt.*; +import java.util.*; +import java.util.List; + +import static com.intellij.execution.ui.ConsoleViewContentType.registerNewConsoleViewType; /** * @author peter @@ -122,4 +132,48 @@ public class ConsoleViewUtil { public static boolean isConsoleViewEditor(Editor editor) { return editor.getUserData(EDITOR_IS_CONSOLE_VIEW) == Boolean.TRUE; } + + // @noinspection MismatchedQueryAndUpdateOfCollection + private static final Map, Key> ourContentTypes = Collections.synchronizedMap(new FactoryMap, Key>() { + protected Key create(List keys) { + EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); + TextAttributes result = scheme.getAttributes(HighlighterColors.TEXT); + StringBuilder keyName = new StringBuilder("Generated_"); + for (TextAttributesKey key : keys) { + TextAttributes attributes = scheme.getAttributes(key); + if (attributes != null) { + keyName.append("_").append(key.getExternalName()); + result = TextAttributes.merge(result, attributes); + } + } + Key newKey = new Key(keyName.toString()); + ConsoleViewContentType contentType = new ConsoleViewContentType(keyName.toString(), result); + registerNewConsoleViewType(newKey, contentType); + return newKey; + } + }); + + public static void printWithHighlighting(@NotNull ConsoleView console, @NotNull String text, @NotNull SyntaxHighlighter highlighter) { + Lexer lexer = highlighter.getHighlightingLexer(); + lexer.start(text, 0, text.length(), 0); + + IElementType tokenType; + while ((tokenType = lexer.getTokenType()) != null) { + TextAttributesKey[] keys = highlighter.getTokenHighlights(tokenType); + ConsoleViewContentType type = keys.length == 0 ? ConsoleViewContentType.NORMAL_OUTPUT : + ConsoleViewContentType.getConsoleViewType(ourContentTypes.get(Arrays.asList(keys))); + console.print(lexer.getTokenText(), type); + lexer.advance(); + } + } + + public static void printAsFileType(@NotNull ConsoleView console, @NotNull String text, @NotNull FileType fileType) { + SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null); + if (highlighter != null) { + printWithHighlighting(console, text, highlighter); + } + else { + console.print(text, ConsoleViewContentType.NORMAL_OUTPUT); + } + } } diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/ActionInstallPlugin.java b/platform/platform-impl/src/com/intellij/ide/plugins/ActionInstallPlugin.java index 9f8c8b831cbc..d7b0b6bbf0d8 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/ActionInstallPlugin.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/ActionInstallPlugin.java @@ -50,6 +50,7 @@ public class ActionInstallPlugin extends AnAction implements DumbAware { this.installed = installed; } + @Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); IdeaPluginDescriptor[] selection = getPluginTable().getSelectedObjects(); @@ -80,6 +81,7 @@ public class ActionInstallPlugin extends AnAction implements DumbAware { presentation.setEnabled(enabled); } + @Override public void actionPerformed(AnActionEvent e) { install(); } @@ -224,6 +226,7 @@ public class ActionInstallPlugin extends AnAction implements DumbAware { message += "updated plugin" + (disabled.size() > 1 ? "s" : ""); } else { + //noinspection SpellCheckingInspection message += "plugin dependenc" + (disabledDependants.size() > 1 ? "ies" : "y"); } message += "?"; diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 034872a00ec6..c1d21ac97c5c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -51,7 +51,7 @@ import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.project.impl.ProjectManagerImpl; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.MessageBuilder; +import com.intellij.openapi.ui.MessageDialogBuilder; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; @@ -881,7 +881,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application .message(hasUnsafeBgTasks ? "exit.confirm.prompt.tasks" : "exit.confirm.prompt", ApplicationNamesInfo.getInstance().getFullProductName()); - if (MessageBuilder.yesNo(ApplicationBundle.message("exit.confirm.title"), message).yesText(ApplicationBundle.message("command.exit")).noText(CommonBundle.message("button.cancel")) + if (MessageDialogBuilder.yesNo(ApplicationBundle.message("exit.confirm.title"), message).yesText(ApplicationBundle.message("command.exit")).noText(CommonBundle.message("button.cancel")) .doNotAsk(option).show() != Messages.YES) { return false; } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java index ceb4bc48eae1..fc32ae9a16d5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java @@ -18,7 +18,6 @@ package com.intellij.openapi.vfs.impl.http; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.VirtualFileSystem; @@ -65,7 +64,7 @@ class VirtualFileImpl extends HttpVirtualFile { } }); - path = StringUtil.trimEnd(UriUtil.trimParameters(path), "/"); + path = UriUtil.trimLastSlash(UriUtil.trimParameters(path)); int lastSlash = path.lastIndexOf('/'); if (lastSlash == -1) { myParentPath = null; diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java index 30ca7fe152b6..ec39e360282b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java @@ -23,21 +23,18 @@ import com.intellij.openapi.util.LowMemoryWatcher; import com.intellij.openapi.util.ShutDownTracker; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.*; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.newvfs.*; import com.intellij.openapi.vfs.newvfs.events.*; import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile; import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry; -import com.intellij.util.ArrayUtil; -import com.intellij.util.Function; -import com.intellij.util.IncorrectOperationException; -import com.intellij.util.SmartList; +import com.intellij.util.*; import com.intellij.util.containers.ConcurrentIntObjectMap; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.StripedLockIntObjectConcurrentHashMap; import com.intellij.util.io.ReplicatorInputStream; +import com.intellij.util.io.URLUtil; import com.intellij.util.messages.MessageBus; import gnu.trove.*; import org.jetbrains.annotations.NonNls; @@ -942,8 +939,7 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone @NotNull private static String normalizeRootUrl(@NotNull String basePath, @NotNull NewVirtualFileSystem fs) { // need to protect against relative path of the form "/x/../y" - String url = fs.getProtocol() + "://" + VfsImplUtil.normalize(fs, FileUtil.toCanonicalPath(basePath)); - return StringUtil.trimEnd(url, "/"); + return UriUtil.trimLastSlash(fs.getProtocol() + URLUtil.SCHEME_SEPARATOR + VfsImplUtil.normalize(fs, FileUtil.toCanonicalPath(basePath))); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java index e7353f040c25..894f50d0f4cd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java @@ -52,7 +52,7 @@ import java.util.List; * User: spLeaner */ public class IdeStatusBarImpl extends JComponent implements StatusBarEx { - private static final int MIN_ICON_HEIGHT = 18; + private static final int MIN_ICON_HEIGHT = 18 + 1 + 1; private final InfoAndProgressPanel myInfoAndProgressPanel; private IdeFrame myFrame; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/ToolWindowsWidget.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/ToolWindowsWidget.java index 835a9baface5..a84ec5f4ae9b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/ToolWindowsWidget.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/ToolWindowsWidget.java @@ -200,7 +200,7 @@ class ToolWindowsWidget extends JLabel implements CustomStatusBarWidget, StatusB PropertiesComponent.getInstance().setValue(key, String.valueOf(true)); Disposer.dispose(alarm); } - }, 120000); + }, 30000); } } diff --git a/platform/platform-impl/src/com/intellij/util/UriUtil.java b/platform/platform-impl/src/com/intellij/util/UriUtil.java index 3a77c87352a8..7ee163431cf8 100644 --- a/platform/platform-impl/src/com/intellij/util/UriUtil.java +++ b/platform/platform-impl/src/com/intellij/util/UriUtil.java @@ -34,15 +34,17 @@ import static com.intellij.openapi.util.text.StringUtil.stripQuotesAroundValue; public final class UriUtil { public static final CharMatcher PARAM_CHAR_MATCHER = CharMatcher.anyOf("?#;"); + public static final CharMatcher SLASH_MATCHER = CharMatcher.is('/'); private static final Pattern DATA_URI_PATTERN = Pattern.compile("data:([^,;]+/[^,;]+)(;charset=[^,;]+)?(;base64)?,(.+)"); private UriUtil() { } - /** - * must be synchronized with trimUrlParameters in utils.js - */ + public static String trimLastSlash(@NotNull String url) { + return SLASH_MATCHER.trimTrailingFrom(url); + } + public static String trimParameters(@NotNull String url) { int end = PARAM_CHAR_MATCHER.indexIn(url); return end != -1 ? url.substring(0, end) : url; diff --git a/platform/platform-impl/src/org/jetbrains/io/BuiltInServer.java b/platform/platform-impl/src/org/jetbrains/io/BuiltInServer.java index cff39b58abf0..a1bfcc0890ea 100644 --- a/platform/platform-impl/src/org/jetbrains/io/BuiltInServer.java +++ b/platform/platform-impl/src/org/jetbrains/io/BuiltInServer.java @@ -39,10 +39,10 @@ import java.net.ServerSocket; import java.util.Map; public class BuiltInServer implements Disposable { - private final ChannelRegistrar channelRegistrar = new ChannelRegistrar(); - static final Logger LOG = Logger.getInstance(BuiltInServer.class); + private final ChannelRegistrar channelRegistrar = new ChannelRegistrar(); + public boolean isRunning() { return !channelRegistrar.isEmpty(); } diff --git a/platform/platform-impl/src/org/jetbrains/io/ChannelExceptionHandler.java b/platform/platform-impl/src/org/jetbrains/io/ChannelExceptionHandler.java index 949453dc9740..748d2228e88b 100644 --- a/platform/platform-impl/src/org/jetbrains/io/ChannelExceptionHandler.java +++ b/platform/platform-impl/src/org/jetbrains/io/ChannelExceptionHandler.java @@ -40,7 +40,7 @@ public final class ChannelExceptionHandler extends ChannelInboundHandlerAdapter public void exceptionCaught(ChannelHandlerContext context, Throwable cause) throws Exception { // don't report about errors while connecting // WEB-7727 - if (cause instanceof ConnectException || (cause.getMessage() != null && cause.getMessage().startsWith("Connection reset"))) { + if (cause instanceof ConnectException) { LOG.debug(cause); } else { diff --git a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java index 04ce26377259..b59788f2a3da 100644 --- a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java +++ b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java @@ -95,7 +95,8 @@ public final class NettyUtil { return (throwable instanceof IOException && message.equals("An existing connection was forcibly closed by the remote host")) || (throwable instanceof ChannelException && message.startsWith("Failed to bind to: ")) || - throwable instanceof BindException; + throwable instanceof BindException || + (message.startsWith("Connection reset") || message.equals("Operation timed out") || message.equals("Connection timed out")); } // applicable only in case of ClientBootstrap&OioClientSocketChannelFactory diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties index 592d20c9ed9e..e4350745f34c 100644 --- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties +++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties @@ -299,7 +299,7 @@ add.parameters.for.fields.to.constructors=Add parameters for &fields to construc 0.already.contains.inner.class.named.1={0} already contains inner class named {1} 0.uses.1.which.is.pushed.down={0} uses {1}, which is pushed down refactoring.cannot.be.performed=Refactoring cannot be performed -there.is.already.a.0.it.will.conflict.with.an.introduced.parameter=There is already a {0}. It will conflict with an introduced parameter +there.is.already.a.0.it.will.conflict.with.an.introduced.parameter=There is already a {0}. It will conflict with the introduced parameter introduce.parameter.command=Extracting parameter to {0} parameter.initializer.contains.0.but.not.all.calls.to.method.are.in.its.class=Parameter initializer contains {0}, but not all calls to method are in its class 0.is.not.accessible.from.1.value.for.introduced.parameter.in.that.method.call.will.be.incorrect={0} is not accessible from {1}. Value for introduced parameter in that method call will be incorrect. diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index d581d4e11b65..2fdff09137d2 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -355,6 +355,8 @@ + + diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java index 7d5f1cba19fb..e2c450b8d82c 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java @@ -12,11 +12,11 @@ import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.content.Content; -import com.intellij.util.Alarm; import com.intellij.util.Consumer; import com.intellij.util.containers.WeakList; import java.util.Collection; +import java.util.Set; /** * @author yole @@ -37,14 +37,14 @@ public class AutoTestManager { public AutoTestManager(Project project) { myProject = project; - myDocumentWatcher = createWatcher(); myDelay = PropertiesComponent.getInstance(myProject).getOrInitInt(AUTO_TEST_MANAGER_DELAY, 3000); + myDocumentWatcher = createWatcher(); } private DelayedDocumentWatcher createWatcher() { - return new DelayedDocumentWatcher(myProject, new Alarm(Alarm.ThreadToUse.SWING_THREAD, myProject), myDelay, new Consumer() { + return new DelayedDocumentWatcher(myProject, myDelay, new Consumer>() { @Override - public void consume(VirtualFile[] files) { + public void consume(Set files) { for (Content content : myEnabledDescriptors) { runAutoTest(content); } @@ -53,7 +53,7 @@ public class AutoTestManager { @Override public boolean value(VirtualFile file) { // Vladimir.Krivosheev — I don't know, why AutoTestManager checks it, but old behavior is preserved - return FileEditorManager.getInstance(myDocumentWatcher.getProject()).isFileOpen(file); + return FileEditorManager.getInstance(myProject).isFileOpen(file); } }); } @@ -61,6 +61,7 @@ public class AutoTestManager { public void setAutoTestEnabled(RunContentDescriptor descriptor, boolean enabled) { Content content = descriptor.getAttachedContent(); if (enabled) { + // TODO Why not just 'myEnabledDescriptors.add(content)'? if (!myEnabledDescriptors.contains(content)) { myEnabledDescriptors.add(content); } @@ -105,6 +106,6 @@ public class AutoTestManager { if (!myEnabledDescriptors.isEmpty()) { myDocumentWatcher.activate(); } - PropertiesComponent.getInstance(myProject).getOrInitInt(AUTO_TEST_MANAGER_DELAY, myDelay); + PropertiesComponent.getInstance(myProject).setValue(AUTO_TEST_MANAGER_DELAY, String.valueOf(myDelay)); } -} \ No newline at end of file +} diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsConsoleBuilderImpl.java b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsConsoleBuilderImpl.java index e1aa421188df..c92e8011544b 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsConsoleBuilderImpl.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsConsoleBuilderImpl.java @@ -35,6 +35,6 @@ public class TestsConsoleBuilderImpl extends TextConsoleBuilderImpl { @Override protected ConsoleView createConsole() { - return new TestsConsoleViewImpl(getProject(), getScope(), isViewer(), null, isUsePredefinedMessageFilter()); + return new TestsConsoleViewImpl(getProject(), getScope(), isViewer(), isUsePredefinedMessageFilter()); } } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsConsoleViewImpl.java b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsConsoleViewImpl.java index 9fe56402b91f..380163913197 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsConsoleViewImpl.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestsConsoleViewImpl.java @@ -19,7 +19,6 @@ import com.intellij.execution.impl.ConsoleState; import com.intellij.execution.impl.ConsoleViewImpl; import com.intellij.execution.impl.ConsoleViewRunningState; import com.intellij.execution.process.ProcessHandler; -import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.psi.search.GlobalSearchScope; @@ -31,9 +30,8 @@ public class TestsConsoleViewImpl extends ConsoleViewImpl { public TestsConsoleViewImpl(final Project project, final GlobalSearchScope searchScope, final boolean viewer, - final FileType fileType, boolean usePredefinedMessageFilter) { - super(project, searchScope, viewer, fileType, + super(project, searchScope, viewer, new ConsoleState.NotStartedStated() { @Override public ConsoleState attachTo(ConsoleViewImpl console, ProcessHandler processHandler) { diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 45695b73861b..4ceb478ef1ae 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -1780,6 +1780,12 @@ public class StringUtil extends StringUtilRt { return replace(text, REPLACES_DISP, REPLACES_REFS); } + @NotNull + public static String htmlEmphasize(String text) { + return "" + escapeXml(text) + ""; + } + + @NotNull public static String escapeToRegexp(@NotNull String text) { final StringBuilder result = new StringBuilder(text.length()); diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java index 2914851e5d1a..dfce14728906 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java @@ -27,7 +27,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diff.impl.dir.actions.popup.WarnOnDeletion; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.MessageBuilder; +import com.intellij.openapi.ui.MessageDialogBuilder; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.popup.Balloon; @@ -804,7 +804,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode } private boolean confirmDeletion(int count) { - return MessageBuilder.yesNo("Confirm Delete", "Delete " + count + " items?").project(myProject).yesText("Delete").noText(CommonBundle.message("button.cancel")).doNotAsk( + return MessageDialogBuilder.yesNo("Confirm Delete", "Delete " + count + " items?").project(myProject).yesText("Delete").noText(CommonBundle.message("button.cancel")).doNotAsk( new DialogWrapper.DoNotAskOption() { @Override public boolean isToBeShown() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java index 4c5b10c890fb..05ba63f17782 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java @@ -34,6 +34,7 @@ import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; import com.intellij.ui.table.TableView; +import com.intellij.util.UriUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.*; import com.intellij.xml.util.XmlStringUtil; @@ -106,7 +107,7 @@ public class VcsDirectoryConfigurationPanel extends JPanel implements Configurab String directory = mapping.getDirectory(); VirtualFile baseDir = myProject.getBaseDir(); if (baseDir != null) { - final File directoryFile = new File(StringUtil.trimEnd(StringUtil.trimEnd(directory, "/"), "\\") + "/"); + final File directoryFile = new File(StringUtil.trimEnd(UriUtil.trimLastSlash(directory), "\\") + "/"); File ioBase = new File(baseDir.getPath()); if (directoryFile.isAbsolute() && !FileUtil.isAncestor(ioBase, directoryFile, false)) { append(new File(directory).getPath()); diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/TimedVcsCommit.java b/platform/vcs-log/api/src/com/intellij/vcs/log/TimedVcsCommit.java index 0047a5ed6193..fa970c7d5af9 100644 --- a/platform/vcs-log/api/src/com/intellij/vcs/log/TimedVcsCommit.java +++ b/platform/vcs-log/api/src/com/intellij/vcs/log/TimedVcsCommit.java @@ -25,6 +25,6 @@ public interface TimedVcsCommit extends VcsCommit { /** * Returns the timestamp indicating the date & time when this commit was made. */ - long getAuthorTime(); + long getTime(); } diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsFullCommitDetails.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsFullCommitDetails.java index 8382c401824f..1b9757abc1ea 100644 --- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsFullCommitDetails.java +++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsFullCommitDetails.java @@ -27,6 +27,6 @@ public interface VcsFullCommitDetails extends VcsShortCommitDetails { @NotNull VcsUser getCommitter(); - long getCommitTime(); + long getAuthorTime(); } diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogObjectsFactory.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogObjectsFactory.java index 89e73c11750a..ddccc05ce778 100644 --- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogObjectsFactory.java +++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogObjectsFactory.java @@ -27,11 +27,11 @@ public interface VcsLogObjectsFactory { VirtualFile root, @NotNull String subject, @NotNull String authorName, String authorEmail); @NotNull - VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List parents, long authorTime, VirtualFile root, + VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List parents, long time, VirtualFile root, @NotNull String subject, @NotNull String authorName, @NotNull String authorEmail, @NotNull String message, @NotNull String committerName, - @NotNull String committerEmail, long commitTime, @NotNull List changes, + @NotNull String committerEmail, long authorTime, @NotNull List changes, @NotNull ContentRevisionFactory contentRevisionFactory); @NotNull diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsShortCommitDetails.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsShortCommitDetails.java index 59e33dbf1ffd..c6e7d4b6832a 100644 --- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsShortCommitDetails.java +++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsShortCommitDetails.java @@ -28,7 +28,7 @@ public interface VcsShortCommitDetails { @NotNull List getParents(); - long getAuthorTime(); + long getTime(); @NotNull String getSubject(); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java index ebb7821c729f..4af25dff7093 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java @@ -589,7 +589,7 @@ public class VcsLogDataHolder implements Disposable { return ContainerUtil.map(firstBlockDetails, new Function() { @Override public TimedVcsCommit fun(VcsFullCommitDetails details) { - return new CompactCommit(details.getHash(), details.getParents(), details.getAuthorTime()); + return new CompactCommit(details.getHash(), details.getParents(), details.getTime()); } }); } @@ -790,15 +790,15 @@ public class VcsLogDataHolder implements Disposable { private final int myHashIndex; private final int myParent; // there is almost always one parent private final int[] myOtherParents; - private final long myAuthorTime; + private final long myTime; public CompactCommit(TimedVcsCommit commit) { - this(commit.getHash(), commit.getParents(), commit.getAuthorTime()); + this(commit.getHash(), commit.getParents(), commit.getTime()); } public CompactCommit(Hash hash, List parents, long time) { myHashIndex = putHash(hash); - myAuthorTime = time; + myTime = time; if (!parents.isEmpty()) { myParent = putHash(parents.get(0)); @@ -819,8 +819,8 @@ public class VcsLogDataHolder implements Disposable { } @Override - public long getAuthorTime() { - return myAuthorTime; + public long getTime() { + return myTime; } @NotNull diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDateFilter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDateFilter.java index fbba0d7a69df..52103a5cd2b7 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDateFilter.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDateFilter.java @@ -33,7 +33,7 @@ public class VcsLogDateFilter implements VcsLogDetailsFilter { @Override public boolean matches(@NotNull VcsFullCommitDetails details) { - Date date = new Date(details.getCommitTime()); // behave like Git does: it filters by commit time, not author time + Date date = new Date(details.getTime()); // Git itself also filters by commit time, not author time boolean matches = true; if (myAfter != null) { matches &= date.after(myAfter); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java index 912f14065c0f..1450371109d6 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java @@ -220,7 +220,7 @@ public class VcsLogJoiner { Collections.sort(newSortedCommits, new Comparator() { @Override public int compare(@NotNull TimedVcsCommit o1, @NotNull TimedVcsCommit o2) { - return new Long(o1.getAuthorTime()).compareTo(o2.getAuthorTime()); + return new Long(o1.getTime()).compareTo(o2.getTime()); } }); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogMultiRepoJoiner.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogMultiRepoJoiner.java index db6bb8228ef3..d0f47ec014a7 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogMultiRepoJoiner.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogMultiRepoJoiner.java @@ -46,8 +46,8 @@ class VcsLogMultiRepoJoiner { long maxTimeStamp = 0; TimedVcsCommit lastCommit = null; for (TimedVcsCommit commit : commits) { - if (commit.getAuthorTime() > maxTimeStamp) { - maxTimeStamp = commit.getAuthorTime(); + if (commit.getTime() > maxTimeStamp) { + maxTimeStamp = commit.getTime(); lastCommit = commit; } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/TimedVcsCommitImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/TimedVcsCommitImpl.java index c5747d18f67d..5101ae0a9862 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/TimedVcsCommitImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/TimedVcsCommitImpl.java @@ -19,7 +19,7 @@ public class TimedVcsCommitImpl extends VcsCommitImpl implements TimedVcsCommit } @Override - public final long getAuthorTime() { + public final long getTime() { return myTime; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsFullCommitDetailsImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsFullCommitDetailsImpl.java index 14a09508c9b0..61f2649c8c9f 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsFullCommitDetailsImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsFullCommitDetailsImpl.java @@ -23,17 +23,17 @@ public class VcsFullCommitDetailsImpl extends VcsShortCommitDetailsImpl implemen @NotNull private final String myFullMessage; @NotNull private final VcsUser myCommitter; - private final long myCommitTime; + private final long myAuthorTime; @NotNull private final Collection myChanges; - public VcsFullCommitDetailsImpl(@NotNull Hash hash, @NotNull List parents, long authorTime, @NotNull VirtualFile root, + public VcsFullCommitDetailsImpl(@NotNull Hash hash, @NotNull List parents, long time, @NotNull VirtualFile root, @NotNull String subject, @NotNull VcsUser author, @NotNull String message, - @NotNull VcsUser committer, long commitTime, + @NotNull VcsUser committer, long authorTime, @NotNull List changes, @NotNull final ContentRevisionFactory contentRevisionFactory) { - super(hash, parents, authorTime, root, subject, author); + super(hash, parents, time, root, subject, author); myCommitter = committer; - myCommitTime = commitTime; + myAuthorTime = authorTime; myFullMessage = message; myChanges = ContainerUtil.map(changes, new Function() { @Override @@ -67,8 +67,8 @@ public class VcsFullCommitDetailsImpl extends VcsShortCommitDetailsImpl implemen } @Override - public long getCommitTime() { - return myCommitTime; + public long getAuthorTime() { + return myAuthorTime; } private static class LightChange { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogObjectsFactoryImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogObjectsFactoryImpl.java index 8023882f9c13..132222c33942 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogObjectsFactoryImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogObjectsFactoryImpl.java @@ -49,14 +49,14 @@ public class VcsLogObjectsFactoryImpl implements VcsLogObjectsFactory { @NotNull @Override - public VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List parents, long authorTime, @NotNull VirtualFile root, + public VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List parents, long time, @NotNull VirtualFile root, @NotNull String subject, @NotNull String authorName, @NotNull String authorEmail, @NotNull String message, @NotNull String committerName, - @NotNull String committerEmail, long commitTime, @NotNull List changes, + @NotNull String committerEmail, long authorTime, @NotNull List changes, @NotNull ContentRevisionFactory contentRevisionFactory) { VcsUser author = createUser(authorName, authorEmail); VcsUser committer = createUser(committerName, committerEmail); - return new VcsFullCommitDetailsImpl(hash, parents, authorTime, root, subject, author, message, committer, commitTime, + return new VcsFullCommitDetailsImpl(hash, parents, time, root, subject, author, message, committer, authorTime, changes, contentRevisionFactory); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsShortCommitDetailsImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsShortCommitDetailsImpl.java index 96a3136beaaa..49225904e216 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsShortCommitDetailsImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsShortCommitDetailsImpl.java @@ -46,8 +46,8 @@ public class VcsShortCommitDetailsImpl implements VcsShortCommitDetails { } @Override - public long getAuthorTime() { - return myTimeCommitParents.getAuthorTime(); + public long getTime() { + return myTimeCommitParents.getTime(); } @Override diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java index ec0a92e0b195..f93b0295fdba 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java @@ -151,16 +151,16 @@ class DetailsPanel extends JPanel implements ListSelectionListener { String authorText = commit.getAuthor().getName() + " at " + DateFormatUtil.formatDateTime(commit.getAuthorTime()); if (!commit.getAuthor().equals(commit.getCommitter())) { String commitTime; - if (commit.getCommitTime() != commit.getAuthorTime()) { - commitTime = " at " + DateFormatUtil.formatDateTime(commit.getCommitTime()); + if (commit.getAuthorTime() != commit.getTime()) { + commitTime = " at " + DateFormatUtil.formatDateTime(commit.getTime()); } else { commitTime = ""; } authorText += " (committed by " + commit.getCommitter().getName() + commitTime + ")"; } - else if (commit.getCommitTime() != commit.getAuthorTime()) { - authorText += " (committed at " + DateFormatUtil.formatDateTime(commit.getCommitTime()) + ")"; + else if (commit.getAuthorTime() != commit.getTime()) { + authorText += " (committed at " + DateFormatUtil.formatDateTime(commit.getTime()) + ")"; } return authorText; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java index 3799e454ea7c..6ab784426042 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java @@ -60,11 +60,11 @@ public abstract class AbstractVcsLogTableModel extends AbstractTableModel { return data.getAuthor().getName(); } case DATE_COLUMN: - if (data == null || data.getAuthorTime() < 0) { + if (data == null || data.getTime() < 0) { return ""; } else { - return DateFormatUtil.formatDateTime(data.getAuthorTime()); + return DateFormatUtil.formatDateTime(data.getTime()); } default: throw new IllegalArgumentException("columnIndex is " + columnIndex + " > " + (COLUMN_COUNT - 1)); diff --git a/platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleTimedVcsCommit.java b/platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleTimedVcsCommit.java index 195d0c0c61dd..e10f69c58948 100644 --- a/platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleTimedVcsCommit.java +++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleTimedVcsCommit.java @@ -32,7 +32,7 @@ public class SimpleTimedVcsCommit implements TimedVcsCommit { } @Override - public long getAuthorTime() { + public long getTime() { return myTime; } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties index 1a006727a621..d2838a820a80 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties @@ -394,7 +394,8 @@ parameter.hides.member.variable.ignore.constructors.option=Ignore for constructo parameter.hides.member.variable.ignore.abstract.methods.option=Ignore for abstract methods parameter.hides.member.variable.ignore.static.parameters.option=Ignore for static method parameters hiding instance fields type.parameter.hides.visible.type.display.name=Type parameter hides visible type -type.parameter.hides.visible.type.problem.descriptor=Type parameter #ref hides a visible type ''{0}'' #loc +type.parameter.hides.visible.type.problem.descriptor=Type parameter #ref hides visible type ''{0}'' #loc +type.parameter.hides.type.parameter.problem.descriptor=Type parameter #ref hides type parameter ''{0}'' #loc anonymous.class.variable.hides.containing.method.variable.display.name=Anonymous class variable hides variable in containing method anonymous.class.parameter.hides.containing.method.variable.problem.descriptor=Anonymous class parameter #ref hides variable in containing method #loc anonymous.class.field.hides.containing.method.variable.problem.descriptor=Anonymous class field #ref hides variable in containing method #loc @@ -1437,7 +1438,7 @@ confusing.octal.escape.sequence.problem.descriptor=Octal escape sequence # field.accessed.synchronized.and.unsynchronized.option=Simple getters and setters are considered field accesses too method.overrides.package.local.method.display.name=Method overrides package-local method of superclass located in other package method.overrides.package.local.method.problem.descriptor=Method #ref() overrides a package-local method of a superclass located in another package #loc -suspicious.to.array.call.display.name=Suspicious 'Collections.toArray()' call +suspicious.to.array.call.display.name=Suspicious 'Collection.toArray()' call suspicious.to.array.call.problem.descriptor=Array of type ''{0}[]'' expected #loc suspicious.system.arraycopy.display.name=Suspicious 'System.arraycopy()' call suspicious.system.arraycopy.problem.descriptor1=Parameter 'srcPos' may not be negative #loc diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/visibility/TypeParameterHidesVisibleTypeInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/visibility/TypeParameterHidesVisibleTypeInspectionBase.java index 3c8ab363db69..61a865296c10 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/visibility/TypeParameterHidesVisibleTypeInspectionBase.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/visibility/TypeParameterHidesVisibleTypeInspectionBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.siyeh.ig.visibility; import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -26,8 +27,7 @@ public class TypeParameterHidesVisibleTypeInspectionBase extends BaseInspection @Override @NotNull public String getDisplayName() { - return InspectionGadgetsBundle.message( - "type.parameter.hides.visible.type.display.name"); + return InspectionGadgetsBundle.message("type.parameter.hides.visible.type.display.name"); } @Override @@ -39,9 +39,16 @@ public class TypeParameterHidesVisibleTypeInspectionBase extends BaseInspection @NotNull public String buildErrorString(Object... infos) { final PsiClass aClass = (PsiClass)infos[0]; - return InspectionGadgetsBundle.message( - "type.parameter.hides.visible.type.problem.descriptor", - aClass.getQualifiedName()); + if (aClass instanceof PsiTypeParameter) { + return InspectionGadgetsBundle.message("type.parameter.hides.type.parameter.problem.descriptor", aClass.getName()); + } + else { + String name = aClass.getQualifiedName(); + if (name == null) { + name = aClass.getName(); + } + return InspectionGadgetsBundle.message("type.parameter.hides.visible.type.problem.descriptor", name); + } } @Override @@ -49,28 +56,28 @@ public class TypeParameterHidesVisibleTypeInspectionBase extends BaseInspection return new TypeParameterHidesVisibleTypeVisitor(); } - private static class TypeParameterHidesVisibleTypeVisitor - extends BaseInspectionVisitor { + private static class TypeParameterHidesVisibleTypeVisitor extends BaseInspectionVisitor { @Override public void visitTypeParameter(PsiTypeParameter parameter) { super.visitTypeParameter(parameter); final String unqualifiedClassName = parameter.getName(); - - final JavaPsiFacade manager = JavaPsiFacade.getInstance(parameter.getProject()); - final PsiFile containingFile = parameter.getContainingFile(); - final PsiResolveHelper resolveHelper = manager.getResolveHelper(); - final PsiClass aClass = - resolveHelper.resolveReferencedClass(unqualifiedClassName, - containingFile); - if (aClass == null) { + PsiElement context = parameter.getOwner(); + if (context == null) { return; } - final PsiIdentifier identifier = parameter.getNameIdentifier(); - if (identifier == null) { - return; + final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(parameter.getProject()).getResolveHelper(); + while (true) { + context = PsiTreeUtil.getParentOfType(context, PsiMember.class); + if (context == null) { + return; + } + final PsiClass aClass = resolveHelper.resolveReferencedClass(unqualifiedClassName, context); + if (aClass != null) { + registerClassError(parameter, aClass); + return; + } } - registerError(identifier, aClass); } } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBoxing.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBoxing.html index d9bc7d43ce9f..00c423b46cd7 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBoxing.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBoxing.html @@ -9,6 +9,5 @@ language level of 5.0 or higher.

Use the checkbox below to only report truly superfluous boxing, where a boxed value will immediately be implicitly or explicitly unboxed. In this case the entire boxing-unboxing step can be removed. Simple explicit boxing will not be reported. -again. \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/visibility/TypeParameterHidesVisibleTypeInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/visibility/TypeParameterHidesVisibleTypeInspection.java deleted file mode 100644 index b5faef7702d5..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/visibility/TypeParameterHidesVisibleTypeInspection.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.siyeh.igtest.visibility; -import java.util.*; - -public abstract class TypeParameterHidesVisibleTypeInspection { - private Map map = new HashMap(); - - public abstract List foo(); - - public abstract Set bar(); - public abstract TypeParameterHidesVisibleTypeInspection baz(); - public abstract InputStream baz3(); - public abstract A baz2(); -} diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/TypeParameterHidesVisibleTypeInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/TypeParameterHidesVisibleTypeInspectionTest.java new file mode 100644 index 000000000000..b174efee0878 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/TypeParameterHidesVisibleTypeInspectionTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2013 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.siyeh.ig.visibility; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; + +/** + * @author Bas Leijdekkers + */ +public class TypeParameterHidesVisibleTypeInspectionTest extends LightInspectionTestCase { + + public void testSimple() { + doTest("import java.util.*;\n" + + "public abstract class TypeParameterHidesVisibleTypeInspection {\n" + + " private Map map = new HashMap();\n" + + " public abstract List foo();\n" + + " public abstract Set bar();\n" + + " public abstract TypeParameterHidesVisibleTypeInspection baz();\n" + + " public abstract InputStream baz3();\n" + + " public abstract A baz2();\n" + + "}\n"); + } + + public void testHiddenTypeParameter() { + doTest("import java.util.*;\n" + + "public abstract class MyList extends AbstractList {\n" + + " private List elements;\n" + + " public T[] toArray( T[] array ) {\n" + + " return elements.toArray( array );\n" + + " }\n" + + "}\n"); + } + + @Override + protected InspectionProfileEntry getInspection() { + return new TypeParameterHidesVisibleTypeInspection(); + } +} diff --git a/plugins/git4idea/src/git4idea/GitCommit.java b/plugins/git4idea/src/git4idea/GitCommit.java index 870bc01d0a91..02a81f0c41af 100644 --- a/plugins/git4idea/src/git4idea/GitCommit.java +++ b/plugins/git4idea/src/git4idea/GitCommit.java @@ -33,10 +33,10 @@ import java.util.List; */ public final class GitCommit extends VcsFullCommitDetailsImpl { - public GitCommit(final Project project, @NotNull Hash hash, @NotNull List parents, long authorTime, @NotNull VirtualFile root, + public GitCommit(final Project project, @NotNull Hash hash, @NotNull List parents, long time, @NotNull VirtualFile root, @NotNull String subject, @NotNull VcsUser author, @NotNull String message, @NotNull VcsUser committer, - long commitTime, @NotNull List changes) { - super(hash, parents, authorTime, root, subject, author, message, committer, commitTime, changes, + long authorTime, @NotNull List changes) { + super(hash, parents, time, root, subject, author, message, committer, authorTime, changes, GitContentRevisionFactory.getInstance(project)); } diff --git a/plugins/git4idea/src/git4idea/branch/GitDeleteRemoteBranchOperation.java b/plugins/git4idea/src/git4idea/branch/GitDeleteRemoteBranchOperation.java index 8dd3608b3c11..29f7bd7f5c99 100644 --- a/plugins/git4idea/src/git4idea/branch/GitDeleteRemoteBranchOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitDeleteRemoteBranchOperation.java @@ -18,7 +18,7 @@ package git4idea.branch; import com.intellij.notification.NotificationType; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.MessageBuilder; +import com.intellij.openapi.ui.MessageDialogBuilder; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; @@ -239,7 +239,7 @@ class GitDeleteRemoteBranchOperation extends GitBranchOperation { } final AtomicBoolean deleteChoice = new AtomicBoolean(); - delete = MessageBuilder.yesNo(title, message).project(myProject).yesText("Delete").noText("Cancel").doNotAsk(new DialogWrapper.DoNotAskOption() { + delete = MessageDialogBuilder.yesNo(title, message).project(myProject).yesText("Delete").noText("Cancel").doNotAsk(new DialogWrapper.DoNotAskOption() { @Override public boolean isToBeShown() { return true; diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java index f07ef24b009a..a7f6719bdd67 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java +++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java @@ -823,7 +823,7 @@ public class GitCheckinEnvironment implements CheckinEnvironment { VcsFullCommitDetails commit = (VcsFullCommitDetails)data; String author = String.format("%s <%s>", commit.getAuthor().getName(), commit.getAuthor().getEmail()); myAuthor.getEditor().setItem(author); - myAuthorDate = new Date(commit.getAuthorTime()); + myAuthorDate = new Date(commit.getTime()); } } } diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index 13a8eeb3c57f..4844c6124607 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -510,7 +510,7 @@ public class GitHistoryUtils { public static List readMiniDetails(final Project project, final VirtualFile root, List hashes) throws VcsException { GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG); GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_NAME, - AUTHOR_EMAIL, AUTHOR_TIME, SUBJECT); + AUTHOR_EMAIL, COMMIT_TIME, SUBJECT); h.setStdoutSuppressed(true); // git show can show either -p, or --name-status, or --name-only, but we need nothing, just details => using git log --no-walk h.addParameters("--no-walk"); @@ -527,7 +527,7 @@ public class GitHistoryUtils { for (String parent : record.getParentsHashes()) { parents.add(HashImpl.build(parent)); } - return vcsObjectsFactory(project).createShortDetails(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(), root, + return vcsObjectsFactory(project).createShortDetails(HashImpl.build(record.getHash()), parents, record.getCommitTime(), root, record.getSubject(), record.getAuthorName(), record.getAuthorEmail()); } }); @@ -540,7 +540,7 @@ public class GitHistoryUtils { final int COMMIT_BUFFER = 1000; GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG); - final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_TIME, + final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, COMMIT_TIME, AUTHOR_NAME, AUTHOR_EMAIL); h.setStdoutSuppressed(true); h.addParameters(parser.getPretty(), "--encoding=UTF-8"); @@ -630,7 +630,7 @@ public class GitHistoryUtils { return HashImpl.build(s); } }); - return factory.createTimedCommit(HashImpl.build(rec.getHash()), parents, rec.getAuthorTimeStamp()); + return factory.createTimedCommit(HashImpl.build(rec.getHash()), parents, rec.getCommitTime()); } @NotNull @@ -789,9 +789,9 @@ public class GitHistoryUtils { } }); VcsLogObjectsFactory factory = vcsObjectsFactory(project); - return new GitCommit(project, HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(), root, record.getSubject(), + return new GitCommit(project, HashImpl.build(record.getHash()), parents, record.getCommitTime(), root, record.getSubject(), factory.createUser(record.getAuthorName(), record.getAuthorEmail()), record.getFullMessage(), - factory.createUser(record.getCommitterName(), record.getCommitterEmail()), record.getLongTimeStamp(), + factory.createUser(record.getCommitterName(), record.getCommitterEmail()), record.getAuthorTimeStamp(), record.parseChanges(project, root)); } @@ -1126,7 +1126,7 @@ public class GitHistoryUtils { } GitLogRecord record = parser.parseOneRecord(line); consumer.consume(new CommitHashPlusParents(record.getHash(), - record.getParentsHashes(), record.getLongTimeStamp(), + record.getParentsHashes(), record.getCommitTime(), record.getAuthorName())); } } catch (ProcessCanceledException e) { diff --git a/plugins/git4idea/src/git4idea/history/GitLogRecord.java b/plugins/git4idea/src/git4idea/history/GitLogRecord.java index 520256509596..6dcaace1aeba 100644 --- a/plugins/git4idea/src/git4idea/history/GitLogRecord.java +++ b/plugins/git4idea/src/git4idea/history/GitLogRecord.java @@ -101,7 +101,7 @@ class GitLogRecord { return GitUtil.parseTimestampWithNFEReport(myOptions.get(COMMIT_TIME), myHandler, myOptions.toString()); } - long getLongTimeStamp() { + long getCommitTime() { return Long.parseLong(myOptions.get(COMMIT_TIME).trim()) * 1000; } diff --git a/plugins/git4idea/src/git4idea/push/GitPushLog.java b/plugins/git4idea/src/git4idea/push/GitPushLog.java index b4e8f1c3c94e..a9cb2852b7d8 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushLog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushLog.java @@ -336,7 +336,7 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { @NotNull private static String getDateString(@NotNull GitCommit commit) { - return DateFormatUtil.formatPrettyDateTime(commit.getAuthorTime()) + " "; + return DateFormatUtil.formatPrettyDateTime(commit.getTime()) + " "; } @NotNull diff --git a/plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java b/plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java index 4e774d318779..dcb97c790d11 100644 --- a/plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java +++ b/plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java @@ -206,7 +206,7 @@ public class GitCommitListPanel extends JPanel implements TypeSafeDataProvider { } private static String getTime(GitCommit commit) { - return DateFormatUtil.formatPrettyDateTime(commit.getAuthorTime()); + return DateFormatUtil.formatPrettyDateTime(commit.getTime()); } private abstract static class GitCommitColumnInfo extends ColumnInfo { diff --git a/plugins/git4idea/tests/git4idea/log/RefParserTest.java b/plugins/git4idea/tests/git4idea/log/RefParserTest.java index c56aeb53f400..34f0375af48b 100644 --- a/plugins/git4idea/tests/git4idea/log/RefParserTest.java +++ b/plugins/git4idea/tests/git4idea/log/RefParserTest.java @@ -94,10 +94,10 @@ public class RefParserTest { @NotNull @Override - public VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List parents, long authorTime, VirtualFile root, + public VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List parents, long time, VirtualFile root, @NotNull String subject, @NotNull String authorName, @NotNull String authorEmail, @NotNull String message, @NotNull String committerName, @NotNull String committerEmail, - long commitTime, @NotNull List changes, + long authorTime, @NotNull List changes, @NotNull ContentRevisionFactory contentRevisionFactory) { throw new UnsupportedOperationException(); } diff --git a/plugins/gradle/gradle.iml b/plugins/gradle/gradle.iml index cc1787cb8c0b..1be3fee967cc 100644 --- a/plugins/gradle/gradle.iml +++ b/plugins/gradle/gradle.iml @@ -34,6 +34,7 @@ + diff --git a/plugins/gradle/lib/gradle-ide-1.9-rc-3.jar b/plugins/gradle/lib/gradle-ide-1.9-rc-3.jar new file mode 100644 index 000000000000..729f532aed5a Binary files /dev/null and b/plugins/gradle/lib/gradle-ide-1.9-rc-3.jar differ diff --git a/plugins/gradle/src/META-INF/plugin.xml b/plugins/gradle/src/META-INF/plugin.xml index e9fa2a1ac8e5..653c626c467e 100644 --- a/plugins/gradle/src/META-INF/plugin.xml +++ b/plugins/gradle/src/META-INF/plugin.xml @@ -36,6 +36,7 @@ + diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ExtIdeaContentRoot.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ExtIdeaContentRoot.java new file mode 100644 index 000000000000..d18aa3ed4389 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ExtIdeaContentRoot.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2013 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.gradle.model; + +import org.gradle.tooling.model.DomainObjectSet; +import org.gradle.tooling.model.idea.IdeaContentRoot; +import org.gradle.tooling.model.idea.IdeaSourceDirectory; + +import java.io.Serializable; + +/** + * @author Vladislav.Soroka + * @since 11/15/13 + */ +public interface ExtIdeaContentRoot extends IdeaContentRoot, Serializable { + + DomainObjectSet getResourceDirectories(); +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ModuleExtendedModel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ModuleExtendedModel.java index 4125a2b08423..2dff22e1ee56 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ModuleExtendedModel.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ModuleExtendedModel.java @@ -15,6 +15,8 @@ */ package org.jetbrains.plugins.gradle.model; +import org.gradle.tooling.model.DomainObjectSet; + import java.io.File; import java.io.Serializable; import java.util.List; @@ -51,4 +53,11 @@ public interface ModuleExtendedModel extends Serializable { * @return */ List getArtifacts(); + + /** + * All IDEA content roots. + * + * @return content roots + */ + DomainObjectSet getContentRoots(); } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/ModuleExtendedModelBuilderImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/ModuleExtendedModelBuilderImpl.java index e88e7e4d20cc..76ac2397655a 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/ModuleExtendedModelBuilderImpl.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/ModuleExtendedModelBuilderImpl.java @@ -17,14 +17,22 @@ package org.jetbrains.plugins.gradle.model.impl; import org.gradle.api.Project; import org.gradle.api.Task; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.bundling.Jar; +import org.gradle.api.tasks.testing.Test; +import org.gradle.plugins.ide.idea.IdeaPlugin; +import org.gradle.plugins.ide.idea.model.IdeaModel; import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot; import org.jetbrains.plugins.gradle.model.ModelBuilderService; import org.jetbrains.plugins.gradle.model.ModuleExtendedModel; +import org.jetbrains.plugins.gradle.model.internal.IdeaContentRootImpl; +import org.jetbrains.plugins.gradle.model.internal.IdeaSourceDirectoryImpl; import java.io.File; -import java.util.ArrayList; -import java.util.List; +import java.io.IOException; +import java.util.*; /** * @author Vladislav.Soroka @@ -32,6 +40,9 @@ import java.util.List; */ public class ModuleExtendedModelBuilderImpl implements ModelBuilderService { + private static final String SOURCE_SETS_PROPERTY = "sourceSets"; + private static final String TEST_SRC_DIRS_PROPERTY = "testSrcDirs"; + @Override public boolean canBuild(String modelName) { return ModuleExtendedModel.class.getName().equals(modelName); @@ -56,6 +67,93 @@ public class ModuleExtendedModelBuilderImpl implements ModelBuilderService { } moduleVersionModel.setArtifacts(artifacts); + + Set testDirectories = new HashSet(); + for (Task task : project.getTasks()) { + if (task instanceof Test) { + Test test = (Test)task; + if (test.hasProperty(TEST_SRC_DIRS_PROPERTY)) { + Object testSrcDirs = test.property(TEST_SRC_DIRS_PROPERTY); + if (testSrcDirs instanceof Iterable) { + for (Object dir : Iterable.class.cast(testSrcDirs)) { + addFilePath(testDirectories, dir); + } + } + } + } + } + + Set javaDirectories = new HashSet(); + Set resourceDirectories = new HashSet(); + + if (project.hasProperty(SOURCE_SETS_PROPERTY)) { + Object sourceSets = project.property(SOURCE_SETS_PROPERTY); + if (sourceSets instanceof SourceSetContainer) { + SourceSetContainer sourceSetContainer = (SourceSetContainer)sourceSets; + for (SourceSet sourceSet : sourceSetContainer) { + for (File javaSrcDir : sourceSet.getAllJava().getSrcDirs()) { + addFilePath(javaDirectories, javaSrcDir); + } + for (File resourcesSrcDir : sourceSet.getResources().getSrcDirs()) { + addFilePath(resourceDirectories, resourcesSrcDir); + } + } + } + } + + + File projectDir = project.getProjectDir(); + IdeaContentRootImpl contentRoot = new IdeaContentRootImpl(projectDir); + + enrichDataFromIdeaPlugin(project, contentRoot, javaDirectories, testDirectories); + + javaDirectories.removeAll(testDirectories); + javaDirectories.removeAll(resourceDirectories); + testDirectories.removeAll(resourceDirectories); + + for (String javaDir : javaDirectories) { + contentRoot.addSourceDirectory(new IdeaSourceDirectoryImpl(new File(javaDir))); + } + for (String testDir : testDirectories) { + contentRoot.addTestDirectory(new IdeaSourceDirectoryImpl(new File(testDir))); + } + for (String resourceDir : resourceDirectories) { + contentRoot.addResourceDirectory(new IdeaSourceDirectoryImpl(new File(resourceDir))); + } + + moduleVersionModel.setContentRoots(Collections.singleton(contentRoot)); return moduleVersionModel; } + + private static void addFilePath(Set filePathSet, Object file) { + if (file instanceof File) { + try { + filePathSet.add(((File)file).getCanonicalPath()); + } + catch (IOException ignore) { + } + } + } + + private static void enrichDataFromIdeaPlugin(Project project, + IdeaContentRootImpl contentRoot, + Set javaDirectories, + Set testDirectories) { + + IdeaPlugin ideaPlugin = project.getPlugins().getPlugin(IdeaPlugin.class); + if (ideaPlugin == null) return; + + IdeaModel ideaModel = ideaPlugin.getModel(); + if (ideaModel == null || ideaModel.getModule() == null) return; + + for (File excludeDir : ideaModel.getModule().getExcludeDirs()) { + contentRoot.addExcludeDirectory(excludeDir); + } + for (File file : ideaModel.getModule().getSourceDirs()) { + javaDirectories.add(file.getPath()); + } + for (File file : ideaModel.getModule().getTestSourceDirs()) { + testDirectories.add(file.getPath()); + } + } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/ModuleExtendedModelImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/ModuleExtendedModelImpl.java index a1dfa157b13f..d915e6a78415 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/ModuleExtendedModelImpl.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/ModuleExtendedModelImpl.java @@ -15,42 +15,48 @@ */ package org.jetbrains.plugins.gradle.model.impl; +import org.gradle.tooling.model.DomainObjectSet; +import org.gradle.tooling.model.internal.ImmutableDomainObjectSet; +import org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot; import org.jetbrains.plugins.gradle.model.ModuleExtendedModel; import java.io.File; import java.util.Collections; import java.util.List; +import java.util.Set; /** * @author Vladislav.Soroka * @since 11/8/13 */ public class ModuleExtendedModelImpl implements ModuleExtendedModel { - private final String name; - private final String group; - private final String version; + private final String myName; + private final String myGroup; + private final String myVersion; private List myArtifacts; + private Set myContentRoots; public ModuleExtendedModelImpl(String name, String group, String version) { - this.name = name; - this.group = group; - this.version = version; - this.myArtifacts = Collections.emptyList(); + myName = name; + myGroup = group; + myVersion = version; + myArtifacts = Collections.emptyList(); + myContentRoots = Collections.emptySet(); } @Override public String getName() { - return name; + return myName; } @Override public String getGroup() { - return group; + return myGroup; } @Override public String getVersion() { - return version; + return myVersion; } @Override @@ -61,4 +67,13 @@ public class ModuleExtendedModelImpl implements ModuleExtendedModel { public void setArtifacts(List artifacts) { this.myArtifacts = artifacts == null ? Collections.emptyList() : artifacts; } + + @Override + public DomainObjectSet getContentRoots() { + return ImmutableDomainObjectSet.of(myContentRoots); + } + + public void setContentRoots(Set contentRoots) { + myContentRoots = contentRoots == null ? Collections.emptySet() : contentRoots; + } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/IdeaContentRootImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/IdeaContentRootImpl.java new file mode 100644 index 000000000000..5de3b4172ca2 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/IdeaContentRootImpl.java @@ -0,0 +1,89 @@ +/* + * Copyright 2000-2013 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.gradle.model.internal; + +import org.gradle.tooling.model.DomainObjectSet; +import org.gradle.tooling.model.idea.IdeaSourceDirectory; +import org.gradle.tooling.model.internal.ImmutableDomainObjectSet; +import org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author Vladislav.Soroka + * @since 11/13/13 + */ +public class IdeaContentRootImpl implements ExtIdeaContentRoot { + + private final File myRootDirectory; + private final List mySourceDirectories; + private final List myTestDirectories; + private final List myResourceDirectories; + private final Set myExcludeDirectories; + + public IdeaContentRootImpl(File rootDirectory) { + myRootDirectory = rootDirectory; + mySourceDirectories = new ArrayList(); + myTestDirectories = new ArrayList(); + myResourceDirectories = new ArrayList(); + myExcludeDirectories = new HashSet(); + } + + @Override + public File getRootDirectory() { + return myRootDirectory; + } + + @Override + public DomainObjectSet getSourceDirectories() { + return ImmutableDomainObjectSet.of(mySourceDirectories); + } + + public void addSourceDirectory(IdeaSourceDirectory sourceDirectory) { + mySourceDirectories.add(sourceDirectory); + } + + public void addTestDirectory(IdeaSourceDirectory testDirectory) { + myTestDirectories.add(testDirectory); + } + + public void addResourceDirectory(IdeaSourceDirectory resourceDirectory) { + myResourceDirectories.add(resourceDirectory); + } + + public void addExcludeDirectory(File excludeDirectory) { + myExcludeDirectories.add(excludeDirectory); + } + + @Override + public DomainObjectSet getTestDirectories() { + return ImmutableDomainObjectSet.of(myTestDirectories); + } + + @Override + public DomainObjectSet getResourceDirectories() { + return ImmutableDomainObjectSet.of(myResourceDirectories); + } + + @Override + public Set getExcludeDirectories() { + return myExcludeDirectories; + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/IdeaSourceDirectoryImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/IdeaSourceDirectoryImpl.java new file mode 100644 index 000000000000..bcc37bd14124 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/IdeaSourceDirectoryImpl.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2013 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.gradle.model.internal; + +import org.gradle.tooling.model.idea.IdeaSourceDirectory; + +import java.io.File; +import java.io.Serializable; + +/** + * @author Vladislav.Soroka + * @since 11/15/13 + */ +public class IdeaSourceDirectoryImpl implements IdeaSourceDirectory, Serializable { + + private final File myDirectory; + + public IdeaSourceDirectoryImpl(File directory) { + myDirectory = directory; + } + + @Override + public File getDirectory() { + return myDirectory; + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java index 12337c07b6a0..25e3000b48e8 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java @@ -50,6 +50,7 @@ import org.gradle.tooling.model.idea.*; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.gradle.model.ExtIdeaContentRoot; import org.jetbrains.plugins.gradle.model.ModuleExtendedModel; import org.jetbrains.plugins.gradle.model.ProjectDependenciesModel; import org.jetbrains.plugins.gradle.model.impl.GradleDependency; @@ -61,6 +62,7 @@ import java.io.File; import java.io.FilenameFilter; import java.net.URL; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -150,7 +152,15 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver @Override public void populateModuleContentRoots(@NotNull IdeaModule gradleModule, @NotNull DataNode ideModule) { - DomainObjectSet contentRoots = gradleModule.getContentRoots(); + DomainObjectSet contentRoots; + ModuleExtendedModel moduleExtendedModel = resolverCtx.getExtraProject(gradleModule, ModuleExtendedModel.class); + if (moduleExtendedModel != null) { + contentRoots = moduleExtendedModel.getContentRoots(); + } + else { + contentRoots = gradleModule.getContentRoots(); + } + if (contentRoots == null) { return; } @@ -164,6 +174,12 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver ideModule.getData().setModuleFileDirectoryPath(ideContentRoot.getRootPath()); populateContentRoot(ideContentRoot, ExternalSystemSourceType.SOURCE, gradleContentRoot.getSourceDirectories()); populateContentRoot(ideContentRoot, ExternalSystemSourceType.TEST, gradleContentRoot.getTestDirectories()); + + if (gradleContentRoot instanceof ExtIdeaContentRoot) { + populateContentRoot(ideContentRoot, ExternalSystemSourceType.RESOURCE, + ExtIdeaContentRoot.class.cast(gradleContentRoot).getResourceDirectories()); + } + Set excluded = gradleContentRoot.getExcludeDirectories(); if (excluded != null) { for (File file : excluded) { @@ -278,7 +294,10 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver @NotNull @Override public List> getExtraJvmArgs() { - return HttpConfigurable.getJvmPropertiesList(false, null); + if (ExternalSystemApiUtil.isInProcessMode(GradleConstants.SYSTEM_ID)) { + return HttpConfigurable.getJvmPropertiesList(false, null); + } + return Collections.emptyList(); } @NotNull diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseProjectImportErrorHandler.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseProjectImportErrorHandler.java index 47f1cb9576a0..aa60940ffa94 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseProjectImportErrorHandler.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseProjectImportErrorHandler.java @@ -24,6 +24,8 @@ import org.gradle.tooling.UnsupportedVersionException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.PrintWriter; +import java.io.StringWriter; import java.net.ConnectException; import java.net.UnknownHostException; @@ -129,6 +131,15 @@ public class BaseProjectImportErrorHandler extends AbstractProjectImportErrorHan } } - return createUserFriendlyError(rootCause.getMessage(), location); + final String errMessage; + if (rootCause.getMessage() == null) { + StringWriter writer = new StringWriter(); + rootCause.printStackTrace(new PrintWriter(writer)); + errMessage = writer.toString(); + } + else { + errMessage = rootCause.getMessage(); + } + return createUserFriendlyError(errMessage, location); } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleIdeaPluginScriptContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleIdeaPluginScriptContributor.java new file mode 100644 index 000000000000..f853386987a0 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleIdeaPluginScriptContributor.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2013 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.gradle.service.resolve; + + +/** + * @author Vladislav.Soroka + * @since 11/18/13 + */ +public class GradleIdeaPluginScriptContributor extends GradleSimpleContributor { + public GradleIdeaPluginScriptContributor() { + super("idea", "org.gradle.plugins.ide.idea.model.IdeaModel"); + } +} \ No newline at end of file diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/ImportFromGradleControl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/ImportFromGradleControl.java index 9742bcc0c74a..5d54bee3fcec 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/ImportFromGradleControl.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/ImportFromGradleControl.java @@ -51,7 +51,9 @@ public class ImportFromGradleControl @NotNull @Override protected ExternalSystemSettingsControl createProjectSettingsControl(@NotNull GradleProjectSettings settings) { - return new GradleProjectSettingsControl(settings); + GradleProjectSettingsControl settingsControl = new GradleProjectSettingsControl(settings); + settingsControl.hideUseAutoImportBox(); + return settingsControl; } @Nullable diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java index 45d37ed54e83..5818cd95777b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java @@ -151,7 +151,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme return myExceptionChecker; } - public void setIntentionActionsFilter(IntentionActionsFilter filter) { + public void setIntentionActionsFilter(@NotNull IntentionActionsFilter filter) { myFilter = filter; } 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 index 20b18ad75c70..b850b44bcf3b 100644 --- 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 @@ -16,10 +16,8 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic; import com.intellij.codeInsight.completion.originInfo.OriginInfoAwareElement; -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 @@ -41,15 +39,7 @@ public class GrMethodWrapper extends GrLightMethodBuilder { 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); - } + getParameterList().copyParameters(method); if (method instanceof OriginInfoAwareElement) { setOriginInfo(((OriginInfoAwareElement)method).getOriginInfo()); diff --git a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/server/MavenServerEmbedder.java b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/server/MavenServerEmbedder.java index dba0c44502b2..8fe4348a0ade 100644 --- a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/server/MavenServerEmbedder.java +++ b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/server/MavenServerEmbedder.java @@ -36,7 +36,7 @@ public interface MavenServerEmbedder extends Remote { @NotNull Collection activeProfiles) throws RemoteException, MavenServerProcessCanceledException; - @NotNull + @Nullable String evaluateEffectivePom(@NotNull File file, @NotNull List activeProfiles) throws RemoteException, MavenServerProcessCanceledException; diff --git a/plugins/maven/maven2-server-impl/src/org/jetbrains/idea/maven/server/embedder/Maven2ServerEmbedderImpl.java b/plugins/maven/maven2-server-impl/src/org/jetbrains/idea/maven/server/embedder/Maven2ServerEmbedderImpl.java index 89f97f522910..630e664c2366 100644 --- a/plugins/maven/maven2-server-impl/src/org/jetbrains/idea/maven/server/embedder/Maven2ServerEmbedderImpl.java +++ b/plugins/maven/maven2-server-impl/src/org/jetbrains/idea/maven/server/embedder/Maven2ServerEmbedderImpl.java @@ -198,7 +198,7 @@ public class Maven2ServerEmbedderImpl extends MavenRemoteObject implements Maven return result; } - @NotNull + @Nullable public String evaluateEffectivePom(@NotNull File file, @NotNull List activeProfiles) { throw new UnsupportedOperationException(); } diff --git a/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedderImpl.java b/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedderImpl.java index bffa0403e26c..6a927fc786a8 100644 --- a/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedderImpl.java +++ b/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedderImpl.java @@ -287,7 +287,7 @@ public class Maven3ServerEmbedderImpl extends MavenRemoteObject implements Maven return createExecutionResult(file, result, listener.getRootNode()); } - @NotNull + @Nullable @Override public String evaluateEffectivePom(@NotNull File file, @NotNull List activeProfiles) throws RemoteException, MavenServerProcessCanceledException { diff --git a/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java b/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java index 180fc0572822..2d0c90dd3c0a 100644 --- a/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java +++ b/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java @@ -17,6 +17,7 @@ import org.jdom.input.SAXBuilder; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; @@ -43,38 +44,43 @@ public class MavenEffectivePomDumper { private static final String SETTINGS_XSD_URL = "http://maven.apache.org/xsd/settings-1.0.0.xsd"; // See org.apache.maven.plugins.help.EffectivePomMojo#execute from maven-help-plugin - + @Nullable public static String evaluateEffectivePom(final Maven3ServerEmbedderImpl embedder, @NotNull final File file, @NotNull List activeProfiles) throws RemoteException, MavenServerProcessCanceledException { - final MavenExecutionRequest - request = embedder.createRequest(file, activeProfiles, Collections.emptyList(), Collections.emptyList()); - final StringWriter w = new StringWriter(); - embedder.executeWithMavenSession(request, new Runnable() { - @Override - public void run() { - try { - // copied from DefaultMavenProjectBuilder.buildWithDependencies - ProjectBuilder builder = embedder.getComponent(ProjectBuilder.class); - ProjectBuildingResult buildingResult = builder.build(new File(file.getPath()), request.getProjectBuildingRequest()); + try { + final MavenExecutionRequest + request = embedder.createRequest(file, activeProfiles, Collections.emptyList(), Collections.emptyList()); - MavenProject project = buildingResult.getProject(); + embedder.executeWithMavenSession(request, new Runnable() { + @Override + public void run() { + try { + // copied from DefaultMavenProjectBuilder.buildWithDependencies + ProjectBuilder builder = embedder.getComponent(ProjectBuilder.class); + ProjectBuildingResult buildingResult = builder.build(new File(file.getPath()), request.getProjectBuildingRequest()); - XMLWriter writer = new PrettyPrintXMLWriter(w, StringUtils.repeat(" ", XmlWriterUtil.DEFAULT_INDENTATION_SIZE)); + MavenProject project = buildingResult.getProject(); - writeHeader(writer); + XMLWriter writer = new PrettyPrintXMLWriter(w, StringUtils.repeat(" ", XmlWriterUtil.DEFAULT_INDENTATION_SIZE)); - writeEffectivePom(project, writer); + writeHeader(writer); + + writeEffectivePom(project, writer); + } + catch (Exception e) { + throw new RuntimeException(e); + } } - catch (Exception e) { - throw new RuntimeException(e); - } - } - }); + }); + } + catch (Exception e) { + return null; + } return w.toString(); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenShowEffectivePom.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenShowEffectivePom.java index 7e1bd642c06b..b938230f8a1d 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenShowEffectivePom.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenShowEffectivePom.java @@ -66,7 +66,10 @@ public class MavenShowEffectivePom extends AnAction implements DumbAware { if (project.isDisposed()) return; if (s == null) { // null means UnsupportedOperationException - showUnsupportedNotification(project, file); + new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, + "Error", + "Failed to evaluate effective pom.", + NotificationType.ERROR).notify(project); return; } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenEmbedderWrapper.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenEmbedderWrapper.java index fad0d0e5f467..c5ac93cd6d7b 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenEmbedderWrapper.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenEmbedderWrapper.java @@ -101,7 +101,7 @@ public abstract class MavenEmbedderWrapper extends RemoteObjectWrapper activeProfiles) throws MavenProcessCanceledException { return perform(new RetriableCancelable() { diff --git a/plugins/properties/src/com/intellij/lang/properties/findUsages/PropertiesFindUsagesProvider.java b/plugins/properties/src/com/intellij/lang/properties/findUsages/PropertiesFindUsagesProvider.java index 50211cd7c332..99e73384850c 100644 --- a/plugins/properties/src/com/intellij/lang/properties/findUsages/PropertiesFindUsagesProvider.java +++ b/plugins/properties/src/com/intellij/lang/properties/findUsages/PropertiesFindUsagesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 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. @@ -22,7 +22,6 @@ import com.intellij.lang.cacheBuilder.WordsScanner; import com.intellij.lang.LangBundle; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNamedElement; -import com.intellij.find.impl.HelpID; import org.jetbrains.annotations.NotNull; /** @@ -34,7 +33,7 @@ public class PropertiesFindUsagesProvider implements FindUsagesProvider { } public String getHelpId(@NotNull PsiElement psiElement) { - return HelpID.FIND_OTHER_USAGES; + return com.intellij.lang.HelpID.FIND_OTHER_USAGES; } @NotNull diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/RootUrlInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/RootUrlInfo.java index d16e4c9e13de..73ec70bfd518 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/RootUrlInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/RootUrlInfo.java @@ -15,8 +15,8 @@ */ package org.jetbrains.idea.svn; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.UriUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.tmatesoft.svn.core.SVNURL; @@ -43,7 +43,7 @@ public class RootUrlInfo implements RootUrlPair { myNode = node; myFormat = format; myRoot = root; - myRepositoryUrl = StringUtil.trimEnd(node.getRepositoryRootUrl().toString(), "/"); + myRepositoryUrl = UriUtil.trimLastSlash(node.getRepositoryRootUrl().toString()); myType = type; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java index 112208830668..cfafc6585e92 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java @@ -23,7 +23,7 @@ import com.intellij.openapi.diff.impl.patch.formove.PatchApplier; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.MessageBuilder; +import com.intellij.openapi.ui.MessageDialogBuilder; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Comparing; @@ -594,7 +594,7 @@ public class MergeFromTheirsResolver { if (!containAdditions(myTheirsChanges) && !containAdditions(myTheirsBinaryChanges)) { return false; } - return Messages.YES == MessageBuilder.yesNo(TreeConflictRefreshablePanel.TITLE, "Keep newly created file(s) in their original place?").yesText("Keep").noText("Move").doNotAsk( + return Messages.YES == MessageDialogBuilder.yesNo(TreeConflictRefreshablePanel.TITLE, "Keep newly created file(s) in their original place?").yesText("Keep").noText("Move").doNotAsk( new DialogWrapper.DoNotAskOption() { @Override public boolean isToBeShown() { diff --git a/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/BaseRepositoryImpl.java b/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/BaseRepositoryImpl.java index 20f96a315783..0d6c2ecc09ec 100644 --- a/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/BaseRepositoryImpl.java +++ b/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/BaseRepositoryImpl.java @@ -1,5 +1,6 @@ package com.intellij.tasks.impl; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.tasks.TaskRepositoryType; import com.intellij.tasks.config.TaskSettings; import com.intellij.tasks.impl.ssl.CertificatesManager; @@ -12,6 +13,7 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.net.ssl.SSLContext; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -23,8 +25,18 @@ import java.net.URLEncoder; public abstract class BaseRepositoryImpl extends BaseRepository { public static final String EASY_HTTPS = "easyhttps"; + private static final Logger LOG = Logger.getInstance(BaseRepositoryImpl.class); + static { - Protocol.registerProtocol("https", CertificatesManager.createDefault().createProtocol()); + try { + SSLContext context = CertificatesManager.createDefault().createSslContext(); + SSLContext.setDefault(context); + } + catch (Exception e) { + LOG.error(e); + } + // Don't do this: protocol created this way will ignore SSL tunnels. See IDEA-115708. + // Protocol.registerProtocol("https", CertificatesManager.createDefault().createProtocol()); Protocol.registerProtocol(EASY_HTTPS, new Protocol(EASY_HTTPS, (ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), 443)); } diff --git a/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/ssl/CertificatesManager.java b/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/ssl/CertificatesManager.java index d3c6a8f3cc45..9ade70c6fd84 100644 --- a/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/ssl/CertificatesManager.java +++ b/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/ssl/CertificatesManager.java @@ -152,7 +152,7 @@ public class CertificatesManager { X509Certificate certificate = certificates[0]; // looks like self-signed certificate if (certificates.length == 1 && certificateIsSelfSigned(certificate)) { - // check-the-act sequence + // check-then-act sequence synchronized (myCustomManager) { try { myCustomManager.checkServerTrusted(certificates, s); diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/OpenTaskDialog.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/OpenTaskDialog.java index 4a7f3e729d4b..f4617f8077ee 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/OpenTaskDialog.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/OpenTaskDialog.java @@ -198,13 +198,17 @@ public class OpenTaskDialog extends DialogWrapper { } if (myCreateBranch.isSelected()) { VcsTaskHandler.TaskInfo item = (VcsTaskHandler.TaskInfo)myBranchFrom.getSelectedItem(); + Runnable createBranch = new Runnable() { + @Override + public void run() { + taskManager.createBranch(localTask, activeTask, myBranchName.getText()); + } + }; if (item != null && !item.equals(myVcsTaskHandler.getActiveTask())) { - myVcsTaskHandler.switchToTask(item, new Runnable() { - @Override - public void run() { - taskManager.createBranch(localTask, activeTask, myBranchName.getText()); - } - }); + myVcsTaskHandler.switchToTask(item, createBranch); + } + else { + createBranch.run(); } } if (myTask.getType() == TaskType.EXCEPTION && AnalyzeTaskStacktraceAction.hasTexts(myTask)) { diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepositoryType.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepositoryType.java index 3b8a640c8fa0..3d10a1c811ee 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepositoryType.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepositoryType.java @@ -3,8 +3,8 @@ package com.intellij.tasks.generic; import com.intellij.icons.AllIcons; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.JDOMUtil; -import com.intellij.tasks.TaskRepositorySubtype; import com.intellij.tasks.TaskRepository; +import com.intellij.tasks.TaskRepositorySubtype; import com.intellij.tasks.config.TaskRepositoryEditor; import com.intellij.tasks.impl.BaseRepositoryType; import com.intellij.util.Consumer; @@ -61,7 +61,8 @@ public class GenericRepositoryType extends BaseRepositoryType this, new AsanaRepository(), new AssemblaRepository(), - new SprintlyRepository() + new SprintlyRepository(), + new GitlabRepository() ); } @@ -126,4 +127,10 @@ public class GenericRepositoryType extends BaseRepositoryType super("Sprintly", TasksIcons.Sprintly); } } + + public final class GitlabRepository extends GenericSubtype { + public GitlabRepository() { + super("Gitlab", TasksIcons.Gitlab); + } + } } diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/connectors/gitlab.xml b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/connectors/gitlab.xml new file mode 100644 index 000000000000..b3ffd3c21111 --- /dev/null +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/connectors/gitlab.xml @@ -0,0 +1,75 @@ + + {id} {summary} + diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/mantis/MantisRepositoryEditor.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/mantis/MantisRepositoryEditor.java index b69f64873ec7..7af64faeabfb 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/mantis/MantisRepositoryEditor.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/mantis/MantisRepositoryEditor.java @@ -1,12 +1,11 @@ package com.intellij.tasks.mantis; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.tasks.config.BaseRepositoryEditor; import com.intellij.ui.components.JBLabel; import com.intellij.util.Consumer; +import com.intellij.util.UriUtil; import com.intellij.util.ui.FormBuilder; import org.jetbrains.annotations.Nullable; @@ -19,8 +18,6 @@ import java.awt.event.ItemListener; * Date: 9/21/12 */ public class MantisRepositoryEditor extends BaseRepositoryEditor { - private static final Logger LOG = Logger.getInstance("#com.intellij.tasks.mantis.MantisRepositoryEditor"); - private ComboBox myProjectCombobox; private ComboBox myFilterCombobox; private JBLabel myProjectLabel; @@ -35,7 +32,7 @@ public class MantisRepositoryEditor extends BaseRepositoryEditor EP_NAME = ExtensionPointName.create("Pythonid.resolveResultRater"); + + int getRate(@NotNull final PsiElement target); +} diff --git a/python/src/META-INF/python-core.xml b/python/src/META-INF/python-core.xml index 4abdce69e8a0..4846385475a9 100644 --- a/python/src/META-INF/python-core.xml +++ b/python/src/META-INF/python-core.xml @@ -513,6 +513,7 @@ + diff --git a/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java b/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java index 57fe1a6230db..6a80851cea1b 100644 --- a/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java +++ b/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python.psi.resolve; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.projectRoots.Sdk; @@ -366,6 +367,9 @@ public class ResolveImportUtil { if (vFile != null && vFile.getLength() > 0) { rate += 100; } + for (PyResolveResultRater rater : Extensions.getExtensions(PyResolveResultRater.EP_NAME)) { + rate += rater.getRate(target); + } } ret.poke(target, rate); } diff --git a/python/src/com/jetbrains/python/refactoring/classes/PyClassRefactoringUtil.java b/python/src/com/jetbrains/python/refactoring/classes/PyClassRefactoringUtil.java index f5ba91893134..9b11d159ae1f 100644 --- a/python/src/com/jetbrains/python/refactoring/classes/PyClassRefactoringUtil.java +++ b/python/src/com/jetbrains/python/refactoring/classes/PyClassRefactoringUtil.java @@ -25,16 +25,15 @@ import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilBase; import com.intellij.psi.util.PsiUtilCore; +import com.intellij.psi.util.QualifiedName; import com.jetbrains.python.PyNames; import com.jetbrains.python.PythonFileType; import com.jetbrains.python.codeInsight.PyCodeInsightSettings; import com.jetbrains.python.codeInsight.imports.AddImportHelper; -import com.jetbrains.python.documentation.DocStringTypeReference; import com.jetbrains.python.psi.*; import com.jetbrains.python.psi.impl.PyBuiltinCache; import com.jetbrains.python.psi.impl.PyImportedModule; import com.jetbrains.python.psi.impl.PyPsiUtils; -import com.intellij.psi.util.QualifiedName; import com.jetbrains.python.psi.resolve.QualifiedNameFinder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -190,7 +189,7 @@ public class PyClassRefactoringUtil { public void visitPyStringLiteralExpression(PyStringLiteralExpression node) { super.visitPyStringLiteralExpression(node); for (PsiReference ref : node.getReferences()) { - if (ref instanceof DocStringTypeReference && ref.isReferenceTo(oldElement)) { + if (ref.isReferenceTo(oldElement)) { ref.bindToElement(newElement); } } diff --git a/python/src/com/jetbrains/python/refactoring/move/PyMoveClassOrFunctionProcessor.java b/python/src/com/jetbrains/python/refactoring/move/PyMoveClassOrFunctionProcessor.java index fe4da8e6cc92..5c22514f28f2 100644 --- a/python/src/com/jetbrains/python/refactoring/move/PyMoveClassOrFunctionProcessor.java +++ b/python/src/com/jetbrains/python/refactoring/move/PyMoveClassOrFunctionProcessor.java @@ -23,6 +23,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; +import com.intellij.psi.util.QualifiedName; import com.intellij.refactoring.BaseRefactoringProcessor; import com.intellij.refactoring.ui.UsageViewDescriptorAdapter; import com.intellij.refactoring.util.CommonRefactoringUtil; @@ -33,9 +34,7 @@ import com.jetbrains.python.PyBundle; import com.jetbrains.python.PyNames; import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil; import com.jetbrains.python.codeInsight.imports.PyImportOptimizer; -import com.jetbrains.python.documentation.DocStringTypeReference; import com.jetbrains.python.psi.*; -import com.intellij.psi.util.QualifiedName; import com.jetbrains.python.psi.resolve.QualifiedNameFinder; import com.jetbrains.python.refactoring.PyRefactoringUtil; import com.jetbrains.python.refactoring.classes.PyClassRefactoringUtil; @@ -193,7 +192,7 @@ public class PyMoveClassOrFunctionProcessor extends BaseRefactoringProcessor { } if (usage instanceof PyStringLiteralExpression) { for (PsiReference ref : usage.getReferences()) { - if (ref instanceof DocStringTypeReference && ref.isReferenceTo(oldElement)) { + if (ref.isReferenceTo(oldElement)) { ref.bindToElement(newElement); } } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java index 01c0bf7ec468..4e6ec59c62b9 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java @@ -82,6 +82,7 @@ public abstract class DomAnchorImpl implements DomAnchor(parentAnchor, description, index); diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/AttributeStub.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/AttributeStub.java index 552675235ce8..4ea707e70e88 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/AttributeStub.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/AttributeStub.java @@ -43,6 +43,11 @@ public class AttributeStub extends DomStub { return Collections.emptyList(); } + @Override + public int getIndex() { + return 0; + } + @Override public ObjectStubSerializer getStubType() { return AttributeStubSerializer.INSTANCE; diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/DomStub.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/DomStub.java index 9b94200b66c9..4097329573f5 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/DomStub.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/DomStub.java @@ -53,11 +53,6 @@ public abstract class DomStub extends ObjectStubBase { public abstract List getChildrenStubs(); - public int getChildIndex(DomStub child) { - List stubs = getChildrenByName(XmlUtil.getLocalName(child.getName()), child.getNamespaceKey()); - return stubs.indexOf(child); - } - public String getName() { return myLocalName.getString(); } @@ -136,4 +131,12 @@ public abstract class DomStub extends ObjectStubBase { public boolean isCustom() { return false; } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + return super.equals(obj); + } + + public abstract int getIndex(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStub.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStub.java index 33002cce1d7d..afbf498a5b48 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStub.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStub.java @@ -31,11 +31,14 @@ import java.util.List; public class ElementStub extends DomStub { private final List myChildren = new SmartList(); + private final int myIndex; private final boolean myCustom; - public ElementStub(@Nullable ElementStub parent, @NotNull StringRef name, @Nullable StringRef namespace, boolean custom) { + public ElementStub(@Nullable ElementStub parent, @NotNull StringRef name, @Nullable StringRef namespace, int index, boolean custom) { super(parent, name, namespace); + myIndex = index; myCustom = custom; + } void addChild(DomStub child) { @@ -58,13 +61,12 @@ public class ElementStub extends DomStub { return StringUtil.isEmpty(key) ? getName() : key + ":" + getName(); } - @Override - public boolean equals(Object obj) { - if (obj == this) return true; - return obj instanceof ElementStub && id == ((ElementStub)obj).id && myLocalName.equals(((ElementStub)obj).myLocalName); - } - public boolean isCustom() { return myCustom; } + + @Override + public int getIndex() { + return myIndex; + } } diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStubSerializer.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStubSerializer.java index d1522f523846..5edc9dc35072 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStubSerializer.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStubSerializer.java @@ -37,13 +37,14 @@ public class ElementStubSerializer implements ObjectStubSerializer children = parentStub.getChildrenStubs(); + if (children.isEmpty()) return null; XmlTag parentTag = parentStub.getHandler().getXmlTag(); if (parentTag == null) return null; // for custom elements, namespace information is lost // todo: propagate ns info through DomChildDescriptions XmlTag[] tags = parentTag.getSubTags(); + int i = 0; - String nameToFind = myStub.isCustom() ? XmlUtil.findLocalNameByQualifiedName(myStub.getName()) : myStub.getName(); - assert nameToFind != null; + String nameToFind = myStub.getName(); for (XmlTag xmlTag : tags) { - if (myStub.isCustom()) { - if (nameToFind.equals(xmlTag.getLocalName())) { - if (index == i++) { - return xmlTag; - } - } - } - else if (nameToFind.equals(xmlTag.getName())) { - if (index == i++) { - return xmlTag; - } + if (nameToFind.equals(xmlTag.getName()) && myStub.getIndex() == i++) { + return xmlTag; } } return null; diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java index f3ead60b0c5f..df7a78a4288e 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java @@ -71,7 +71,7 @@ public class DomStubBuilder implements BinaryFileStubBuilder { FileStub fileStub = new FileStub(header); XmlTag rootTag = xmlFile.getRootTag(); if (rootTag != null) { - new DomStubBuilderVisitor(DomManagerImpl.getDomManager(project)).visitXmlElement(rootTag, fileStub); + new DomStubBuilderVisitor(DomManagerImpl.getDomManager(project)).visitXmlElement(rootTag, fileStub, 0); } return fileStub; } @@ -83,7 +83,7 @@ public class DomStubBuilder implements BinaryFileStubBuilder { @Override public int getStubVersion() { - int version = 9; + int version = 10; DomFileDescription[] descriptions = Extensions.getExtensions(DomFileDescription.EP_NAME); for (DomFileDescription description : descriptions) { version += description.getStubVersion(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilderVisitor.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilderVisitor.java index 80289dc4ec94..d15ba90bce3b 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilderVisitor.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilderVisitor.java @@ -28,6 +28,9 @@ import com.intellij.util.xml.reflect.DomChildrenDescription; import com.intellij.util.xml.stubs.AttributeStub; import com.intellij.util.xml.stubs.ElementStub; +import java.util.HashMap; +import java.util.Map; + /** * @author Dmitry Avdeev * Date: 8/7/12 @@ -39,7 +42,7 @@ class DomStubBuilderVisitor { myManager = manager; } - void visitXmlElement(XmlElement element, ElementStub parent) { + void visitXmlElement(XmlElement element, ElementStub parent, int index) { DomInvocationHandler handler = myManager.getDomHandler(element); if (handler == null || handler.getAnnotation(Stubbed.class) == null && !handler.getChildDescription().isStubbed()) return; @@ -50,12 +53,18 @@ class DomStubBuilderVisitor { ElementStub stub = new ElementStub(parent, StringRef.fromString(tag.getName()), StringRef.fromNullableString(nsKey), + index, description instanceof CustomDomChildrenDescription); for (XmlAttribute attribute : tag.getAttributes()) { - visitXmlElement(attribute, stub); + visitXmlElement(attribute, stub, 0); } + Map indices = new HashMap(); for (final XmlTag subTag : tag.getSubTags()) { - visitXmlElement(subTag, stub); + String name = subTag.getName(); + Integer i = indices.get(name); + i = i == null ? 0 : i + 1; + visitXmlElement(subTag, stub, i); + indices.put(name, i); } } else if (element instanceof XmlAttribute) { new AttributeStub(parent, StringRef.fromString(((XmlAttribute)element).getLocalName()), diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java index a80b08d9d972..3797ae99d06f 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java @@ -65,7 +65,7 @@ import java.util.List; /** * @author Eugene.Kudelevsky */ -public class ZenCodingTemplate implements CustomLiveTemplate { +public class ZenCodingTemplate extends CustomLiveTemplateBase { public static final char MARKER = '\0'; private static final String EMMET_RECENT_WRAP_ABBREVIATIONS_KEY = "emmet.recent.wrap.abbreviations"; private static final String EMMET_LAST_WRAP_ABBREVIATIONS_KEY = "emmet.last.wrap.abbreviations"; diff --git a/xml/impl/src/com/intellij/ide/browsers/Urls.java b/xml/impl/src/com/intellij/ide/browsers/Urls.java index f3d2152091ea..e1abd3727a63 100644 --- a/xml/impl/src/com/intellij/ide/browsers/Urls.java +++ b/xml/impl/src/com/intellij/ide/browsers/Urls.java @@ -15,12 +15,11 @@ */ package com.intellij.ide.browsers; -import com.google.common.base.CharMatcher; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.StandardFileSystems; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.io.URLUtil; import org.jetbrains.annotations.NotNull; @@ -35,15 +34,13 @@ import java.util.regex.Pattern; public final class Urls { private static final Logger LOG = Logger.getInstance(Urls.class); - public static final CharMatcher SLASH_MATCHER = CharMatcher.is('/'); - // about ";" see WEB-100359 private static final Pattern URI_PATTERN = Pattern.compile("^([^:/?#]+)://([^/?#]*)([^?#;]*)(.*)"); @NotNull public static Url newFromEncoded(@NotNull String url) { Url result = parse(url, true); - LOG.assertTrue(result != null); + LOG.assertTrue(result != null, url); return result; } @@ -52,13 +49,19 @@ public final class Urls { return new UrlImpl("http", authority, path); } + // java.net.URI.create cannot parse "file:///Test Stuff" - but you don't need to worry about it - this method is aware + @Nullable + public static Url newFromIdea(@NotNull String url) { + return URLUtil.containsScheme(url) ? parseUrl(url) : new LocalFileUrl(url); + } + @Nullable public static Url parse(@NotNull String url, boolean asLocalIfNoScheme) { if (asLocalIfNoScheme && !URLUtil.containsScheme(url)) { // nodejs debug — files only in local filesystem return new LocalFileUrl(url); } - return parseUrl(VfsUtil.toIdeaUrl(url)); + return parseUrl(VfsUtilCore.toIdeaUrl(url)); } @Nullable @@ -112,12 +115,6 @@ public final class Urls { return new UrlImpl(scheme, authority, path, parameters); } - // java.net.URI.create cannot parse "file:///Test Stuff" - but you don't need to worry about it - this method is aware - @Nullable - public static Url newFromIdea(@NotNull String url) { - return URLUtil.containsScheme(url) ? parseUrl(VfsUtil.toIdeaUrl(url)) : new LocalFileUrl(url); - } - // must not be used in NodeJS public static Url newFromVirtualFile(@NotNull VirtualFile file) { if (file.isInLocalFileSystem()) { diff --git a/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java b/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java index 19089b62405f..41b456d41119 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ */ package com.intellij.lang.xml; -import com.intellij.find.impl.HelpID; import com.intellij.lang.LangBundle; import com.intellij.lang.cacheBuilder.WordsScanner; import com.intellij.lang.findUsages.DescriptiveNameUtil; @@ -73,7 +72,7 @@ public class XmlFindUsagesProvider implements FindUsagesProvider { } public String getHelpId(@NotNull PsiElement element) { - return HelpID.FIND_OTHER_USAGES; + return com.intellij.lang.HelpID.FIND_OTHER_USAGES; } @NotNull diff --git a/xml/xml-psi-api/src/com/intellij/javaee/UriUtil.java b/xml/xml-psi-api/src/com/intellij/javaee/UriUtil.java index c9d9180d00dc..c2dd5593f8bb 100644 --- a/xml/xml-psi-api/src/com/intellij/javaee/UriUtil.java +++ b/xml/xml-psi-api/src/com/intellij/javaee/UriUtil.java @@ -19,6 +19,7 @@ */ package com.intellij.javaee; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFileSystemItem; @@ -40,4 +41,10 @@ public class UriUtil { String location = ExternalResourceManager.getInstance().getResourceLocation(uri, base.getProject()); return VfsUtilCore.findRelativeFile(location, base.getVirtualFile()); } + + // cannot use UriUtil.SLASH_MATCHER.trimFrom - we don't depend on guava + @NotNull + public static String trimSlashFrom(@NotNull String path) { + return StringUtil.trimStart(StringUtil.trimEnd(path, "/"), "/"); + } } \ No newline at end of file diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java index b46b6bfca0c8..ca96d33c034e 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 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. diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java index 712cf2053f32..bfbc4a7bad8c 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java @@ -376,7 +376,7 @@ public class XmlUtil { return XSLT_URI.equals(ns) || XINCLUDE_URI.equals(ns); } - public static char getCharFromEntityRef(@NonNls String text) { + public static char getCharFromEntityRef(@NonNls @NotNull String text) { try { if (text.charAt(1) != '#') { text = text.substring(1, text.length() - 1);