Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2014-03-06 20:37:51 +01:00
504 changed files with 12688 additions and 3740 deletions
+7 -7
View File
@@ -85,6 +85,7 @@
<module fileurl="file://$PROJECT_DIR$/java/java-psi-api/java-psi-api.iml" filepath="$PROJECT_DIR$/java/java-psi-api/java-psi-api.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/java-psi-impl/java-psi-impl.iml" filepath="$PROJECT_DIR$/java/java-psi-impl/java-psi-impl.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/java-runtime/java-runtime.iml" filepath="$PROJECT_DIR$/java/java-runtime/java-runtime.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/java-structure-view/java-structure-view.iml" filepath="$PROJECT_DIR$/java/java-structure-view/java-structure-view.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/java-tests/java-tests.iml" filepath="$PROJECT_DIR$/java/java-tests/java-tests.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/plugins/javaFX/javaFX.iml" filepath="$PROJECT_DIR$/plugins/javaFX/javaFX.iml" group="plugins/JavaFX" />
<module fileurl="file://$PROJECT_DIR$/plugins/javaFX/javaFX-CE/javaFX-CE.iml" filepath="$PROJECT_DIR$/plugins/javaFX/javaFX-CE/javaFX-CE.iml" group="plugins/JavaFX" />
@@ -98,8 +99,8 @@
<module fileurl="file://$PROJECT_DIR$/jps/model-api/jps-model-api.iml" filepath="$PROJECT_DIR$/jps/model-api/jps-model-api.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/model-impl/jps-model-impl.iml" filepath="$PROJECT_DIR$/jps/model-impl/jps-model-impl.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/model-serialization/jps-model-serialization.iml" filepath="$PROJECT_DIR$/jps/model-serialization/jps-model-serialization.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/model-impl/jps-model-tests.iml" filepath="$PROJECT_DIR$/jps/model-impl/jps-model-tests.iml"/>
<module fileurl="file://$PROJECT_DIR$/jps/model-serialization/jps-serialization-tests.iml" filepath="$PROJECT_DIR$/jps/model-serialization/jps-serialization-tests.iml" group="jps"/>
<module fileurl="file://$PROJECT_DIR$/jps/model-impl/jps-model-tests.iml" filepath="$PROJECT_DIR$/jps/model-impl/jps-model-tests.iml" />
<module fileurl="file://$PROJECT_DIR$/jps/model-serialization/jps-serialization-tests.iml" filepath="$PROJECT_DIR$/jps/model-serialization/jps-serialization-tests.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/standalone-builder/jps-standalone-builder.iml" filepath="$PROJECT_DIR$/jps/standalone-builder/jps-standalone-builder.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/java/jsp-base-openapi/jsp-base-openapi.iml" filepath="$PROJECT_DIR$/java/jsp-base-openapi/jsp-base-openapi.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/jsp-openapi/jsp-openapi.iml" filepath="$PROJECT_DIR$/java/jsp-openapi/jsp-openapi.iml" group="java" />
@@ -157,6 +158,8 @@
<module fileurl="file://$PROJECT_DIR$/platform/smRunner/smRunner.iml" filepath="$PROJECT_DIR$/platform/smRunner/smRunner.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/cvs/smartcvs-src/smartcvs-src.iml" filepath="$PROJECT_DIR$/plugins/cvs/smartcvs-src/smartcvs-src.iml" group="plugins/VCS/cvs" />
<module fileurl="file://$PROJECT_DIR$/spellchecker/spellchecker.iml" filepath="$PROJECT_DIR$/spellchecker/spellchecker.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/platform/structure-view-api/structure-view-api.iml" filepath="$PROJECT_DIR$/platform/structure-view-api/structure-view-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/structure-view-impl/structure-view-impl.iml" filepath="$PROJECT_DIR$/platform/structure-view-impl/structure-view-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/svn4idea/svn4idea.iml" filepath="$PROJECT_DIR$/plugins/svn4idea/svn4idea.iml" group="plugins/VCS" />
<module fileurl="file://$PROJECT_DIR$/plugins/svn4idea/svn4idea-tests.iml" filepath="$PROJECT_DIR$/plugins/svn4idea/svn4idea-tests.iml" group="plugins/VCS" />
<module fileurl="file://$PROJECT_DIR$/plugins/tasks/tasks-api/tasks-api.iml" filepath="$PROJECT_DIR$/plugins/tasks/tasks-api/tasks-api.iml" group="plugins/tasks" />
@@ -189,17 +192,14 @@
<module fileurl="file://$PROJECT_DIR$/xml/openapi/xml-openapi.iml" filepath="$PROJECT_DIR$/xml/openapi/xml-openapi.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/xml/xml-psi-api/xml-psi-api.iml" filepath="$PROJECT_DIR$/xml/xml-psi-api/xml-psi-api.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/xml/xml-psi-impl/xml-psi-impl.iml" filepath="$PROJECT_DIR$/xml/xml-psi-impl/xml-psi-impl.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/xml/xml-structure-view-api/xml-structure-view-api.iml" filepath="$PROJECT_DIR$/xml/xml-structure-view-api/xml-structure-view-api.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/xml/xml-structure-view-impl/xml-structure-view-impl.iml" filepath="$PROJECT_DIR$/xml/xml-structure-view-impl/xml-structure-view-impl.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/xml/tests/xml-tests.iml" filepath="$PROJECT_DIR$/xml/tests/xml-tests.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/plugins/xpath/xpath.iml" filepath="$PROJECT_DIR$/plugins/xpath/xpath.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/xslt-debugger.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/xslt-debugger.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/engine/xslt-debugger-engine.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/engine/xslt-debugger-engine.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/xpath/xslt-rt/xslt-rt.iml" filepath="$PROJECT_DIR$/plugins/xpath/xslt-rt/xslt-rt.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/platform/structure-view-api/structure-view-api.iml" filepath="$PROJECT_DIR$/platform/structure-view-api/structure-view-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/structure-view-impl/structure-view-impl.iml" filepath="$PROJECT_DIR$/platform/structure-view-impl/structure-view-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/java/java-structure-view/java-structure-view.iml" filepath="$PROJECT_DIR$/java/java-structure-view/java-structure-view.iml" group="java"/>
<module fileurl="file://$PROJECT_DIR$/xml/xml-structure-view-api/xml-structure-view-api.iml" filepath="$PROJECT_DIR$/xml/xml-structure-view-api/xml-structure-view-api.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/xml/xml-structure-view-impl/xml-structure-view-impl.iml" filepath="$PROJECT_DIR$/xml/xml-structure-view-impl/xml-structure-view-impl.iml" group="xml" />
</modules>
</component>
</project>
@@ -3,8 +3,8 @@
<company name="JetBrains s.r.o." url="http://www.jetbrains.com/?fromIDE"/>
<build number="__BUILD_NUMBER__" date="__BUILD_DATE__"/>
<install-over minbuild="129.1" maxbuild="135.9999" version="13.1"/>
<logo url="/idea_community_logo.png" textcolor="dddddd" progressColor="ffaa16" progressY="235" progressTailIcon="/community_progress_tail.png"/>
<about url="/idea_community_about.png" foreground="dddddd" linkColor="8BBAF9" logoX="300" logoY="265" logoW="75" logoH="30"/>
<logo url="/idea_community_logo.png" textcolor="444444" progressColor="ffaa16" progressY="222" progressTailIcon="/community_progress_tail.png"/>
<about url="/idea_community_about.png" foreground="444444" linkColor="000099" logoX="300" logoY="265" logoW="75" logoH="30"/>
<icon size32="/icon_CE.png" size16="/icon_CEsmall.png" size32opaque="/icon_CEwhite.png" size12="/toolwindows/toolWindowProject.png" size128="/icon_CE_128.png" ico="idea_CE.ico"/>
<package code="__PACKAGE_CODE__"/>
<names product="IDEA" fullname="IntelliJ IDEA" script="idea"/>
@@ -910,7 +910,7 @@ public class CompileDriver {
if (!outputs.isEmpty()) {
final ProgressIndicator indicator = compileContext.getProgressIndicator();
indicator.setText("Synchronizing output directories...");
lfs.refreshIoFiles(outputs, _status == ExitStatus.CANCELLED, false, null);
CompilerUtil.refreshOutputDirectories(outputs, _status == ExitStatus.CANCELLED);
indicator.setText("");
}
if (compileContext.isAnnotationProcessorsEnabled() && !myProject.isDisposed()) {
@@ -35,7 +35,10 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.util.ThrowableRunnable;
@@ -128,6 +131,35 @@ public class CompilerUtil {
}
}
public static void refreshOutputDirectories(Set<File> outputs, boolean async) {
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
List<VirtualFile> toRefresh = new ArrayList<VirtualFile>();
int newDirectories = 0;
for (File ioOutput : outputs) {
VirtualFile output = fileSystem.findFileByIoFile(ioOutput);
if (output != null) {
toRefresh.add(output);
}
else if (ioOutput.exists()) {
VirtualFile parent = fileSystem.refreshAndFindFileByIoFile(ioOutput.getParentFile());
if (parent != null) {
parent.getChildren();
toRefresh.add(parent);
newDirectories++;
}
}
}
if (newDirectories > 10) {
LOG.info(newDirectories + " new output directories were created, refreshing their parents together to avoid too many rootsChange events");
RefreshQueue.getInstance().refresh(async, false, null, toRefresh);
}
else {
LOG.debug("Refreshing " + outputs.size() + " outputs");
fileSystem.refreshIoFiles(outputs, async, false, null);
}
}
public static void refreshIOFile(final File file) {
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
if (vFile != null) {
@@ -234,7 +266,7 @@ public class CompilerUtil {
final boolean is3OrNewer = is4OrNewer || isOfVersion(versionString, "1.3");
final boolean is2OrNewer = is3OrNewer || isOfVersion(versionString, "1.2");
final boolean is1OrNewer = is2OrNewer || isOfVersion(versionString, "1.0") || isOfVersion(versionString, "1.1");
if (!is1OrNewer) {
// unknown jdk version, cannot say anything about the corresponding language level, so leave it unchanged
return languageLevel;
@@ -25,6 +25,10 @@ import org.jetbrains.annotations.NotNull;
/**
* @author nik
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class GenericCompiler<Key, SourceState, OutputState> implements Compiler {
protected static final KeyDescriptor<String> STRING_KEY_DESCRIPTOR = new EnumeratorStringDescriptor();
@@ -21,6 +21,10 @@ package com.intellij.openapi.compiler;
* This affects the order of compiler calls:
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface ClassInstrumentingCompiler extends FileProcessingCompiler {
}
@@ -21,6 +21,10 @@ package com.intellij.openapi.compiler;
* This affects the order of compiler calls:
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface ClassPostProcessingCompiler extends FileProcessingCompiler {
}
@@ -63,6 +63,10 @@ public abstract class CompilerManager {
* @param compiler compiler implementation
* @param inputTypes a set of filetypes that compiler accepts as input
* @param outputTypes a set of filetypes that compiler can generate
*
* @deprecated this method is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract void addTranslatingCompiler(@NotNull TranslatingCompiler compiler, Set<FileType> inputTypes, Set<FileType> outputTypes);
@@ -32,6 +32,10 @@ import java.util.List;
/**
* Compiler which copies the compiled files to a different directory.
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class CopyingCompiler implements PackagingCompiler{
public abstract VirtualFile[] getFilesToCopy(CompileContext context);
@@ -21,6 +21,10 @@ import com.intellij.openapi.vfs.VirtualFile;
/**
* A base interface for all compilers that generate new files. The generated files may be processed by other compilers.
* Actual implementation should implement one of its subinterfaces. Currently only {@link SourceGeneratingCompiler} is available.
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface GeneratingCompiler extends Compiler, ValidityStateFactory, IntermediateOutputCompiler {
/**
@@ -19,6 +19,10 @@ import com.intellij.openapi.vfs.VirtualFile;
/**
* This compiler is called right before the java sources compiler.
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface JavaSourceTransformingCompiler extends Compiler {
@@ -23,6 +23,10 @@ import org.jetbrains.annotations.Nullable;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface PackagingCompiler extends FileProcessingCompiler{
/**
@@ -23,6 +23,10 @@ import com.intellij.openapi.vfs.VirtualFile;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface SourceGeneratingCompiler extends GeneratingCompiler {
@@ -26,6 +26,10 @@ import java.util.Collection;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
*
* @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface TranslatingCompiler extends Compiler {
@@ -15,6 +15,11 @@
*/
package com.intellij.openapi.compiler.make;
/**
* @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface BuildInstruction {
String getOutputRelativePath();
@@ -15,7 +15,11 @@
*/
package com.intellij.openapi.compiler.make;
/**
* @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class BuildInstructionVisitor {
public boolean visitInstruction(BuildInstruction instruction) throws Exception {
return true;
@@ -20,7 +20,9 @@ import com.intellij.packaging.artifacts.Artifact;
import org.jetbrains.annotations.Nullable;
/**
* @deprecated use interfaces from {@link com.intellij.openapi.compiler.Compiler}'s hierarchy instead
* @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class BuildParticipant {
public static final BuildParticipant[] EMPTY_ARRAY = new BuildParticipant[0];
@@ -24,7 +24,9 @@ import java.util.Collection;
/**
* @author nik
*
* @deprecated use interfaces from {@link com.intellij.openapi.compiler.Compiler}'s hierarchy instead
* @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class BuildParticipantProvider {
public static final ExtensionPointName<BuildParticipantProvider> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.compiler.buildParticipantProvider");
@@ -15,10 +15,13 @@
*/
package com.intellij.openapi.compiler.make;
import org.jetbrains.annotations.Nullable;
import java.io.File;
/**
* @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
* integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
* Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface FileCopyInstruction extends BuildInstruction {
File getFile();
@@ -32,6 +32,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.Nullable;
public class AdjustArrayRangeAction extends DebuggerAction {
@Override
public void actionPerformed(AnActionEvent e) {
DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
if(debuggerContext == null) {
@@ -73,6 +74,7 @@ public class AdjustArrayRangeAction extends DebuggerAction {
if(editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
@Override
public void contextAction() throws Exception {
final ValueDescriptorImpl nodeDescriptor = (ValueDescriptorImpl)selectedNode.getDescriptor();
final Renderer lastRenderer = nodeDescriptor.getLastRenderer();
@@ -92,6 +94,7 @@ public class AdjustArrayRangeAction extends DebuggerAction {
}
}
@Override
public void update(AnActionEvent e) {
boolean enable = false;
DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
@@ -139,10 +142,12 @@ public class AdjustArrayRangeAction extends DebuggerAction {
myTitle = title;
}
@Override
public String getDisplayName() {
return myTitle;
}
@Override
public String getHelpTopic() {
return null;
}
@@ -72,12 +72,12 @@ import com.intellij.util.EventDispatcher;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
import com.sun.jdi.*;
import com.sun.jdi.connect.*;
import com.sun.jdi.request.EventRequest;
import com.sun.jdi.request.EventRequestManager;
import com.sun.jdi.request.StepRequest;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -119,7 +119,10 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
private Map<String, Connector.Argument> myArguments;
private final List<NodeRenderer> myRenderers = new ArrayList<NodeRenderer>();
private final Map<Type, NodeRenderer> myNodeRenderersMap = new THashMap<Type, NodeRenderer>();
// we use null key here
private final Map<Type, NodeRenderer> myNodeRenderersMap = new HashMap<Type, NodeRenderer>();
private final NodeRendererSettingsListener mySettingsListener = new NodeRendererSettingsListener() {
@Override
public void renderersChanged() {
@@ -37,15 +37,16 @@ import org.jetbrains.annotations.TestOnly;
* @author lex
*/
public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerCommandImpl> implements DebuggerManagerThread, Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.DebuggerManagerThreadImpl");
private static final Logger LOG = Logger.getInstance(DebuggerManagerThreadImpl.class);
public static final int COMMAND_TIMEOUT = 3000;
private static final int RESTART_TIMEOUT = 500;
private volatile boolean myDisposed;
DebuggerManagerThreadImpl(@NotNull Disposable parent) {
Disposer.register(parent, this);
}
@Override
public void dispose() {
myDisposed = true;
}
@@ -63,6 +64,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
LOG.assertTrue(isManagerThread(), "Should be invoked in manager thread, use DebuggerManagerThreadImpl.getInstance(..).invoke...");
}
@Override
public void invokeAndWait(DebuggerCommandImpl managerCommand) {
LOG.assertTrue(!isManagerThread(), "Should be invoked outside manager thread, use DebuggerManagerThreadImpl.getInstance(..).invoke...");
super.invokeAndWait(managerCommand);
@@ -77,6 +79,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
}
@Override
public boolean pushBack(DebuggerCommandImpl managerCommand) {
final boolean pushed = super.pushBack(managerCommand);
if (!pushed) {
@@ -85,6 +88,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
return pushed;
}
@Override
public boolean schedule(DebuggerCommandImpl managerCommand) {
final boolean scheduled = super.schedule(managerCommand);
if (!scheduled) {
@@ -106,6 +110,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
if (currentCommand != null) {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
alarm.addRequest(new Runnable() {
@Override
public void run() {
try {
if (currentCommand == myEvents.getCurrentEvent()) {
@@ -135,10 +140,11 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
@Override
public void processEvent(@NotNull DebuggerCommandImpl managerCommand) {
assertIsManagerThread();
try {
if(myEvents.isClosed()) {
if (myEvents.isClosed()) {
managerCommand.notifyCancelled();
}
else {
@@ -161,14 +167,17 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
public void startProgress(final DebuggerCommandImpl command, final ProgressWindowWithNotification progressWindow) {
progressWindow.addListener(new ProgressIndicatorListenerAdapter() {
@Override
public void cancelled() {
command.release();
}
});
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
ProgressManager.getInstance().runProcess(new Runnable() {
@Override
public void run() {
invokeAndWait(command);
}
@@ -193,10 +202,12 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
super.invokeAndWait(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
switchToRequest(request);
}
@Override
protected void commandCancelled() {
if (LOG.isDebugEnabled()) {
LOG.debug("Event queue was closed, killing request");
@@ -207,14 +218,17 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
}
@Override
public void invokeCommand(final DebuggerCommand command) {
if(command instanceof SuspendContextCommand) {
SuspendContextCommand suspendContextCommand = (SuspendContextCommand)command;
schedule(new SuspendContextCommandImpl((SuspendContextImpl)suspendContextCommand.getSuspendContext()) {
@Override
public void contextAction() throws Exception {
command.action();
}
@Override
protected void commandCancelled() {
command.commandCancelled();
}
@@ -222,10 +236,12 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
else {
schedule(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
command.action();
}
@Override
protected void commandCancelled() {
command.commandCancelled();
}
@@ -29,7 +29,6 @@ import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
@@ -258,14 +257,43 @@ public class PositionManagerImpl implements PositionManager {
private static int getNestingDepth(PsiClass aClass) {
int depth = 0;
PsiClass enclosing = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
PsiClass enclosing = getEnclosingClass(aClass);
while (enclosing != null) {
depth++;
enclosing = PsiTreeUtil.getParentOfType(enclosing, PsiClass.class, true);
enclosing = getEnclosingClass(enclosing);
}
return depth;
}
/**
* See IDEA-121739
* Anonymous classes inside other anonymous class parameters list should belong to parent class
* Inner in = new Inner(new Inner2(){}) {};
* Parent of Inner2 sub class here is not Inner sub class
*/
private static PsiClass getEnclosingClass(PsiElement element) {
if (element == null) {
return null;
}
element = element.getParent();
PsiElement previous = null;
while (element != null) {
if (PsiClass.class.isInstance(element) && !(previous instanceof PsiExpressionList)) {
//noinspection unchecked
return (PsiClass)element;
}
if (element instanceof PsiFile) {
return null;
}
previous = element;
element = element.getParent();
}
return null;
}
@Nullable
private ReferenceType findNested(final ReferenceType fromClass, final int currentDepth, final PsiClass classToFind, final int requiredDepth, final SourcePosition position) {
final VirtualMachineProxyImpl vmProxy = myDebugProcess.getVirtualMachineProxy();
@@ -91,6 +91,7 @@ public class RequestHint {
}
}
@NotNull
public DebugProcess getDebugProcess() {
return suspendContext.getDebugProcess();
}
@@ -50,12 +50,12 @@ public abstract class SuspendContextImpl implements SuspendContext {
protected Set<ThreadReferenceProxyImpl> myResumedThreads;
private final EventSet myEventSet;
private volatile boolean myIsResumed;
private volatile boolean myIsResumed;
public ConcurrentLinkedQueue<SuspendContextCommandImpl> myPostponedCommands = new ConcurrentLinkedQueue<SuspendContextCommandImpl>();
public volatile boolean myInProgress;
private final HashSet<ObjectReference> myKeptReferences = new HashSet<ObjectReference>();
private EvaluationContextImpl myEvaluationContext = null;
public volatile boolean myInProgress;
private final HashSet<ObjectReference> myKeptReferences = new HashSet<ObjectReference>();
private EvaluationContextImpl myEvaluationContext = null;
SuspendContextImpl(@NotNull DebugProcessImpl debugProcess, int suspendPolicy, int eventVotes, EventSet set) {
myDebugProcess = debugProcess;
@@ -82,7 +82,7 @@ public abstract class SuspendContextImpl implements SuspendContext {
try {
objectReference.enableCollection();
}
catch (UnsupportedOperationException e) {
catch (UnsupportedOperationException ignored) {
// ignore: some J2ME implementations does not provide this operation
}
}
@@ -115,25 +115,30 @@ public abstract class SuspendContextImpl implements SuspendContext {
return myEventSet;
}
@Override
@NotNull
public DebugProcessImpl getDebugProcess() {
assertNotResumed();
return myDebugProcess;
}
@Override
public StackFrameProxyImpl getFrameProxy() {
assertNotResumed();
try {
return myThread != null && myThread.frameCount() > 0 ? myThread.frame(0) : null;
}
catch (EvaluateException e) {
catch (EvaluateException ignored) {
return null;
}
}
@Override
public ThreadReferenceProxyImpl getThread() {
return myThread;
}
@Override
public int getSuspendPolicy() {
assertNotResumed();
return mySuspendPolicy;
@@ -145,7 +150,7 @@ public abstract class SuspendContextImpl implements SuspendContext {
}
public boolean isExplicitlyResumed(ThreadReferenceProxyImpl thread) {
return myResumedThreads != null ? myResumedThreads.contains(thread) : false;
return myResumedThreads != null && myResumedThreads.contains(thread);
}
public boolean suspends(ThreadReferenceProxyImpl thread) {
@@ -194,7 +199,7 @@ public abstract class SuspendContextImpl implements SuspendContext {
try {
reference.disableCollection();
}
catch (UnsupportedOperationException e) {
catch (UnsupportedOperationException ignored) {
// ignore: some J2ME implementations does not provide this operation
}
}
@@ -21,6 +21,7 @@ import com.sun.jdi.InternalException;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.event.EventSet;
import com.sun.jdi.request.EventRequest;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -33,7 +34,7 @@ public class SuspendManagerImpl implements SuspendManager {
private final LinkedList<SuspendContextImpl> myEventContexts = new LinkedList<SuspendContextImpl>();
/**
* contexts, paused at breakpoint or another debugger event requests. Note that thread, explicitly paused by user is not considered as
* "paused at breakpoint" and JDI prohibits data queries on its stackframes
* "paused at breakpoint" and JDI prohibits data queries on its stack frames
*/
private final LinkedList<SuspendContextImpl> myPausedContexts = new LinkedList<SuspendContextImpl>();
private final Set<ThreadReferenceProxyImpl> myFrozenThreads = Collections.synchronizedSet(new HashSet<ThreadReferenceProxyImpl>());
@@ -42,9 +43,10 @@ public class SuspendManagerImpl implements SuspendManager {
public int suspends = 0;
public SuspendManagerImpl(DebugProcessImpl debugProcess) {
public SuspendManagerImpl(@NotNull DebugProcessImpl debugProcess) {
myDebugProcess = debugProcess;
myDebugProcess.addDebugProcessListener(new DebugProcessAdapterImpl() {
@Override
public void processDetached(DebugProcessImpl process, boolean closedByUser) {
myEventContexts.clear();
myPausedContexts.clear();
@@ -53,8 +55,10 @@ public class SuspendManagerImpl implements SuspendManager {
});
}
@Override
public SuspendContextImpl pushSuspendContext(final int suspendPolicy, int nVotes) {
SuspendContextImpl suspendContext = new SuspendContextImpl(myDebugProcess, suspendPolicy, nVotes, null) {
@Override
protected void resumeImpl() {
if (LOG.isDebugEnabled()) {
LOG.debug("Start resuming...");
@@ -71,9 +75,9 @@ public class SuspendManagerImpl implements SuspendManager {
catch (InternalException e) {
//InternalException 13 means that there are running threads that we are trying to resume
//On MacOS it happened that native thread didn't stop while some java thread reached breakpoint
//noinspection StatementWithEmptyBody
if (/*Patches.MAC_RESUME_VM_HACK && */e.errorCode() == 13) {
//Its funny, but second resume solves the problem
continue;
}
else {
LOG.error(e);
@@ -108,8 +112,10 @@ public class SuspendManagerImpl implements SuspendManager {
return suspendContext;
}
@Override
public SuspendContextImpl pushSuspendContext(final EventSet set) {
SuspendContextImpl suspendContext = new SuspendContextImpl(myDebugProcess, set.suspendPolicy(), set.size(), set) {
@Override
protected void resumeImpl() {
if (LOG.isDebugEnabled()) {
LOG.debug("Start resuming eventSet " + set.toString() + " suspendPolicy = " + set.suspendPolicy() + ",size = " + set.size());
@@ -138,14 +144,13 @@ public class SuspendManagerImpl implements SuspendManager {
catch (ObjectCollectedException e) {
// according to error reports set.resume() may throw this if one of the threads has been collected
LOG.info(e);
continue;
}
catch (InternalException e) {
//InternalException 13 means that there are running threads that we are trying to resume
//On MacOS it happened that native thread didn't stop while some java thread reached breakpoint
//noinspection StatementWithEmptyBody
if (/*Patches.MAC_RESUME_VM_HACK && */e.errorCode() == 13 && set.suspendPolicy() == EventRequest.SUSPEND_ALL) {
//Its funny, but second resume solves the problem
continue;
}
else {
LOG.error(e);
@@ -172,6 +177,7 @@ public class SuspendManagerImpl implements SuspendManager {
}
}
@Override
public void resume(SuspendContextImpl context) {
SuspendManagerUtil.prepareForResume(context);
@@ -182,6 +188,7 @@ public class SuspendManagerImpl implements SuspendManager {
myDebugProcess.clearCashes(suspendPolicy);
}
@Override
public void popFrame(SuspendContextImpl suspendContext) {
popContext(suspendContext);
SuspendContextImpl newSuspendContext = pushSuspendContext(suspendContext.getSuspendPolicy(), 0);
@@ -189,6 +196,7 @@ public class SuspendManagerImpl implements SuspendManager {
notifyPaused(newSuspendContext);
}
@Override
public SuspendContextImpl getPausedContext() {
return !myPausedContexts.isEmpty() ? myPausedContexts.getFirst() : null;
}
@@ -216,15 +224,18 @@ public class SuspendManagerImpl implements SuspendManager {
return myEventContexts.contains(suspendContext);
}
@Override
public List<SuspendContextImpl> getEventContexts() {
DebuggerManagerThreadImpl.assertIsManagerThread();
return Collections.unmodifiableList(myEventContexts);
}
@Override
public boolean isFrozen(ThreadReferenceProxyImpl thread) {
return myFrozenThreads.contains(thread);
}
@Override
public boolean isSuspended(ThreadReferenceProxyImpl thread) throws ObjectCollectedException{
DebuggerManagerThreadImpl.assertIsManagerThread();
@@ -249,6 +260,7 @@ public class SuspendManagerImpl implements SuspendManager {
return suspended && (thread == null || thread.isSuspended());
}
@Override
public void suspendThread(SuspendContextImpl context, ThreadReferenceProxyImpl thread) {
LOG.assertTrue(thread != context.getThread(), "Thread is already suspended at the breakpoint");
@@ -258,6 +270,7 @@ public class SuspendManagerImpl implements SuspendManager {
}
}
@Override
public void resumeThread(SuspendContextImpl context, ThreadReferenceProxyImpl thread) {
LOG.assertTrue(thread != context.getThread(), "Use resume() instead of resuming breakpoint thread");
LOG.assertTrue(!context.isExplicitlyResumed(thread));
@@ -269,12 +282,14 @@ public class SuspendManagerImpl implements SuspendManager {
thread.resume();
}
@Override
public void freezeThread(ThreadReferenceProxyImpl thread) {
if (myFrozenThreads.add(thread)) {
thread.suspend();
}
}
@Override
public void unfreezeThread(ThreadReferenceProxyImpl thread) {
if (myFrozenThreads.remove(thread)) {
thread.resume();
@@ -310,6 +325,7 @@ public class SuspendManagerImpl implements SuspendManager {
myDebugProcess.myDebugProcessDispatcher.getMulticaster().paused(suspendContext);
}
@Override
public void voteResume(SuspendContextImpl suspendContext) {
if (LOG.isDebugEnabled()) {
LOG.debug("Resume voted");
@@ -317,6 +333,7 @@ public class SuspendManagerImpl implements SuspendManager {
processVote(suspendContext);
}
@Override
public void voteSuspend(SuspendContextImpl suspendContext) {
suspendContext.myIsVotedForResume = false;
processVote(suspendContext);
@@ -41,33 +41,41 @@ public final class EvaluationContextImpl implements EvaluationContext{
mySuspendContext = suspendContext;
}
@Override
public Value getThisObject() {
return myThisObject;
}
@Override
public SuspendContextImpl getSuspendContext() {
return mySuspendContext;
}
@Override
public StackFrameProxyImpl getFrameProxy() {
return myFrameProxy;
}
@NotNull
@Override
public DebugProcessImpl getDebugProcess() {
return getSuspendContext().getDebugProcess();
}
@Override
public Project getProject() {
DebugProcessImpl debugProcess = getDebugProcess();
return debugProcess != null ? debugProcess.getProject() : null;
return debugProcess.getProject();
}
@Override
public EvaluationContextImpl createEvaluationContext(Value value) {
final EvaluationContextImpl copy = new EvaluationContextImpl(getSuspendContext(), getFrameProxy(), value);
copy.setAutoLoadClasses(myAutoLoadClasses);
return copy;
}
@Override
public ClassLoaderReference getClassLoader() throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
return myFrameProxy != null ? myFrameProxy.getClassLoader() : null;
@@ -21,6 +21,7 @@
package com.intellij.debugger.engine.evaluation.expression;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
@@ -45,10 +46,12 @@ class BinaryExpressionEvaluator implements Evaluator {
myExpectedType = expectedType;
}
@Override
public Modifier getModifier() {
return null;
}
@Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
Value leftResult = (Value)myLeftOperand.evaluate(context);
return evaluateOperation(leftResult, myOpType, myRightOperand, myExpectedType, context);
@@ -72,12 +75,12 @@ class BinaryExpressionEvaluator implements Evaluator {
}
Value rightResult = (Value)rightOperand.evaluate(context);
if (opType == JavaTokenType.PLUS) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
final double v1 = ((PrimitiveValue)leftResult).doubleValue();
final double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
@@ -88,19 +91,19 @@ class BinaryExpressionEvaluator implements Evaluator {
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
}
if (leftResult instanceof StringReference || rightResult instanceof StringReference) {
String v1 = DebuggerUtilsEx.getValueAsString(context, leftResult);
String v2 = DebuggerUtilsEx.getValueAsString(context, rightResult);
String v1 = DebuggerUtils.getValueAsString(context, leftResult);
String v2 = DebuggerUtils.getValueAsString(context, rightResult);
return vm.mirrorOf(v1 + v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "+"));
}
else if (opType == JavaTokenType.MINUS) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
@@ -113,12 +116,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "-"));
}
else if (opType == JavaTokenType.ASTERISK) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
@@ -131,12 +134,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "*"));
}
else if (opType == JavaTokenType.DIV) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
@@ -149,12 +152,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "/"));
}
else if (opType == JavaTokenType.PERC) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
@@ -167,7 +170,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "%"));
}
else if (opType == JavaTokenType.LTLT) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue)rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() << v2);
@@ -186,7 +189,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<<"));
}
else if (opType == JavaTokenType.GTGT) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue)rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() >> v2);
@@ -205,7 +208,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">>"));
}
else if (opType == JavaTokenType.GTGTGT) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue)rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() >>> v2);
@@ -224,7 +227,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">>>"));
}
else if (opType == JavaTokenType.AND) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 & v2);
@@ -242,7 +245,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "&"));
}
else if (opType == JavaTokenType.OR) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 | v2);
@@ -260,7 +263,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "|"));
}
else if (opType == JavaTokenType.XOR) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 ^ v2);
@@ -282,17 +285,17 @@ class BinaryExpressionEvaluator implements Evaluator {
return DebuggerUtilsEx.createValue(vm, expectedType, true);
}
if (leftResult == null) {
return DebuggerUtilsEx.createValue(vm, expectedType, rightResult.equals(leftResult));
return DebuggerUtilsEx.createValue(vm, expectedType, rightResult.equals(null));
}
if (rightResult == null) {
return DebuggerUtilsEx.createValue(vm, expectedType, leftResult.equals(rightResult));
return DebuggerUtilsEx.createValue(vm, expectedType, leftResult.equals(null));
}
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
@@ -332,14 +335,14 @@ class BinaryExpressionEvaluator implements Evaluator {
}
else if (opType == JavaTokenType.NE) {
if (leftResult == null && rightResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, false);
if (leftResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !rightResult.equals(leftResult));
if (rightResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !leftResult.equals(rightResult));
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (leftResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !rightResult.equals(null));
if (rightResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !leftResult.equals(null));
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
@@ -362,12 +365,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "!="));
}
else if (opType == JavaTokenType.LT) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
@@ -380,12 +383,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<"));
}
else if (opType == JavaTokenType.GT) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
@@ -398,12 +401,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">"));
}
else if (opType == JavaTokenType.LE) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
@@ -416,12 +419,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<="));
}
else if (opType == JavaTokenType.GE) {
if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
}
if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
@@ -26,6 +26,7 @@ public abstract class DebuggerCommandImpl extends DebuggerTaskImpl {
protected void commandCancelled() {
}
@Override
public Priority getPriority() {
return Priority.LOW;
}
@@ -22,14 +22,16 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.sun.jdi.ObjectCollectedException;
import org.jetbrains.annotations.NotNull;
public abstract class DebuggerContextCommandImpl extends SuspendContextCommandImpl {
private static final Logger LOG = Logger.getInstance(DebuggerContextCommandImpl.class);
private final DebuggerContextImpl myDebuggerContext;
protected DebuggerContextCommandImpl(DebuggerContextImpl debuggerContext) {
protected DebuggerContextCommandImpl(@NotNull DebuggerContextImpl debuggerContext) {
super(debuggerContext.getSuspendContext());
myDebuggerContext = debuggerContext;
}
@@ -40,7 +42,6 @@ public abstract class DebuggerContextCommandImpl extends SuspendContextCommandIm
@Override
public final void contextAction() throws Exception {
final SuspendManager suspendManager = myDebuggerContext.getDebugProcess().getSuspendManager();
final ThreadReferenceProxyImpl debuggerContextThread = myDebuggerContext.getThreadProxy();
final boolean isSuspendedByContext;
try {
@@ -17,33 +17,32 @@ package com.intellij.debugger.engine.events;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.engine.managerThread.SuspendContextCommand;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.Nullable;
/**
* Created by IntelliJ IDEA.
* User: lex
* Date: Feb 24, 2004
* Time: 7:01:31 PM
* Performs contextAction when evaluation is available in suspend context
*/
public abstract class SuspendContextCommandImpl extends DebuggerCommandImpl {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.SuspendContextCommand");
private static final Logger LOG = Logger.getInstance(SuspendContextCommand.class);
private final SuspendContextImpl mySuspendContext;
protected SuspendContextCommandImpl(SuspendContextImpl suspendContext) {
protected SuspendContextCommandImpl(@Nullable SuspendContextImpl suspendContext) {
mySuspendContext = suspendContext;
}
public abstract void contextAction() throws Exception;
@Override
public final void action() throws Exception {
if(LOG.isDebugEnabled()) {
if (LOG.isDebugEnabled()) {
LOG.debug("trying " + this);
}
final SuspendContextImpl suspendContext = getSuspendContext();
if (suspendContext == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("skip processing - context is null " + this);
@@ -52,12 +51,12 @@ public abstract class SuspendContextCommandImpl extends DebuggerCommandImpl {
return;
}
if(suspendContext.myInProgress) {
if (suspendContext.myInProgress) {
suspendContext.postponeCommand(this);
}
else {
try {
if(!suspendContext.isResumed()) {
if (!suspendContext.isResumed()) {
suspendContext.myInProgress = true;
contextAction();
}
@@ -65,7 +64,7 @@ public abstract class SuspendContextCommandImpl extends DebuggerCommandImpl {
notifyCancelled();
}
}
finally{
finally {
suspendContext.myInProgress = false;
if (suspendContext.isResumed()) {
for (SuspendContextCommandImpl postponed = suspendContext.pollPostponedCommand(); postponed != null; postponed = suspendContext.pollPostponedCommand()) {
@@ -90,6 +89,7 @@ public abstract class SuspendContextCommandImpl extends DebuggerCommandImpl {
}
}
@Nullable
public SuspendContextImpl getSuspendContext() {
return mySuspendContext;
}
@@ -47,16 +47,23 @@ public final class DebuggerContextImpl implements DebuggerContext {
private boolean myInitialized;
@Nullable
private final DebuggerSession myDebuggerSession;
private final DebugProcessImpl myDebugProcess;
private final SuspendContextImpl mySuspendContext;
private final DebuggerSession myDebuggerSession;
private final DebugProcessImpl myDebugProcess;
private final SuspendContextImpl mySuspendContext;
private final ThreadReferenceProxyImpl myThreadProxy;
private StackFrameProxyImpl myFrameProxy;
private SourcePosition mySourcePosition;
private PsiElement myContextElement;
private StackFrameProxyImpl myFrameProxy;
private SourcePosition mySourcePosition;
private PsiElement myContextElement;
private DebuggerContextImpl(@Nullable DebuggerSession session, DebugProcessImpl debugProcess, SuspendContextImpl context, ThreadReferenceProxyImpl threadProxy, StackFrameProxyImpl frameProxy, SourcePosition position, PsiElement contextElement, boolean initialized) {
private DebuggerContextImpl(@Nullable DebuggerSession session,
@Nullable DebugProcessImpl debugProcess,
@Nullable SuspendContextImpl context,
ThreadReferenceProxyImpl threadProxy,
StackFrameProxyImpl frameProxy,
SourcePosition position,
PsiElement contextElement,
boolean initialized) {
LOG.assertTrue(frameProxy == null || threadProxy == null || threadProxy == frameProxy.threadProxy());
LOG.assertTrue(debugProcess != null || frameProxy == null && threadProxy == null);
myDebuggerSession = session;
@@ -74,6 +81,7 @@ public final class DebuggerContextImpl implements DebuggerContext {
return myDebuggerSession;
}
@Nullable
@Override
public DebugProcessImpl getDebugProcess() {
return myDebugProcess;
@@ -133,7 +141,10 @@ public final class DebuggerContextImpl implements DebuggerContext {
return new EvaluationContextImpl(getSuspendContext(), frameProxy, objectReference);
}
public static DebuggerContextImpl createDebuggerContext(DebuggerSession session, SuspendContextImpl context, ThreadReferenceProxyImpl threadProxy, StackFrameProxyImpl frameProxy) {
public static DebuggerContextImpl createDebuggerContext(@Nullable DebuggerSession session,
@Nullable SuspendContextImpl context,
ThreadReferenceProxyImpl threadProxy,
StackFrameProxyImpl frameProxy) {
LOG.assertTrue(frameProxy == null || threadProxy == null || threadProxy == frameProxy.threadProxy());
LOG.assertTrue(session == null || session.getProcess() != null);
return new DebuggerContextImpl(session, session != null ? session.getProcess() : null, context, threadProxy, frameProxy, null, null, context == null);
@@ -153,7 +164,7 @@ public final class DebuggerContextImpl implements DebuggerContext {
}
}
if(myFrameProxy != null) {
if (myFrameProxy != null) {
PsiDocumentManager.getInstance(getProject()).commitAndRunReadAction(new Runnable() {
@Override
public void run() {
@@ -144,10 +144,10 @@ public abstract class InvokeThread<E extends PrioritizedTask> {
processEvent(myEvents.get());
}
catch (VMDisconnectedException e) {
catch (VMDisconnectedException ignored) {
break;
}
catch (EventQueueClosedException e) {
catch (EventQueueClosedException ignored) {
break;
}
catch (RuntimeException e) {
@@ -15,9 +15,10 @@
*/
package com.intellij.debugger.impl;
import com.intellij.debugger.engine.StackFrameContext;
import com.intellij.debugger.engine.DebugProcess;
import com.intellij.debugger.engine.StackFrameContext;
import com.intellij.debugger.engine.jdi.StackFrameProxy;
import org.jetbrains.annotations.NotNull;
/**
* @author Eugene Zhuravlev
@@ -32,10 +33,13 @@ public final class SimpleStackFrameContext implements StackFrameContext{
myProcess = process;
}
@Override
public StackFrameProxy getFrameProxy() {
return myProxy;
}
@Override
@NotNull
public DebugProcess getDebugProcess() {
return myProcess;
}
@@ -18,6 +18,7 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.ui.impl.watch.ArgumentValueDescriptorImpl;
import com.intellij.openapi.project.Project;
import com.sun.jdi.Value;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ArgValueData extends DescriptorData<ArgumentValueDescriptorImpl>{
@@ -33,7 +34,7 @@ public class ArgValueData extends DescriptorData<ArgumentValueDescriptorImpl>{
myDisplayName = displayName;
}
protected ArgumentValueDescriptorImpl createDescriptorImpl(Project project) {
protected ArgumentValueDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ArgumentValueDescriptorImpl(project, myIndex, myValue, myDisplayName);
}
@@ -36,7 +36,7 @@ public final class ArrayItemData extends DescriptorData<ArrayElementDescriptorIm
myIndex = idx;
}
protected ArrayElementDescriptorImpl createDescriptorImpl(Project project) {
protected ArrayElementDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ArrayElementDescriptorImpl(project, myArray, myIndex);
}
@@ -18,6 +18,7 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.ui.tree.NodeDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;
public abstract class DescriptorData <T extends NodeDescriptor> implements DescriptorKey<T>{
private static final Key DESCRIPTOR_DATA = new Key("DESCRIPTOR_DATA");
@@ -25,13 +26,13 @@ public abstract class DescriptorData <T extends NodeDescriptor> implements Descr
protected DescriptorData() {
}
public T createDescriptor(Project project) {
public T createDescriptor(@NotNull Project project) {
T descriptor = createDescriptorImpl(project);
descriptor.putUserData(DESCRIPTOR_DATA, this);
return descriptor;
}
protected abstract T createDescriptorImpl(Project project);
protected abstract T createDescriptorImpl(@NotNull Project project);
public abstract boolean equals(Object object);
@@ -30,7 +30,7 @@ public final class FieldData extends DescriptorData<FieldDescriptorImpl>{
myField = field;
}
protected FieldDescriptorImpl createDescriptorImpl(Project project) {
protected FieldDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new FieldDescriptorImpl(project, myObjRef, myField);
}
@@ -19,6 +19,7 @@ import com.intellij.debugger.jdi.LocalVariableProxyImpl;
import com.intellij.debugger.ui.impl.watch.LocalVariableDescriptorImpl;
import com.intellij.openapi.project.Project;
import com.intellij.util.StringBuilderSpinAllocator;
import org.jetbrains.annotations.NotNull;
public class LocalData extends DescriptorData<LocalVariableDescriptorImpl>{
private final LocalVariableProxyImpl myLocalVariable;
@@ -28,7 +29,7 @@ public class LocalData extends DescriptorData<LocalVariableDescriptorImpl>{
myLocalVariable = localVariable;
}
protected LocalVariableDescriptorImpl createDescriptorImpl(Project project) {
protected LocalVariableDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new LocalVariableDescriptorImpl(project, myLocalVariable);
}
@@ -41,7 +41,7 @@ public final class MethodReturnValueData extends DescriptorData<MethodReturnValu
return myMethod;
}
protected MethodReturnValueDescriptorImpl createDescriptorImpl(Project project) {
protected MethodReturnValueDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new MethodReturnValueDescriptorImpl(project, myMethod, myReturnValue);
}
@@ -21,27 +21,30 @@ import com.intellij.debugger.ui.impl.watch.NodeManagerImpl;
import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.NotNull;
public class StackFrameData extends DescriptorData<StackFrameDescriptorImpl>{
private final StackFrameProxyImpl myFrame;
private final FrameDisplayKey myDisplayKey;
private final MethodsTracker myMethodsTracker;
public StackFrameData(StackFrameProxyImpl frame) {
public StackFrameData(@NotNull StackFrameProxyImpl frame) {
super();
myFrame = frame;
myDisplayKey = new FrameDisplayKey(NodeManagerImpl.getContextKeyForFrame(frame));
myMethodsTracker = new MethodsTracker();
}
protected StackFrameDescriptorImpl createDescriptorImpl(Project project) {
@Override
protected StackFrameDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new StackFrameDescriptorImpl(myFrame, myMethodsTracker);
}
public boolean equals(Object object) {
if(!(object instanceof StackFrameData)) return false;
if (!(object instanceof StackFrameData)) {
return false;
}
return ((StackFrameData)object).myFrame == myFrame;
}
@@ -49,6 +52,7 @@ public class StackFrameData extends DescriptorData<StackFrameDescriptorImpl>{
return myFrame.hashCode();
}
@Override
public DisplayKey<StackFrameDescriptorImpl> getDisplayKey() {
return myDisplayKey;
}
@@ -74,6 +78,5 @@ public class StackFrameData extends DescriptorData<StackFrameDescriptorImpl>{
public int hashCode() {
return myContextKey == null? 0 : myContextKey.hashCode();
}
}
}
}
@@ -34,7 +34,7 @@ public final class StaticData extends DescriptorData<StaticDescriptorImpl>{
return myRefType;
}
protected StaticDescriptorImpl createDescriptorImpl(Project project) {
protected StaticDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new StaticDescriptorImpl(myRefType);
}
@@ -27,7 +27,7 @@ public final class StaticFieldData extends DescriptorData<FieldDescriptorImpl>{
myField = field;
}
protected FieldDescriptorImpl createDescriptorImpl(Project project) {
protected FieldDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new FieldDescriptorImpl(project, null, myField);
}
@@ -18,12 +18,13 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.ui.impl.watch.ThisDescriptorImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;
public final class ThisData extends DescriptorData<ThisDescriptorImpl>{
private static final Key THIS = new Key("THIS");
protected ThisDescriptorImpl createDescriptorImpl(Project project) {
protected ThisDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ThisDescriptorImpl(project);
}
@@ -18,6 +18,7 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
public class ThreadData extends DescriptorData<ThreadDescriptorImpl> {
private final ThreadReferenceProxyImpl myThread;
@@ -26,7 +27,7 @@ public class ThreadData extends DescriptorData<ThreadDescriptorImpl> {
myThread = thread;
}
protected ThreadDescriptorImpl createDescriptorImpl(Project project) {
protected ThreadDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ThreadDescriptorImpl(myThread);
}
@@ -18,6 +18,7 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.jdi.ThreadGroupReferenceProxyImpl;
import com.intellij.debugger.ui.impl.watch.ThreadGroupDescriptorImpl;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
public class ThreadGroupData extends DescriptorData<ThreadGroupDescriptorImpl>{
private final ThreadGroupReferenceProxyImpl myThreadGroup;
@@ -27,7 +28,7 @@ public class ThreadGroupData extends DescriptorData<ThreadGroupDescriptorImpl>{
myThreadGroup = threadGroup;
}
protected ThreadGroupDescriptorImpl createDescriptorImpl(Project project) {
protected ThreadGroupDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ThreadGroupDescriptorImpl(myThreadGroup);
}
@@ -28,7 +28,7 @@ public final class ThrownExceptionValueData extends DescriptorData<ThrownExcepti
myExceptionObj = exceptionObj;
}
protected ThrownExceptionValueDescriptorImpl createDescriptorImpl(Project project) {
protected ThrownExceptionValueDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ThrownExceptionValueDescriptorImpl(project, myExceptionObj);
}
@@ -20,6 +20,7 @@ import com.intellij.debugger.ui.impl.watch.UserExpressionDescriptorImpl;
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
import com.intellij.debugger.ui.tree.UserExpressionDescriptor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
public class UserExpressionData extends DescriptorData<UserExpressionDescriptor>{
private final ValueDescriptorImpl myParentDescriptor;
@@ -35,7 +36,7 @@ public class UserExpressionData extends DescriptorData<UserExpressionDescriptor>
myText = text;
}
protected UserExpressionDescriptorImpl createDescriptorImpl(Project project) {
protected UserExpressionDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new UserExpressionDescriptorImpl(project, myParentDescriptor, myTypeName, myName, myText);
}
@@ -19,6 +19,7 @@ import com.intellij.debugger.engine.evaluation.TextWithImports;
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
import com.intellij.openapi.project.Project;
import com.sun.jdi.Value;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -34,7 +35,7 @@ public final class WatchItemData extends DescriptorData<WatchItemDescriptor>{
myValue = value;
}
protected WatchItemDescriptor createDescriptorImpl(final Project project) {
protected WatchItemDescriptor createDescriptorImpl(@NotNull final Project project) {
return new WatchItemDescriptor(project, myText, myValue);
}
@@ -40,6 +40,7 @@ public class LocalVariableProxyImpl extends JdiProxy implements LocalVariablePro
myVariable = variable;
}
@Override
protected void clearCaches() {
myVariable = null;
myVariableType = null;
@@ -47,10 +48,9 @@ public class LocalVariableProxyImpl extends JdiProxy implements LocalVariablePro
public LocalVariable getVariable() throws EvaluateException {
checkValid();
if(myVariable == null) {
if (myVariable == null) {
myVariable = myFrame.visibleVariableByNameInt(myVariableName);
if(myVariable == null) {
if (myVariable == null) {
//myFrame is not this variable's frame
throw EvaluateExceptionUtil.createEvaluateException(new IncompatibleThreadStateException());
}
@@ -75,7 +75,7 @@ public class LocalVariableProxyImpl extends JdiProxy implements LocalVariablePro
}
public boolean equals(Object o) {
if(o instanceof LocalVariableProxyImpl) {
if (o instanceof LocalVariableProxyImpl) {
LocalVariableProxyImpl proxy = (LocalVariableProxyImpl)o;
return Comparing.equal(proxy.myFrame, myFrame) && myVariableName.equals(proxy.myVariableName);
}
@@ -87,7 +87,7 @@ public class ObjectReferenceProxyImpl extends JdiProxy {
try {
myIsCollected = Boolean.valueOf(VirtualMachineProxyImpl.isCollected(myObjectReference));
}
catch (VMDisconnectedException e) {
catch (VMDisconnectedException ignored) {
myIsCollected = Boolean.TRUE;
}
}
@@ -128,7 +128,7 @@ public class ObjectReferenceProxyImpl extends JdiProxy {
if(this == o) return true;
ObjectReference ref = myObjectReference;
return ref != null && ref.equals(((ObjectReferenceProxyImpl)o).myObjectReference);
return ref.equals(((ObjectReferenceProxyImpl)o).myObjectReference);
}
@@ -139,9 +139,10 @@ public class ObjectReferenceProxyImpl extends JdiProxy {
/**
* The advice to the proxy to clear cached data.
*/
@Override
protected void clearCaches() {
if (Boolean.FALSE.equals(myIsCollected)) {
// clearing cache makes sence only if the object has not been collected yet
// clearing cache makes sense only if the object has not been collected yet
myIsCollected = null;
}
}
@@ -107,7 +107,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
checkValid();
if(myStackFrame == null) {
if (myStackFrame == null) {
try {
final ThreadReference threadRef = myThreadProxy.getThreadReference();
myStackFrame = threadRef.frame(getFrameIndex());
@@ -35,14 +35,15 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
// cached data
private String myName;
private int myFrameCount = -1;
// stackframes, 0 - bottom
// stack frames, 0 - bottom
private final List<StackFrameProxyImpl> myFramesFromBottom = new ArrayList<StackFrameProxyImpl>();
//cache build on the base of myFramesFromBottom 0 - top, initially nothing is cached
private List<StackFrameProxyImpl> myFrames = null;
private ThreadGroupReferenceProxyImpl myThreadGroupProxy;
public static Comparator<ThreadReferenceProxyImpl> ourComparator = new Comparator<ThreadReferenceProxyImpl>() {
public static final Comparator<ThreadReferenceProxyImpl> ourComparator = new Comparator<ThreadReferenceProxyImpl>() {
@Override
public int compare(ThreadReferenceProxyImpl th1, ThreadReferenceProxyImpl th2) {
return th1.name().compareToIgnoreCase(th2.name());
}
@@ -52,11 +53,13 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
super(virtualMachineProxy, threadReference);
}
@Override
public ThreadReference getThreadReference() {
DebuggerManagerThreadImpl.assertIsManagerThread();
return (ThreadReference)getObjectReference();
}
@Override
public VirtualMachineProxyImpl getVirtualMachine() {
DebuggerManagerThreadImpl.assertIsManagerThread();
return (VirtualMachineProxyImpl) myTimer;
@@ -68,10 +71,10 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
myName = getThreadReference().name();
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
myName = "";
}
catch (IllegalThreadStateException e) {
catch (IllegalThreadStateException ignored) {
myName = "zombie";
}
}
@@ -84,7 +87,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
return getThreadReference().suspendCount();
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
return 0;
}
}
@@ -106,7 +109,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
threadRefString = getThreadReference().toString() ;
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
threadRefString = "[thread collected]";
}
return "ThreadReferenceProxyImpl: " + threadRefString + " " + super.toString();
@@ -127,6 +130,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
}
}
@Override
protected void clearCaches() {
DebuggerManagerThreadImpl.assertIsManagerThread();
myName = null;
@@ -139,7 +143,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
return getThreadReference().status();
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
return ThreadReference.THREAD_STATUS_ZOMBIE;
}
}
@@ -152,7 +156,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
threadGroupRef = getThreadReference().threadGroup();
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
threadGroupRef = null;
}
myThreadGroupProxy = getVirtualMachineProxy().getThreadGroupReferenceProxy(threadGroupRef);
@@ -160,6 +164,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
return myThreadGroupProxy;
}
@Override
public int frameCount() throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
checkValid();
@@ -168,7 +173,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
myFrameCount = threadReference.frameCount();
}
catch(ObjectCollectedException e) {
catch(ObjectCollectedException ignored) {
myFrameCount = 0;
}
catch (IncompatibleThreadStateException e) {
@@ -176,7 +181,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
isSuspended = threadReference.isSuspended();
}
catch (Throwable th) {
catch (Throwable ignored) {
// unable to determine whether the thread is actually suspended, so propagating original exception
throw EvaluateExceptionUtil.createEvaluateException(e);
}
@@ -207,12 +212,11 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
myFrames = new ArrayList<StackFrameProxyImpl>(frameCount());
for (ListIterator<StackFrameProxyImpl> iterator = myFramesFromBottom.listIterator(frameCount()); iterator.hasPrevious();) {
StackFrameProxyImpl stackFrameProxy = iterator.previous();
myFrames.add(stackFrameProxy);
myFrames.add(iterator.previous());
}
}
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
return Collections.emptyList();
}
return myFrames;
@@ -234,13 +238,13 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
int index = myFramesFromBottom.size() + 1;
for (ListIterator<StackFrame> iterator = frames.listIterator(count - myFramesFromBottom.size()); iterator.hasPrevious();) {
StackFrame stackFrame = iterator.previous();
myFramesFromBottom.add(new StackFrameProxyImpl(this, stackFrame, index));
myFramesFromBottom.add(new StackFrameProxyImpl(this, iterator.previous(), index));
index++;
}
}
}
@Override
public StackFrameProxyImpl frame(int i) throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
final ThreadReference threadReference = getThreadReference();
@@ -255,10 +259,10 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
}
return myFramesFromBottom.get(frameCount - i - 1);
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
return null;
}
catch (IllegalThreadStateException e) {
catch (IllegalThreadStateException ignored) {
return null;
}
}
@@ -59,6 +59,7 @@ import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.Alarm;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.VMDisconnectedException;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@@ -102,6 +103,7 @@ public class FramesPanel extends UpdatableDebuggerView {
myFramesList.addListSelectionListener(myFramesListener);
myFramesList.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
int index = myFramesList.locationToIndex(e.getPoint());
if (index >= 0 && myFramesList.isSelectedIndex(index)) {
@@ -140,6 +142,7 @@ public class FramesPanel extends UpdatableDebuggerView {
return toolbar;
}
@Override
public DebuggerStateManager getContextManager() {
return myStateManager;
}
@@ -151,6 +154,7 @@ public class FramesPanel extends UpdatableDebuggerView {
myIsEnabled = enabled;
}
@Override
public void valueChanged(ListSelectionEvent e) {
if (!myIsEnabled || e.getValueIsAdjusting()) {
return;
@@ -169,6 +173,7 @@ public class FramesPanel extends UpdatableDebuggerView {
private void registerThreadsPopupMenu(final JList framesList) {
final PopupHandler popupHandler = new PopupHandler() {
@Override
public void invokePopup(Component comp, int x, int y) {
DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction(DebuggerActions.THREADS_PANEL_POPUP);
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(DebuggerActions.THREADS_PANEL_POPUP, group);
@@ -177,6 +182,7 @@ public class FramesPanel extends UpdatableDebuggerView {
};
framesList.addMouseListener(popupHandler);
registerDisposable(new Disposable() {
@Override
public void dispose() {
myThreadsCombo.removeItemListener(myThreadsListener);
framesList.removeMouseListener(popupHandler);
@@ -191,6 +197,7 @@ public class FramesPanel extends UpdatableDebuggerView {
myIsEnabled = enabled;
}
@Override
public void itemStateChanged(ItemEvent e) {
if (!myIsEnabled) return;
if (e.getStateChange() == ItemEvent.SELECTED) {
@@ -202,6 +209,7 @@ public class FramesPanel extends UpdatableDebuggerView {
private final AtomicBoolean myPerformFullRebuild = new AtomicBoolean(false);
@Override
protected void rebuild(int event) {
myRebuildAlarm.cancelAllRequests();
final boolean isRefresh = event == DebuggerSession.EVENT_REFRESH ||
@@ -211,12 +219,12 @@ public class FramesPanel extends UpdatableDebuggerView {
myPerformFullRebuild.set(true);
}
myRebuildAlarm.addRequest(new Runnable() {
@Override
public void run() {
try {
doRebuild(!myPerformFullRebuild.getAndSet(false));
}
catch (VMDisconnectedException e) {
// ignored
catch (VMDisconnectedException ignored) {
}
}
}, 100, ModalityState.NON_MODAL);
@@ -298,6 +306,7 @@ public class FramesPanel extends UpdatableDebuggerView {
return descriptors;
}
@Override
public void threadAction() {
if (myRefreshOnly && myThreadDescriptorsToUpdate.length != myThreadsCombo.getItemCount()) {
// there is no sense in refreshing combobox if thread list has changed since creation of this command
@@ -329,6 +338,7 @@ public class FramesPanel extends UpdatableDebuggerView {
descriptor.updateRepresentation(evaluationContext, DescriptorLabelListener.DUMMY_LISTENER);
}
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
@Override
public void run() {
try {
myThreadsListener.setEnabled(false);
@@ -346,6 +356,7 @@ public class FramesPanel extends UpdatableDebuggerView {
}
}
@Override
protected void commandCancelled() {
if (!DebuggerManagerThreadImpl.isManagerThread()) {
return;
@@ -372,6 +383,7 @@ public class FramesPanel extends UpdatableDebuggerView {
private void refillThreadsCombo(final ThreadReferenceProxyImpl threadToSelect) {
final List<ThreadDescriptorImpl> threadItems = createThreadDescriptorsList();
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
@Override
public void run() {
try {
myThreadsListener.setEnabled(false);
@@ -400,9 +412,11 @@ public class FramesPanel extends UpdatableDebuggerView {
myDebuggerContext = debuggerContext;
}
@Override
public void contextAction() throws Exception {
updateFrameList(myDebuggerContext.getThreadProxy());
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
@Override
public void run() {
try {
myFramesListener.setEnabled(false);
@@ -425,7 +439,7 @@ public class FramesPanel extends UpdatableDebuggerView {
return;
}
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
return;
}
@@ -462,11 +476,13 @@ public class FramesPanel extends UpdatableDebuggerView {
myDebuggerContext = debuggerContext;
}
@Override
public void contextAction() throws Exception {
final ThreadReferenceProxyImpl thread = myDebuggerContext.getThreadProxy();
try {
if(!getSuspendContext().getDebugProcess().getSuspendManager().isSuspended(thread)) {
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
@Override
public void run() {
try {
myFramesListener.setEnabled(false);
@@ -491,7 +507,7 @@ public class FramesPanel extends UpdatableDebuggerView {
return;
}
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
return;
}
@@ -499,7 +515,7 @@ public class FramesPanel extends UpdatableDebuggerView {
try {
frames = thread.frames();
}
catch (EvaluateException e) {
catch (EvaluateException ignored) {
frames = Collections.emptyList();
}
@@ -601,7 +617,7 @@ public class FramesPanel extends UpdatableDebuggerView {
private final long myTimestamp;
private final IndexCounter myCounter;
public AppendFrameCommand(SuspendContextImpl suspendContext, StackFrameProxyImpl frame, EvaluationContextImpl evaluationContext,
public AppendFrameCommand(@NotNull SuspendContextImpl suspendContext, @NotNull StackFrameProxyImpl frame, EvaluationContextImpl evaluationContext,
MethodsTracker tracker, int indexToInsert, final boolean isContextFrame, final long timestamp, IndexCounter counter) {
super(suspendContext);
myFrame = frame;
@@ -613,12 +629,14 @@ public class FramesPanel extends UpdatableDebuggerView {
myCounter = counter;
}
@Override
public void contextAction() throws Exception {
final StackFrameDescriptorImpl descriptor = new StackFrameDescriptorImpl(myFrame, myTracker);
descriptor.setContext(myEvaluationContext);
descriptor.updateRepresentation(myEvaluationContext, DescriptorLabelListener.DUMMY_LISTENER);
final Project project = getProject();
DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
@Override
public void run() {
try {
myFramesListener.setEnabled(false);
@@ -650,6 +668,7 @@ public class FramesPanel extends UpdatableDebuggerView {
}
}
@Override
public void requestFocus() {
myFramesList.requestFocus();
}
@@ -672,6 +691,7 @@ public class FramesPanel extends UpdatableDebuggerView {
myShouldShow = DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES;
}
@Override
public void update(final AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
@@ -679,10 +699,12 @@ public class FramesPanel extends UpdatableDebuggerView {
presentation.setText(shouldShow ? ourTextWhenShowIsOn : ourTextWhenShowIsOff);
}
@Override
public boolean isSelected(AnActionEvent e) {
return !myShouldShow;
}
@Override
public void setSelected(AnActionEvent e, boolean enabled) {
myShouldShow = !enabled;
DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES = myShouldShow;
@@ -31,6 +31,7 @@ import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.xdebugger.AbstractDebuggerSession;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
@@ -41,6 +42,7 @@ import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointPanelProvider;
import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler;
import com.intellij.xdebugger.impl.settings.DebuggerSettingsPanelProvider;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -194,7 +196,7 @@ public class JavaDebuggerSupport extends DebuggerSupport {
@NotNull
@Override
public EditBreakpointActionHandler getEditBreakpointAction() {
return DISABLED_EDIT;
return X_EDIT;
}
@Override
@@ -374,10 +376,10 @@ public class JavaDebuggerSupport extends DebuggerSupport {
}
};
private static final EditBreakpointActionHandler DISABLED_EDIT = new EditBreakpointActionHandler() {
private static final EditBreakpointActionHandler X_EDIT = new EditBreakpointActionHandler() {
@Override
protected void doShowPopup(Project project, JComponent component, Point whereToShow, Object breakpoint) {
DebuggerUIUtil.showXBreakpointEditorBalloon(project, whereToShow, component, false, (XBreakpoint)breakpoint);
}
@Override
@@ -56,6 +56,7 @@ import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
import com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager;
import com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl;
import com.sun.jdi.InternalException;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.request.*;
@@ -173,13 +174,16 @@ public class BreakpointManager {
DebuggerInvocationUtil.swingInvokeLater(myProject, new Runnable() {
@Override
public void run() {
final RangeHighlighter highlighter = ((BreakpointWithHighlighter)breakpoint).getHighlighter();
if (highlighter != null) {
final GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
if (renderer != null) {
DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(
myProject, editor, breakpoint, renderer
);
XBreakpoint xBreakpoint = breakpoint.myXBreakpoint;
if (xBreakpoint instanceof XLineBreakpointImpl) {
RangeHighlighter highlighter = ((XLineBreakpointImpl)xBreakpoint).getHighlighter();
if (highlighter != null) {
GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
if (renderer != null) {
DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(
myProject, editor, breakpoint.myXBreakpoint, renderer
);
}
}
}
}
@@ -65,7 +65,7 @@ import javax.swing.tree.TreePath;
import java.util.*;
public class FrameVariablesTree extends DebuggerTree {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.impl.FrameDebuggerTree");
private static final Logger LOG = Logger.getInstance(FrameVariablesTree.class);
private boolean myAnyNewLocals;
private boolean myAutoWatchMode = false;
@@ -122,7 +122,7 @@ public class FrameVariablesTree extends DebuggerTree {
@Override
protected DebuggerCommandImpl getBuildNodeCommand(final DebuggerTreeNodeImpl node) {
protected DebuggerCommandImpl getBuildNodeCommand(@NotNull DebuggerTreeNodeImpl node) {
if (node.getDescriptor() instanceof StackFrameDescriptorImpl) {
return new BuildFrameTreeVariablesCommand(node);
}
@@ -192,9 +192,6 @@ public class FrameVariablesTree extends DebuggerTree {
catch (EvaluateException e) {
if (e.getCause() instanceof AbsentInformationException) {
final StackFrameProxyImpl frame = stackDescriptor.getFrameProxy();
if (frame == null) {
throw e;
}
final Collection<Value> argValues = frame.getArgumentValues();
int index = 0;
@@ -281,9 +278,6 @@ public class FrameVariablesTree extends DebuggerTree {
private static Map<String, LocalVariableProxyImpl> getVisibleVariables(final StackFrameDescriptorImpl stackDescriptor) throws EvaluateException {
final StackFrameProxyImpl frame = stackDescriptor.getFrameProxy();
if (frame == null) {
return Collections.emptyMap();
}
final Map<String, LocalVariableProxyImpl> vars = new HashMap<String, LocalVariableProxyImpl>();
for (LocalVariableProxyImpl localVariableProxy : frame.visibleVariables()) {
vars.put(localVariableProxy.name(), localVariableProxy);
@@ -442,7 +436,6 @@ public class FrameVariablesTree extends DebuggerTree {
try {
StackFrameProxyImpl frame = debuggerContext.getFrameProxy();
if (frame != null) {
NodeManagerImpl nodeManager = getNodeFactory();
rootNode = nodeManager.createNode(nodeManager.getStackFrameDescriptor(null, frame), debuggerContext.createEvaluationContext());
@@ -26,6 +26,7 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.ui.AppUIUtil;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.SystemProperties;
import com.intellij.xdebugger.XSourcePosition;
@@ -60,6 +61,7 @@ public class VariablesPanel extends DebuggerTreePanel implements DataProvider {
myCards.add(frameTree, TREE);
myXTree = new MyXVariablesView(project);
registerDisposable(myXTree);
myCards.add(myXTree.getTree(), X_TREE);
add(ScrollPaneFactory.createScrollPane(myCards), BorderLayout.CENTER);
@@ -101,15 +103,20 @@ public class VariablesPanel extends DebuggerTreePanel implements DataProvider {
return (FrameVariablesTree)getTree();
}
public void stackChanged(@Nullable XStackFrame xStackFrame) {
myXTree.stackChanged(xStackFrame);
((CardLayout)(myCards.getLayout())).show(myCards, xStackFrame == null ? TREE : X_TREE);
public void stackChanged(@Nullable final XStackFrame xStackFrame) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
myXTree.stackChanged(xStackFrame);
((CardLayout)(myCards.getLayout())).show(myCards, xStackFrame == null ? TREE : X_TREE);
}
});
}
private static final class MyXVariablesView extends XVariablesViewBase {
private XStackFrame myCurrentXStackFrame;
public MyXVariablesView(Project project) {
public MyXVariablesView(@NotNull Project project) {
super(project, new XDebuggerEditorsProvider() {
@NotNull
@Override
@@ -68,7 +68,7 @@ import java.util.*;
import java.util.List;
public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvider {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.impl.watch.DebuggerTree");
private static final Logger LOG = Logger.getInstance(DebuggerTree.class);
protected static final Key<Rectangle> VISIBLE_RECT = Key.create("VISIBLE_RECT");
public static final DataKey<DebuggerTree> DATA_KEY = DataKey.create("DebuggerTree");
@@ -444,9 +444,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
try {
final StackFrameDescriptorImpl stackDescriptor = (StackFrameDescriptorImpl)getNode().getDescriptor();
final StackFrameProxyImpl frame = stackDescriptor.getFrameProxy();
if (frame == null) {
return;
}
final DebuggerContextImpl debuggerContext = getDebuggerContext();
final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
@@ -538,12 +535,10 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
protected void buildVariables(final StackFrameDescriptorImpl stackDescriptor, final EvaluationContextImpl evaluationContext) throws EvaluateException {
final StackFrameProxyImpl frame = stackDescriptor.getFrameProxy();
if (frame != null) {
for (final LocalVariableProxyImpl local : frame.visibleVariables()) {
final LocalVariableDescriptorImpl localVariableDescriptor = myNodeManager.getLocalVariableDescriptor(stackDescriptor, local);
final DebuggerTreeNodeImpl variableNode = myNodeManager.createNode(localVariableDescriptor, evaluationContext);
myChildren.add(variableNode);
}
for (final LocalVariableProxyImpl local : frame.visibleVariables()) {
final LocalVariableDescriptorImpl localVariableDescriptor = myNodeManager.getLocalVariableDescriptor(stackDescriptor, local);
final DebuggerTreeNodeImpl variableNode = myNodeManager.createNode(localVariableDescriptor, evaluationContext);
myChildren.add(variableNode);
}
}
}
@@ -44,7 +44,6 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
private boolean myIsPrimitive;
private boolean myIsNewLocal = true;
private boolean myIsVisible = true;
public LocalVariableDescriptorImpl(Project project,
@NotNull LocalVariableProxyImpl local) {
@@ -54,6 +53,7 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
myLocalVariable = local;
}
@Override
public LocalVariableProxyImpl getLocalVariable() {
return myLocalVariable;
}
@@ -83,13 +83,15 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
return myIsNewLocal;
}
@Override
public boolean isPrimitive() {
return myIsPrimitive;
}
@Override
public Value calcValue(EvaluationContextImpl evaluationContext) throws EvaluateException {
myIsVisible = myFrameProxy.isLocalVariableVisible(getLocalVariable());
if (myIsVisible) {
boolean isVisible = myFrameProxy.isLocalVariableVisible(getLocalVariable());
if (isVisible) {
final String typeName = getLocalVariable().typeName();
myTypeName = typeName;
myIsPrimitive = DebuggerUtils.isPrimitiveType(typeName);
@@ -103,6 +105,7 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
myIsNewLocal = aNew;
}
@Override
public void displayAs(NodeDescriptor descriptor) {
super.displayAs(descriptor);
if(descriptor instanceof LocalVariableDescriptorImpl) {
@@ -110,10 +113,12 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
}
}
@Override
public String getName() {
return myLocalVariable.name();
}
@Override
public String calcValueName() {
final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer();
StringBuilder buf = StringBuilderSpinAllocator.alloc();
@@ -130,6 +135,7 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
}
}
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
try {
@@ -32,6 +32,7 @@ import com.intellij.debugger.ui.tree.UserExpressionDescriptor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.sun.jdi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
@@ -97,6 +98,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
final MarkedDescriptorTree displayDescriptorTree = new MarkedDescriptorTree();
tree.dfst(new DescriptorTree.DFSTWalker() {
@Override
public void visit(NodeDescriptor parent, NodeDescriptor child) {
final DescriptorData<NodeDescriptor> descriptorData = DescriptorData.getDescriptorData(child);
descriptorTree.addChild(parent, child, descriptorData);
@@ -130,10 +132,12 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
return descriptorTree;
}
@Override
public ArrayElementDescriptorImpl getArrayItemDescriptor(NodeDescriptor parent, ArrayReference array, int index) {
return getDescriptor(parent, new ArrayItemData(array, index));
}
@Override
public FieldDescriptorImpl getFieldDescriptor(NodeDescriptor parent, ObjectReference objRef, Field field) {
final DescriptorData<FieldDescriptorImpl> descriptorData;
if (objRef == null ) {
@@ -148,6 +152,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
return getDescriptor(parent, descriptorData);
}
@Override
public LocalVariableDescriptorImpl getLocalVariableDescriptor(NodeDescriptor parent, LocalVariableProxy local) {
return getDescriptor(parent, new LocalData((LocalVariableProxyImpl)local));
}
@@ -156,7 +161,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
return getDescriptor(parent, new ArgValueData(index, value, name));
}
public StackFrameDescriptorImpl getStackFrameDescriptor(NodeDescriptorImpl parent, StackFrameProxyImpl frameProxy) {
public StackFrameDescriptorImpl getStackFrameDescriptor(@Nullable NodeDescriptorImpl parent, @NotNull StackFrameProxyImpl frameProxy) {
return getDescriptor(parent, new StackFrameData(frameProxy));
}
@@ -184,6 +189,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
return getDescriptor(parent, new ThreadGroupData(group));
}
@Override
public UserExpressionDescriptor getUserExpressionDescriptor(NodeDescriptor parent, final DescriptorData<UserExpressionDescriptor> data) {
return getDescriptor(parent, data);
}
@@ -232,6 +238,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
super(descriportTree);
}
@Override
protected NodeDescriptor getSearched(NodeDescriptor parent) {
NodeDescriptor searched = super.getSearched(parent);
if(searched == null) {
@@ -35,6 +35,7 @@ import com.intellij.util.ui.TextTransferable;
import com.intellij.xdebugger.frame.XStackFrame;
import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
import com.sun.jdi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -58,8 +59,9 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
private Icon myIcon = AllIcons.Debugger.StackFrame;
public StackFrameDescriptorImpl(StackFrameProxyImpl frame, final MethodsTracker tracker) {
public StackFrameDescriptorImpl(@NotNull StackFrameProxyImpl frame, @NotNull MethodsTracker tracker) {
myFrame = frame;
try {
myUiIndex = frame.getFrameIndex();
myLocation = frame.location();
@@ -112,10 +114,12 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
}
@Override
@NotNull
public StackFrameProxyImpl getFrameProxy() {
return myFrame;
}
@NotNull
@Override
public DebugProcess getDebugProcess() {
return myFrame.getVirtualMachine().getDebugProcess();
@@ -76,7 +76,8 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
myProject = project;
}
public boolean isArray() {
@Override
public boolean isArray() {
return myValue instanceof ArrayReference;
}
@@ -84,11 +85,13 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return myIsDirty;
}
public boolean isLvalue() {
@Override
public boolean isLvalue() {
return myIsLvalue;
}
public boolean isNull() {
@Override
public boolean isNull() {
return myValue == null;
}
@@ -97,6 +100,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return myValue instanceof StringReference;
}
@Override
public boolean isPrimitive() {
return myValue instanceof PrimitiveValue;
}
@@ -113,6 +117,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
myShowIdLabel = showIdLabel;
}
@Override
public Value getValue() {
// the following code makes sense only if we do not use ObjectReference.enableCollection() / disableCollection()
// to keep temporary objects
@@ -124,6 +129,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
final Semaphore semaphore = new Semaphore();
semaphore.down();
evalContext.getDebugProcess().getManagerThread().invoke(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {
@Override
public void contextAction() throws Exception {
// re-setting the context will cause value recalculation
try {
@@ -134,6 +140,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
}
}
@Override
protected void commandCancelled() {
semaphore.up();
}
@@ -145,12 +152,14 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return myValue;
}
@Override
public boolean isExpandable() {
return myIsExpandable;
}
public abstract Value calcValue(EvaluationContextImpl evaluationContext) throws EvaluateException;
@Override
public final void setContext(EvaluationContextImpl evaluationContext) {
DebuggerManagerThreadImpl.assertIsManagerThread();
myStoredEvaluationContext = evaluationContext;
@@ -170,7 +179,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
myIsDirty = (value == null) ? myValue != null : !value.equals(myValue);
}
}
catch (ObjectCollectedException e) {
catch (ObjectCollectedException ignored) {
myIsDirty = true;
}
}
@@ -227,6 +236,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return exceptionObj;
}
@Override
public void setAncestor(NodeDescriptor oldDescriptor) {
super.setAncestor(oldDescriptor);
myIsNew = false;
@@ -237,6 +247,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
myIsLvalue = value;
}
@Override
protected String calcRepresentation(EvaluationContextImpl context, DescriptorLabelListener labelListener){
DebuggerManagerThreadImpl.assertIsManagerThread();
@@ -288,18 +299,21 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
}
@Override
public String setValueLabel(String label) {
final String customLabel = getCustomLabel(label);
myValueLabel = customLabel;
return setLabel(calcValueName() + " = " + customLabel);
}
@Override
public String setValueLabelFailed(EvaluateException e) {
final String label = setFailed(e);
setValueLabel(label);
return label;
}
@Override
public Icon setValueIcon(Icon icon) {
return myValueIcon = icon;
}
@@ -311,6 +325,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
public abstract String calcValueName();
@Override
public void displayAs(NodeDescriptor descriptor) {
if (descriptor instanceof ValueDescriptorImpl) {
ValueDescriptorImpl valueDescriptor = (ValueDescriptorImpl)descriptor;
@@ -370,6 +385,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
//use 'this' to reference parent node
//for ex. FieldDescriptorImpl should return
//this.fieldName
@Override
public abstract PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException;
public static String getIdLabel(ObjectReference objRef) {
@@ -425,12 +441,14 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
}
//Context is set to null
@Override
public void clear() {
super.clear();
setValueLabel("");
myIsExpandable = false;
}
@Override
@Nullable
public ValueMarkup getMarkup(final DebugProcess debugProcess) {
final Value value = getValue();
@@ -444,6 +462,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return null;
}
@Override
public void setMarkup(final DebugProcess debugProcess, @Nullable final ValueMarkup markup) {
final Value value = getValue();
if (value instanceof ObjectReference) {
@@ -18,8 +18,10 @@ package com.intellij.debugger;
import com.intellij.debugger.engine.StackFrameContext;
import com.intellij.debugger.engine.SuspendContext;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nullable;
public interface DebuggerContext extends StackFrameContext{
public interface DebuggerContext extends StackFrameContext {
@Nullable
SuspendContext getSuspendContext();
Project getProject();
@@ -17,6 +17,7 @@ package com.intellij.debugger;
import com.intellij.debugger.engine.DebugProcess;
import com.intellij.openapi.extensions.ExtensionPointName;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -26,5 +27,5 @@ public abstract class PositionManagerFactory {
public static final ExtensionPointName<PositionManagerFactory> EP_NAME = ExtensionPointName.create("com.intellij.debugger.positionManagerFactory");
@Nullable
public abstract PositionManager createPositionManager(DebugProcess process);
public abstract PositionManager createPositionManager(@NotNull DebugProcess process);
}
@@ -18,15 +18,10 @@ package com.intellij.debugger.engine;
import com.intellij.debugger.engine.jdi.StackFrameProxy;
import org.jetbrains.annotations.Nullable;
/**
* Created by IntelliJ IDEA.
* User: lex
* Date: Jun 3, 2003
* Time: 5:58:58 PM
* To change this template use Options | File Templates.
*/
public interface StackFrameContext {
@Nullable
StackFrameProxy getFrameProxy();
DebugProcess getDebugProcess();
StackFrameProxy getFrameProxy();
@Nullable
DebugProcess getDebugProcess();
}
@@ -18,7 +18,7 @@ package com.intellij.debugger.engine;
import com.intellij.debugger.engine.jdi.ThreadReferenceProxy;
public interface SuspendContext extends StackFrameContext {
public int getSuspendPolicy();
int getSuspendPolicy();
ThreadReferenceProxy getThread();
}
@@ -21,8 +21,10 @@ import com.intellij.debugger.engine.SuspendContext;
import com.intellij.openapi.project.Project;
import com.sun.jdi.ClassLoaderReference;
import com.sun.jdi.Value;
import org.jetbrains.annotations.NotNull;
public interface EvaluationContext extends StackFrameContext{
@NotNull
DebugProcess getDebugProcess();
EvaluationContext createEvaluationContext(Value value);
@@ -81,14 +81,15 @@ public class AddTypeCastFix extends LocalQuickFixAndIntentionActionOnPsiElement
originalExpression.replace(typeCast);
}
static PsiExpression createCastExpression(PsiExpression originalExpression, Project project, PsiType type) {
static PsiExpression createCastExpression(PsiExpression original, Project project, PsiType type) {
// remove nested casts
PsiElement expression = PsiUtil.deparenthesizeExpression(originalExpression);
PsiElement expression = PsiUtil.deparenthesizeExpression(original);
if (expression == null) return null;
PsiElementFactory factory = JavaPsiFacade.getInstance(originalExpression.getProject()).getElementFactory();
PsiTypeCastExpression typeCast = (PsiTypeCastExpression)factory.createExpressionFromText("(Type)value", null);
assertNotNull(typeCast.getCastType()).replace(factory.createTypeElement(type));
PsiElementFactory factory = JavaPsiFacade.getInstance(original.getProject()).getElementFactory();
if (type instanceof PsiEllipsisType) type = ((PsiEllipsisType)type).toArrayType();
String text = "(" + type.getCanonicalText(false) + ")value";
PsiTypeCastExpression typeCast = (PsiTypeCastExpression)factory.createExpressionFromText(text, original);
typeCast = (PsiTypeCastExpression)CodeStyleManager.getInstance(project).reformat(typeCast);
if (expression instanceof PsiConditionalExpression) {
@@ -124,5 +125,4 @@ public class AddTypeCastFix extends LocalQuickFixAndIntentionActionOnPsiElement
public boolean startInWriteAction() {
return true;
}
}
@@ -195,6 +195,13 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
PsiStatement body = foreachStatement.getBody();
final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
if (body != null && iteratedValue != null) {
final Collection<PsiComment> comments = PsiTreeUtil.findChildrenOfType(body, PsiComment.class);
final PsiElement parent = foreachStatement.getParent();
for (PsiElement comment : PsiTreeUtil.findChildrenOfType(body, PsiComment.class)) {
parent.addBefore(comment, foreachStatement);
}
final PsiParameter parameter = foreachStatement.getIterationParameter();
final PsiIfStatement ifStmt = extractIfStatement(body);
@@ -294,13 +301,19 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
iteration += ").collect(java.util.stream.Collectors.";
String variableName = null;
PsiExpression initializer = null;
PsiExpression primitiveInitializer = null;
final PsiExpression qualifierExpression = methodCallExpression.getMethodExpression().getQualifierExpression();
if (qualifierExpression instanceof PsiReferenceExpression) {
final PsiElement resolve = ((PsiReferenceExpression)qualifierExpression).resolve();
if (resolve instanceof PsiVariable) {
if (resolve instanceof PsiLocalVariable && foreachStatement.equals(PsiTreeUtil.skipSiblingsForward(resolve.getParent(), PsiWhiteSpace.class))) {
initializer = ((PsiVariable)resolve).getInitializer();
final PsiExpression initializer = ((PsiVariable)resolve).getInitializer();
if (initializer instanceof PsiNewExpression) {
final PsiExpressionList argumentList = ((PsiNewExpression)initializer).getArgumentList();
if (argumentList != null && argumentList.getExpressions().length == 0) {
primitiveInitializer = initializer;
}
}
}
variableName = ((PsiVariable)resolve).getName() + ".";
}
@@ -308,19 +321,26 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
variableName = "";
}
if (variableName != null) {
final PsiElement parent = foreachStatement.getParent();
for (PsiElement comment : PsiTreeUtil.findChildrenOfType(body, PsiComment.class)) {
parent.addBefore(comment, foreachStatement);
}
}
PsiElement result = null;
if (initializer != null) {
final PsiType initializerType = initializer.getType();
if (primitiveInitializer != null) {
final PsiType initializerType = primitiveInitializer.getType();
final PsiClassType rawType = initializerType instanceof PsiClassType ? ((PsiClassType)initializerType).rawType() : null;
if (rawType != null && rawType.equalsToText(CommonClassNames.JAVA_UTIL_ARRAY_LIST)) {
iteration += "toList()";
} else if (rawType != null && rawType.equalsToText(CommonClassNames.JAVA_UTIL_HASH_SET)) {
iteration += "toSet()";
} else {
iteration += "toCollection(() -> " + initializer.getText() +")";
iteration += "toCollection(() -> " + primitiveInitializer.getText() +")";
}
iteration += ")";
result = initializer.replace(JavaPsiFacade.getElementFactory(project).createExpressionFromText(iteration, foreachStatement));
result = primitiveInitializer.replace(JavaPsiFacade.getElementFactory(project).createExpressionFromText(iteration, foreachStatement));
foreachStatement.delete();
} else if (variableName != null){
iteration += "toList())";
@@ -57,8 +57,21 @@ public class AddExceptionToThrowsFix extends BaseIntentionAction {
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiMethod targetMethod = PsiTreeUtil.getParentOfType(myWrongElement, PsiMethod.class);
List<PsiClassType> exceptions = getUnhandledExceptions(myWrongElement, targetMethod);
PsiElement targetElement = null;
PsiMethod targetMethod = null;
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(myWrongElement, PsiLambdaExpression.class);
if (lambdaExpression != null) {
targetMethod = LambdaUtil.getFunctionalInterfaceMethod(lambdaExpression);
targetElement = lambdaExpression.getBody();
}
if (targetElement == null && targetMethod == null) {
targetMethod = PsiTreeUtil.getParentOfType(myWrongElement, PsiMethod.class);
targetElement = targetMethod;
}
List<PsiClassType> exceptions = getUnhandledExceptions(myWrongElement, targetElement, targetMethod);
if (exceptions == null || targetMethod == null) return;
Set<PsiClassType> unhandledExceptions = new THashSet<PsiClassType>(exceptions);
@@ -168,9 +181,21 @@ public class AddExceptionToThrowsFix extends BaseIntentionAction {
if (!(file instanceof PsiJavaFile)) return false;
if (myWrongElement == null || !myWrongElement.isValid()) return false;
PsiMethod method = PsiTreeUtil.getParentOfType(myWrongElement, PsiMethod.class);
if (method == null || !method.getThrowsList().isPhysical()) return false;
List<PsiClassType> unhandled = getUnhandledExceptions(myWrongElement, method);
PsiElement targetElement = null;
PsiMethod targetMethod = null;
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(myWrongElement, PsiLambdaExpression.class);
if (lambdaExpression != null) {
targetMethod = LambdaUtil.getFunctionalInterfaceMethod(lambdaExpression);
targetElement = lambdaExpression.getBody();
}
if (targetElement == null && targetMethod == null) {
targetMethod = PsiTreeUtil.getParentOfType(myWrongElement, PsiMethod.class);
targetElement = targetMethod;
}
if (targetElement == null || targetMethod == null || !targetMethod.getThrowsList().isPhysical()) return false;
List<PsiClassType> unhandled = getUnhandledExceptions(myWrongElement, targetElement, targetMethod);
if (unhandled == null || unhandled.isEmpty()) return false;
setText(QuickFixBundle.message("add.exception.to.throws.text", unhandled.size()));
@@ -184,13 +209,13 @@ public class AddExceptionToThrowsFix extends BaseIntentionAction {
}
@Nullable
private static List<PsiClassType> getUnhandledExceptions(@Nullable PsiElement element, PsiMethod topElement) {
private static List<PsiClassType> getUnhandledExceptions(@Nullable PsiElement element, PsiElement topElement, PsiMethod targetMethod) {
if (element == null || element == topElement) return null;
List<PsiClassType> unhandledExceptions = ExceptionUtil.getUnhandledExceptions(element);
if (!filterInProjectExceptions(topElement, unhandledExceptions).isEmpty()) {
if (!filterInProjectExceptions(targetMethod, unhandledExceptions).isEmpty()) {
return unhandledExceptions;
}
return getUnhandledExceptions(element.getParent(), topElement);
return getUnhandledExceptions(element.getParent(), topElement, targetMethod);
}
@NotNull
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package com.intellij.codeInsight.intention.impl;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.highlighting.HighlightManager;
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
import com.intellij.codeInsight.intention.BaseElementAtCaretIntentionAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColors;
@@ -39,7 +39,7 @@ import java.util.List;
/**
* @author ven
*/
public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction {
public class AddOnDemandStaticImportAction extends BaseElementAtCaretIntentionAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.AddOnDemandStaticImportAction");
@Override
@@ -103,13 +103,16 @@ public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction
if (aClass == null) {
return;
}
PsiImportStaticStatement importStaticStatement =
JavaPsiFacade.getInstance(file.getProject()).getElementFactory().createImportStaticStatement(aClass, "*");
PsiImportList importList = ((PsiJavaFile)file).getImportList();
if (importList == null) {
return;
final PsiClass containingClass = PsiUtil.getTopLevelClass(refExpr);
if (aClass != containingClass) {
PsiImportStaticStatement importStaticStatement =
JavaPsiFacade.getInstance(file.getProject()).getElementFactory().createImportStaticStatement(aClass, "*");
PsiImportList importList = ((PsiJavaFile)file).getImportList();
if (importList == null) {
return;
}
importList.add(importStaticStatement);
}
importList.add(importStaticStatement);
List<PsiFile> roots = file.getViewProvider().getAllFiles();
for (final PsiFile root : roots) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
@@ -72,6 +73,7 @@ public class ShortenToStaticImportProcessor implements TemplateOptionalProcessor
}
}
Collections.reverse(staticImportTargets);
for (Pair<PsiElement, StaticImporter> pair : staticImportTargets) {
if (pair.first.isValid()) {
pair.second.perform(project, file, editor, pair.first);
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.template.postfix.templates;
import com.intellij.codeInsight.template.postfix.util.PostfixTemplatesUtils;
@@ -65,8 +80,14 @@ public abstract class ExpressionPostfixTemplateWithChooser extends PostfixTempla
}
@NotNull
protected List<PsiExpression> getExpressions(@NotNull PsiElement context, @NotNull Document document, int offset) {
List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(context.getContainingFile(), document, offset, false);
protected List<PsiExpression> getExpressions(@NotNull PsiElement context, @NotNull Document document, final int offset) {
List<PsiExpression> expressions = ContainerUtil.filter(IntroduceVariableBase.collectExpressions(context.getContainingFile(), document, offset - 1, false),
new Condition<PsiExpression>() {
@Override
public boolean value(PsiExpression expression) {
return expression.getTextRange().getEndOffset() == offset;
}
});
return ContainerUtil.filter(expressions.isEmpty() ? maybeTopmostExpression(context) : expressions, getTypeCondition());
}
@@ -1441,7 +1441,10 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
@Override
public void visitTypeElement(PsiTypeElement type) {
if (myType2 == JavaTokenType.ELLIPSIS || myType2 == JavaTokenType.LBRACKET || myType2 == JavaTokenType.RBRACKET) {
if (myType1 == JavaElementType.ANNOTATION || myType2 == JavaElementType.ANNOTATION) {
createSpaceInCode(true);
}
else if (myType2 == JavaTokenType.ELLIPSIS || myType2 == JavaTokenType.LBRACKET || myType2 == JavaTokenType.RBRACKET) {
createSpaceInCode(false);
}
else if (type.getType() instanceof PsiDisjunctionType) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,12 +44,12 @@ public class FilePathReferenceProvider extends PsiReferenceProvider {
}
@NotNull
public PsiReference[] getReferencesByElement(PsiElement element, String text, int offset, final boolean soft) {
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, String text, int offset, final boolean soft) {
return getReferencesByElement(element, text, offset, soft, Module.EMPTY_ARRAY);
}
@NotNull
public PsiReference[] getReferencesByElement(PsiElement element,
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
String text,
int offset,
final boolean soft,
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,7 +75,7 @@ public class PathListReferenceProvider extends PsiReferenceProvider {
return ',';
}
protected PsiReference[] createReferences(PsiElement element, String s, int offset, final boolean soft) {
protected PsiReference[] createReferences(@NotNull PsiElement element, String s, int offset, final boolean soft) {
int contentOffset = StringUtil.findFirst(s, CharFilter.NOT_WHITESPACE_FILTER);
if (contentOffset >= 0) {
offset += contentOffset;
@@ -33,6 +33,7 @@ import java.util.*;
* Date: 7/17/12
*/
public class LambdaUtil {
public static ThreadLocal<Map<PsiElement, PsiType>> ourFunctionTypes = new ThreadLocal<Map<PsiElement, PsiType>>();
private static final Logger LOG = Logger.getInstance("#" + LambdaUtil.class.getName());
@NonNls public static final String JAVA_LANG_FUNCTIONAL_INTERFACE = "java.lang.FunctionalInterface";
@@ -318,6 +319,13 @@ public class LambdaUtil {
final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, (PsiMethod)resolve, parameters);
if (finalLambdaIdx < parameters.length) {
if (!tryToSubstitute) return getNormalizedType(parameters[finalLambdaIdx]);
final Map<PsiElement, PsiType> map = ourFunctionTypes.get();
if (map != null) {
final PsiType type = map.get(expression);
if (type != null) {
return type;
}
}
return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, true, new Computable<PsiType>() {
@Override
public PsiType compute() {
@@ -58,7 +58,7 @@ public abstract class PsiNameHelper {
* @param languageLevel to check text against. For instance 'assert' or 'enum' might or might not be identifiers depending on language level
* @return true if the text is an identifier, false otherwise
*/
public abstract boolean isIdentifier(@Nullable String text, LanguageLevel languageLevel);
public abstract boolean isIdentifier(@Nullable String text, @NotNull LanguageLevel languageLevel);
/**
* Checks if the specified text is a Java keyword, using the language level of the project
@@ -80,7 +80,9 @@ public abstract class PsiNameHelper {
@NotNull
public static String getShortClassName(@NotNull String referenceText) {
int lessPos = referenceText.length(), bracesBalance = 0, i;
int lessPos = referenceText.length();
int bracesBalance = 0;
int i;
loop:
for (i = referenceText.length() - 1; i >= 0; i--) {
@@ -137,7 +139,7 @@ public abstract class PsiNameHelper {
}
@NotNull
public static String getQualifiedClassName(String referenceText, boolean removeWhitespace) {
public static String getQualifiedClassName(@NotNull String referenceText, boolean removeWhitespace) {
if (removeWhitespace) {
referenceText = removeWhitespace(referenceText);
}
@@ -166,7 +168,7 @@ public abstract class PsiNameHelper {
}
private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?:\\s)|(?:/\\*.*\\*/)|(?://[^\\n]*)");
private static String removeWhitespace(String referenceText) {
private static String removeWhitespace(@NotNull String referenceText) {
return WHITESPACE_PATTERN.matcher(referenceText).replaceAll("");
}
@@ -178,7 +180,8 @@ public abstract class PsiNameHelper {
* @param referenceText the text of the reference to calculate type parameters for.
* @return the calculated array of type parameters.
*/
public static String[] getClassParametersText(String referenceText) {
@NotNull
public static String[] getClassParametersText(@NotNull String referenceText) {
if (referenceText.indexOf('<') < 0) return ArrayUtil.EMPTY_STRING_ARRAY;
referenceText = removeWhitespace(referenceText);
final char[] chars = referenceText.toCharArray();
@@ -287,6 +290,6 @@ public abstract class PsiNameHelper {
}
sb.append(' ');
}
return annotations.size() > 0;
return !annotations.isEmpty();
}
}
@@ -82,9 +82,11 @@ public class MethodCandidateInfo extends CandidateInfo{
@ApplicabilityLevelConstant
private int getApplicabilityLevelInner() {
if (myArgumentTypes == null) return ApplicabilityLevel.NOT_APPLICABLE;
final PsiType[] argumentTypes = getArgumentTypes();
int level = PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(), myArgumentTypes, myLanguageLevel);
if (argumentTypes == null) return ApplicabilityLevel.NOT_APPLICABLE;
int level = PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(), argumentTypes, myLanguageLevel);
if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable()) level = ApplicabilityLevel.NOT_APPLICABLE;
return level;
}
@@ -104,18 +106,17 @@ public class MethodCandidateInfo extends CandidateInfo{
return getApplicabilityLevel();
}
if (myArgumentTypes == null) {
return ApplicabilityLevel.NOT_APPLICABLE;
}
@ApplicabilityLevelConstant int level;
Integer boxedLevel = ourOverloadGuard.doPreventingRecursion(myArgumentList, false, new Computable<Integer>() {
@Override
public Integer compute() {
final PsiMethod method = getElement();
if (method != null && method.hasTypeParameters() || myArgumentList == null || !PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
return PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(false), myArgumentTypes, myLanguageLevel);
if (PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
final PsiType[] argumentTypes = getArgumentTypes();
if (argumentTypes == null) {
return ApplicabilityLevel.NOT_APPLICABLE;
}
return PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(false), argumentTypes, myLanguageLevel);
}
return getApplicabilityLevelInner();
}
@@ -127,7 +128,17 @@ public class MethodCandidateInfo extends CandidateInfo{
}
public PsiSubstitutor getSiteSubstitutor() {
return super.getSubstitutor();
PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
if (myTypeArguments != null) {
PsiMethod method = getElement();
if (method != null) {
PsiTypeParameter[] typeParams = method.getTypeParameters();
for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
}
}
}
return incompleteSubstitutor;
}
@NotNull
@@ -206,22 +217,10 @@ public class MethodCandidateInfo extends CandidateInfo{
return inferTypeArguments(policy, arguments, true);
}
else {
return typeArgumentsSubstitutor();
return getSiteSubstitutor();
}
}
public PsiSubstitutor typeArgumentsSubstitutor() {
PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
PsiMethod method = getElement();
if (method != null) {
PsiTypeParameter[] typeParams = method.getTypeParameters();
for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
}
}
return incompleteSubstitutor;
}
@NotNull
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy,
@NotNull PsiExpression[] arguments,
@@ -283,6 +282,10 @@ public class MethodCandidateInfo extends CandidateInfo{
}
}
public PsiType[] getArgumentTypes() {
return myArgumentTypes;
}
public static class ApplicabilityLevel {
public static final int NOT_APPLICABLE = 1;
public static final int VARARGS = 2;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ public class PsiNameHelperImpl extends PsiNameHelper {
return isIdentifier(text, getLanguageLevel());
}
@NotNull
protected LanguageLevel getLanguageLevel() {
return myLanguageLevelExtension.getLanguageLevel();
}
@@ -65,6 +66,7 @@ public class PsiNameHelperImpl extends PsiNameHelper {
public static PsiNameHelper getInstance() {
return new PsiNameHelperImpl() {
@NotNull
@Override
protected LanguageLevel getLanguageLevel() {
return LanguageLevel.HIGHEST;
@@ -74,7 +74,9 @@ public class InferenceIncorporationPhase {
}
public boolean incorporate() {
for (InferenceVariable inferenceVariable : mySession.getInferenceVariables()) {
final Collection<InferenceVariable> inferenceVariables = mySession.getInferenceVariables();
final PsiSubstitutor substitutor = mySession.retrieveNonPrimitiveEqualsBounds(inferenceVariables);
for (InferenceVariable inferenceVariable : inferenceVariables) {
if (inferenceVariable.getInstantiation() != PsiType.NULL) continue;
final List<PsiType> eqBounds = inferenceVariable.getBounds(InferenceBound.EQ);
final List<PsiType> upperBounds = inferenceVariable.getBounds(InferenceBound.UPPER);
@@ -82,15 +84,14 @@ public class InferenceIncorporationPhase {
eqEq(eqBounds);
upDown(lowerBounds, upperBounds);
upDown(eqBounds, upperBounds);
upDown(lowerBounds, eqBounds);
upDown(lowerBounds, upperBounds, substitutor);
upDown(eqBounds, upperBounds, substitutor);
upDown(lowerBounds, eqBounds, substitutor);
upUp(upperBounds);
for (PsiType eqBound : eqBounds) {
if (mySession.isProperType(eqBound)) {
final PsiSubstitutor substitutor = PsiSubstitutor.EMPTY.put(inferenceVariable.getParameter(), eqBound);
for (PsiType upperBound : upperBounds) {
if (!mySession.isProperType(upperBound)) {
addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), eqBound));
@@ -274,12 +275,12 @@ public class InferenceIncorporationPhase {
* or
* S <: a & a <: T imply S <: T
*/
private void upDown(List<PsiType> eqBounds, List<PsiType> upperBounds) {
private void upDown(List<PsiType> eqBounds, List<PsiType> upperBounds, PsiSubstitutor substitutor) {
for (PsiType upperBound : upperBounds) {
if (upperBound == null) continue;
for (PsiType eqBound : eqBounds) {
if (eqBound == null) continue;
addConstraint(new StrictSubtypingConstraint(upperBound, eqBound));
addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), substitutor.substitute(eqBound)));
}
}
}
@@ -289,7 +290,7 @@ public class InferenceIncorporationPhase {
*/
private void eqEq(List<PsiType> eqBounds) {
for (int i = 0; i < eqBounds.size(); i++) {
PsiType sBound= eqBounds.get(i);
PsiType sBound = eqBounds.get(i);
for (int j = i + 1; j < eqBounds.size(); j++) {
final PsiType tBound = eqBounds.get(j);
addConstraint(new TypeEqualityConstraint(tBound, sBound));
@@ -823,15 +823,19 @@ public class InferenceSession {
MethodCandidateInfo.updateSubstitutor(argumentList, substitutor);
}
for (ConstraintFormula additionalConstraint : subset) {
additionalConstraint.apply(substitutor);
}
try {
for (ConstraintFormula additionalConstraint : subset) {
additionalConstraint.apply(substitutor);
}
myConstraints.addAll(subset);
if (!repeatInferencePhases(true)) {
return false;
myConstraints.addAll(subset);
if (!repeatInferencePhases(true)) {
return false;
}
}
finally {
LambdaUtil.ourFunctionTypes.set(null);
}
}
return true;
}
@@ -995,8 +999,9 @@ public class InferenceSession {
return true;
}
if (sReturnType == PsiType.VOID && session != null) {
return false;
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
if (sReturnType == PsiType.VOID) {
return returnExpressions.isEmpty() && session == null;
}
if (LambdaUtil.isFunctionalType(sReturnType) && LambdaUtil.isFunctionalType(tReturnType) &&
@@ -1005,15 +1010,14 @@ public class InferenceSession {
//Otherwise, if R1 and R2 are functional interface types, and neither interface is a subinterface of the other,
//then these rules are applied recursively to R1 and R2, for each result expression in expi.
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
if (!isFunctionalTypeMoreSpecific(sReturnType, tReturnType, session, returnExpressions.toArray(new PsiExpression[returnExpressions.size()]))) {
return false;
}
} else {
final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType;
final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType;
final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType && sReturnType != PsiType.VOID;
final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType && tReturnType != PsiType.VOID;
if (sPrimitive ^ tPrimitive) {
for (PsiExpression returnExpression : LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg)) {
for (PsiExpression returnExpression : returnExpressions) {
if (!PsiPolyExpressionUtil.isPolyExpression(returnExpression)) {
final PsiType returnExpressionType = returnExpression.getType();
if (sPrimitive) {
@@ -22,9 +22,7 @@ import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
/**
* User: anna
@@ -110,5 +108,11 @@ public abstract class InputOutputConstraintFormula implements ConstraintFormula
@Override
public void apply(PsiSubstitutor substitutor) {
setT(substitutor.substitute(getT()));
Map<PsiElement, PsiType> map = LambdaUtil.ourFunctionTypes.get();
if (map == null) {
map = new HashMap<PsiElement, PsiType>();
LambdaUtil.ourFunctionTypes.set(map);
}
map.put(getExpression(), getT());
}
}
@@ -161,7 +161,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
if (containingClass != null) {
PsiMethod[] methods = null;
if (element instanceof PsiIdentifier) {
methods = containingClass.findMethodsByName(element.getText(), false);
methods = containingClass.findMethodsByName(element.getText(), true);
}
else if (isConstructor()) {
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
@@ -72,7 +72,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (conflicts.isEmpty()) return null;
if (conflicts.size() == 1) return conflicts.get(0);
boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParameterTypes().length, true);
boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParametersLength(), true);
if (conflicts.size() == 1) return conflicts.get(0);
checkSameSignatures(conflicts);
@@ -81,7 +81,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
checkAccessStaticLevels(conflicts, true);
if (conflicts.size() == 1) return conflicts.get(0);
checkParametersNumber(conflicts, getActualParameterTypes().length, false);
checkParametersNumber(conflicts, getActualParametersLength(), false);
if (conflicts.size() == 1) return conflicts.get(0);
final int applicabilityLevel = checkApplicability(conflicts);
@@ -97,7 +97,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
checkSpecifics(conflicts, applicabilityLevel, myLanguageLevel);
if (conflicts.size() == 1) return conflicts.get(0);
checkPrimitiveVarargs(conflicts, getActualParameterTypes().length);
checkPrimitiveVarargs(conflicts, getActualParametersLength());
if (conflicts.size() == 1) return conflicts.get(0);
checkAccessStaticLevels(conflicts, false);
@@ -110,23 +110,51 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
private void checkLambdaApplicable(@NotNull List<CandidateInfo> conflicts, @NotNull LanguageLevel languageLevel) {
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) return;
for (int i = 0; i < getActualParameterTypes().length; i++) {
PsiType parameterType = getActualParameterTypes()[i];
if (parameterType instanceof PsiLambdaExpressionType) {
final PsiLambdaExpression lambdaExpression = ((PsiLambdaExpressionType)parameterType).getExpression();
for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext(); ) {
ProgressManager.checkCanceled();
final CandidateInfo conflict = iterator.next();
final PsiMethod method = (PsiMethod)conflict.getElement();
if (method != null) {
final PsiParameter[] methodParameters = method.getParameterList().getParameters();
if (methodParameters.length == 0) continue;
final PsiParameter param = i < methodParameters.length ? methodParameters[i] : methodParameters[methodParameters.length - 1];
final PsiType paramType = param.getType();
if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType), lambdaExpression.hasFormalParameterTypes())) {
iterator.remove();
}
}
for (int i = 0; i < getActualParametersLength(); i++) {
PsiExpression expression;
if (myArgumentsList instanceof PsiExpressionList) {
expression = ((PsiExpressionList)myArgumentsList).getExpressions()[i];
}
else {
final PsiType argType = getActualParameterTypes()[i];
expression = argType instanceof PsiLambdaExpressionType ? ((PsiLambdaExpressionType)argType).getExpression() : null;
}
final PsiLambdaExpression lambdaExpression = findNestedLambdaExpression(expression);
if (lambdaExpression != null) {
checkLambdaApplicable(conflicts, i, lambdaExpression);
}
}
}
private static PsiLambdaExpression findNestedLambdaExpression(PsiExpression expression) {
if (expression instanceof PsiLambdaExpression) {
return (PsiLambdaExpression)expression;
} else if (expression instanceof PsiParenthesizedExpression) {
return findNestedLambdaExpression(((PsiParenthesizedExpression)expression).getExpression());
} else if (expression instanceof PsiConditionalExpression) {
PsiLambdaExpression lambdaExpression = findNestedLambdaExpression(((PsiConditionalExpression)expression).getThenExpression());
if (lambdaExpression != null) {
return lambdaExpression;
}
return findNestedLambdaExpression(((PsiConditionalExpression)expression).getElseExpression());
}
return null;
}
private static void checkLambdaApplicable(List<CandidateInfo> conflicts, int i, PsiLambdaExpression lambdaExpression) {
for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext(); ) {
ProgressManager.checkCanceled();
final CandidateInfo conflict = iterator.next();
final PsiMethod method = (PsiMethod)conflict.getElement();
if (method != null) {
final PsiParameter[] methodParameters = method.getParameterList().getParameters();
if (methodParameters.length == 0) continue;
final PsiParameter param = i < methodParameters.length ? methodParameters[i] : methodParameters[methodParameters.length - 1];
final PsiType paramType = param.getType();
if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType), lambdaExpression.hasFormalParameterTypes())) {
iterator.remove();
}
}
}
@@ -411,6 +439,14 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return myActualParameterTypes;
}
private int getActualParametersLength() {
if (myActualParameterTypes == null) {
LOG.assertTrue(myArgumentsList instanceof PsiExpressionList, myArgumentsList);
return ((PsiExpressionList)myArgumentsList).getExpressions().length;
}
return myActualParameterTypes.length;
}
protected PsiType[] getArgumentTypes() {
return ((PsiExpressionList)myArgumentsList).getExpressionTypes();
}
@@ -500,8 +536,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
final PsiSubstitutor siteSubstitutor1 = info1.getSiteSubstitutor();
final PsiSubstitutor siteSubstitutor2 = info2.getSiteSubstitutor();
final PsiType[] types2AtSite = typesAtSite(types2, siteSubstitutor2, typeParameters2);
final PsiType[] types1AtSite = typesAtSite(types1, siteSubstitutor1, typeParameters1);
final PsiType[] types2AtSite = typesAtSite(types2, siteSubstitutor2);
final PsiType[] types1AtSite = typesAtSite(types1, siteSubstitutor1);
final PsiSubstitutor methodSubstitutor1 = calculateMethodSubstitutor(typeParameters1, method1, siteSubstitutor1, types1, types2AtSite,
languageLevel);
@@ -538,7 +574,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && myArgumentsList instanceof PsiExpressionList && (typeParameters1.length == 0 || typeParameters2.length == 0)) {
boolean toCompareFunctional = false;
for (int i = 0; i < myActualParameterTypes.length; i++) {
for (int i = 0; i < getActualParametersLength(); i++) {
if (types1.length > 0 && LambdaUtil.isFunctionalType(types1[Math.min(i, types1.length - 1)]) &&
types2.length > 0 && LambdaUtil.isFunctionalType(types2[Math.min(i, types2.length - 1)])) {
types1AtSite[Math.min(i, types1.length - 1)] = PsiType.NULL;
@@ -555,7 +591,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (applicable12ignoreFunctionalType || applicable21ignoreFunctionalType) {
Specifics specifics = null;
for (int i = 0; i < myActualParameterTypes.length; i++) {
for (int i = 0; i < getActualParametersLength(); i++) {
if (types1.length > 0 && types1AtSite[Math.min(i, types1.length - 1)] == PsiType.NULL &&
types2.length > 0 && types2AtSite[Math.min(i, types2.length - 1)] == PsiType.NULL) {
Specifics specific = isFunctionalTypeMoreSpecific(info1, info2, ((PsiExpressionList)myArgumentsList).getExpressions()[i], i);
@@ -642,7 +678,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
}
private static PsiType[] typesAtSite(PsiType[] types1, PsiSubstitutor siteSubstitutor1, PsiTypeParameter[] typeParameters1) {
private static PsiType[] typesAtSite(PsiType[] types1, PsiSubstitutor siteSubstitutor1) {
final PsiType[] types = PsiType.createArray(types1.length);
for (int i = 0; i < types1.length; i++) {
types[i] = siteSubstitutor1.substitute(types1[i]);
@@ -63,7 +63,12 @@ public class MethodCandidatesProcessor extends MethodsProcessor{
final boolean staticProblem, final boolean accessible) {
final PsiExpressionList argumentList = getArgumentList();
return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext,
getExpressionTypes(argumentList), getTypeArguments(), getLanguageLevel());
null, getTypeArguments(), getLanguageLevel()) {
@Override
public PsiType[] getArgumentTypes() {
return getExpressionTypes(argumentList);
}
};
}
protected PsiType[] getExpressionTypes(PsiExpressionList argumentList) {
@@ -0,0 +1,14 @@
abstract class Test {
abstract <Tf extends String> Tf foo(Class<Tf> c);
abstract <Tf1> Tf1 foo1(Class<Tf1> c);
abstract <U> Class<? extends U> bar(Class<U> clazz);
abstract <U1> Class<U1> bar1(Class<U1> clazz);
{
foo(bar(String.class));
foo(bar1(String.class));
foo1(bar(String.class));
foo1(bar1(String.class));
}
}
@@ -22,6 +22,6 @@ class AmbiguityRawGenerics {
<Z> void foo(I3<Z> s) { }
void bar() {
foo<error descr="Ambiguous method call: both 'AmbiguityRawGenerics.foo(I1)' and 'AmbiguityRawGenerics.foo(I2)' match">(()-> { throw new RuntimeException(); })</error>;
foo<error descr="Ambiguous method call: both 'AmbiguityRawGenerics.foo(I)' and 'AmbiguityRawGenerics.foo(I1)' match">(()-> { throw new RuntimeException(); })</error>;
}
}
@@ -0,0 +1,19 @@
class Test {
interface A<T> {
T a();
}
interface B<T> {
T b();
}
private void m(A<Integer> <warning descr="Parameter 'a' is never used">a</warning>) { }
private void <warning descr="Private method 'm(Test.B<java.lang.String>)' is never used">m</warning>(B<String> <warning descr="Parameter 'b' is never used">b</warning>) { }
{
m((() -> 42));
m(true ? () -> 42 : () -> 42);
m(true ? null : (() -> 42));
}
}
@@ -0,0 +1,13 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class IDEA118965 {
{
Stream<String> words = Arrays.asList("one", "one", "two").stream();
List<Map.Entry<String,Integer>> res = words.collect(Collectors.toMap(w -> w, w -> 1, (a, b) -> a + b))
.entrySet().stream().filter(e -> e.getValue() > 1).collect(Collectors.toList());
}
}
@@ -0,0 +1,22 @@
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class IDEA121315 {
class Issue {
Long getId() {
return 1l;
}
}
<T> T id(T i) {
return i;
}
void foo(Stream<Issue> map){
Map<Long, Issue> id2Issue = map.collect(Collectors.toMap(null, p -> id(p)));
Map<Long, Issue> id2Issue1 = map.collect(Collectors.toMap(null, p -> p));
Map<Long, Issue> id2Issue2 = map.collect(Collectors.toMap(null, this::id));
}
}
@@ -0,0 +1,39 @@
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
interface Base {
int getInt(String a);
int getInt();
void foo();
}
abstract class ABase implements Base {
@Override
public int getInt(String a) {
return 0;
}
@Override
public int getInt() {
return 0;
}
}
class Impl extends ABase {
@Override
public int getInt() {
return 0;
}
@Override
public void foo() {
List<String> strs = Arrays.asList("one", "two");
List<Integer> withMethodRef = strs
.stream()
.map(this::getInt)
.collect( Collectors.toList());
}
}
@@ -0,0 +1,10 @@
// "Add on demand static import for 'test.Foo'" "true"
package test;
class Foo {
public static void m() {}
public static void main(String[] args) {
m();
}
}
@@ -0,0 +1,10 @@
// "Add on demand static import for 'test.Foo'" "true"
package test;
class Foo {
public static void m() {}
public static void main(String[] args) {
Foo<caret>.m();
}
}
@@ -0,0 +1,12 @@
// "Add Exception to Method Signature" "true"
class C {
interface I {
void a() throws InterruptedException;
}
{
I i = () -> {
Thread.sleep(2000);
};
}
}
@@ -0,0 +1,9 @@
// "Add Exception to Method Signature" "false"
class C {
public static void main(String[] args) throws InterruptedException {
new Thread(( ) -> {
Thread.sl<caret>eep(2000);
}).start();
}
}
@@ -0,0 +1,12 @@
// "Add Exception to Method Signature" "true"
class C {
interface I {
void a();
}
{
I i = () -> {
Thread.sl<caret>eep(2000);
};
}
}
@@ -7,6 +7,6 @@ import static java.lang.annotation.ElementType.*;
class C {
{
Object o = null;
@TA int @TA [] a = (@TA int @TA[]) o;
@TA int @TA [] a = (int[]) o;
}
}
@@ -1,12 +0,0 @@
// "Cast to 'int'" "true"
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;
@Target({TYPE_USE}) @interface TA { }
class C {
{
Object o = null;
@TA <caret>int i = (@TA int) o;
}
}

Some files were not shown because too many files have changed in this diff Show More