mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 09:03:31 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -28,11 +28,8 @@ import org.jdom.Element;
|
||||
* @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
|
||||
*/
|
||||
@State(
|
||||
name = "Images.OptionsManager",
|
||||
roamingType = RoamingType.DISABLED,
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/images.support.xml")
|
||||
}
|
||||
name = "Images.OptionsManager",
|
||||
storages = {@Storage(file = StoragePathMacros.APP_CONFIG + "/images.support.xml", roamingType = RoamingType.DISABLED)}
|
||||
)
|
||||
final class OptionsManagerImpl extends OptionsManager implements PersistentStateComponent<Element> {
|
||||
private final OptionsImpl options = new OptionsImpl();
|
||||
|
||||
@@ -110,7 +110,7 @@ public class CompileAction extends CompileActionBase {
|
||||
elementDescription = "'" + file.getName() + "'";
|
||||
}
|
||||
else {
|
||||
if (!ActionPlaces.MAIN_MENU.equals(event.getPlace())) {
|
||||
if (!ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) {
|
||||
// the action should be invisible in popups for non-java files
|
||||
presentation.setEnabled(false);
|
||||
presentation.setVisible(false);
|
||||
|
||||
@@ -73,7 +73,10 @@ import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.FileNameCache;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.concurrency.SequentialTaskExecutor;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
@@ -897,9 +900,6 @@ public class BuildManager implements ApplicationComponent{
|
||||
if (!Registry.is("compiler.process.use.memory.temp.cache")) {
|
||||
cmdLine.addParameter("-D"+ GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION + "=false");
|
||||
}
|
||||
if (Registry.is("compiler.process.use.external.javac")) {
|
||||
cmdLine.addParameter("-D"+ GlobalOptions.USE_EXTERNAL_JAVAC_OPTION);
|
||||
}
|
||||
|
||||
// javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language
|
||||
if (mySystemCharset != null) {
|
||||
@@ -941,7 +941,6 @@ public class BuildManager implements ApplicationComponent{
|
||||
cmdLine.addParameter(launcherClass.getName());
|
||||
|
||||
final List<String> cp = ClasspathBootstrap.getBuildProcessApplicationClasspath(true);
|
||||
cp.add(getJpsPluginSystemClassesPath());
|
||||
cp.addAll(myClasspathManager.getBuildProcessPluginsClasspath(project));
|
||||
if (isProfilingMode) {
|
||||
cp.add(new File(workDirectory, "yjp-controller-api-redist.jar").getPath());
|
||||
@@ -967,17 +966,6 @@ public class BuildManager implements ApplicationComponent{
|
||||
};
|
||||
}
|
||||
|
||||
private static String getJpsPluginSystemClassesPath() {
|
||||
File classesRoot = new File(PathUtil.getJarPathForClass(BuildManager.class));
|
||||
if (classesRoot.isDirectory()) {
|
||||
//running from sources: load classes from .../out/production/jps-plugin-system
|
||||
return new File(classesRoot.getParentFile(), "jps-plugin-system").getAbsolutePath();
|
||||
}
|
||||
else {
|
||||
return new File(classesRoot.getParentFile(), "rt/jps-plugin-system.jar").getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
public File getBuildSystemDirectory() {
|
||||
return new File(mySystemDirectory, SYSTEM_ROOT);
|
||||
}
|
||||
|
||||
+2
-2
@@ -67,7 +67,7 @@
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="none" title="Jar files from libraries"/>
|
||||
<border type="none" title="JAR files from libraries"/>
|
||||
<children>
|
||||
<component id="f9a17" class="javax.swing.JRadioButton" binding="myExtractJarsRadioButton">
|
||||
<constraints>
|
||||
@@ -75,7 +75,7 @@
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text value="&extract to the target jar"/>
|
||||
<text value="&extract to the target JAR"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="90c4f">
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class JarArtifactFromModulesDialog extends DialogWrapper {
|
||||
public JarArtifactFromModulesDialog(PackagingElementResolvingContext context) {
|
||||
super(context.getProject());
|
||||
myContext = context;
|
||||
setTitle("Create Jar from Modules");
|
||||
setTitle("Create JAR from Modules");
|
||||
myMainClassLabel.setLabelFor(myMainClassField.getTextField());
|
||||
myManifestDirLabel.setLabelFor(myManifestDirField.getTextField());
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.List;
|
||||
*/
|
||||
public class JarArtifactType extends ArtifactType {
|
||||
public JarArtifactType() {
|
||||
super("jar", "Jar");
|
||||
super("jar", "JAR");
|
||||
}
|
||||
|
||||
public static JarArtifactType getInstance() {
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ public class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createExtractedDirectory(@NotNull VirtualFile jarEntry) {
|
||||
LOG.assertTrue(jarEntry.getFileSystem() instanceof JarFileSystem, "Expected file from jar but file from " + jarEntry.getFileSystem() + " found");
|
||||
LOG.assertTrue(jarEntry.getFileSystem() instanceof JarFileSystem, "Expected file from JAR but file from " + jarEntry.getFileSystem() + " found");
|
||||
final String fullPath = jarEntry.getPath();
|
||||
final int jarEnd = fullPath.indexOf(JarFileSystem.JAR_SEPARATOR);
|
||||
return new ExtractedDirectoryPackagingElement(fullPath.substring(0, jarEnd), fullPath.substring(jarEnd + 1));
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.debugger;
|
||||
|
||||
import com.intellij.diagnostic.logging.LogFilesManager;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
@@ -37,8 +36,6 @@ public interface DebugUIEnvironment {
|
||||
@Nullable
|
||||
Icon getIcon();
|
||||
|
||||
void initLogs(RunContentDescriptor content, LogFilesManager logFilesManager);
|
||||
|
||||
void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -15,14 +15,10 @@
|
||||
*/
|
||||
package com.intellij.debugger;
|
||||
|
||||
import com.intellij.diagnostic.logging.LogFilesManager;
|
||||
import com.intellij.diagnostic.logging.OutputFileUtil;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
import com.intellij.execution.configurations.RunConfigurationBase;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.RestartAction;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
@@ -63,21 +59,6 @@ public class DefaultDebugUIEnvironment implements DebugUIEnvironment {
|
||||
return getRunProfile().getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initLogs(RunContentDescriptor content, LogFilesManager logFilesManager) {
|
||||
ProcessHandler processHandler = content.getProcessHandler();
|
||||
if (getRunProfile() instanceof RunConfigurationBase) {
|
||||
RunConfigurationBase runConfiguration = (RunConfigurationBase)getRunProfile();
|
||||
|
||||
logFilesManager.registerFileMatcher(runConfiguration);
|
||||
|
||||
if (processHandler != null) {
|
||||
logFilesManager.initLogConsoles(runConfiguration, processHandler);
|
||||
OutputFileUtil.attachDumpListener(runConfiguration, processHandler, content.getExecutionConsole());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) {
|
||||
Executor executor = myExecutionEnvironment.getExecutor();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.debugger.actions;
|
||||
|
||||
import com.intellij.debugger.engine.DebugProcessImpl;
|
||||
import com.intellij.debugger.engine.JavaValue;
|
||||
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.settings.ArrayRendererConfigurable;
|
||||
@@ -27,6 +28,9 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.xdebugger.frame.XValue;
|
||||
import com.intellij.xdebugger.impl.ui.tree.actions.XDebuggerTreeActionBase;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AdjustArrayRangeAction extends DebuggerAction {
|
||||
@@ -44,42 +48,48 @@ public class AdjustArrayRangeAction extends DebuggerAction {
|
||||
|
||||
final Project project = debuggerContext.getProject();
|
||||
|
||||
final DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
|
||||
if (selectedNode == null) {
|
||||
return;
|
||||
}
|
||||
NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
|
||||
if(!(descriptor instanceof ValueDescriptorImpl /*&& ((ValueDescriptorImpl)descriptor).isArray()*/)) {
|
||||
final XValueNodeImpl node = XDebuggerTreeActionBase.getSelectedNode(e.getDataContext());
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ArrayRenderer renderer = getArrayRenderer((ValueDescriptorImpl)descriptor)/*(ArrayRenderer)((ValueDescriptorImpl)selectedNode.getDescriptor()).getLastRenderer()*/;
|
||||
XValue container = node.getValueContainer();
|
||||
if (!(container instanceof JavaValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ValueDescriptorImpl descriptor = ((JavaValue)container).getDescriptor();
|
||||
ArrayRenderer renderer = getArrayRenderer(descriptor);
|
||||
if (renderer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String title = createNodeTitle("", selectedNode);
|
||||
String label = selectedNode.toString();
|
||||
int index = label.indexOf('=');
|
||||
if (index > 0) {
|
||||
title = title + " " + label.substring(index);
|
||||
}
|
||||
//String title = createNodeTitle("", selectedNode);
|
||||
//String label = selectedNode.toString();
|
||||
//int index = label.indexOf('=');
|
||||
//if (index > 0) {
|
||||
// title = title + " " + label.substring(index);
|
||||
//}
|
||||
String title = node.getName();
|
||||
final ArrayRenderer clonedRenderer = renderer.clone();
|
||||
clonedRenderer.setForced(true);
|
||||
if (ShowSettingsUtil.getInstance().editConfigurable(project, new NamedArrayConfigurable(title, clonedRenderer))) {
|
||||
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
|
||||
@Override
|
||||
public void contextAction() throws Exception {
|
||||
final ValueDescriptorImpl nodeDescriptor = (ValueDescriptorImpl)selectedNode.getDescriptor();
|
||||
final Renderer lastRenderer = nodeDescriptor.getLastRenderer();
|
||||
final Renderer lastRenderer = descriptor.getLastRenderer();
|
||||
if (lastRenderer instanceof ArrayRenderer) {
|
||||
selectedNode.setRenderer(clonedRenderer);
|
||||
descriptor.setRenderer(clonedRenderer);
|
||||
refreshViews(node);
|
||||
//selectedNode.setRenderer(clonedRenderer);
|
||||
}
|
||||
else if (lastRenderer instanceof CompoundNodeRenderer) {
|
||||
final CompoundNodeRenderer compoundRenderer = (CompoundNodeRenderer)lastRenderer;
|
||||
final ChildrenRenderer childrenRenderer = compoundRenderer.getChildrenRenderer();
|
||||
if (childrenRenderer instanceof ExpressionChildrenRenderer) {
|
||||
ExpressionChildrenRenderer.setPreferableChildrenRenderer(nodeDescriptor, clonedRenderer);
|
||||
selectedNode.calcRepresentation();
|
||||
ExpressionChildrenRenderer.setPreferableChildrenRenderer(descriptor, clonedRenderer);
|
||||
refreshViews(node);
|
||||
//selectedNode.calcRepresentation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,10 +100,14 @@ public class AdjustArrayRangeAction extends DebuggerAction {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
boolean enable = false;
|
||||
DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
|
||||
if(selectedNode != null) {
|
||||
NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
|
||||
enable = descriptor instanceof ValueDescriptorImpl && getArrayRenderer((ValueDescriptorImpl)descriptor) != null;
|
||||
XValueNodeImpl node = XDebuggerTreeActionBase.getSelectedNode(e.getDataContext());
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
XValue container = node.getValueContainer();
|
||||
if (container instanceof JavaValue) {
|
||||
ValueDescriptorImpl descriptor = ((JavaValue)container).getDescriptor();
|
||||
enable = getArrayRenderer(descriptor) != null;
|
||||
}
|
||||
e.getPresentation().setVisible(enable);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package com.intellij.debugger.actions;
|
||||
|
||||
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.engine.JavaDebugProcess;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerStateManager;
|
||||
import com.intellij.debugger.ui.impl.DebuggerTreePanel;
|
||||
@@ -32,6 +33,11 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.DoubleClickListener;
|
||||
import com.intellij.xdebugger.XDebugProcess;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.impl.frame.XDebugView;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -153,4 +159,18 @@ public abstract class DebuggerAction extends AnAction {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void refreshViews(@NotNull XValueNodeImpl node) {
|
||||
refreshViews(XDebugView.getSession(node.getTree()));
|
||||
}
|
||||
|
||||
public static void refreshViews(@Nullable XDebugSession session) {
|
||||
if (session != null) {
|
||||
XDebugProcess process = session.getDebugProcess();
|
||||
if (process instanceof JavaDebugProcess) {
|
||||
((JavaDebugProcess)process).saveNodeHistory();
|
||||
}
|
||||
session.rebuildViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -50,6 +50,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.intellij.openapi.actionSystem.PlatformDataKeys.CONTEXT_COMPONENT;
|
||||
|
||||
/*
|
||||
* Class SetValueAction
|
||||
* @author Jeka
|
||||
@@ -71,7 +73,8 @@ public class JavaMarkObjectActionHandler extends MarkObjectActionHandler {
|
||||
|
||||
final DebuggerTree tree = node.getTree();
|
||||
tree.saveState(node);
|
||||
|
||||
|
||||
final Component parent = event.getData(CONTEXT_COMPONENT);
|
||||
final ValueDescriptorImpl valueDescriptor = ((ValueDescriptorImpl)descriptor);
|
||||
final DebuggerContextImpl debuggerContext = tree.getDebuggerContext();
|
||||
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
|
||||
@@ -93,7 +96,7 @@ public class JavaMarkObjectActionHandler extends MarkObjectActionHandler {
|
||||
final boolean suggestAdditionalMarkup = canSuggestAdditionalMarkup(debugProcess, valueDescriptor.getValue());
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
ObjectMarkupPropertiesDialog dialog = new ObjectMarkupPropertiesDialog(defaultText, suggestAdditionalMarkup);
|
||||
ObjectMarkupPropertiesDialog dialog = new ObjectMarkupPropertiesDialog(parent, defaultText, suggestAdditionalMarkup);
|
||||
dialog.show();
|
||||
if (dialog.isOK()) {
|
||||
result.set(Pair.create(dialog.getConfiguredMarkup(), dialog.isMarkAdditionalFields()));
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import com.intellij.openapi.ui.ex.MultiLineLabel;
|
||||
import com.intellij.xdebugger.impl.ui.tree.ValueMarkerPresentationDialogBase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -35,8 +36,8 @@ public class ObjectMarkupPropertiesDialog extends ValueMarkerPresentationDialogB
|
||||
private JPanel myAdditionalPropertiesPanel;
|
||||
private MultiLineLabel myDescriptionLabel;
|
||||
|
||||
public ObjectMarkupPropertiesDialog(@NotNull final String defaultText, boolean suggestAdditionalMarkup) {
|
||||
super(defaultText);
|
||||
public ObjectMarkupPropertiesDialog(@Nullable Component parent, @NotNull final String defaultText, boolean suggestAdditionalMarkup) {
|
||||
super(parent, defaultText);
|
||||
mySuggestAdditionalMarkup = suggestAdditionalMarkup;
|
||||
myDescriptionLabel.setText("If the value is referenced by a constant field of an abstract class,\n" +
|
||||
"IDEA could additionally mark all values referenced from this class with the names of referencing fields.");
|
||||
|
||||
@@ -270,7 +270,7 @@ public class PopFrameAction extends DebuggerAction {
|
||||
enable = virtualMachineProxy.canPopFrames();
|
||||
}
|
||||
|
||||
if(ActionPlaces.MAIN_MENU.equals(e.getPlace()) || ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) {
|
||||
if(ActionPlaces.isMainMenuOrActionSearch(e.getPlace()) || ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) {
|
||||
e.getPresentation().setEnabled(enable);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -22,13 +22,11 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.settings.NodeRendererSettings;
|
||||
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
|
||||
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener;
|
||||
import com.intellij.debugger.ui.tree.render.NodeRenderer;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.xdebugger.frame.XValue;
|
||||
import com.intellij.xdebugger.frame.XValuePlace;
|
||||
import com.intellij.xdebugger.impl.ui.tree.actions.XDebuggerTreeActionBase;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -66,7 +64,7 @@ public class ViewAsGroup extends ActionGroup implements DumbAware {
|
||||
}
|
||||
XValue container = node.getValueContainer();
|
||||
if (container instanceof JavaValue) {
|
||||
if (((ValueDescriptorImpl)((JavaValue)container).getDescriptor()).getLastRenderer() != myNodeRenderer) {
|
||||
if (((JavaValue)container).getDescriptor().getLastRenderer() != myNodeRenderer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -83,11 +81,12 @@ public class ViewAsGroup extends ActionGroup implements DumbAware {
|
||||
public void threadAction() {
|
||||
XValue container = node.getValueContainer();
|
||||
if (container instanceof JavaValue) {
|
||||
final ValueDescriptorImpl valueDescriptor = (ValueDescriptorImpl)((JavaValue)container).getDescriptor();
|
||||
final ValueDescriptorImpl valueDescriptor = ((JavaValue)container).getDescriptor();
|
||||
if (state) {
|
||||
valueDescriptor.setRenderer(myNodeRenderer);
|
||||
valueDescriptor.updateRepresentation(debuggerContext.createEvaluationContext(), DescriptorLabelListener.DUMMY_LISTENER);
|
||||
container.computePresentation(node, XValuePlace.TREE);
|
||||
DebuggerAction.refreshViews(node);
|
||||
//valueDescriptor.updateRepresentation(debuggerContext.createEvaluationContext(), DescriptorLabelListener.DUMMY_LISTENER);
|
||||
//container.computePresentation(node, XValuePlace.TREE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.intellij.debugger.requests.Requestor;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.ui.DebuggerPanelsManager;
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.breakpoints.BreakpointManager;
|
||||
import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -57,15 +56,15 @@ import com.sun.jdi.request.ThreadStartRequest;
|
||||
* @author lex
|
||||
*/
|
||||
public class DebugProcessEvents extends DebugProcessImpl {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.DebugProcessEvents");
|
||||
private static final Logger LOG = Logger.getInstance(DebugProcessEvents.class);
|
||||
|
||||
private DebuggerEventThread myEventThread;
|
||||
private final BreakpointManager myBreakpointManager;
|
||||
|
||||
public DebugProcessEvents(Project project) {
|
||||
super(project);
|
||||
myBreakpointManager = DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void commitVM(final VirtualMachine vm) {
|
||||
super.commitVM(vm);
|
||||
if(vm != null) {
|
||||
@@ -134,18 +133,19 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
return myIsStopped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
EventQueue eventQueue = myVmProxy.eventQueue();
|
||||
while (!isStopped()) {
|
||||
try {
|
||||
final EventSet eventSet = eventQueue.remove();
|
||||
|
||||
|
||||
final boolean methodWatcherActive = myReturnValueWatcher != null && myReturnValueWatcher.isEnabled();
|
||||
int processed = 0;
|
||||
for (EventIterator eventIterator = eventSet.eventIterator(); eventIterator.hasNext();) {
|
||||
final Event event = eventIterator.nextEvent();
|
||||
|
||||
|
||||
if (methodWatcherActive) {
|
||||
if (event instanceof MethodExitEvent) {
|
||||
if (myReturnValueWatcher.processMethodExitEvent((MethodExitEvent)event)) {
|
||||
@@ -158,6 +158,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
processed++;
|
||||
final ThreadReference thread = ((ThreadStartEvent)event).thread();
|
||||
getManagerThread().schedule(new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() throws Exception {
|
||||
getVirtualMachineProxy().threadStarted(thread);
|
||||
myDebugProcessDispatcher.getMulticaster().threadStarted(DebugProcessEvents.this, thread);
|
||||
@@ -168,6 +169,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
processed++;
|
||||
final ThreadReference thread = ((ThreadDeathEvent)event).thread();
|
||||
getManagerThread().schedule(new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() throws Exception {
|
||||
getVirtualMachineProxy().threadStopped(thread);
|
||||
myDebugProcessDispatcher.getMulticaster().threadStopped(DebugProcessEvents.this, thread);
|
||||
@@ -175,15 +177,15 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (processed == eventSet.size()) {
|
||||
eventSet.resume();
|
||||
continue;
|
||||
}
|
||||
|
||||
getManagerThread().invokeAndWait(new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() throws Exception {
|
||||
|
||||
if (eventSet.suspendPolicy() == EventRequest.SUSPEND_ALL && !DebuggerSession.enableBreakpointsDuringEvaluation()) {
|
||||
// check if there is already one request with policy SUSPEND_ALL
|
||||
for (SuspendContextImpl context : getSuspendManager().getEventContexts()) {
|
||||
@@ -193,12 +195,10 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final SuspendContextImpl suspendContext = getSuspendManager().pushSuspendContext(eventSet);
|
||||
|
||||
for (EventIterator eventIterator = eventSet.eventIterator(); eventIterator.hasNext();) {
|
||||
final Event event = eventIterator.nextEvent();
|
||||
|
||||
//if (LOG.isDebugEnabled()) {
|
||||
// LOG.debug("EVENT : " + event);
|
||||
//}
|
||||
@@ -207,10 +207,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
//Sun WTK fails when J2ME when event set is resumed on VMStartEvent
|
||||
processVMStartEvent(suspendContext, (VMStartEvent)event);
|
||||
}
|
||||
else if (event instanceof VMDeathEvent) {
|
||||
processVMDeathEvent(suspendContext, event);
|
||||
}
|
||||
else if (event instanceof VMDisconnectEvent) {
|
||||
else if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
|
||||
processVMDeathEvent(suspendContext, event);
|
||||
}
|
||||
else if (event instanceof ClassPrepareEvent) {
|
||||
@@ -240,7 +237,6 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
catch (InternalException e) {
|
||||
LOG.debug(e);
|
||||
@@ -264,13 +260,15 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
}
|
||||
catch (VMDisconnectedException e) {
|
||||
invokeVMDeathEvent();
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
Thread.interrupted(); // reset interrupted status
|
||||
}
|
||||
}
|
||||
|
||||
private void invokeVMDeathEvent() {
|
||||
getManagerThread().invokeAndWait(new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() throws Exception {
|
||||
SuspendContextImpl suspendContext = getSuspendManager().pushSuspendContext(EventRequest.SUSPEND_NONE, 1);
|
||||
processVMDeathEvent(suspendContext, null);
|
||||
@@ -307,7 +305,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
if(myState.compareAndSet(STATE_INITIAL, STATE_ATTACHED)) {
|
||||
final VirtualMachineProxyImpl machineProxy = getVirtualMachineProxy();
|
||||
final EventRequestManager requestManager = machineProxy.eventRequestManager();
|
||||
|
||||
|
||||
if (machineProxy.canGetMethodReturnValues()) {
|
||||
myReturnValueWatcher = new MethodReturnValueWatcher(requestManager);
|
||||
}
|
||||
@@ -378,7 +376,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
RequestHint hint = (RequestHint)event.request().getProperty("hint");
|
||||
|
||||
deleteStepRequests(event.thread());
|
||||
|
||||
|
||||
boolean shouldResume = false;
|
||||
|
||||
final Project project = getProject();
|
||||
@@ -426,8 +424,9 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
preprocessEvent(suspendContext, thread);
|
||||
|
||||
//we use schedule to allow processing other events during processing this one
|
||||
//this is especially nesessary if a method is breakpoint condition
|
||||
//this is especially necessary if a method is breakpoint condition
|
||||
getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
|
||||
@Override
|
||||
public void contextAction() throws Exception {
|
||||
final SuspendManager suspendManager = getSuspendManager();
|
||||
SuspendContextImpl evaluatingContext = SuspendManagerUtil.getEvaluatingContext(suspendManager, getSuspendContext().getThread());
|
||||
@@ -441,7 +440,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
final LocatableEventRequestor requestor = (LocatableEventRequestor) getRequestsManager().findRequestor(event.request());
|
||||
|
||||
boolean resumePreferred = requestor != null && DebuggerSettings.SUSPEND_NONE.equals(requestor.getSuspendPolicy());
|
||||
boolean requestHit = false;
|
||||
boolean requestHit;
|
||||
try {
|
||||
requestHit = (requestor != null) && requestor.processLocatableEvent(this, event);
|
||||
}
|
||||
@@ -451,6 +450,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
|
||||
}
|
||||
final boolean[] considerRequestHit = new boolean[]{true};
|
||||
DebuggerInvocationUtil.invokeAndWait(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DebuggerPanelsManager.getInstance(getProject()).toFront(mySession);
|
||||
final String displayName = requestor instanceof Breakpoint? ((Breakpoint)requestor).getDisplayName() : requestor.getClass().getSimpleName();
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.debugger.engine;
|
||||
|
||||
import com.intellij.Patches;
|
||||
import com.intellij.debugger.*;
|
||||
import com.intellij.debugger.actions.DebuggerAction;
|
||||
import com.intellij.debugger.actions.DebuggerActions;
|
||||
import com.intellij.debugger.apiAdapters.ConnectionServiceWrapper;
|
||||
import com.intellij.debugger.engine.evaluation.*;
|
||||
@@ -43,10 +44,7 @@ import com.intellij.execution.CantRunException;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessListener;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.process.*;
|
||||
import com.intellij.execution.runners.ExecutionUtil;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -170,10 +168,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
final DebuggerSession session = mySession;
|
||||
if (session != null && session.isAttached()) {
|
||||
session.refresh(true);
|
||||
XDebugSession xDebugSession = mySession.getXDebugSession();
|
||||
if (xDebugSession != null) {
|
||||
xDebugSession.rebuildViews();
|
||||
}
|
||||
DebuggerAction.refreshViews(mySession.getXDebugSession());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -354,10 +349,16 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
return new CompoundPositionManager(new PositionManagerImpl(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printToConsole(final String text) {
|
||||
myExecutionResult.getProcessHandler().notifyTextAvailable(text, ProcessOutputTypes.SYSTEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessHandler getProcessHandler() {
|
||||
return myExecutionResult.getProcessHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param suspendContext
|
||||
@@ -653,8 +654,8 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
|
||||
public void addProcessListener(ProcessListener processListener) {
|
||||
synchronized(myProcessListeners) {
|
||||
if(getExecutionResult() != null) {
|
||||
getExecutionResult().getProcessHandler().addProcessListener(processListener);
|
||||
if(getProcessHandler() != null) {
|
||||
getProcessHandler().addProcessListener(processListener);
|
||||
}
|
||||
else {
|
||||
myProcessListeners.add(processListener);
|
||||
@@ -664,8 +665,8 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
|
||||
public void removeProcessListener(ProcessListener processListener) {
|
||||
synchronized (myProcessListeners) {
|
||||
if(getExecutionResult() != null) {
|
||||
getExecutionResult().getProcessHandler().removeProcessListener(processListener);
|
||||
if(getProcessHandler() != null) {
|
||||
getProcessHandler().removeProcessListener(processListener);
|
||||
}
|
||||
else {
|
||||
myProcessListeners.remove(processListener);
|
||||
@@ -1711,15 +1712,17 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
|
||||
createVirtualMachine(environment.getSessionName(), environment.isPollConnection());
|
||||
|
||||
ExecutionResult executionResult;
|
||||
try {
|
||||
synchronized (myProcessListeners) {
|
||||
myExecutionResult = environment.createExecutionResult();
|
||||
if (myExecutionResult == null) {
|
||||
executionResult = environment.createExecutionResult();
|
||||
myExecutionResult = executionResult;
|
||||
if (executionResult == null) {
|
||||
fail();
|
||||
return null;
|
||||
}
|
||||
for (ProcessListener processListener : myProcessListeners) {
|
||||
myExecutionResult.getProcessHandler().addProcessListener(processListener);
|
||||
executionResult.getProcessHandler().addProcessListener(processListener);
|
||||
}
|
||||
myProcessListeners.clear();
|
||||
}
|
||||
@@ -1732,7 +1735,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
// writing to volatile field ensures the other threads will see the right values in non-volatile fields
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return myExecutionResult;
|
||||
return executionResult;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1760,7 +1763,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
});
|
||||
*/
|
||||
|
||||
return myExecutionResult;
|
||||
return executionResult;
|
||||
}
|
||||
|
||||
private void fail() {
|
||||
@@ -1885,8 +1888,8 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
}
|
||||
MyProcessAdapter processListener = new MyProcessAdapter();
|
||||
addProcessListener(processListener);
|
||||
if(myExecutionResult != null) {
|
||||
if(myExecutionResult.getProcessHandler().isStartNotified()) {
|
||||
if (myExecutionResult != null) {
|
||||
if (myExecutionResult.getProcessHandler().isStartNotified()) {
|
||||
processListener.run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,18 @@ package com.intellij.debugger.engine;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.actions.DebuggerActions;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContext;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
|
||||
import com.intellij.debugger.impl.*;
|
||||
import com.intellij.debugger.jdi.StackFrameProxyImpl;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.ui.DebuggerContentInfo;
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.impl.ThreadsPanel;
|
||||
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.MessageDescriptor;
|
||||
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.NodeManagerImpl;
|
||||
import com.intellij.debugger.ui.tree.NodeDescriptor;
|
||||
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.ui.ExecutionConsole;
|
||||
import com.intellij.execution.ui.ExecutionConsoleEx;
|
||||
@@ -150,29 +148,40 @@ public class JavaDebugProcess extends XDebugProcess {
|
||||
};
|
||||
session.addSessionListener(new XDebugSessionAdapter() {
|
||||
@Override
|
||||
public void beforeSessionResume() {
|
||||
myJavaSession.getProcess().getManagerThread().schedule(new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() throws Exception {
|
||||
myNodeManager.setHistoryByContext(getDebuggerStateManager().getContext());
|
||||
}
|
||||
@Override
|
||||
public Priority getPriority() {
|
||||
return Priority.NORMAL;
|
||||
}
|
||||
});
|
||||
public void sessionPaused() {
|
||||
saveNodeHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stackFrameChanged() {
|
||||
XStackFrame frame = session.getCurrentStackFrame();
|
||||
if (frame instanceof JavaStackFrame) {
|
||||
DebuggerContextUtil.setStackFrame(javaSession.getContextManager(), ((JavaStackFrame)frame).getStackFrameProxy());
|
||||
StackFrameProxyImpl frameProxy = ((JavaStackFrame)frame).getStackFrameProxy();
|
||||
DebuggerContextUtil.setStackFrame(javaSession.getContextManager(), frameProxy);
|
||||
saveNodeHistory(frameProxy);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveNodeHistory() {
|
||||
saveNodeHistory(getDebuggerStateManager().getContext().getFrameProxy());
|
||||
}
|
||||
|
||||
private void saveNodeHistory(final StackFrameProxyImpl frameProxy) {
|
||||
myJavaSession.getProcess().getManagerThread().invoke(new DebuggerCommandImpl() {
|
||||
@Override
|
||||
protected void action() throws Exception {
|
||||
myNodeManager.setHistoryByContext(frameProxy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Priority getPriority() {
|
||||
return Priority.NORMAL;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private DebuggerStateManager getDebuggerStateManager() {
|
||||
return myJavaSession.getContextManager();
|
||||
}
|
||||
@@ -243,7 +252,7 @@ public class JavaDebugProcess extends XDebugProcess {
|
||||
@Nullable
|
||||
@Override
|
||||
protected ProcessHandler doGetProcessHandler() {
|
||||
return myJavaSession.getProcess().getExecutionResult().getProcessHandler();
|
||||
return myJavaSession.getProcess().getProcessHandler();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -302,23 +311,16 @@ public class JavaDebugProcess extends XDebugProcess {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar) {
|
||||
public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) {
|
||||
Constraints beforeRunner = new Constraints(Anchor.BEFORE, "Runner.Layout");
|
||||
leftToolbar.add(Separator.getInstance(), beforeRunner);
|
||||
leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.EXPORT_THREADS), beforeRunner);
|
||||
leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.DUMP_THREADS), beforeRunner);
|
||||
leftToolbar.add(Separator.getInstance(), beforeRunner);
|
||||
|
||||
for (AnAction action : leftToolbar.getChildren(null)) {
|
||||
//TODO: maybe introduce API for extra settings?
|
||||
if (action instanceof DefaultActionGroup && "DebuggerSettings".equals(action.getTemplatePresentation().getText())) {
|
||||
DefaultActionGroup settings = (DefaultActionGroup)action;
|
||||
addActionToGroup(settings, XDebuggerActions.AUTO_TOOLTIP);
|
||||
settings.addAction(new AutoVarsSwitchAction(), Constraints.FIRST);
|
||||
settings.addAction(new WatchLastMethodReturnValueAction(), Constraints.FIRST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
addActionToGroup(settings, XDebuggerActions.AUTO_TOOLTIP);
|
||||
settings.addAction(new AutoVarsSwitchAction(), Constraints.FIRST);
|
||||
settings.addAction(new WatchLastMethodReturnValueAction(), Constraints.FIRST);
|
||||
}
|
||||
|
||||
private static class AutoVarsSwitchAction extends ToggleAction {
|
||||
|
||||
@@ -103,6 +103,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ValueDescriptorImpl getDescriptor() {
|
||||
return myValueDescriptor;
|
||||
}
|
||||
@@ -428,6 +429,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
|
||||
public String getEvaluationExpression() {
|
||||
if (evaluationExpression == null) {
|
||||
// TODO: change API to allow to calculate it asynchronously
|
||||
if (myEvaluationContext.getSuspendContext().isResumed()) return null;
|
||||
DebugProcessImpl debugProcess = myEvaluationContext.getDebugProcess();
|
||||
debugProcess.getManagerThread().invokeAndWait(new DebuggerCommandImpl() {
|
||||
@Override
|
||||
|
||||
@@ -100,10 +100,12 @@ public class JavaValueModifier extends XValueModifier {
|
||||
@Override
|
||||
public void setValue(@NotNull String expression, @NotNull XModificationCallback callback) {
|
||||
final NodeDescriptorImpl descriptor = myJavaValue.getDescriptor();
|
||||
if (!(descriptor instanceof ValueDescriptorImpl)) {
|
||||
if(!((ValueDescriptorImpl)descriptor).canSetValue()) {
|
||||
return;
|
||||
}
|
||||
if(!((ValueDescriptorImpl)descriptor).canSetValue()) {
|
||||
|
||||
if (myJavaValue.getEvaluationContext().getSuspendContext().isResumed()) {
|
||||
callback.errorOccurred(DebuggerBundle.message("error.context.has.changed"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,12 @@ import com.intellij.debugger.jdi.StackFrameProxyImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -75,7 +76,9 @@ public class DebuggerContextUtil {
|
||||
final XDebugSession debugSession = session.getXDebugSession();
|
||||
if (debugSession != null) {
|
||||
final XSourcePosition position = debugSession.getCurrentPosition();
|
||||
final Editor editor = PsiUtilBase.findEditor(psi);
|
||||
Editor editor = ((FileEditorManagerImpl)FileEditorManager.getInstance(file.getProject())).getSelectedTextEditor(true);
|
||||
|
||||
//final Editor editor = fileEditor instanceof TextEditorImpl ? ((TextEditorImpl)fileEditor).getEditor() : null;
|
||||
if (editor != null && position != null && file.getVirtualFile().equals(position.getFile())) {
|
||||
final Couple<Collection<TextRange>> usages = IdentifierHighlighterPass.getHighlightUsages(psi, file);
|
||||
final List<TextRange> ranges = new ArrayList<TextRange>();
|
||||
|
||||
@@ -607,8 +607,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
}
|
||||
|
||||
private void dispose(DebuggerSession session) {
|
||||
ProcessHandler processHandler = session.getProcess().getExecutionResult().getProcessHandler();
|
||||
|
||||
ProcessHandler processHandler = session.getProcess().getProcessHandler();
|
||||
synchronized (mySessions) {
|
||||
DebuggerSession removed = mySessions.remove(processHandler);
|
||||
LOG.assertTrue(removed != null);
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.debugger.*;
|
||||
import com.intellij.debugger.DebugEnvironment;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerInvocationUtil;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.engine.*;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationListener;
|
||||
@@ -29,14 +32,11 @@ import com.intellij.debugger.ui.breakpoints.BreakpointWithHighlighter;
|
||||
import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.ModuleRunProfile;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
import com.intellij.execution.configurations.RemoteState;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -199,6 +199,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
ValueLookupManager.getInstance(getProject()).startListening();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DebuggerStateManager getContextManager() {
|
||||
return myContextManager;
|
||||
}
|
||||
@@ -251,7 +252,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
case STATE_DISPOSED:
|
||||
return DebuggerBundle.message("status.debug.stopped");
|
||||
}
|
||||
return myState.myDescription;
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Stepping */
|
||||
@@ -371,7 +372,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return getState() == STATE_RUNNING && !getProcess().getExecutionResult().getProcessHandler().isProcessTerminated();
|
||||
return getState() == STATE_RUNNING && !getProcess().getProcessHandler().isProcessTerminated();
|
||||
}
|
||||
|
||||
private SuspendContextImpl getSuspendContext() {
|
||||
@@ -379,19 +380,6 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
return getContextManager().getContext().getSuspendContext();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ExecutionResult attach(@NotNull Executor executor,
|
||||
@NotNull ProgramRunner runner,
|
||||
@NotNull ModuleRunProfile profile,
|
||||
@NotNull RunProfileState state,
|
||||
RemoteConnection remoteConnection,
|
||||
boolean pollConnection) throws ExecutionException {
|
||||
return attach(new DefaultDebugEnvironment(new ExecutionEnvironmentBuilder(myDebugProcess.getProject(), executor).runProfile(profile).runner(runner).build(),
|
||||
state,
|
||||
remoteConnection,
|
||||
pollConnection));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ExecutionResult attach(DebugEnvironment environment) throws ExecutionException {
|
||||
RemoteConnection remoteConnection = environment.getRemoteConnection();
|
||||
@@ -603,7 +591,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
final String transportName = DebuggerBundle.getTransportName(connection);
|
||||
final String message = DebuggerBundle.message("status.connected", addressDisplayName, transportName);
|
||||
|
||||
process.getExecutionResult().getProcessHandler().notifyTextAvailable(message + "\n", ProcessOutputTypes.SYSTEM);
|
||||
process.printToConsole(message + "\n");
|
||||
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -630,12 +618,12 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
@Override
|
||||
public void processDetached(final DebugProcessImpl debugProcess, boolean closedByUser) {
|
||||
if (!closedByUser) {
|
||||
ExecutionResult executionResult = debugProcess.getExecutionResult();
|
||||
if(executionResult != null) {
|
||||
ProcessHandler processHandler = debugProcess.getProcessHandler();
|
||||
if(processHandler != null) {
|
||||
final RemoteConnection connection = getProcess().getConnection();
|
||||
final String addressDisplayName = DebuggerBundle.getAddressDisplayName(connection);
|
||||
final String transportName = DebuggerBundle.getTransportName(connection);
|
||||
executionResult.getProcessHandler().notifyTextAvailable(DebuggerBundle.message("status.disconnected", addressDisplayName, transportName) + "\n", ProcessOutputTypes.SYSTEM);
|
||||
processHandler.notifyTextAvailable(DebuggerBundle.message("status.disconnected", addressDisplayName, transportName) + "\n", ProcessOutputTypes.SYSTEM);
|
||||
}
|
||||
}
|
||||
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
|
||||
@@ -659,7 +647,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
public void threadStopped(DebugProcess proc, ThreadReference thread) {
|
||||
notifyThreadsRefresh();
|
||||
}
|
||||
|
||||
|
||||
private void notifyThreadsRefresh() {
|
||||
if (!myUpdateAlarm.isDisposed()) {
|
||||
myUpdateAlarm.cancelAllRequests();
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
@@ -408,8 +409,13 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
CodeFragmentFactory factory = ApplicationManager.getApplication().runReadAction(new Computable<CodeFragmentFactory>() {
|
||||
@Override
|
||||
public CodeFragmentFactory compute() {
|
||||
for (CodeFragmentFactory factory : getCodeFragmentFactories(context)) {
|
||||
if (factory.getFileType().equals(text.getFileType())) {
|
||||
final FileType fileType = text.getFileType();
|
||||
final List<CodeFragmentFactory> factories = getCodeFragmentFactories(context);
|
||||
if (fileType == null) {
|
||||
return factories.get(0);
|
||||
}
|
||||
for (CodeFragmentFactory factory : factories) {
|
||||
if (factory.getFileType().equals(fileType)) {
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-15
@@ -53,7 +53,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
private JCheckBox myCbShowObjectId;
|
||||
|
||||
private StateRestoringCheckBox myCbShowStaticFinalFields;
|
||||
private final ArrayRendererConfigurable myArrayRendererConfigurable;
|
||||
//private final ArrayRendererConfigurable myArrayRendererConfigurable;
|
||||
private JCheckBox myCbEnableAlternateViews;
|
||||
|
||||
private JCheckBox myCbEnableToString;
|
||||
@@ -66,12 +66,12 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
|
||||
public DebuggerDataViewsConfigurable(@Nullable Project project) {
|
||||
myProject = project;
|
||||
myArrayRendererConfigurable = new ArrayRendererConfigurable(NodeRendererSettings.getInstance().getArrayRenderer());
|
||||
//myArrayRendererConfigurable = new ArrayRendererConfigurable(NodeRendererSettings.getInstance().getArrayRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
myArrayRendererConfigurable.disposeUIResources();
|
||||
//myArrayRendererConfigurable.disposeUIResources();
|
||||
myToStringFilterEditor = null;
|
||||
myProject = null;
|
||||
}
|
||||
@@ -165,13 +165,14 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
|
||||
panel.add(showPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
|
||||
|
||||
final JPanel arraysPanel = new JPanel(new BorderLayout(0, UIUtil.DEFAULT_VGAP));
|
||||
final JComponent arraysComponent = myArrayRendererConfigurable.createComponent();
|
||||
assert arraysComponent != null;
|
||||
arraysPanel.add(arraysComponent, BorderLayout.CENTER);
|
||||
arraysPanel.add(myCbHideNullArrayElements, BorderLayout.SOUTH);
|
||||
arraysPanel.setBorder(IdeBorderFactory.createTitledBorder("Arrays", true));
|
||||
panel.add(arraysPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
||||
//final JPanel arraysPanel = new JPanel(new BorderLayout(0, UIUtil.DEFAULT_VGAP));
|
||||
//final JComponent arraysComponent = myArrayRendererConfigurable.createComponent();
|
||||
//assert arraysComponent != null;
|
||||
//arraysPanel.add(arraysComponent, BorderLayout.CENTER);
|
||||
//arraysPanel.add(myCbHideNullArrayElements, BorderLayout.SOUTH);
|
||||
//arraysPanel.setBorder(IdeBorderFactory.createTitledBorder("Arrays", true));
|
||||
//panel.add(arraysPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
||||
panel.add(myCbHideNullArrayElements, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
panel.add(myCbEnableAlternateViews, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 10), 0, 0));
|
||||
// starting 4-th row
|
||||
@@ -209,7 +210,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
|
||||
myAutoTooltip.save();
|
||||
|
||||
myArrayRendererConfigurable.apply();
|
||||
//myArrayRendererConfigurable.apply();
|
||||
|
||||
rendererSettings.fireRenderersChanged();
|
||||
}
|
||||
@@ -250,7 +251,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
myRbFromList.setEnabled(toStringEnabled);
|
||||
myRbAllThatOverride.setEnabled(toStringEnabled);
|
||||
|
||||
myArrayRendererConfigurable.reset();
|
||||
//myArrayRendererConfigurable.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,9 +267,9 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
}
|
||||
|
||||
private boolean areDefaultRenderersModified() {
|
||||
if (myArrayRendererConfigurable.isModified()) {
|
||||
return true;
|
||||
}
|
||||
//if (myArrayRendererConfigurable.isModified()) {
|
||||
// return true;
|
||||
//}
|
||||
|
||||
final NodeRendererSettings rendererSettings = NodeRendererSettings.getInstance();
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ExecutionConsoleEx;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunnerLayoutUi;
|
||||
import com.intellij.execution.ui.layout.PlaceInGrid;
|
||||
import com.intellij.icons.AllIcons;
|
||||
@@ -109,7 +108,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
|
||||
if (XDebuggerSettingsManager.getInstanceImpl().getGeneralSettings().isHideDebuggerOnProcessTermination()) {
|
||||
try {
|
||||
ExecutionManager.getInstance(getProject()).getContentManager().hideRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), myRunContentDescriptor);
|
||||
ExecutionManager.getInstance(project).getContentManager().hideRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), myRunContentDescriptor);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
//if we can get closeProcess after the project have been closed
|
||||
@@ -130,8 +129,8 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
topToolbar.add(Separator.getInstance(), new Constraints(Anchor.AFTER, DebuggerActions.POP_FRAME));
|
||||
myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
|
||||
|
||||
myWatchPanel = new MainWatchPanel(getProject(), getContextManager());
|
||||
myFramesPanel = new FramesPanel(getProject(), getContextManager());
|
||||
myWatchPanel = new MainWatchPanel(project, getContextManager());
|
||||
myFramesPanel = new FramesPanel(project, getContextManager());
|
||||
|
||||
final AlertIcon breakpointAlert = new AlertIcon(AllIcons.Debugger.BreakpointAlert);
|
||||
|
||||
@@ -151,7 +150,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
myUi.addContent(framesContent, 0, PlaceInGrid.left, false);
|
||||
|
||||
// variables
|
||||
myVariablesPanel = new VariablesPanel(getProject(), myStateManager, this);
|
||||
myVariablesPanel = new VariablesPanel(project, myStateManager, this);
|
||||
myVariablesPanel.getFrameTree().setAutoVariablesMode(debuggerSettings.AUTO_VARIABLES_MODE);
|
||||
Content vars = myUi.createContent(DebuggerContentInfo.VARIABLES_CONTENT, myVariablesPanel, XDebuggerBundle.message("debugger.session.tab.variables.title"),
|
||||
AllIcons.Debugger.Value, null);
|
||||
@@ -200,11 +199,11 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
}
|
||||
});
|
||||
|
||||
ExecutionResult executionResult = debuggerSession.getProcess().getExecutionResult();
|
||||
myConsole = executionResult.getExecutionConsole();
|
||||
myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName(),
|
||||
environment.getIcon());
|
||||
initUI(executionResult);
|
||||
// ExecutionResult executionResult = debuggerSession.getProcess().getExecutionResult();
|
||||
// myConsole = executionResult.getExecutionConsole();
|
||||
// myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName(),
|
||||
// environment.getIcon());
|
||||
// initUI(executionResult);
|
||||
}
|
||||
|
||||
private static void updateStatus(final Content content) {
|
||||
@@ -226,11 +225,6 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
return myWatchPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunContentDescriptor getRunContentDescriptor() {
|
||||
return myRunContentDescriptor;
|
||||
}
|
||||
|
||||
private void initUI(ExecutionResult executionResult) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
@@ -270,7 +264,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
|
||||
}
|
||||
console.setActions(consoleActions, ActionPlaces.DEBUGGER_TOOLBAR, myConsole.getPreferredFocusableComponent());
|
||||
|
||||
myDebugUIEnvironment.initLogs(myRunContentDescriptor, myManager);
|
||||
// myDebugUIEnvironment.initLogs(myRunContentDescriptor, myManager);
|
||||
|
||||
DefaultActionGroup leftToolbar = new DefaultActionGroup();
|
||||
|
||||
|
||||
+6
-3
@@ -93,6 +93,10 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
|
||||
}
|
||||
|
||||
public void deriveHistoryTree(DescriptorTree tree, final StackFrameContext context) {
|
||||
deriveHistoryTree(tree, context.getFrameProxy());
|
||||
}
|
||||
|
||||
public void deriveHistoryTree(DescriptorTree tree, final StackFrameProxy frameProxy) {
|
||||
|
||||
final MarkedDescriptorTree descriptorTree = new MarkedDescriptorTree();
|
||||
final MarkedDescriptorTree displayDescriptorTree = new MarkedDescriptorTree();
|
||||
@@ -109,13 +113,12 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
|
||||
myDescriptorSearcher = new DescriptorTreeSearcher(descriptorTree);
|
||||
myDisplayDescriptorSearcher = new DisplayDescriptorTreeSearcher(displayDescriptorTree);
|
||||
|
||||
myCurrentHistoryTree = createDescriptorTree(context, tree);
|
||||
myCurrentHistoryTree = createDescriptorTree(frameProxy, tree);
|
||||
}
|
||||
|
||||
private static DescriptorTree createDescriptorTree(final StackFrameContext context, final DescriptorTree fromTree) {
|
||||
private static DescriptorTree createDescriptorTree(final StackFrameProxy frameProxy, final DescriptorTree fromTree) {
|
||||
int frameCount = -1;
|
||||
int frameIndex = -1;
|
||||
final StackFrameProxy frameProxy = context.getFrameProxy();
|
||||
if (frameProxy != null) {
|
||||
try {
|
||||
final ThreadReferenceProxy threadReferenceProxy = frameProxy.threadProxy();
|
||||
|
||||
@@ -75,11 +75,15 @@ public class NodeManagerImpl extends NodeDescriptorFactoryImpl implements NodeMa
|
||||
}
|
||||
|
||||
public void setHistoryByContext(final DebuggerContextImpl context) {
|
||||
setHistoryByContext(context.getFrameProxy());
|
||||
}
|
||||
|
||||
public void setHistoryByContext(StackFrameProxyImpl frameProxy) {
|
||||
if (myHistoryKey != null) {
|
||||
myHistories.put(myHistoryKey, getCurrentHistoryTree());
|
||||
}
|
||||
|
||||
final String historyKey = getContextKey(context.getFrameProxy());
|
||||
final String historyKey = getContextKey(frameProxy);
|
||||
final DescriptorTree descriptorTree;
|
||||
if (historyKey != null) {
|
||||
final DescriptorTree historyTree = myHistories.get(historyKey);
|
||||
@@ -89,7 +93,7 @@ public class NodeManagerImpl extends NodeDescriptorFactoryImpl implements NodeMa
|
||||
descriptorTree = new DescriptorTree(true);
|
||||
}
|
||||
|
||||
deriveHistoryTree(descriptorTree, context);
|
||||
deriveHistoryTree(descriptorTree, frameProxy);
|
||||
myHistoryKey = historyKey;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ public class ArrayRenderer extends NodeRendererImpl{
|
||||
public int ENTRIES_LIMIT = 101;
|
||||
private final static String MORE_ELEMENTS = "...";
|
||||
|
||||
private boolean myForced = false;
|
||||
|
||||
public ArrayRenderer() {
|
||||
myProperties.setEnabled(true);
|
||||
}
|
||||
@@ -97,13 +99,19 @@ public class ArrayRenderer extends NodeRendererImpl{
|
||||
return ClassRenderer.calcLabel(descriptor);
|
||||
}
|
||||
|
||||
public void setForced(boolean forced) {
|
||||
myForced = forced;
|
||||
}
|
||||
|
||||
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
List<DebuggerTreeNode> children = new ArrayList<DebuggerTreeNode>();
|
||||
NodeManagerImpl nodeManager = (NodeManagerImpl)builder.getNodeManager();
|
||||
NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
|
||||
|
||||
builder.initChildrenArrayRenderer(this);
|
||||
if (!myForced) {
|
||||
builder.initChildrenArrayRenderer(this);
|
||||
}
|
||||
|
||||
ArrayReference array = (ArrayReference)value;
|
||||
if (array.length() > 0) {
|
||||
@@ -182,7 +190,7 @@ public class ArrayRenderer extends NodeRendererImpl{
|
||||
// children.add(0, nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
|
||||
//}
|
||||
|
||||
if(END_INDEX < array.length() - 1) {
|
||||
if(!myForced && END_INDEX < array.length() - 1) {
|
||||
//children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
|
||||
builder.setRemaining(array.length()-END_INDEX);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.debugger.engine.jdi.VirtualMachineProxy;
|
||||
import com.intellij.debugger.engine.managerThread.DebuggerManagerThread;
|
||||
import com.intellij.debugger.requests.RequestManager;
|
||||
import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -37,7 +38,7 @@ import java.util.List;
|
||||
public interface DebugProcess {
|
||||
@NonNls String JAVA_STRATUM = "Java";
|
||||
|
||||
<T> T getUserData(Key<T> key);
|
||||
<T> T getUserData(Key<T> key);
|
||||
<T> void putUserData(Key<T> key, T value);
|
||||
|
||||
Project getProject();
|
||||
@@ -76,17 +77,17 @@ public interface DebugProcess {
|
||||
List args) throws EvaluateException;
|
||||
|
||||
/**
|
||||
* Is equivalent to invokeInstanceMethod(evaluationContext, classType, method, args, 0)
|
||||
* Is equivalent to invokeInstanceMethod(evaluationContext, classType, method, args, 0)
|
||||
*/
|
||||
Value invokeMethod(EvaluationContext evaluationContext,
|
||||
ClassType classType,
|
||||
Method method,
|
||||
List args) throws EvaluateException;
|
||||
|
||||
Value invokeInstanceMethod(EvaluationContext evaluationContext,
|
||||
ObjectReference objRef,
|
||||
Method method,
|
||||
List args,
|
||||
Value invokeInstanceMethod(EvaluationContext evaluationContext,
|
||||
ObjectReference objRef,
|
||||
Method method,
|
||||
List args,
|
||||
int invocationOptions) throws EvaluateException;
|
||||
|
||||
ReferenceType findClass(EvaluationContext evaluationContext,
|
||||
@@ -112,4 +113,8 @@ public interface DebugProcess {
|
||||
*/
|
||||
@NotNull
|
||||
GlobalSearchScope getSearchScope();
|
||||
|
||||
void printToConsole(String text);
|
||||
|
||||
ProcessHandler getProcessHandler();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.debugger.NoDataException;
|
||||
import com.intellij.debugger.PositionManager;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.requests.ClassPrepareRequestor;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
@@ -167,11 +166,11 @@ public abstract class JSR45PositionManager<Scope> implements PositionManager {
|
||||
}
|
||||
catch(AbsentInformationException ignored) {
|
||||
}
|
||||
catch(ClassNotPreparedException ignored) {
|
||||
catch(ClassNotPreparedException ignored) {
|
||||
}
|
||||
catch (InternalError ignored) {
|
||||
myDebugProcess.getExecutionResult().getProcessHandler().notifyTextAvailable(
|
||||
DebuggerBundle.message("internal.error.locations.of.line", type.name()), ProcessOutputTypes.SYSTEM);
|
||||
myDebugProcess.printToConsole(
|
||||
DebuggerBundle.message("internal.error.locations.of.line", type.name()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+4
-3
@@ -22,6 +22,7 @@ package com.intellij.execution.actions;
|
||||
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
import com.intellij.execution.testframework.JavaAwareFilter;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComponentContainer;
|
||||
@@ -29,9 +30,10 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
|
||||
|
||||
protected JavaRerunFailedTestsAction(@NotNull ComponentContainer componentContainer) {
|
||||
public JavaRerunFailedTestsAction(@NotNull ComponentContainer componentContainer, @NotNull TestConsoleProperties consoleProperties) {
|
||||
super(componentContainer);
|
||||
|
||||
init(consoleProperties);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -39,5 +41,4 @@ public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
|
||||
protected Filter getFilter(Project project, GlobalSearchScope searchScope) {
|
||||
return super.getFilter(project, searchScope).and(JavaAwareFilter.METHOD(project, searchScope));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-39
@@ -21,20 +21,16 @@ import com.intellij.execution.configuration.EnvironmentVariablesComponent;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.junit.RefactoringListeners;
|
||||
import com.intellij.execution.process.KillableColoredProcessHandler;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.util.JavaParametersUtil;
|
||||
import com.intellij.execution.util.ProgramParametersUtil;
|
||||
import com.intellij.openapi.components.PathMacroManager;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.options.SettingsEditorGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -81,7 +77,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
|
||||
@Override
|
||||
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
|
||||
final JavaCommandLineState state = new JavaApplicationCommandLineState(this, env);
|
||||
final JavaCommandLineState state = new JavaApplicationCommandLineState<ApplicationConfiguration>(this, env);
|
||||
JavaRunConfigurationModule module = getConfigurationModule();
|
||||
state.setConsoleBuilder(TextConsoleBuilderFactory.getInstance().createBuilder(getProject(), module.getSearchScope()));
|
||||
return state;
|
||||
@@ -253,14 +249,9 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
|
||||
}
|
||||
|
||||
public static class JavaApplicationCommandLineState extends JavaCommandLineState {
|
||||
|
||||
private final ApplicationConfiguration myConfiguration;
|
||||
|
||||
public JavaApplicationCommandLineState(@NotNull final ApplicationConfiguration configuration,
|
||||
final ExecutionEnvironment environment) {
|
||||
super(environment);
|
||||
myConfiguration = configuration;
|
||||
public static class JavaApplicationCommandLineState<T extends ApplicationConfiguration> extends BaseJavaApplicationCommandLineState<T> {
|
||||
public JavaApplicationCommandLineState(@NotNull final T configuration, final ExecutionEnvironment environment) {
|
||||
super(environment, configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -269,37 +260,14 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
final JavaRunConfigurationModule module = myConfiguration.getConfigurationModule();
|
||||
|
||||
final int classPathType = JavaParametersUtil.getClasspathType(module,
|
||||
myConfiguration.MAIN_CLASS_NAME,
|
||||
myConfiguration.MAIN_CLASS_NAME,
|
||||
false);
|
||||
final String jreHome = myConfiguration.ALTERNATIVE_JRE_PATH_ENABLED ? myConfiguration.ALTERNATIVE_JRE_PATH
|
||||
: null;
|
||||
final String jreHome = myConfiguration.ALTERNATIVE_JRE_PATH_ENABLED ? myConfiguration.ALTERNATIVE_JRE_PATH : null;
|
||||
JavaParametersUtil.configureModule(module, params, classPathType, jreHome);
|
||||
JavaParametersUtil.configureConfiguration(params, myConfiguration);
|
||||
|
||||
params.setMainClass(myConfiguration.MAIN_CLASS_NAME);
|
||||
for(RunConfigurationExtension ext: Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
|
||||
ext.updateJavaParameters(myConfiguration, params, getRunnerSettings());
|
||||
}
|
||||
setupJavaParameters(params);
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected OSProcessHandler startProcess() throws ExecutionException {
|
||||
OSProcessHandler handler = SystemInfo.isWindows ? super.startProcess() : KillableColoredProcessHandler.create(createCommandLine());
|
||||
RunnerSettings runnerSettings = getRunnerSettings();
|
||||
JavaRunConfigurationExtensionManager.getInstance().attachExtensionsToProcess(myConfiguration, handler, runnerSettings);
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean ansiColoringEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ApplicationConfiguration getConfiguration() {
|
||||
return myConfiguration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.execution.application;
|
||||
|
||||
import com.intellij.execution.CommonJavaRunConfigurationParameters;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.JavaRunConfigurationExtensionManager;
|
||||
import com.intellij.execution.RunConfigurationExtension;
|
||||
import com.intellij.execution.configurations.JavaCommandLineState;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.execution.configurations.RunConfigurationBase;
|
||||
import com.intellij.execution.configurations.RunnerSettings;
|
||||
import com.intellij.execution.process.KillableColoredProcessHandler;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.util.JavaParametersUtil;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class BaseJavaApplicationCommandLineState<T extends RunConfigurationBase&CommonJavaRunConfigurationParameters> extends JavaCommandLineState {
|
||||
protected final T myConfiguration;
|
||||
|
||||
public BaseJavaApplicationCommandLineState(ExecutionEnvironment environment, @NotNull final T configuration) {
|
||||
super(environment);
|
||||
myConfiguration = configuration;
|
||||
}
|
||||
|
||||
protected void setupJavaParameters(JavaParameters params) throws ExecutionException {
|
||||
JavaParametersUtil.configureConfiguration(params, myConfiguration);
|
||||
|
||||
for(RunConfigurationExtension ext: Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
|
||||
ext.updateJavaParameters(getConfiguration(), params, getRunnerSettings());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected OSProcessHandler startProcess() throws ExecutionException {
|
||||
OSProcessHandler handler = SystemInfo.isWindows ? super.startProcess() : KillableColoredProcessHandler.create(createCommandLine());
|
||||
RunnerSettings runnerSettings = getRunnerSettings();
|
||||
JavaRunConfigurationExtensionManager.getInstance().attachExtensionsToProcess(getConfiguration(), handler, runnerSettings);
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean ansiColoringEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected T getConfiguration() {
|
||||
return myConfiguration;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.unscramble.AnalyzeStacktraceUtil;
|
||||
import com.intellij.unscramble.ThreadDumpConsoleFactory;
|
||||
import com.intellij.unscramble.ThreadDumpParser;
|
||||
@@ -97,7 +96,6 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
|
||||
onProcessStarted(env.getRunnerSettings(), executionResult);
|
||||
|
||||
final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, env);
|
||||
Disposer.register(env.getProject(), contentBuilder);
|
||||
if (shouldAddDefaultActions) {
|
||||
addDefaultActions(contentBuilder);
|
||||
}
|
||||
@@ -116,7 +114,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
|
||||
final ExecutionResult executionResult = contentBuilder.getExecutionResult();
|
||||
final ExecutionConsole executionConsole = executionResult.getExecutionConsole();
|
||||
final JComponent consoleComponent = executionConsole != null ? executionConsole.getComponent() : null;
|
||||
final ControlBreakAction controlBreakAction = new ControlBreakAction(contentBuilder.getProcessHandler());
|
||||
final ControlBreakAction controlBreakAction = new ControlBreakAction(executionResult.getProcessHandler());
|
||||
if (consoleComponent != null) {
|
||||
controlBreakAction.registerCustomShortcutSet(controlBreakAction.getShortcutSet(), consoleComponent);
|
||||
final ProcessHandler processHandler = executionResult.getProcessHandler();
|
||||
@@ -130,7 +128,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
|
||||
});
|
||||
}
|
||||
contentBuilder.addAction(controlBreakAction);
|
||||
contentBuilder.addAction(new SoftExitAction(contentBuilder.getProcessHandler()));
|
||||
contentBuilder.addAction(new SoftExitAction(executionResult.getProcessHandler()));
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +141,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final AnActionEvent event) {
|
||||
public void update(@NotNull final AnActionEvent event) {
|
||||
final Presentation presentation = event.getPresentation();
|
||||
if (!isVisible()) {
|
||||
presentation.setVisible(false);
|
||||
@@ -172,7 +170,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
public void actionPerformed(@NotNull final AnActionEvent e) {
|
||||
ProcessProxy proxy = ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler);
|
||||
if (proxy != null) {
|
||||
final WiseDumpThreadsListener wiseListener = Boolean.TRUE.equals(Boolean.getBoolean(ourWiseThreadDumpProperty)) ?
|
||||
@@ -254,7 +252,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
public void actionPerformed(@NotNull final AnActionEvent e) {
|
||||
ProcessProxy proxy = ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler);
|
||||
if (proxy != null) {
|
||||
proxy.sendStop();
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.execution.jar;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.application.BaseJavaApplicationCommandLineState;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.util.JavaParametersUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JarApplicationCommandLineState extends BaseJavaApplicationCommandLineState<JarApplicationConfiguration> {
|
||||
public JarApplicationCommandLineState(@NotNull final JarApplicationConfiguration configuration, final ExecutionEnvironment environment) {
|
||||
super(environment, configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaParameters createJavaParameters() throws ExecutionException {
|
||||
final JavaParameters params = new JavaParameters();
|
||||
final String jreHome = myConfiguration.isAlternativeJrePathEnabled() ? myConfiguration.getAlternativeJrePath() : null;
|
||||
params.setJdk(JavaParametersUtil.createProjectJdk(myConfiguration.getProject(), jreHome));
|
||||
setupJavaParameters(params);
|
||||
params.setJarPath(FileUtil.toSystemDependentName(myConfiguration.getJarPath()));
|
||||
return params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.jar.JarApplicationConfigurable">
|
||||
<grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="530" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="73391" class="com.intellij.execution.ui.CommonJavaParametersPanel" binding="myCommonProgramParameters">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<vspacer id="9634c">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="a09fc" class="com.intellij.execution.ui.AlternativeJREPanel" binding="myAlternativeJREPanel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="cab16" class="com.intellij.openapi.ui.LabeledComponent" binding="myJarPathComponent" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelLocation value="West"/>
|
||||
<text value="Path to &JAR"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6fe96" class="com.intellij.openapi.ui.LabeledComponent" binding="myModuleComponent">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<componentClass value="com.intellij.application.options.ModulesComboBox"/>
|
||||
<labelLocation value="West"/>
|
||||
<text value="Search sources using m&odule's classpath"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.execution.jar;
|
||||
|
||||
import com.intellij.application.options.ModulesComboBox;
|
||||
import com.intellij.execution.ui.AlternativeJREPanel;
|
||||
import com.intellij.execution.ui.CommonJavaParametersPanel;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.LabeledComponent;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.ui.PanelWithAnchor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class JarApplicationConfigurable extends SettingsEditor<JarApplicationConfiguration> implements PanelWithAnchor {
|
||||
private CommonJavaParametersPanel myCommonProgramParameters;
|
||||
private LabeledComponent<TextFieldWithBrowseButton> myJarPathComponent;
|
||||
private LabeledComponent<ModulesComboBox> myModuleComponent;
|
||||
private JPanel myWholePanel;
|
||||
|
||||
private AlternativeJREPanel myAlternativeJREPanel;
|
||||
private final Project myProject;
|
||||
private JComponent myAnchor;
|
||||
|
||||
public JarApplicationConfigurable(final Project project) {
|
||||
myProject = project;
|
||||
myAnchor = UIUtil.mergeComponentsWithAnchor(myJarPathComponent, myCommonProgramParameters, myAlternativeJREPanel);
|
||||
ModulesComboBox modulesComboBox = myModuleComponent.getComponent();
|
||||
modulesComboBox.allowEmptySelection("<whole project>");
|
||||
modulesComboBox.fillModules(project);
|
||||
}
|
||||
|
||||
public void applyEditorTo(final JarApplicationConfiguration configuration) throws ConfigurationException {
|
||||
myCommonProgramParameters.applyTo(configuration);
|
||||
configuration.setAlternativeJrePath(myAlternativeJREPanel.getPath());
|
||||
configuration.setAlternativeJrePathEnabled(myAlternativeJREPanel.isPathEnabled());
|
||||
configuration.setJarPath(FileUtil.toSystemIndependentName(myJarPathComponent.getComponent().getText()));
|
||||
configuration.setModule(myModuleComponent.getComponent().getSelectedModule());
|
||||
}
|
||||
|
||||
public void resetEditorFrom(final JarApplicationConfiguration configuration) {
|
||||
myCommonProgramParameters.reset(configuration);
|
||||
myJarPathComponent.getComponent().setText(FileUtil.toSystemDependentName(configuration.getJarPath()));
|
||||
myAlternativeJREPanel.init(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled());
|
||||
myModuleComponent.getComponent().setSelectedModule(configuration.getModule());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent createEditor() {
|
||||
return myWholePanel;
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
myJarPathComponent = new LabeledComponent<TextFieldWithBrowseButton>();
|
||||
TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
|
||||
textFieldWithBrowseButton.addBrowseFolderListener("Choose JAR File", null, myProject,
|
||||
new FileChooserDescriptor(false, false, true, true, false, false));
|
||||
myJarPathComponent.setComponent(textFieldWithBrowseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getAnchor() {
|
||||
return myAnchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnchor(@Nullable JComponent anchor) {
|
||||
myAnchor = anchor;
|
||||
myCommonProgramParameters.setAnchor(anchor);
|
||||
myAlternativeJREPanel.setAnchor(anchor);
|
||||
myJarPathComponent.setAnchor(anchor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* 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.execution.jar;
|
||||
|
||||
import com.intellij.diagnostic.logging.LogConfigurationPanel;
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configuration.EnvironmentVariablesComponent;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.util.JavaParametersUtil;
|
||||
import com.intellij.execution.util.ProgramParametersUtil;
|
||||
import com.intellij.openapi.components.PathMacroManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.options.SettingsEditorGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JarApplicationConfiguration extends LocatableConfigurationBase implements CommonJavaRunConfigurationParameters, SearchScopeProvidingRunProfile {
|
||||
private static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
|
||||
private JarApplicationConfigurationBean myBean = new JarApplicationConfigurationBean();
|
||||
private Map<String, String> myEnvs = new LinkedHashMap<String, String>();
|
||||
private JavaRunConfigurationModule myConfigurationModule;
|
||||
|
||||
public JarApplicationConfiguration(Project project, ConfigurationFactory factory, String name) {
|
||||
super(project, factory, name);
|
||||
myConfigurationModule = new JavaRunConfigurationModule(project, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
|
||||
SettingsEditorGroup<JarApplicationConfiguration> group = new SettingsEditorGroup<JarApplicationConfiguration>();
|
||||
group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new JarApplicationConfigurable(getProject()));
|
||||
JavaRunConfigurationExtensionManager.getInstance().appendEditors(this, group);
|
||||
group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel<JarApplicationConfiguration>());
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
PathMacroManager.getInstance(getProject()).expandPaths(element);
|
||||
super.readExternal(element);
|
||||
JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element);
|
||||
XmlSerializer.deserializeInto(myBean, element);
|
||||
EnvironmentVariablesComponent.readExternal(element, getEnvs());
|
||||
myConfigurationModule.readExternal(element);
|
||||
}
|
||||
|
||||
public void setModule(Module module) {
|
||||
myConfigurationModule.setModule(module);
|
||||
}
|
||||
|
||||
public Module getModule() {
|
||||
return myConfigurationModule.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
super.writeExternal(element);
|
||||
JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
|
||||
XmlSerializer.serializeInto(myBean, element, SERIALIZATION_FILTERS);
|
||||
EnvironmentVariablesComponent.writeExternal(element, getEnvs());
|
||||
PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
|
||||
if (myConfigurationModule.getModule() != null) {
|
||||
myConfigurationModule.writeExternal(element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration() throws RuntimeConfigurationException {
|
||||
JavaParametersUtil.checkAlternativeJRE(this);
|
||||
ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), null);
|
||||
File jarFile = new File(getJarPath());
|
||||
if (!jarFile.exists()) {
|
||||
throw new RuntimeConfigurationWarning("JAR file '" + jarFile.getAbsolutePath() + "' doesn't exist");
|
||||
}
|
||||
JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Module[] getModules() {
|
||||
Module module = myConfigurationModule.getModule();
|
||||
return module != null ? new Module[] {module}: Module.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
|
||||
return new JarApplicationCommandLineState(this, environment);
|
||||
}
|
||||
|
||||
public String getJarPath() {
|
||||
return myBean.JAR_PATH;
|
||||
}
|
||||
|
||||
public void setJarPath(String jarPath) {
|
||||
myBean.JAR_PATH = jarPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVMParameters(String value) {
|
||||
myBean.VM_PARAMETERS = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVMParameters() {
|
||||
return myBean.VM_PARAMETERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlternativeJrePathEnabled() {
|
||||
return myBean.ALTERNATIVE_JRE_PATH_ENABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlternativeJrePathEnabled(boolean enabled) {
|
||||
myBean.ALTERNATIVE_JRE_PATH_ENABLED = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlternativeJrePath() {
|
||||
return myBean.ALTERNATIVE_JRE_PATH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlternativeJrePath(String path) {
|
||||
myBean.ALTERNATIVE_JRE_PATH = path;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getRunClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPackage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgramParameters(@Nullable String value) {
|
||||
myBean.PROGRAM_PARAMETERS = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getProgramParameters() {
|
||||
return myBean.PROGRAM_PARAMETERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkingDirectory(@Nullable String value) {
|
||||
myBean.WORKING_DIRECTORY = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getWorkingDirectory() {
|
||||
return myBean.WORKING_DIRECTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvs(@NotNull Map<String, String> envs) {
|
||||
myEnvs.clear();
|
||||
myEnvs.putAll(envs);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, String> getEnvs() {
|
||||
return myEnvs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassParentEnvs(boolean passParentEnvs) {
|
||||
myBean.PASS_PARENT_ENVS = passParentEnvs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassParentEnvs() {
|
||||
return myBean.PASS_PARENT_ENVS;
|
||||
}
|
||||
|
||||
private static class JarApplicationConfigurationBean {
|
||||
public String JAR_PATH = "";
|
||||
public String VM_PARAMETERS = "";
|
||||
public String PROGRAM_PARAMETERS = "";
|
||||
public String WORKING_DIRECTORY = "";
|
||||
public boolean ALTERNATIVE_JRE_PATH_ENABLED;
|
||||
public String ALTERNATIVE_JRE_PATH = "";
|
||||
public boolean PASS_PARENT_ENVS = true;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.execution.jar;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.actions.ConfigurationContext;
|
||||
import com.intellij.execution.actions.RunConfigurationProducer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JarApplicationConfigurationProducer extends RunConfigurationProducer<JarApplicationConfiguration> {
|
||||
public JarApplicationConfigurationProducer() {
|
||||
super(JarApplicationConfigurationType.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setupConfigurationFromContext(JarApplicationConfiguration configuration,
|
||||
ConfigurationContext context,
|
||||
Ref<PsiElement> sourceElement) {
|
||||
VirtualFile file = getJarFileFromContext(context);
|
||||
if (file != null) {
|
||||
configuration.setName(file.getName());
|
||||
configuration.setJarPath(file.getPath());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile getJarFileFromContext(ConfigurationContext context) {
|
||||
Location location = context.getLocation();
|
||||
if (location == null) return null;
|
||||
|
||||
VirtualFile file = location.getVirtualFile();
|
||||
return file != null && FileUtilRt.extensionEquals(file.getName(), "jar") ? file : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurationFromContext(JarApplicationConfiguration configuration, ConfigurationContext context) {
|
||||
VirtualFile file = getJarFileFromContext(context);
|
||||
return file != null && FileUtil.pathsEqual(file.getPath(), configuration.getJarPath());
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.execution.jar;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.configuration.ConfigurationFactoryEx;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.execution.configurations.ConfigurationTypeBase;
|
||||
import com.intellij.execution.configurations.ConfigurationTypeUtil;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JarApplicationConfigurationType extends ConfigurationTypeBase implements ConfigurationType {
|
||||
@NotNull
|
||||
public static JarApplicationConfigurationType getInstance() {
|
||||
return ConfigurationTypeUtil.findConfigurationType(JarApplicationConfigurationType.class);
|
||||
}
|
||||
|
||||
public JarApplicationConfigurationType() {
|
||||
super("JarApplication", ExecutionBundle.message("jar.application.configuration.name"),
|
||||
ExecutionBundle.message("jar.application.configuration.description"), AllIcons.FileTypes.Archive);
|
||||
addFactory(new ConfigurationFactoryEx(this) {
|
||||
@Override
|
||||
public void onNewConfigurationCreated(@NotNull RunConfiguration configuration) {
|
||||
JarApplicationConfiguration jarApplicationConfiguration = (JarApplicationConfiguration)configuration;
|
||||
if (StringUtil.isEmpty(jarApplicationConfiguration.getWorkingDirectory())) {
|
||||
String baseDir = FileUtil.toSystemIndependentName(StringUtil.notNullize(configuration.getProject().getBasePath()));
|
||||
jarApplicationConfiguration.setWorkingDirectory(baseDir);
|
||||
}
|
||||
}
|
||||
|
||||
public RunConfiguration createTemplateConfiguration(Project project) {
|
||||
return new JarApplicationConfiguration(project, this, "");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.execution.jar;
|
||||
|
||||
import com.intellij.debugger.impl.GenericDebuggerRunner;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.executors.DefaultDebugExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JarApplicationDebuggerRunner extends GenericDebuggerRunner {
|
||||
@Override
|
||||
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
|
||||
return DefaultDebugExecutor.EXECUTOR_ID.equals(executorId) && profile instanceof JarApplicationConfiguration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getRunnerId() {
|
||||
return "JarDebug";
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,7 @@ public class InheritorChooser {
|
||||
}
|
||||
}
|
||||
}
|
||||
final int numberOfInheritors = classes.size();
|
||||
final PsiClassListCellRenderer renderer = new PsiClassListCellRenderer() {
|
||||
@Override
|
||||
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
|
||||
@@ -124,7 +125,7 @@ public class InheritorChooser {
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
if (value == null) {
|
||||
renderer.append("All");
|
||||
renderer.append("All (" + numberOfInheritors + ")");
|
||||
return true;
|
||||
}
|
||||
return super.customizeNonPsiElementLeftRenderer(renderer, list, value, index, selected, hasFocus);
|
||||
|
||||
@@ -30,15 +30,16 @@ import java.io.File;
|
||||
public class ProcessProxyFactoryImpl extends ProcessProxyFactory {
|
||||
public ProcessProxy createCommandLineProxy(final JavaCommandLine javaCmdLine) throws ExecutionException {
|
||||
ProcessProxyImpl proxy = null;
|
||||
if (ProcessProxyImpl.useLauncher()) {
|
||||
final JavaParameters javaParameters = javaCmdLine.getJavaParameters();
|
||||
String mainClass = javaParameters.getMainClass();
|
||||
if (ProcessProxyImpl.useLauncher() && mainClass != null) {
|
||||
try {
|
||||
proxy = new ProcessProxyImpl();
|
||||
final JavaParameters javaParameters = javaCmdLine.getJavaParameters();
|
||||
JavaSdkUtil.addRtJar(javaParameters.getClassPath());
|
||||
final ParametersList vmParametersList = javaParameters.getVMParametersList();
|
||||
vmParametersList.defineProperty(ProcessProxyImpl.PROPERTY_PORT_NUMBER, String.valueOf(proxy.getPortNumber()));
|
||||
vmParametersList.defineProperty(ProcessProxyImpl.PROPERTY_BINPATH, PathManager.getBinPath());
|
||||
javaParameters.getProgramParametersList().prepend(javaParameters.getMainClass());
|
||||
javaParameters.getProgramParametersList().prepend(mainClass);
|
||||
javaParameters.setMainClass(ProcessProxyImpl.LAUNCH_MAIN_CLASS);
|
||||
}
|
||||
catch (ProcessProxyImpl.NoMoreSocketsException e) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.ex.PathUtilEx;
|
||||
@@ -118,7 +117,7 @@ public class JavaParametersUtil {
|
||||
return jreHome == null ? JavaParameters.getModuleJdk(module) : createAlternativeJdk(jreHome);
|
||||
}
|
||||
|
||||
private static Sdk createProjectJdk(final Project project, final String jreHome) throws CantRunException {
|
||||
public static Sdk createProjectJdk(final Project project, final String jreHome) throws CantRunException {
|
||||
return jreHome == null ? createProjectJdk(project) : createAlternativeJdk(jreHome);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class CommandLineBuilder {
|
||||
if (exePath == null) {
|
||||
throw new CantRunException(ExecutionBundle.message("run.configuration.cannot.find.vm.executable"));
|
||||
}
|
||||
if (javaParameters.getMainClass() == null) {
|
||||
if (javaParameters.getMainClass() == null && javaParameters.getJarPath() == null) {
|
||||
throw new CantRunException(ExecutionBundle.message("main.class.is.not.specified.error.message"));
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
<componentStyle value="SMALL"/>
|
||||
<enabled value="true"/>
|
||||
<fontColor value="BRIGHTER"/>
|
||||
<text value="<html>{} jars will be downloaded into <b>lib</b> directory<br> Project level library <b>spring</b> will be created</html>"/>
|
||||
<text value="<html>{} JARs will be downloaded into <b>lib</b> directory<br> Project level library <b>spring</b> will be created</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="84326" class="javax.swing.JLabel" binding="myHiddenLabel">
|
||||
|
||||
@@ -490,7 +490,7 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
else {
|
||||
path = PathUtil.getFileName(downloadPath);
|
||||
}
|
||||
return MessageFormat.format("{0} {0, choice, 1#jar|2#jars} will be downloaded into <b>{1}</b> directory<br>" +
|
||||
return MessageFormat.format("{0} {0, choice, 1#JAR|2#JARs} will be downloaded into <b>{1}</b> directory<br>" +
|
||||
"{2} library <b>{3}</b> will be created",
|
||||
downloadSettings.getSelectedDownloads().size(),
|
||||
path,
|
||||
|
||||
@@ -23,10 +23,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@State(
|
||||
name = "RecentProjectsManager",
|
||||
roamingType = RoamingType.DISABLED,
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml"),
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/recentProjects.xml")
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml", roamingType = RoamingType.DISABLED),
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/recentProjects.xml", roamingType = RoamingType.DISABLED)
|
||||
},
|
||||
storageChooser = LastStorageChooserForWrite.class
|
||||
)
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ImportModuleAction extends AnAction {
|
||||
if (lastLocation != null) {
|
||||
toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation);
|
||||
}
|
||||
VirtualFile[] files = chooser.choose(toSelect, project);
|
||||
VirtualFile[] files = chooser.choose(project, toSelect);
|
||||
if (files.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,9 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
|
||||
myEditors.add(new ModuleConfigurableWrapper(moduleConfigurable));
|
||||
}
|
||||
for(ModuleConfigurableEP extension : myModule.getExtensions(MODULE_CONFIGURABLES)) {
|
||||
myEditors.add(new ModuleConfigurableWrapper(extension.createConfigurable()));
|
||||
if (extension.canCreateConfigurable()) {
|
||||
myEditors.add(new ModuleConfigurableWrapper(extension.createConfigurable()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -197,9 +197,9 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
myToolbarComponent = toolbar.getComponent();
|
||||
if (Registry.is("ide.new.project.settings")) {
|
||||
left.setBackground(UIUtil.getSidePanelColor());
|
||||
} else {
|
||||
left.add(myToolbarComponent, BorderLayout.NORTH);
|
||||
myToolbarComponent.setBackground(UIUtil.getSidePanelColor());
|
||||
}
|
||||
left.add(myToolbarComponent, BorderLayout.NORTH);
|
||||
left.add(mySidePanel, BorderLayout.CENTER);
|
||||
|
||||
mySplitter.setFirstComponent(left);
|
||||
|
||||
+3
@@ -76,6 +76,9 @@ public class LanguageLevelModuleExtension extends ModuleExtension<LanguageLevelM
|
||||
//bad value was stored
|
||||
}
|
||||
}
|
||||
else {
|
||||
myLanguageLevel = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
@@ -67,6 +67,9 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
|
||||
if (body instanceof PsiCodeBlock) {
|
||||
PsiExpression psiExpression = getExpression((PsiCodeBlock)body);
|
||||
if (psiExpression != null) {
|
||||
if (!expression.isVoidCompatible() && LambdaUtil.isExpressionStatementExpression(psiExpression)) {
|
||||
return;
|
||||
}
|
||||
final PsiElement errorElement;
|
||||
final PsiElement parent = psiExpression.getParent();
|
||||
if (parent instanceof PsiReturnStatement) {
|
||||
|
||||
+6
@@ -333,6 +333,9 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig
|
||||
else {
|
||||
PsiType exprType = RefactoringUtil.getTypeByExpression(expression);
|
||||
if (exprType == null) return null;
|
||||
if (exprType instanceof PsiDisjunctionType) {
|
||||
exprType = ((PsiDisjunctionType)exprType).getLeastUpperBound();
|
||||
}
|
||||
final ParameterInfoImpl changedParameterInfo = new ParameterInfoImpl(i, parameter.getName(), exprType);
|
||||
result.add(changedParameterInfo);
|
||||
changedParams.add(changedParameterInfo);
|
||||
@@ -403,6 +406,9 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig
|
||||
if (varargParam != null && pi >= parameters.length) return false;
|
||||
PsiType exprType = RefactoringUtil.getTypeByExpression(expression);
|
||||
if (exprType == null) return false;
|
||||
if (exprType instanceof PsiDisjunctionType) {
|
||||
exprType = ((PsiDisjunctionType)exprType).getLeastUpperBound();
|
||||
}
|
||||
JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(expression.getProject());
|
||||
String name = suggestUniqueParameterName(codeStyleManager, expression, exprType, existingNames);
|
||||
final ParameterInfoImpl newParameterInfo = new ParameterInfoImpl(-1, name, exprType, expression.getText().replace('\n', ' '));
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction {
|
||||
}
|
||||
else if (Messages.showOkCancelDialog(project, "Infer Nullity Annotations requires that the nullity annotations" +
|
||||
" be available in all your project sources.\n\nYou will need to add annotations.jar as a library. " +
|
||||
"It is possible to configure custom jar in e.g. Constant Conditions & Exceptions inspection or use JetBrains annotations available in installation. " +
|
||||
"It is possible to configure custom JAR in e.g. Constant Conditions & Exceptions inspection or use JetBrains annotations available in installation. " +
|
||||
" IntelliJ IDEA nullity annotations are freely usable and redistributable under the Apache 2.0 license. Would you like to do it now?",
|
||||
INFER_NULLITY_ANNOTATIONS, Messages.getErrorIcon()) == Messages.OK) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
|
||||
+16
-14
@@ -69,23 +69,25 @@ public class ClassHierarchyScopeDescriptor extends ScopeDescriptor {
|
||||
chooser.showDialog();
|
||||
|
||||
PsiClass aClass = chooser.getSelected();
|
||||
if (aClass == null) return null;
|
||||
if (aClass == null) {
|
||||
myCachedScope = GlobalSearchScope.EMPTY_SCOPE;
|
||||
} else {
|
||||
final List<PsiElement> classesToSearch = new LinkedList<PsiElement>();
|
||||
classesToSearch.add(aClass);
|
||||
|
||||
final List<PsiElement> classesToSearch = new LinkedList<PsiElement>();
|
||||
classesToSearch.add(aClass);
|
||||
classesToSearch.addAll(ClassInheritorsSearch.search(aClass, true).findAll());
|
||||
|
||||
classesToSearch.addAll(ClassInheritorsSearch.search(aClass, true).findAll());
|
||||
FunctionalExpressionSearch.search(aClass).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
classesToSearch.add(expression);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
FunctionalExpressionSearch.search(aClass).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
classesToSearch.add(expression);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
myCachedScope = new LocalSearchScope(PsiUtilCore.toPsiElementArray(classesToSearch),
|
||||
IdeBundle.message("scope.hierarchy", ClassPresentationUtil.getNameForClass(aClass, true)));
|
||||
myCachedScope = new LocalSearchScope(PsiUtilCore.toPsiElementArray(classesToSearch),
|
||||
IdeBundle.message("scope.hierarchy", ClassPresentationUtil.getNameForClass(aClass, true)));
|
||||
}
|
||||
}
|
||||
|
||||
return myCachedScope;
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class FindJarFix<T extends PsiElement> implements IntentionActio
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Find jar on web";
|
||||
return "Find JAR on web";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -190,7 +190,7 @@ public abstract class FindJarFix<T extends PsiElement> implements IntentionActio
|
||||
} else {
|
||||
JBPopupFactory.getInstance()
|
||||
.createListPopupBuilder(libNames)
|
||||
.setTitle("Select a jar file")
|
||||
.setTitle("Select a JAR file")
|
||||
.setItemChoosenCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
+6
-7
@@ -22,17 +22,16 @@ package com.intellij.openapi.projectRoots.impl;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.*;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkTypeId;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jdom.Element;
|
||||
|
||||
@State(
|
||||
name="ProjectJdkTable",
|
||||
roamingType = RoamingType.DISABLED,
|
||||
storages= {
|
||||
@Storage(
|
||||
file = StoragePathMacros.APP_CONFIG + "/jdk.table.xml"
|
||||
)}
|
||||
name = "ProjectJdkTable",
|
||||
storages = {@Storage(file = StoragePathMacros.APP_CONFIG + "/jdk.table.xml", roamingType = RoamingType.DISABLED)}
|
||||
)
|
||||
public class JavaAwareProjectJdkTableImpl extends ProjectJdkTableImpl {
|
||||
public static JavaAwareProjectJdkTableImpl getInstanceEx() {
|
||||
|
||||
+8
-15
@@ -20,25 +20,18 @@
|
||||
*/
|
||||
package com.intellij.refactoring.extractMethod;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.refactoring.util.VariableData;
|
||||
|
||||
public abstract class AbstractExtractDialog extends DialogWrapper {
|
||||
protected AbstractExtractDialog(Project project) {
|
||||
super(project, true);
|
||||
}
|
||||
|
||||
|
||||
public abstract String getChosenMethodName();
|
||||
|
||||
public abstract VariableData[] getChosenParameters();
|
||||
public interface AbstractExtractDialog {
|
||||
|
||||
String getChosenMethodName();
|
||||
VariableData[] getChosenParameters();
|
||||
@PsiModifier.ModifierConstant
|
||||
public abstract String getVisibility();
|
||||
String getVisibility();
|
||||
boolean isMakeStatic();
|
||||
boolean isChainedConstructor();
|
||||
|
||||
public abstract boolean isMakeStatic();
|
||||
|
||||
public abstract boolean isChainedConstructor();
|
||||
void show();
|
||||
boolean isOK();
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -59,7 +60,7 @@ import java.awt.event.*;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@SuppressWarnings("MethodMayBeStatic")
|
||||
public class ExtractMethodDialog extends AbstractExtractDialog {
|
||||
public class ExtractMethodDialog extends DialogWrapper implements AbstractExtractDialog {
|
||||
public static final String EXTRACT_METHOD_DEFAULT_VISIBILITY = "extract.method.default.visibility";
|
||||
private final Project myProject;
|
||||
private final PsiType myReturnType;
|
||||
@@ -96,7 +97,7 @@ public class ExtractMethodDialog extends AbstractExtractDialog {
|
||||
String title,
|
||||
String helpId,
|
||||
final PsiElement[] elementsToExtract) {
|
||||
super(project);
|
||||
super(project, true);
|
||||
myProject = project;
|
||||
myTargetClass = targetClass;
|
||||
myReturnType = returnType;
|
||||
|
||||
+51
-16
@@ -463,14 +463,14 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
protected void apply(final AbstractExtractDialog dialog) {
|
||||
myMethodName = dialog.getChosenMethodName();
|
||||
myVariableDatum = dialog.getChosenParameters();
|
||||
myStatic |= dialog.isMakeStatic();
|
||||
myStatic = isStatic() | dialog.isMakeStatic();
|
||||
myIsChainedConstructor = dialog.isChainedConstructor();
|
||||
myMethodVisibility = dialog.getVisibility();
|
||||
}
|
||||
|
||||
protected AbstractExtractDialog createExtractMethodDialog(final boolean direct) {
|
||||
return new ExtractMethodDialog(myProject, myTargetClass, myInputVariables, myReturnType, myTypeParameterList,
|
||||
myThrownExceptions, myStatic, myCanBeStatic, myCanBeChainedConstructor,
|
||||
return new ExtractMethodDialog(myProject, myTargetClass, myInputVariables, myReturnType, getTypeParameterList(),
|
||||
getThrownExceptions(), isStatic(), isCanBeStatic(), myCanBeChainedConstructor,
|
||||
suggestInitialMethodName(),
|
||||
myRefactoringName, myHelpId, myElements) {
|
||||
protected boolean areTypesDirected() {
|
||||
@@ -575,10 +575,16 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
|
||||
chooseAnchor();
|
||||
|
||||
int col = myEditor.getCaretModel().getLogicalPosition().column;
|
||||
int line = myEditor.getCaretModel().getLogicalPosition().line;
|
||||
LogicalPosition pos = new LogicalPosition(0, 0);
|
||||
myEditor.getCaretModel().moveToLogicalPosition(pos);
|
||||
LogicalPosition pos1;
|
||||
if (myEditor != null) {
|
||||
int col = myEditor.getCaretModel().getLogicalPosition().column;
|
||||
int line = myEditor.getCaretModel().getLogicalPosition().line;
|
||||
pos1 = new LogicalPosition(line, col);
|
||||
LogicalPosition pos = new LogicalPosition(0, 0);
|
||||
myEditor.getCaretModel().moveToLogicalPosition(pos);
|
||||
} else {
|
||||
pos1 = null;
|
||||
}
|
||||
|
||||
final SearchScope processConflictsScope = myMethodVisibility.equals(PsiModifier.PRIVATE) ?
|
||||
new LocalSearchScope(myTargetClass) :
|
||||
@@ -610,17 +616,18 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
ApplicationManager.getApplication().runWriteAction(extract);
|
||||
}
|
||||
|
||||
LogicalPosition pos1 = new LogicalPosition(line, col);
|
||||
myEditor.getCaretModel().moveToLogicalPosition(pos1);
|
||||
int offset = myMethodCall.getMethodExpression().getTextRange().getStartOffset();
|
||||
myEditor.getCaretModel().moveToOffset(offset);
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
myEditor.getSelectionModel().removeSelection();
|
||||
if (myEditor != null) {
|
||||
myEditor.getCaretModel().moveToLogicalPosition(pos1);
|
||||
int offset = myMethodCall.getMethodExpression().getTextRange().getStartOffset();
|
||||
myEditor.getCaretModel().moveToOffset(offset);
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
myEditor.getSelectionModel().removeSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void doExtract() throws IncorrectOperationException {
|
||||
|
||||
PsiMethod newMethod = generateEmptyMethod(myThrownExceptions, myStatic);
|
||||
PsiMethod newMethod = generateEmptyMethod(getThrownExceptions(), isStatic());
|
||||
|
||||
myExpression = myInputVariables.replaceWrappedReferences(myElements, myExpression);
|
||||
renameInputVariables();
|
||||
@@ -991,6 +998,10 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
return myTargetClass;
|
||||
}
|
||||
|
||||
public PsiType getReturnType() {
|
||||
return myReturnType;
|
||||
}
|
||||
|
||||
private PsiMethod generateEmptyMethod(PsiClassType[] exceptions, boolean isStatic) throws IncorrectOperationException {
|
||||
PsiMethod newMethod;
|
||||
if (myIsChainedConstructor) {
|
||||
@@ -1001,8 +1012,8 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
PsiUtil.setModifierProperty(newMethod, PsiModifier.STATIC, isStatic);
|
||||
}
|
||||
PsiUtil.setModifierProperty(newMethod, myMethodVisibility, true);
|
||||
if (myTypeParameterList != null) {
|
||||
newMethod.getTypeParameterList().replace(myTypeParameterList);
|
||||
if (getTypeParameterList() != null) {
|
||||
newMethod.getTypeParameterList().replace(getTypeParameterList());
|
||||
}
|
||||
PsiCodeBlock body = newMethod.getBody();
|
||||
LOG.assertTrue(body != null);
|
||||
@@ -1400,4 +1411,28 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
public InputVariables getInputVariables() {
|
||||
return myInputVariables;
|
||||
}
|
||||
|
||||
public PsiTypeParameterList getTypeParameterList() {
|
||||
return myTypeParameterList;
|
||||
}
|
||||
|
||||
public PsiClassType[] getThrownExceptions() {
|
||||
return myThrownExceptions;
|
||||
}
|
||||
|
||||
public boolean isStatic() {
|
||||
return myStatic;
|
||||
}
|
||||
|
||||
public boolean isCanBeStatic() {
|
||||
return myCanBeStatic;
|
||||
}
|
||||
|
||||
public PsiElement[] getElements() {
|
||||
return myElements;
|
||||
}
|
||||
|
||||
public PsiVariable[] getOutputVariables() {
|
||||
return myOutputVariables;
|
||||
}
|
||||
}
|
||||
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* 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.refactoring.extractMethodObject;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.*;
|
||||
import com.intellij.refactoring.extractMethod.AbstractExtractDialog;
|
||||
import com.intellij.refactoring.extractMethod.InputVariables;
|
||||
import com.intellij.refactoring.extractMethod.PrepareFailedException;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.VariableData;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ExtractLightMethodObjectHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#" + ExtractLightMethodObjectHandler.class.getName());
|
||||
|
||||
public static class ExtractedData {
|
||||
private String myGeneratedCallText;
|
||||
private PsiClass myGeneratedInnerClass;
|
||||
|
||||
public ExtractedData(String generatedCallText, PsiClass generatedInnerClass) {
|
||||
myGeneratedCallText = generatedCallText;
|
||||
myGeneratedInnerClass = generatedInnerClass;
|
||||
}
|
||||
|
||||
public String getGeneratedCallText() {
|
||||
return myGeneratedCallText;
|
||||
}
|
||||
|
||||
public PsiClass getGeneratedInnerClass() {
|
||||
return myGeneratedInnerClass;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ExtractedData extractLightMethodObject(final Project project,
|
||||
final PsiFile file,
|
||||
@NotNull final PsiCodeFragment fragment,
|
||||
final String methodName) throws PrepareFailedException {
|
||||
final PsiElement[] elements = fragment.getChildren();
|
||||
if (elements.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final PsiFile copy = PsiFileFactory.getInstance(project)
|
||||
.createFileFromText(file.getName(), file.getFileType(), file.getText(), file.getModificationStamp(), true);
|
||||
|
||||
final PsiElement originalContext = fragment.getContext();
|
||||
if (originalContext == null) {
|
||||
return null;
|
||||
}
|
||||
final TextRange range = originalContext.getTextRange();
|
||||
final PsiElement originalAnchor =
|
||||
CodeInsightUtil.findElementInRange(copy, range.getStartOffset(), range.getEndOffset(), originalContext.getClass());
|
||||
//todo before this or super, not found etc
|
||||
final PsiElement anchor = RefactoringUtil.getParentStatement(originalAnchor, false);
|
||||
final PsiElement[] elementsCopy = new PsiElement[elements.length];
|
||||
final PsiElement container = anchor.getParent();
|
||||
elementsCopy[0] = ApplicationManager.getApplication().runWriteAction(new Computable<PsiElement>() {
|
||||
@Override
|
||||
public PsiElement compute() {
|
||||
return container.addRangeAfter(elements[0], elements[elements.length - 1], anchor);
|
||||
}
|
||||
});
|
||||
for (int i = 1; i < elements.length; i++) {
|
||||
elementsCopy[i] = elementsCopy[i - 1].getNextSibling();
|
||||
}
|
||||
|
||||
final ControlFlow controlFlow;
|
||||
try {
|
||||
controlFlow = ControlFlowFactory.getInstance(project).getControlFlow(container, AllVariablesControlFlowPolicy.getInstance());
|
||||
}
|
||||
catch (AnalysisCanceledException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<PsiVariable> variables = ControlFlowUtil.getUsedVariables(controlFlow, 0, controlFlow.getSize());
|
||||
|
||||
final String outputVariables = StringUtil.join(variables, new Function<PsiVariable, String>() {
|
||||
@Override
|
||||
public String fun(PsiVariable variable) {
|
||||
return "\"variable: \" + " + variable.getName();
|
||||
}
|
||||
}, " +");
|
||||
final PsiStatement outStatement = JavaPsiFacade.getElementFactory(project).createStatementFromText("System.out.println(" + outputVariables + ");", anchor);
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
container.addAfter(outStatement, elementsCopy[elementsCopy.length - 1]);
|
||||
}
|
||||
});
|
||||
|
||||
final Document document = PsiDocumentManager.getInstance(project).getDocument(copy);
|
||||
LOG.assertTrue(document != null);
|
||||
|
||||
final int startOffset = elementsCopy[0].getTextRange().getStartOffset();
|
||||
final int endOffset = elementsCopy[elementsCopy.length - 1].getTextRange().getEndOffset();
|
||||
|
||||
final RangeMarker callSiteMarker = document.createRangeMarker(startOffset, endOffset);
|
||||
callSiteMarker.setGreedyToLeft(true);
|
||||
callSiteMarker.setGreedyToRight(true);
|
||||
|
||||
try {
|
||||
final ExtractMethodObjectProcessor extractMethodObjectProcessor = new ExtractMethodObjectProcessor(project, null, elementsCopy, "") {
|
||||
@Override
|
||||
protected AbstractExtractDialog createExtractMethodObjectDialog(MyExtractMethodProcessor processor) {
|
||||
return new LightExtractMethodObjectDialog(this, methodName);
|
||||
}
|
||||
};
|
||||
extractMethodObjectProcessor.getExtractProcessor().setShowErrorDialogs(false);
|
||||
|
||||
ExtractMethodObjectHandler.extractMethodObject(project, null, extractMethodObjectProcessor);
|
||||
|
||||
final String generatedCall = document.getText(new TextRange(callSiteMarker.getStartOffset(), callSiteMarker.getEndOffset()));
|
||||
return new ExtractedData(generatedCall, extractMethodObjectProcessor.getInnerClass());
|
||||
}
|
||||
finally {
|
||||
callSiteMarker.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static class LightExtractMethodObjectDialog implements AbstractExtractDialog {
|
||||
private final ExtractMethodObjectProcessor myProcessor;
|
||||
private final String myMethodName;
|
||||
|
||||
public LightExtractMethodObjectDialog(ExtractMethodObjectProcessor processor, String methodName) {
|
||||
myProcessor = processor;
|
||||
myMethodName = methodName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChosenMethodName() {
|
||||
return myMethodName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableData[] getChosenParameters() {
|
||||
final InputVariables inputVariables = myProcessor.getExtractProcessor().getInputVariables();
|
||||
return inputVariables.getInputVariables().toArray(new VariableData[inputVariables.getInputVariables().size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVisibility() {
|
||||
return PsiModifier.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMakeStatic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChainedConstructor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {}
|
||||
|
||||
@Override
|
||||
public boolean isOK() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.psi.*;
|
||||
@@ -44,7 +45,7 @@ import java.awt.event.ActionListener;
|
||||
import java.util.Enumeration;
|
||||
|
||||
|
||||
public class ExtractMethodObjectDialog extends AbstractExtractDialog {
|
||||
public class ExtractMethodObjectDialog extends DialogWrapper implements AbstractExtractDialog {
|
||||
private final Project myProject;
|
||||
private final PsiType myReturnType;
|
||||
private final PsiTypeParameterList myTypeParameterList;
|
||||
@@ -86,7 +87,7 @@ public class ExtractMethodObjectDialog extends AbstractExtractDialog {
|
||||
public ExtractMethodObjectDialog(Project project, PsiClass targetClass, final InputVariables inputVariables, PsiType returnType,
|
||||
PsiTypeParameterList typeParameterList, PsiType[] exceptions, boolean isStatic, boolean canBeStatic,
|
||||
final PsiElement[] elementsToExtract, final boolean multipleExitPoints) {
|
||||
super(project);
|
||||
super(project, true);
|
||||
myProject = project;
|
||||
myTargetClass = targetClass;
|
||||
myReturnType = returnType;
|
||||
|
||||
+26
-15
@@ -30,9 +30,7 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
@@ -55,7 +53,10 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler {
|
||||
});
|
||||
}
|
||||
|
||||
private void invokeOnElements(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull PsiElement[] elements) {
|
||||
private static void invokeOnElements(@NotNull final Project project,
|
||||
@NotNull final Editor editor,
|
||||
@NotNull PsiFile file,
|
||||
@NotNull PsiElement[] elements) {
|
||||
if (elements.length == 0) {
|
||||
String message = RefactoringBundle
|
||||
.getCannotRefactorMessage(RefactoringBundle.message("selected.block.should.represent.a.set.of.statements.or.an.expression"));
|
||||
@@ -63,17 +64,18 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
final ExtractMethodObjectProcessor processor = new ExtractMethodObjectProcessor(project, editor, elements, "");
|
||||
final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
|
||||
try {
|
||||
if (!extractProcessor.prepare()) return;
|
||||
extractMethodObject(project, editor, new ExtractMethodObjectProcessor(project, editor, elements, ""));
|
||||
}
|
||||
catch (PrepareFailedException e) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, e.getMessage(), ExtractMethodObjectProcessor.REFACTORING_NAME, HelpID.EXTRACT_METHOD_OBJECT);
|
||||
ExtractMethodHandler.highlightPrepareError(e, file, editor, project);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void extractMethodObject(Project project, Editor editor, ExtractMethodObjectProcessor processor) throws PrepareFailedException {
|
||||
final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
|
||||
if (!extractProcessor.prepare()) return;
|
||||
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, extractProcessor.getTargetClass().getContainingFile())) return;
|
||||
if (extractProcessor.showDialog()) {
|
||||
run(project, editor, processor, extractProcessor);
|
||||
@@ -81,11 +83,16 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler {
|
||||
}
|
||||
|
||||
public static void run(@NotNull final Project project,
|
||||
@NotNull final Editor editor,
|
||||
final Editor editor,
|
||||
@NotNull final ExtractMethodObjectProcessor processor,
|
||||
@NotNull final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor) {
|
||||
final int offset = editor.getCaretModel().getOffset();
|
||||
final RangeMarker marker = editor.getDocument().createRangeMarker(new TextRange(offset, offset));
|
||||
final RangeMarker marker;
|
||||
if (editor != null) {
|
||||
final int offset = editor.getCaretModel().getOffset();
|
||||
marker = editor.getDocument().createRangeMarker(new TextRange(offset, offset));
|
||||
} else {
|
||||
marker = null;
|
||||
}
|
||||
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
|
||||
public void run() {
|
||||
PostprocessReformattingAspect.getInstance(project).postponeFormattingInside(new Runnable() {
|
||||
@@ -110,7 +117,9 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler {
|
||||
if (processor.isCreateInnerClass()) {
|
||||
processor.moveUsedMethodsToInner();
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
DuplicatesImpl.processDuplicates(extractProcessor, project, editor);
|
||||
if (editor != null) {
|
||||
DuplicatesImpl.processDuplicates(extractProcessor, project, editor);
|
||||
}
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
@@ -125,9 +134,11 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler {
|
||||
});
|
||||
}
|
||||
}, ExtractMethodObjectProcessor.REFACTORING_NAME, ExtractMethodObjectProcessor.REFACTORING_NAME);
|
||||
editor.getCaretModel().moveToOffset(marker.getStartOffset());
|
||||
marker.dispose();
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
if (editor != null) {
|
||||
editor.getCaretModel().moveToOffset(marker.getStartOffset());
|
||||
marker.dispose();
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
}
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, @NotNull final PsiElement[] elements, final DataContext dataContext) {
|
||||
|
||||
+30
-13
@@ -37,10 +37,13 @@ import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
import com.intellij.psi.impl.source.PsiImmediateClassType;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
|
||||
@@ -52,6 +55,7 @@ import com.intellij.refactoring.ui.MemberSelectionPanel;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.classMembers.MemberInfo;
|
||||
import com.intellij.refactoring.util.duplicates.Match;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
@@ -100,8 +104,12 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
|
||||
@NotNull
|
||||
protected UsageInfo[] findUsages() {
|
||||
final ArrayList<UsageInfo> result = new ArrayList<UsageInfo>();
|
||||
final PsiClass containingClass = getMethod().getContainingClass();
|
||||
final SearchScope scope = PsiUtilCore.getVirtualFile(containingClass) instanceof LightVirtualFile
|
||||
? new LocalSearchScope(containingClass)
|
||||
: GlobalSearchScope.projectScope(myProject);
|
||||
PsiReference[] refs =
|
||||
ReferencesSearch.search(getMethod(), GlobalSearchScope.projectScope(myProject), false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
ReferencesSearch.search(getMethod(), scope, false).toArray(PsiReference.EMPTY_ARRAY);
|
||||
for (PsiReference ref : refs) {
|
||||
final PsiElement element = ref.getElement();
|
||||
if (element != null && element.isValid()) {
|
||||
@@ -320,7 +328,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
|
||||
for (PsiElement declaredElement : declaredElements) {
|
||||
if (declaredElement instanceof PsiVariable) {
|
||||
for (PsiVariable variable : outputVariables) {
|
||||
PsiLocalVariable var = (PsiLocalVariable)declaredElement;
|
||||
PsiVariable var = (PsiVariable)declaredElement;
|
||||
if (Comparing.strEqual(var.getName(), variable.getName())) {
|
||||
final PsiExpression initializer = var.getInitializer();
|
||||
if (initializer == null) {
|
||||
@@ -400,8 +408,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
private String getPureName(PsiVariable var) {
|
||||
final JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(myProject);
|
||||
final VariableKind kind = var instanceof PsiLocalVariable ? VariableKind.LOCAL_VARIABLE : VariableKind.PARAMETER;
|
||||
return styleManager.variableNameToPropertyName(var.getName(), kind);
|
||||
return styleManager.variableNameToPropertyName(var.getName(), styleManager.getVariableKind(var));
|
||||
}
|
||||
|
||||
public PsiExpression processMethodDeclaration( PsiExpressionList expressionList) throws IncorrectOperationException {
|
||||
@@ -517,7 +524,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
|
||||
LOG.assertTrue(methodBody != null);
|
||||
replacedMethodBody.replace(methodBody);
|
||||
PsiUtil.setModifierProperty(newMethod, PsiModifier.STATIC, myInnerClass.hasModifierProperty(PsiModifier.STATIC) && notHasGeneratedFields());
|
||||
myInnerMethod = (PsiMethod)myInnerClass.add(newMethod);
|
||||
myInnerMethod = (PsiMethod)JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(myInnerClass.add(newMethod));
|
||||
}
|
||||
|
||||
private boolean notHasGeneratedFields() {
|
||||
@@ -624,6 +631,22 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
|
||||
return myExtractProcessor;
|
||||
}
|
||||
|
||||
protected AbstractExtractDialog createExtractMethodObjectDialog(final MyExtractMethodProcessor processor) {
|
||||
return new ExtractMethodObjectDialog(myProject, processor.getTargetClass(), processor.getInputVariables(), processor.getReturnType(),
|
||||
processor.getTypeParameterList(),
|
||||
processor.getThrownExceptions(), processor.isStatic(), processor.isCanBeStatic(),
|
||||
processor.getElements(), myMultipleExitPoints){
|
||||
@Override
|
||||
protected boolean isUsedAfter(PsiVariable variable) {
|
||||
return ArrayUtil.find(processor.getOutputVariables(), variable) != -1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public PsiClass getInnerClass() {
|
||||
return myInnerClass;
|
||||
}
|
||||
|
||||
public class MyExtractMethodProcessor extends ExtractMethodProcessor {
|
||||
|
||||
public MyExtractMethodProcessor(Project project,
|
||||
@@ -640,19 +663,13 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
|
||||
@Override
|
||||
protected void apply(final AbstractExtractDialog dialog) {
|
||||
super.apply(dialog);
|
||||
myCreateInnerClass = ((ExtractMethodObjectDialog)dialog).createInnerClass();
|
||||
myCreateInnerClass = !(dialog instanceof ExtractMethodObjectDialog) || ((ExtractMethodObjectDialog)dialog).createInnerClass();
|
||||
myInnerClassName = myCreateInnerClass ? StringUtil.capitalize(dialog.getChosenMethodName()) : dialog.getChosenMethodName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractExtractDialog createExtractMethodDialog(final boolean direct) {
|
||||
return new ExtractMethodObjectDialog(myProject, myTargetClass, myInputVariables, myReturnType, myTypeParameterList,
|
||||
myThrownExceptions, myStatic, myCanBeStatic, myElements, myMultipleExitPoints){
|
||||
@Override
|
||||
protected boolean isUsedAfter(PsiVariable variable) {
|
||||
return ArrayUtil.find(myOutputVariables, variable) != -1;
|
||||
}
|
||||
};
|
||||
return createExtractMethodObjectDialog(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -262,7 +262,9 @@ public class GenericsUtil {
|
||||
for (PsiTypeParameter typeParameter : typeParams) {
|
||||
PsiType substituted = substitutor.substitute(typeParameter);
|
||||
if (substituted == null) return null;
|
||||
substituted = PsiUtil.captureToplevelWildcards(substituted, context);
|
||||
if (context != null) {
|
||||
substituted = PsiUtil.captureToplevelWildcards(substituted, context);
|
||||
}
|
||||
|
||||
PsiClassType[] extendsTypes = typeParameter.getExtendsListTypes();
|
||||
for (PsiClassType type : extendsTypes) {
|
||||
|
||||
@@ -477,6 +477,17 @@ public class LambdaUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
//JLS 14.8 Expression Statements
|
||||
public static boolean isExpressionStatementExpression(PsiElement body) {
|
||||
return body instanceof PsiAssignmentExpression ||
|
||||
body instanceof PsiPrefixExpression &&
|
||||
(((PsiPrefixExpression)body).getOperationTokenType() == JavaTokenType.PLUSPLUS ||
|
||||
((PsiPrefixExpression)body).getOperationTokenType() == JavaTokenType.MINUSMINUS) ||
|
||||
body instanceof PsiPostfixExpression ||
|
||||
body instanceof PsiCallExpression ||
|
||||
body instanceof PsiReferenceExpression && !body.isPhysical();
|
||||
}
|
||||
|
||||
public static class TypeParamsChecker extends PsiTypeVisitor<Boolean> {
|
||||
private PsiMethod myMethod;
|
||||
private final PsiClass myClass;
|
||||
|
||||
@@ -1108,8 +1108,11 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
}
|
||||
|
||||
public static PsiReturnStatement[] findReturnStatements(PsiMethod method) {
|
||||
return findReturnStatements(method.getBody());
|
||||
}
|
||||
|
||||
public static PsiReturnStatement[] findReturnStatements(PsiCodeBlock body) {
|
||||
ArrayList<PsiReturnStatement> vector = new ArrayList<PsiReturnStatement>();
|
||||
PsiCodeBlock body = method.getBody();
|
||||
if (body != null) {
|
||||
addReturnStatements(vector, body);
|
||||
}
|
||||
|
||||
@@ -638,7 +638,7 @@ public class JavaDocInfoGenerator {
|
||||
String text = o.toString();
|
||||
PsiType type = variable.getType();
|
||||
if (type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
|
||||
text = "\"" + StringUtil.shortenPathWithEllipsis(text, 120) + "\"";
|
||||
text = "\"" + StringUtil.escapeLineBreak(StringUtil.shortenPathWithEllipsis(text, 120)) + "\"";
|
||||
}
|
||||
else if (type.equalsToText("char")) text = "'" + text + "'";
|
||||
try {
|
||||
|
||||
@@ -389,7 +389,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
}
|
||||
else {
|
||||
//unbounded
|
||||
substituted = PsiWildcardType.createExtends(manager, substitutedBoundType);
|
||||
substituted = substitutedBoundType instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)substitutedBoundType).getWildcard() : PsiWildcardType.createExtends(manager, substitutedBoundType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-11
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.resolve;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
@@ -211,16 +210,8 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
.getSubstitutionForTypeParameter(typeParam, param, arg, isContraVariantPosition, languageLevel);
|
||||
}
|
||||
|
||||
private PsiInferenceHelper myTestHelper;
|
||||
|
||||
public void setTestHelper(PsiInferenceHelper testHelper) {
|
||||
myTestHelper = testHelper;
|
||||
}
|
||||
|
||||
public PsiInferenceHelper getInferenceHelper(LanguageLevel languageLevel) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() && myTestHelper != null) {
|
||||
return myTestHelper;
|
||||
}
|
||||
@NotNull
|
||||
public PsiInferenceHelper getInferenceHelper(@NotNull LanguageLevel languageLevel) {
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
return new PsiGraphInferenceHelper(myManager);
|
||||
}
|
||||
|
||||
+16
-12
@@ -174,7 +174,6 @@ public class InferenceSession {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (expr instanceof PsiLambdaExpression) {
|
||||
if (!((PsiLambdaExpression)expr).hasFormalParameterTypes()) {
|
||||
@@ -278,8 +277,7 @@ public class InferenceSession {
|
||||
if (arg instanceof PsiCallExpression) {
|
||||
//If the expression is a poly class instance creation expression (15.9) or a poly method invocation expression (15.12),
|
||||
//the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
|
||||
final JavaResolveResult resolveResult = getMethodResult((PsiCallExpression)arg);
|
||||
final PsiMethod calledMethod = resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
|
||||
final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)arg);
|
||||
if (PsiPolyExpressionUtil.isMethodCallPolyExpression(arg, calledMethod)) {
|
||||
collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)arg);
|
||||
}
|
||||
@@ -290,6 +288,20 @@ public class InferenceSession {
|
||||
}
|
||||
}
|
||||
|
||||
private static PsiMethod getCalledMethod(PsiCallExpression arg) {
|
||||
final PsiExpressionList argumentList = arg.getArgumentList();
|
||||
if (argumentList == null || argumentList.getExpressions().length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
|
||||
if (properties != null) {
|
||||
return properties.getMethod();
|
||||
}
|
||||
final JavaResolveResult resolveResult = getMethodResult(arg);
|
||||
return resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
|
||||
}
|
||||
|
||||
private void collectLambdaReturnExpression(Set<ConstraintFormula> additionalConstraints,
|
||||
PsiLambdaExpression lambdaExpression,
|
||||
PsiType parameterType) {
|
||||
@@ -306,8 +318,7 @@ public class InferenceSession {
|
||||
PsiExpression returnExpression,
|
||||
PsiType functionalType) {
|
||||
if (returnExpression instanceof PsiCallExpression) {
|
||||
final JavaResolveResult resolveResult = getMethodResult((PsiCallExpression)returnExpression);
|
||||
final PsiMethod calledMethod = resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
|
||||
final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)returnExpression);
|
||||
if (PsiPolyExpressionUtil.isMethodCallPolyExpression(returnExpression, calledMethod)) {
|
||||
collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)returnExpression);
|
||||
}
|
||||
@@ -1194,9 +1205,6 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
|
||||
if (sReturnType == PsiType.VOID) {
|
||||
return returnExpressions.isEmpty() && session == null;
|
||||
}
|
||||
|
||||
if (LambdaUtil.isFunctionalType(sReturnType) && LambdaUtil.isFunctionalType(tReturnType) &&
|
||||
!TypeConversionUtil.isAssignable(TypeConversionUtil.erasure(sReturnType), TypeConversionUtil.erasure(tReturnType)) &&
|
||||
@@ -1252,10 +1260,6 @@ public class InferenceSession {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sReturnType == PsiType.VOID && session != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType && sReturnType != PsiType.VOID;
|
||||
final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType && tReturnType != PsiType.VOID;
|
||||
|
||||
|
||||
+39
-19
@@ -30,7 +30,6 @@ import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -78,16 +77,11 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
@Override
|
||||
public boolean isVoidCompatible() {
|
||||
final PsiElement body = getBody();
|
||||
if (body != null) {
|
||||
try {
|
||||
ControlFlow controlFlow = ControlFlowFactory.getInstance(getProject()).getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy
|
||||
.getInstance());
|
||||
int startOffset = controlFlow.getStartOffset(body);
|
||||
int endOffset = controlFlow.getEndOffset(body);
|
||||
return startOffset != -1 && endOffset != -1 && !ControlFlowUtil.canCompleteNormally(controlFlow, startOffset, endOffset);
|
||||
}
|
||||
catch (AnalysisCanceledException e) {
|
||||
return true;
|
||||
if (body instanceof PsiCodeBlock) {
|
||||
for (PsiReturnStatement statement : PsiUtil.findReturnStatements((PsiCodeBlock)body)) {
|
||||
if (statement.getReturnValue() != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -96,18 +90,25 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
@Override
|
||||
public boolean isValueCompatible() {
|
||||
final PsiElement body = getBody();
|
||||
if (body != null) {
|
||||
if (body instanceof PsiCodeBlock) {
|
||||
try {
|
||||
final ControlFlow controlFlow =
|
||||
ControlFlowFactory.getInstance(getProject()).getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance(), false);
|
||||
if (ControlFlowUtil.findExitPointsAndStatements(controlFlow, 0, controlFlow.getSize(), new IntArrayList(),
|
||||
PsiReturnStatement.class,
|
||||
PsiThrowStatement.class).isEmpty()) {
|
||||
ControlFlow controlFlow =
|
||||
ControlFlowFactory.getInstance(getProject()).getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy
|
||||
.getInstance());
|
||||
int startOffset = controlFlow.getStartOffset(body);
|
||||
int endOffset = controlFlow.getEndOffset(body);
|
||||
if (startOffset != -1 && endOffset != -1 && ControlFlowUtil.canCompleteNormally(controlFlow, startOffset, endOffset)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (AnalysisCanceledException e) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (PsiReturnStatement statement : PsiUtil.findReturnStatements((PsiCodeBlock)body)) {
|
||||
if (statement.getReturnValue() == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -200,17 +201,36 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//A lambda expression (§15.27) is potentially compatible with a functional interface type (§9.8) if all of the following are true:
|
||||
// The arity of the target type's function type is the same as the arity of the lambda expression.
|
||||
// If the target type's function type has a void return, then the lambda body is either a statement expression (§14.8) or a void-compatible block (§15.27.2).
|
||||
// If the target type's function type has a (non-void) return type, then the lambda body is either an expression or a value-compatible block (§15.27.2).
|
||||
PsiType methodReturnType = interfaceMethod.getReturnType();
|
||||
if (checkReturnType) {
|
||||
final String uniqueVarName = JavaCodeStyleManager.getInstance(getProject()).suggestUniqueVariableName("l", this, true);
|
||||
final String canonicalText = toArray(leftType).getCanonicalText();
|
||||
final PsiStatement assignmentFromText = JavaPsiFacade.getElementFactory(getProject())
|
||||
.createStatementFromText(canonicalText + " " + uniqueVarName + " = " + getText(), this);
|
||||
final PsiLocalVariable localVariable = (PsiLocalVariable)((PsiDeclarationStatement)assignmentFromText).getDeclaredElements()[0];
|
||||
PsiType methodReturnType = interfaceMethod.getReturnType();
|
||||
if (methodReturnType != null) {
|
||||
return LambdaHighlightingUtil.checkReturnTypeCompatible((PsiLambdaExpression)localVariable.getInitializer(),
|
||||
substitutor.substitute(methodReturnType)) == null;
|
||||
}
|
||||
} else {
|
||||
final PsiElement body = getBody();
|
||||
if (methodReturnType == PsiType.VOID) {
|
||||
if (body instanceof PsiCodeBlock) {
|
||||
return isVoidCompatible();
|
||||
} else {
|
||||
return LambdaUtil.isExpressionStatementExpression(body);
|
||||
}
|
||||
} else {
|
||||
if (body instanceof PsiCodeBlock) {
|
||||
return isValueCompatible();
|
||||
}
|
||||
return body instanceof PsiExpression;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-1
@@ -158,7 +158,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
// A lambda expression or a method reference expression is potentially compatible with a type variable if the type variable is a type parameter of the candidate method.
|
||||
final PsiClass paramClass = PsiUtil.resolveClassInType(paramType);
|
||||
if (paramClass instanceof PsiTypeParameter && ((PsiTypeParameter)paramClass).getOwner() == method) continue;
|
||||
if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType), lambdaExpression.hasFormalParameterTypes())) {
|
||||
if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType),
|
||||
InferenceSession.isPertinentToApplicability(lambdaExpression, method))) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test<X extends Getter<?, ?> & Runnable> {}
|
||||
|
||||
interface Supplier<K> {
|
||||
K get();
|
||||
}
|
||||
|
||||
interface Getter<C, S extends C> extends Supplier<C> {
|
||||
public S get();
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map<Integer, Object> map = <error descr="Inferred type 'java.lang.Object' for type parameter 'V' is not within its bound; should implement 'java.lang.Comparable'">make()</error>;
|
||||
}
|
||||
|
||||
|
||||
public static <K extends Comparable, V extends Comparable> Map<K,V> make() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import java.util.Map;
|
||||
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
<error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.lang.Object>'">Map<Object, Object> b = newMapTrie();</error>
|
||||
<error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>'">Map<Object, Map<Object, Object>> c = newMapTrie();</error>
|
||||
<error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>>'">Map<Object, Map<Object, Map<Object, Object>>> d = newMapTrie();</error>
|
||||
<error descr="Incompatible types. Found: 'T', required: 'java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.util.Map<java.lang.Object,java.lang.Object>>>>'">Map<Object, Map<Object, Map<Object, Map<Object, Object>>>> e = newMapTrie();</error>
|
||||
}
|
||||
|
||||
public static <T extends Map<Byte, T>> T newMapTrie() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ class Ambiguity1 {
|
||||
static <T> void m(I2<T> i2) {}
|
||||
|
||||
{
|
||||
m<error descr="Ambiguous method call: both 'Ambiguity1.m(I1)' and 'Ambiguity1.m(I2<Object>)' match">(()->{throw new AssertionError();})</error>;
|
||||
m(()->{throw new AssertionError();});
|
||||
m(() -> {});
|
||||
m(() -> {
|
||||
if (false) return;
|
||||
|
||||
+1
-1
@@ -22,6 +22,6 @@ class AmbiguityRawGenerics {
|
||||
<Z> void foo(I3<Z> s) { }
|
||||
|
||||
void bar() {
|
||||
foo<error descr="Ambiguous method call: both 'AmbiguityRawGenerics.foo(I)' and 'AmbiguityRawGenerics.foo(I1)' match">(()-> { throw new RuntimeException(); })</error>;
|
||||
foo<error descr="Ambiguous method call: both 'AmbiguityRawGenerics.foo(I1)' and 'AmbiguityRawGenerics.foo(I2)' match">(()-> { throw new RuntimeException(); })</error>;
|
||||
}
|
||||
}
|
||||
+34
@@ -142,3 +142,37 @@ class IDEA128196 {
|
||||
new Thread(() -> System.out.println(value));
|
||||
}
|
||||
}
|
||||
|
||||
class FinalAssignmentInInitializer {
|
||||
private final String x;
|
||||
{
|
||||
Runnable r = () -> <error descr="Cannot assign a value to final variable 'x'">x</error> = "";
|
||||
x = "";
|
||||
}
|
||||
}
|
||||
|
||||
class AssignmentToFinalInsideLambda {
|
||||
boolean isTrue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Runnable r = () -> {
|
||||
final int i;
|
||||
if (isTrue()) {
|
||||
i = 1;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
};
|
||||
|
||||
void a() {
|
||||
Runnable r = () -> {
|
||||
final int i;
|
||||
if (isTrue()) {
|
||||
i = 1;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ class Test {
|
||||
void call(I2 p) { }
|
||||
|
||||
void test() {
|
||||
call<error descr="Ambiguous method call: both 'Test.call(I1)' and 'Test.call(I2)' match">(() -> { throw new RuntimeException(); })</error>;
|
||||
call(() -> { throw new RuntimeException(); });
|
||||
call(() -> { if (true) return ""; throw new RuntimeException(); });
|
||||
call(() -> { if (true) return; throw new RuntimeException(); });
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
abstract class PertinentToApplicabilityOfExplicitlyTypedLambdaTest {
|
||||
|
||||
interface A {
|
||||
B m(int a);
|
||||
}
|
||||
|
||||
interface B {
|
||||
int m(int b);
|
||||
}
|
||||
|
||||
abstract void foo(A a);
|
||||
abstract void foo(B b);
|
||||
|
||||
{
|
||||
foo<error descr="Ambiguous method call: both 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(A)' and 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(B)' match">(x -> y -> 42)</error>;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
interface A {
|
||||
int m(int x);
|
||||
}
|
||||
|
||||
interface B {
|
||||
void m(boolean x);
|
||||
}
|
||||
|
||||
abstract class Test {
|
||||
abstract void foo(A j);
|
||||
abstract void foo(B i);
|
||||
|
||||
void bar(Object o) {
|
||||
foo(x -> {
|
||||
return x += 1;
|
||||
});
|
||||
foo(x -> <error descr="Incompatible types. Found: 'int', required: '<lambda parameter>'">x += 1</error>);
|
||||
foo(x -> 1);
|
||||
foo(x -> <error descr="Operator '!' cannot be applied to 'int'">!x</error>);
|
||||
foo(x -> <error descr="Operator '++' cannot be applied to '<lambda parameter>'">++x</error>);
|
||||
foo(x -> o instanceof String ? 1 : 0);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Add 'Exception' as 1st parameter to method 'f'" "true"
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
public void createFileInputStream() {
|
||||
try {
|
||||
new FileInputStream("test");
|
||||
} catch (IOException |NullPointerException e) {
|
||||
f(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void f(Exception e) { }
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Add 'Exception' as 1st parameter to method 'f'" "true"
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
public void createFileInputStream() {
|
||||
try {
|
||||
new FileInputStream("test");
|
||||
} catch (IOException |NullPointerException e) {
|
||||
f(<caret>e);
|
||||
}
|
||||
}
|
||||
|
||||
public void f() { }
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Replace with expression lambda" "false"
|
||||
interface A {
|
||||
int m(int x);
|
||||
}
|
||||
|
||||
interface B {
|
||||
void m(boolean x);
|
||||
}
|
||||
|
||||
abstract class X {
|
||||
abstract void foo(A j);
|
||||
abstract void foo(B i);
|
||||
|
||||
void bar(Object o) {
|
||||
foo(x -> {
|
||||
retu<caret>rn x += 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Sample {
|
||||
void foo() {
|
||||
System.out.println("hello <caret>world");
|
||||
}
|
||||
}
|
||||
+4
-14
@@ -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.
|
||||
@@ -17,9 +17,6 @@ package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -117,16 +114,9 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testInferFromRawType() throws Exception {
|
||||
final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
|
||||
helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
|
||||
try {
|
||||
configureByFile("/" + getTestName(false) + ".java");
|
||||
assertNotNull(myItems);
|
||||
assertTrue(myItems.length == 0);
|
||||
}
|
||||
finally {
|
||||
helper.setTestHelper(null);
|
||||
}
|
||||
configureByFile("/" + getTestName(false) + ".java");
|
||||
assertNotNull(myItems);
|
||||
assertTrue(myItems.length == 0);
|
||||
}
|
||||
|
||||
public void testDiamondsInsideMethodCall() throws Exception {
|
||||
|
||||
@@ -372,6 +372,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA126633() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA124363() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA78402() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA106985() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testCaptureWildcardFromUnboundCaptureWildcard() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testSuperCaptureSubstitutionWhenTypeParameterHasUpperBounds() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testParameterBoundsWithCapturedWildcard() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
//jdk should propagate LL 1.4 but actually it provides LL 1.7?!
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) {
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-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.
|
||||
@@ -54,6 +54,6 @@ public class ExceptionVariablesInferenceTest extends LightDaemonAnalyzerTestCase
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) throws Exception {
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class FunctionalExpressionIncompleteHighlightingTest extends LightDaemonA
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) {
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class FunctionalTypeWildcardParameterizationTest extends LightDaemonAnaly
|
||||
|
||||
private void doTest() {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-13
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http:www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -24,9 +24,6 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -772,14 +769,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
private void doTest(boolean warnings) {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), myTestRootDisposable);
|
||||
final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
|
||||
helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
|
||||
try {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
|
||||
}
|
||||
finally {
|
||||
helper.setTestHelper(null);
|
||||
}
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-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.
|
||||
@@ -236,13 +236,17 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIncompatibleBoundsFromAssignment() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) throws Exception {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) {
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user