diff --git a/build/dependencies/setupJdk.gradle b/build/dependencies/setupJdk.gradle index 6b58c0f8534d..9dc71e2f4e7d 100644 --- a/build/dependencies/setupJdk.gradle +++ b/build/dependencies/setupJdk.gradle @@ -60,24 +60,23 @@ task setupJdk18(dependsOn: downloadJdk18) { def unpackJdk(jdkArchive, outputDir) { logger.info("Unpacking $jdkArchive to ${outputDir}") file(outputDir).deleteDir() - if (!org.gradle.internal.os.OperatingSystem.current().isWindows()) { - exec { commandLine 'mkdir', '-p', outputDir } - exec { commandLine 'tar', 'xpf', "${jdkArchive.absolutePath}", '--directory', outputDir } - def jdkContents = file("${outputDir}/jdk/Contents") - if (org.gradle.internal.os.OperatingSystem.current().isMacOsX() && jdkContents.exists()) { - copy { - from fileTree(jdkContents) - into outputDir - } - jdkContents.deleteDir() - } - } - else { + def currentOs = org.gradle.internal.os.OperatingSystem.current() + if (currentOs.isWindows()) { copy { from tarTree(jdkArchive) into outputDir } } + else { + exec { commandLine 'mkdir', '-p', outputDir } + exec { commandLine 'tar', 'xpf', "$jdkArchive.absolutePath", '--directory', outputDir } + def jdkContents = file("${outputDir}/jdk/Contents") + if (currentOs.isMacOsX() && jdkContents.exists()) { + jdkContents.listFiles().each { file -> + exec { commandLine 'mv', "$file.absolutePath", outputDir } + } + } + } } static def currentPlatformName() { diff --git a/build/scripts/common_tests.gant b/build/scripts/common_tests.gant deleted file mode 100644 index 898b8938f613..000000000000 --- a/build/scripts/common_tests.gant +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2000-2017 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. - */ -import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome - -includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant") - -requireProperty("out", "$home/out") - -target(compile: "Compile project") { - ant.delete(failonerror: false) { - fileset(dir: "$home/reports") - fileset(dir: "$home/bin", includes: "*.hprof") - } - - loadProject() - prepareOutputFolder() - - if (System.getProperty("tests.only")) { - ant.delete(dir: "$home/out") - ant.unzip(src: "$home/out.zip", dest: "$home/out") - return - } - - if (!isDefined("avoid.project.rebuild")) { - projectBuilder.cleanOutput() - projectBuilder.buildAll() - } -} - -private pass(List args, String prop) { - if (isDefined(prop)) { - args << "-D$prop=${p(prop)}" - } -} - -target('run_tests': 'Run java tests') { - depends([compile]) - - def classpathFile = "$home/junit.classpath" - //todo[nik] currently runtime classpath includes path to JDKs from all modules in it so we need to manually exclude paths from JDK 1.6 - List testRuntimeClasspath = removeJdkJarFiles(projectBuilder.moduleRuntimeClasspath(findModule("community-main"), true)) - testRuntimeClasspath << "${jdk8Home}/lib/tools.jar" - projectBuilder.info("Test runtime classpath=" + testRuntimeClasspath) - new File(classpathFile).text = testRuntimeClasspath.findAll({ new File((String)it).exists() }).join('\n') - - List bootstrapClasspath = removeJdkJarFiles(projectBuilder.moduleRuntimeClasspath(findModule("tests_bootstrap"), false)) - bootstrapClasspath << "${jdk8Home}/lib/tools.jar" - projectBuilder.info("Bootstrap classpath=" + bootstrapClasspath) - - testcases.each { testCase -> - List jvmArgs = [ - "-Dclasspath.file=${classpathFile}", - "-Didea.platform.prefix=Idea", - "-Dbootstrap.testcases=$testCase" - ] - - [ - "idea.test.group", - "idea.test.patterns", - "idea.coverage.enabled.build", - "teamcity.tests.recentlyFailedTests.file" - ].each { pass(jvmArgs, it) } - - def tempDir = p("teamcity.build.tempDir", p("java.io.tmpdir")) - jvmArgs << "-Djava.io.tmpdir=${tempDir}" - jvmArgs << "-Dteamcity.build.tempDir=${tempDir}" - - System.getProperties().entrySet().each { - if (it.key.startsWith("pass.")) { - def trimmed = it.key.substring("pass.".length()); - jvmArgs << "-D${trimmed}=${it.value}" - }; - } - jvmArgs.addAll(commonJvmArgsForTests()) - if (isDefined("jvm_args")) { - jvmArgs.addAll(jvm_args) - } - - projectBuilder.info("Starting JUnit $testCase, JVM options: $jvmArgs") - ant.junit(fork: "yes", showoutput: "true", logfailedtests: false) { - jvmArgs.each { - jvmarg(value: it) - } - - classpath { - bootstrapClasspath.each { - pathelement(location: it) - } - } - - test(name: 'com.intellij.tests.BootstrapTests') - } - } -} - -target('default' : "Run all tests") { - depends([compile, run_tests]) -} \ No newline at end of file diff --git a/build/scripts/tests.gant b/build/scripts/tests.gant deleted file mode 100644 index 4a943ded52f7..000000000000 --- a/build/scripts/tests.gant +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2015 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. - */ -import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome - -def home = guessHome(this) - -includeTargets << new File("${home}/build/scripts/common_tests.gant") - -def args = [] - -def mem = System.getProperty("test.jvm.memory") -if (mem != null) { - args.addAll(mem.split()) -} -else { - args += [ - "-Xmx450m", - "-Dsun.io.useCanonCaches=false" - ] -} - -args << "-Djna.nosys=true" - -setProperty("jvm_args", args) - -setProperty("testcases", ["com.intellij.AllTests"]) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java index 808a2fd701a5..cc0248b49442 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java @@ -25,6 +25,7 @@ import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.jdi.VirtualMachineProxyImpl; import com.intellij.debugger.requests.ClassPrepareRequestor; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; @@ -203,18 +204,26 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio return new JavaSourcePosition(sourcePosition, location.declaringType(), method, lambdaOrdinal); } - private static class JavaSourcePosition extends RemappedSourcePosition { + public static class JavaSourcePosition extends RemappedSourcePosition { private final String myExpectedClassName; private final String myExpectedMethodName; private final int myLambdaOrdinal; - public JavaSourcePosition(SourcePosition delegate, ReferenceType declaringType, Method method, int lambdaOrdinal) { + public JavaSourcePosition(@NotNull SourcePosition delegate, ReferenceType declaringType, Method method, int lambdaOrdinal) { super(delegate); myExpectedClassName = declaringType != null ? declaringType.name() : null; myExpectedMethodName = method != null ? method.name() : null; myLambdaOrdinal = lambdaOrdinal; } + public JavaSourcePosition(@NotNull SourcePosition delegate, int lambdaOrdinal) { + super(delegate); + assert lambdaOrdinal > -1; + myExpectedClassName = null; + myExpectedMethodName = "lambda$"; // fake lambda name + myLambdaOrdinal = lambdaOrdinal; + } + private PsiElement remapElement(PsiElement element) { String name = JVMNameUtil.getClassVMName(getEnclosingClass(element)); if (name != null && !name.equals(myExpectedClassName)) { @@ -244,37 +253,34 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio @Override public SourcePosition mapDelegate(final SourcePosition original) { - return ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public SourcePosition compute() { - PsiFile file = original.getFile(); - int line = original.getLine(); - if (DebuggerUtilsEx.isLambdaName(myExpectedMethodName) && myLambdaOrdinal > -1) { - List lambdas = DebuggerUtilsEx.collectLambdas(original, true); + return ReadAction.compute(() -> { + PsiFile file = original.getFile(); + int line = original.getLine(); + if (DebuggerUtilsEx.isLambdaName(myExpectedMethodName) && myLambdaOrdinal > -1) { + List lambdas = DebuggerUtilsEx.collectLambdas(original, true); - Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); - if (document == null || line >= document.getLineCount()) { - return original; - } - if (myLambdaOrdinal < lambdas.size()) { - PsiElement firstElem = DebuggerUtilsEx.getFirstElementOnTheLine(lambdas.get(myLambdaOrdinal), document, line); - if (firstElem != null) { - return SourcePosition.createFromElement(firstElem); - } + Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); + if (document == null || line >= document.getLineCount()) { + return original; + } + if (myLambdaOrdinal < lambdas.size()) { + PsiElement firstElem = DebuggerUtilsEx.getFirstElementOnTheLine(lambdas.get(myLambdaOrdinal), document, line); + if (firstElem != null) { + return SourcePosition.createFromElement(firstElem); } } - else { - // There may be more than one class/method code on the line, so we need to find out the correct place - for (PsiElement elem : getLineElements(file, line)) { - PsiElement remappedElement = remapElement(elem); - if (remappedElement != null) { - if (remappedElement.getTextOffset() <= original.getOffset()) break; - return SourcePosition.createFromElement(remappedElement); - } - } - } - return original; } + else { + // There may be more than one class/method code on the line, so we need to find out the correct place + for (PsiElement elem : getLineElements(file, line)) { + PsiElement remappedElement = remapElement(elem); + if (remappedElement != null) { + if (remappedElement.getTextOffset() <= original.getOffset()) break; + return SourcePosition.createFromElement(remappedElement); + } + } + } + return original; }); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/RemappedSourcePosition.java b/java/debugger/impl/src/com/intellij/debugger/engine/RemappedSourcePosition.java index 8fb462314bd9..51d2bd00017e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/RemappedSourcePosition.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/RemappedSourcePosition.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -28,7 +28,7 @@ abstract class RemappedSourcePosition extends SourcePosition { private SourcePosition myDelegate; private boolean myMapped = false; - public RemappedSourcePosition(SourcePosition delegate) { + public RemappedSourcePosition(@NotNull SourcePosition delegate) { myDelegate = delegate; } diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java index 63e3db1c90f1..7ea837515204 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java @@ -761,6 +761,20 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils { return null; } + @Nullable + public static SourcePosition toSourcePosition(@Nullable XSourcePosition position, Project project) { + if (position != null) { + if (position instanceof JavaXSourcePosition) { + return ((JavaXSourcePosition)position).mySourcePosition; + } + PsiFile psiFile = PsiManager.getInstance(project).findFile(position.getFile()); + if (psiFile != null) { + return SourcePosition.createFromLine(psiFile, position.getLine()); + } + } + return null; + } + private static class JavaXSourcePosition implements XSourcePosition, ExecutionPointHighlighter.HighlighterProvider { private final SourcePosition mySourcePosition; @NotNull private final VirtualFile myFile; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java index 2e4ec9617827..628309e30364 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,6 +23,7 @@ import com.intellij.debugger.engine.JVMNameUtil; import com.intellij.debugger.engine.events.DebuggerCommandImpl; import com.intellij.debugger.engine.requests.RequestManagerImpl; import com.intellij.debugger.impl.DebuggerContextImpl; +import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; @@ -235,14 +236,9 @@ public abstract class BreakpointWithHighlighter

return true; } - @Nullable + @NotNull @Override public final XBreakpointCustomPropertiesPanel> createCustomRightPropertiesPanel(@NotNull Project project) { return new JavaBreakpointFiltersPanel<>(project); } - @Nullable + @NotNull @Override public final XDebuggerEditorsProvider getEditorsProvider(@NotNull XBreakpoint breakpoint, @NotNull Project project) { return new JavaDebuggerEditorsProvider(); @@ -64,14 +63,9 @@ public abstract class JavaBreakpointTypeBase public XSourcePosition getSourcePosition(@NotNull XBreakpoint breakpoint) { Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint); if (javaBreakpoint != null) { - final PsiClass aClass = javaBreakpoint.getPsiClass(); + PsiClass aClass = javaBreakpoint.getPsiClass(); if (aClass != null) { - return ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public XSourcePosition compute() { - return XDebuggerUtil.getInstance().createPositionByElement(aClass); - } - }); + return ReadAction.compute(() -> XDebuggerUtil.getInstance().createPositionByElement(aClass)); } } return null; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java index 0acacde8c0f2..2842845cbca7 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -18,6 +18,7 @@ package com.intellij.debugger.ui.breakpoints; import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.HelpID; import com.intellij.debugger.SourcePosition; +import com.intellij.debugger.engine.PositionManagerImpl; import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.icons.AllIcons; import com.intellij.openapi.editor.Document; @@ -33,6 +34,7 @@ import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XLineBreakpoint; import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule; import com.intellij.xdebugger.impl.XSourcePositionImpl; +import com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -99,12 +101,11 @@ public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase computeVariants(@NotNull Project project, @NotNull XSourcePosition position) { - PsiFile file = PsiManager.getInstance(project).findFile(position.getFile()); - if (file == null) { + SourcePosition pos = DebuggerUtilsEx.toSourcePosition(position, project); + if (pos == null) { return Collections.emptyList(); } - SourcePosition pos = SourcePosition.createFromLine(file, position.getLine()); List lambdas = DebuggerUtilsEx.collectLambdas(pos, true); if (lambdas.isEmpty()) { return Collections.emptyList(); @@ -116,7 +117,7 @@ public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase breakpoint) { - JavaLineBreakpointProperties properties = breakpoint.getProperties(); - if (properties != null) { - Integer ordinal = properties.getLambdaOrdinal(); - if (ordinal != null) { - Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint); - if (javaBreakpoint instanceof LineBreakpoint) { - PsiElement method = getContainingMethod((LineBreakpoint)javaBreakpoint); - if (method != null) { - return method.getTextRange(); - } + Integer ordinal = getLambdaOrdinal(breakpoint); + if (ordinal != null) { + Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint); + if (javaBreakpoint instanceof LineBreakpoint) { + PsiElement method = getContainingMethod((LineBreakpoint)javaBreakpoint); + if (method != null) { + return method.getTextRange(); } } } return null; } + @Override + public XSourcePosition getSourcePosition(@NotNull XBreakpoint breakpoint) { + Integer ordinal = getLambdaOrdinal(breakpoint); + if (ordinal != null && ordinal > -1) { + SourcePosition linePosition = createLineSourcePosition((XLineBreakpointImpl)breakpoint); + if (linePosition != null) { + return DebuggerUtilsEx.toXSourcePosition(new PositionManagerImpl.JavaSourcePosition(linePosition, ordinal)); + } + } + return null; + } + + @Nullable + private static Integer getLambdaOrdinal(XBreakpoint breakpoint) { + JavaLineBreakpointProperties properties = breakpoint.getProperties(); + return properties != null ? properties.getLambdaOrdinal() : null; + } + + @Nullable + private static SourcePosition createLineSourcePosition(XLineBreakpointImpl breakpoint) { + VirtualFile file = breakpoint.getFile(); + if (file != null) { + PsiFile psiFile = PsiManager.getInstance(breakpoint.getProject()).findFile(file); + if (psiFile != null) { + return SourcePosition.createFromLine(psiFile, breakpoint.getLine()); + } + } + return null; + } + @Override public boolean canBeHitInOtherPlaces() { return true; // line breakpoints could be hit in other versions of the same classes diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/ActionHint.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/ActionHint.java index ec9ba3eedbc9..fd1cd6823644 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/ActionHint.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/ActionHint.java @@ -68,7 +68,8 @@ public class ActionHint { * @return true if this ActionHint checks that some action should be present * or false if it checks that some action should be absent */ - boolean shouldPresent() { + @SuppressWarnings("WeakerAccess") // used in kotlin + public boolean shouldPresent() { return myShouldPresent; } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java index 9194be86566a..458153ccd66e 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java @@ -225,6 +225,6 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { @Override public Icon getDefaultIcon() { - return JBUI.scale(EmptyIcon.create(20)).asUIResource(); + return EmptyIcon.create(JBUI.scale(20)).asUIResource(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index d3905ab5211f..f2f6f014f445 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -3017,8 +3017,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi type == VERTICAL_SCROLLBAR_LEFT ? JBScrollPane.Flip.HORIZONTAL : null); - JScrollBar vsb = myScrollPane.getVerticalScrollBar(); - if (vsb != null) vsb.setOpaque(true); myScrollingModel.scrollHorizontally(currentHorOffset); } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index 1e93115d23be..50ad08b0b7e3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -33,6 +33,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.ShutDownTracker; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.AppIconScheme; import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; @@ -488,7 +489,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica Disposer.dispose(prevTask); } - if (PowerSaveMode.isEnabled()) { + if (PowerSaveMode.isEnabled() && Registry.is("pause.indexing.in.power.save.mode")) { indicator.setText("Indexing paused during Power Save mode..."); runWhenPowerSaveModeChanges(() -> result.complete(pollTaskQueue())); completeWhenProjectClosed(result); diff --git a/platform/platform-impl/src/com/intellij/ui/tree/AsyncTreeModel.java b/platform/platform-impl/src/com/intellij/ui/tree/AsyncTreeModel.java index 9e2816b20a78..df4066ed261e 100644 --- a/platform/platform-impl/src/com/intellij/ui/tree/AsyncTreeModel.java +++ b/platform/platform-impl/src/com/intellij/ui/tree/AsyncTreeModel.java @@ -38,6 +38,7 @@ import javax.swing.tree.TreePath; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import static java.util.Collections.emptyList; import static java.util.Collections.unmodifiableList; @@ -137,15 +138,68 @@ public final class AsyncTreeModel extends AbstractTreeModel implements Disposabl return model instanceof Navigatable ? resolve(((Navigatable)model).prevTreePath(path, object)) : rejectedPromise(); } - private Promise resolve(Promise promise) { + @NotNull + public Promise resolve(TreePath path) { AsyncPromise async = new AsyncPromise<>(); - promise.rejected(error -> processor.foreground.invokeLaterIfNeeded(() -> async.setError(error))); - promise.done(result -> processor.foreground.invokeLaterIfNeeded(() -> sync(async, result))); + processor.foreground.invokeLaterIfNeeded(() -> resolve(async, path, entry -> async.setResult(entry))); return async; } - private void sync(AsyncPromise promise, TreePath path) { - promise.setResult(path);//todo load + private Promise resolve(Promise promise) { + AsyncPromise async = new AsyncPromise<>(); + promise.rejected(error -> processor.foreground.invokeLaterIfNeeded(() -> async.setError(error))); + promise.done(result -> processor.foreground.invokeLaterIfNeeded(() -> resolve(async, result, entry -> async.setResult(entry)))); + return async; + } + + private void resolve(AsyncPromise async, TreePath path, Consumer> consumer) { + if (path == null) { + async.setError("path is null"); + return; + } + Object object = path.getLastPathComponent(); + if (object == null) { + async.setError("path is wrong"); + return; + } + if (!consume(consumer, tree.findEntry(object))) { + TreePath parent = path.getParentPath(); + if (parent == null) { + promiseRootEntry().done(entry -> { + if (entry == null) { + async.setError("root is null"); + } + else if (object != entry.getNode()) { + async.setError("root is wrong"); + } + else { + consumer.accept(entry); + } + }); + } + else { + resolve(async, parent, entry -> processor.process(new Command>>() { + private CmdGetChildren command = new CmdGetChildren("Sync children", entry, false); + + @Override + public List> get() { + return command.get(); + } + + @Override + public void accept(List> children) { + command.accept(children); + if (!consume(consumer, tree.findEntry(object))) async.setError("path not found"); + } + })); + } + } + } + + private static boolean consume(Consumer> consumer, Entry entry) { + if (entry == null) return false; + consumer.accept(entry); + return true; } @Override @@ -278,17 +332,26 @@ public final class AsyncTreeModel extends AbstractTreeModel implements Disposabl Object object = entry.getNode(); if (model.isLeaf(object)) return null; + if (model instanceof ChildrenProvider) { + //noinspection unchecked + ChildrenProvider provider = (ChildrenProvider)model; + ArrayList> children = new ArrayList<>(); + provider.getChildren(object).forEach(child -> add(children, child)); + return unmodifiableList(children); + } + int count = model.getChildCount(object); if (count <= 0) return emptyList(); ArrayList> children = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - Object child = model.getChild(object, i); - children.add(Pair.create(child, model.isLeaf(child))); - } + for (int i = 0; i < count; i++) add(children, model.getChild(object, i)); return unmodifiableList(children); } + private void add(List> children, Object child) { + if (child != null) children.add(Pair.create(child, model.isLeaf(child))); + } + @Override public void accept(List> children) { Object object = entry.getNode(); diff --git a/platform/platform-impl/src/com/intellij/ui/tree/ChildrenProvider.java b/platform/platform-impl/src/com/intellij/ui/tree/ChildrenProvider.java new file mode 100644 index 000000000000..04d643f1a1d2 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/tree/ChildrenProvider.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2017 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.ui.tree; + +import org.jetbrains.annotations.NotNull; + +import javax.swing.tree.TreeModel; +import java.util.List; + +/** + * This is an extension for the {@link TreeModel} which is supported by {@link AsyncTreeModel}. + * It is intended to simplify implementing of a couple corresponding methods in a model. + * + * @see TreeModel#getChildCount(Object) + * @see TreeModel#getChild(Object, int) + * + * @author Sergey.Malenkov + */ +public interface ChildrenProvider { + /** + * @param parent a tree node + * @return all children of the specified parent node + */ + @NotNull + List getChildren(Object parent); +} diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 207916075ac3..ba9e25bac1de 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -449,7 +449,7 @@ command.find.next=Find Next command.find.previous=Find Previous command.select.all=Select All message.no.targets.available=No targets available in this context -title.popup.select.target=Select Target +title.popup.select.target=Select In title.popup.recent.files=Recent Files action.split.vertically=Split _Vertically action.split.horizontally=Split Hori_zontally diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index fd65762d4486..7eaea4953946 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -966,6 +966,9 @@ dumb.aware.run.configurations.description=Enable executing run configurations in select.run.configuration.from.context=true select.run.configuration.from.context.description=Select run configuration when run from context (gutter icon, popup menu) +pause.indexing.in.power.save.mode=false +pause.indexing.in.power.save.mode.description=Whether indexing activities should be paused during Power Save Mode to reduce power consumption. If enabled, code insight functionality won't be available after changes to project model and after project opening. + ide.run.dashboard=false ide.run.dashboard.description=Enable Run Dashboard tool window ide.run.dashboard.restartRequired=true diff --git a/platform/util/src/com/intellij/util/ui/EmptyIcon.java b/platform/util/src/com/intellij/util/ui/EmptyIcon.java index df750196011c..98d85dbcf353 100644 --- a/platform/util/src/com/intellij/util/ui/EmptyIcon.java +++ b/platform/util/src/com/intellij/util/ui/EmptyIcon.java @@ -17,6 +17,7 @@ package com.intellij.util.ui; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.plaf.UIResource; @@ -115,7 +116,7 @@ public class EmptyIcon extends JBUI.CachingScalableJBIcon { @Override public EmptyIcon withJBUIPreScaled(boolean preScaled) { if (myUseCache && isJBUIPreScaled() != preScaled) { - Integer key = key(width, height, isJBUIPreScaled()); + Integer key = key(width, height); if (key != null) cache.remove(key); // rather useless to keep it in cache return create(width, height, preScaled); } @@ -123,7 +124,7 @@ public class EmptyIcon extends JBUI.CachingScalableJBIcon { } private static EmptyIcon create(int width, int height, boolean preScaled) { - Integer key = key(width, height, preScaled); + Integer key = key(width, height); EmptyIcon icon = key != null ? cache.get(key) : null; if (icon == null) { icon = new EmptyIcon(width, height, true); @@ -133,8 +134,9 @@ public class EmptyIcon extends JBUI.CachingScalableJBIcon { return icon; } - private static Integer key(int width, int height, boolean preScaled) { - return width == height && width < 129 ? preScaled ? width : JBUI.scale(width) : null; + @Nullable + private static Integer key(int width, int height) { + return width == height && width < 129 ? width : null; } @Override diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/committed/VcsCommittedListsZipperAdapter.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/committed/VcsCommittedListsZipperAdapter.java index 24cdde7eb8e7..a3f45649ed47 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/committed/VcsCommittedListsZipperAdapter.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/committed/VcsCommittedListsZipperAdapter.java @@ -20,6 +20,7 @@ import com.intellij.openapi.vcs.RepositoryLocation; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.util.containers.MultiMap; +import gnu.trove.THashSet; import java.util.ArrayList; import java.util.Collection; @@ -68,12 +69,13 @@ public abstract class VcsCommittedListsZipperAdapter implements VcsCommittedList return lists.get(0); } final CommittedChangeList result = lists.get(0); + + Set processed = new THashSet<>(result.getChanges()); + for (int i = 1; i < lists.size(); i++) { - final CommittedChangeList list = lists.get(i); - for (Change change : list.getChanges()) { - final Collection resultChanges = result.getChanges(); - if (! resultChanges.contains(change)) { - resultChanges.add(change); + for (Change change : lists.get(i).getChanges()) { + if (!processed.add(change)) { + result.getChanges().add(change); } } } diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XLineBreakpointType.java b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XLineBreakpointType.java index d526ead2df76..47320ec0354d 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XLineBreakpointType.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/XLineBreakpointType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -76,10 +76,10 @@ public abstract class XLineBreakpointType

exten } /** - * Source position for line breakpoint is determined by its file and line + * Source position for line breakpoint by default is determined by its file and line */ @Override - public final XSourcePosition getSourcePosition(@NotNull XBreakpoint

breakpoint) { + public XSourcePosition getSourcePosition(@NotNull XBreakpoint

breakpoint) { return null; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java index 47d67064a56b..9ca82c47ad7a 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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,8 +17,6 @@ package com.intellij.xdebugger.impl.breakpoints; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ReadAction; -import com.intellij.openapi.application.Result; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; @@ -148,7 +146,7 @@ public class XLineBreakpointImpl

extends XBreak } @Nullable - private VirtualFile getFile() { + public VirtualFile getFile() { return VirtualFileManager.getInstance().findFileByUrl(getFileUrl()); } @@ -191,13 +189,12 @@ public class XLineBreakpointImpl

extends XBreak @Override public XSourcePosition getSourcePosition() { + if (mySourcePosition != null) { + return mySourcePosition; + } + mySourcePosition = super.getSourcePosition(); if (mySourcePosition == null) { - new ReadAction() { - @Override - protected void run(@NotNull Result result) { - mySourcePosition = XDebuggerUtil.getInstance().createPosition(getFile(), getLine()); - } - }.execute(); + mySourcePosition = XDebuggerUtil.getInstance().createPosition(getFile(), getLine()); } return mySourcePosition; } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginDomUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginDomUtil.java index cb47ab8fd446..444219f26077 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginDomUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginDomUtil.java @@ -16,6 +16,7 @@ package org.jetbrains.idea.maven.dom; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; @@ -58,7 +59,7 @@ public class MavenPluginDomUtil { String groupId = pluginElement.getGroupId().getStringValue(); String artifactId = pluginElement.getArtifactId().getStringValue(); String version = pluginElement.getVersion().getStringValue(); - if (version == null) { + if (StringUtil.isEmpty(version)) { MavenProject mavenProject = findMavenProject(element); if (mavenProject != null) { for (MavenPlugin plugin : mavenProject.getPlugins()) { diff --git a/python/build.xml b/python/build.xml index 22f999027050..0669a300ee4e 100644 --- a/python/build.xml +++ b/python/build.xml @@ -38,7 +38,7 @@ diff --git a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java index 976cca554fb9..8266e1450c7f 100644 --- a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java +++ b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java @@ -224,6 +224,7 @@ public class BreadcrumbsXmlWrapper implements Disposable { breadcrumbs.onHover(this::itemHovered); breadcrumbs.onSelect(this::itemSelected); breadcrumbs.setFont(getEditorFont(myEditor)); + breadcrumbs.setBorder(BorderFactory.createEmptyBorder(above ? 2 : 0, 0, above ? 0 : 2, 0)); myComponent.setOpaque(false); myComponent.add(BorderLayout.CENTER, breadcrumbs);