From 9e775fc8edf2517d3c162da54036a2d26dce5485 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Fri, 1 Mar 2013 16:57:54 +0400 Subject: [PATCH 1/7] reusing project frames --- .../com/intellij/openapi/wm/impl/WindowManagerImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index c96f5501a93a..d1aa0f2a33a5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -623,8 +623,13 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat frame.setFileTitle(null, null); myProject2Frame.remove(project); - Disposer.dispose(frame.getStatusBar()); - frame.dispose(); + if (myProject2Frame.isEmpty()) { + myProject2Frame.put(null, frame); + } + else { + Disposer.dispose(frame.getStatusBar()); + frame.dispose(); + } } public final void disposeRootFrame() { From 864210182cfd4db5de584a3e90068733407cca8d Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 1 Mar 2013 16:33:18 +0400 Subject: [PATCH 2/7] cleanup --- .../com/intellij/debugger/ui/DebuggerSessionTab.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java index 9c73e63e3d09..2bb3f1391d7a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java @@ -86,14 +86,12 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos private final ThreadsPanel myThreadsPanel; private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump"; - private final Icon myIcon; public DebuggerSessionTab(final Project project, final String sessionName, @NotNull final DebugUIEnvironment environment, - DebuggerSession debuggerSession) throws ExecutionException { + @NotNull DebuggerSession debuggerSession) throws ExecutionException { super(project, "JavaDebugger", sessionName); - myIcon = environment.getIcon(); myDebuggerSession = debuggerSession; myDebugUIEnvironment = environment; @@ -204,7 +202,8 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos ExecutionResult executionResult = debuggerSession.getProcess().getExecutionResult(); myConsole = executionResult.getExecutionConsole(); - myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName(), myIcon); + myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName(), + environment.getIcon()); initUI(executionResult); } @@ -516,8 +515,6 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos private class AutoVarsSwitchAction extends ToggleAction { private volatile boolean myAutoModeEnabled; - private static final String myAutoModeText = "Auto-Variables Mode"; - private static final String myDefaultModeText = "All-Variables Mode"; public AutoVarsSwitchAction() { super("", "", AllIcons.Debugger.AutoVariablesMode); @@ -528,7 +525,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos super.update(e); final Presentation presentation = e.getPresentation(); final boolean autoModeEnabled = (Boolean)presentation.getClientProperty(SELECTED_PROPERTY); - presentation.setText(autoModeEnabled ? myDefaultModeText : myAutoModeText); + presentation.setText(autoModeEnabled ? "All-Variables Mode" : "Auto-Variables Mode"); } public boolean isSelected(AnActionEvent e) { From 872772ddbc781973e7bbf99dc324d4842c1c3060 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 1 Mar 2013 17:19:27 +0400 Subject: [PATCH 3/7] take search scope obtained from run configuration into account to navigate to correct class when user clicks on stacktrace printed in console or log (IDEA-63362) --- .../debugger/DefaultDebugEnvironment.java | 24 +----------- .../debugger/ui/DebuggerSessionTab.java | 6 +-- .../impl/DefaultJavaProgramRunner.java | 4 +- .../diagnostic/logging/LogConsoleBase.java | 11 ++++-- .../diagnostic/logging/LogConsoleImpl.java | 24 +++++++++++- .../logging/LogConsoleManagerBase.java | 15 +++++-- .../runners/DefaultProgramRunner.java | 4 +- .../execution/runners/RunContentBuilder.java | 39 +++++++++++++++++++ .../impl/ui/DebuggerSessionTabBase.java | 6 ++- .../xdebugger/impl/ui/XDebugSessionTab.java | 3 +- 10 files changed, 93 insertions(+), 43 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java index dc2e1afdc547..e0f463eccf90 100644 --- a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java +++ b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java @@ -23,10 +23,9 @@ import com.intellij.execution.filters.ExceptionFilters; import com.intellij.execution.filters.Filter; import com.intellij.execution.filters.TextConsoleBuilder; import com.intellij.execution.runners.ProgramRunner; -import com.intellij.openapi.module.Module; +import com.intellij.execution.runners.RunContentBuilder; import com.intellij.openapi.project.Project; import com.intellij.psi.search.GlobalSearchScope; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -58,26 +57,7 @@ public class DefaultDebugEnvironment implements DebugEnvironment { myRemoteConnection = remoteConnection; myPollConnection = pollConnection; - mySearchScope = createSearchScope(project, runProfile); - } - - @NotNull - public static GlobalSearchScope createSearchScope(Project project, RunProfile runProfile) { - Module[] modules = null; - if (runProfile instanceof ModuleRunProfile) { - modules = ((ModuleRunProfile)runProfile).getModules(); - } - if (modules == null || modules.length == 0) { - return GlobalSearchScope.allScope(project); - } - else { - GlobalSearchScope scope = GlobalSearchScope.moduleRuntimeScope(modules[0], true); - for (int idx = 1; idx < modules.length; idx++) { - Module module = modules[idx]; - scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(module, true)); - } - return scope; - } + mySearchScope = RunContentBuilder.createSearchScope(project, runProfile); } @Override diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java index 2bb3f1391d7a..c189e4b64dab 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java @@ -87,11 +87,9 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos private final ThreadsPanel myThreadsPanel; private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump"; - public DebuggerSessionTab(final Project project, - final String sessionName, - @NotNull final DebugUIEnvironment environment, + public DebuggerSessionTab(final Project project, final String sessionName, @NotNull final DebugUIEnvironment environment, @NotNull DebuggerSession debuggerSession) throws ExecutionException { - super(project, "JavaDebugger", sessionName); + super(project, "JavaDebugger", sessionName, debuggerSession.getSearchScope()); myDebuggerSession = debuggerSession; myDebugUIEnvironment = environment; diff --git a/java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java b/java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java index 697a51bbd103..bfe8dd65e02f 100644 --- a/java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java +++ b/java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java @@ -86,10 +86,8 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner { onProcessStarted(env.getRunnerSettings(), executionResult); - final RunContentBuilder contentBuilder = new RunContentBuilder(project, this, executor); + final RunContentBuilder contentBuilder = new RunContentBuilder(project, this, executor, executionResult, env); Disposer.register(project, contentBuilder); - contentBuilder.setExecutionResult(executionResult); - contentBuilder.setEnvironment(env); if (shouldAddDefaultActions) { addDefaultActions(contentBuilder); } diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java index 96781ff93033..fc5895ba353d 100644 --- a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java +++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java @@ -37,6 +37,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.FilterComponent; import com.intellij.util.Alarm; import com.intellij.util.containers.ContainerUtil; @@ -54,7 +55,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.OutputStream; import java.io.Reader; -import java.util.ArrayList; import java.util.List; /** @@ -98,7 +98,12 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L private JComboBox myLogFilterCombo; private JPanel myTextFilterWrapper; - public LogConsoleBase(Project project, @Nullable Reader reader, String title, final boolean buildInActions, LogFilterModel model) { + public LogConsoleBase(@NotNull Project project, @Nullable Reader reader, String title, final boolean buildInActions, LogFilterModel model) { + this(project, reader, title, buildInActions, model, GlobalSearchScope.allScope(project)); + } + + public LogConsoleBase(@NotNull Project project, @Nullable Reader reader, String title, final boolean buildInActions, LogFilterModel model, + @NotNull GlobalSearchScope scope) { super(new BorderLayout()); myProject = project; myTitle = title; @@ -106,7 +111,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L myFilters = myModel.getLogFilters(); myReaderThread = new ReaderThread(reader); myBuildInActions = buildInActions; - TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project); + TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project, scope); myConsole = builder.getConsole(); myConsole.attachToProcess(myProcessHandler); myDisposed = false; diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleImpl.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleImpl.java index 60bd74544a06..6c79dee769d9 100644 --- a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleImpl.java @@ -18,6 +18,7 @@ package com.intellij.diagnostic.logging; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,8 +37,27 @@ public abstract class LogConsoleImpl extends LogConsoleBase { private final Charset myCharset; private long myOldLength = 0; - public LogConsoleImpl(Project project, @NotNull File file, @NotNull Charset charset, long skippedContents, String title, final boolean buildInActions) { - super(project, getReader(file, charset, skippedContents),title, buildInActions, new DefaultLogFilterModel(project)); + /** + * @deprecated use {@link #LogConsoleImpl(com.intellij.openapi.project.Project, java.io.File, java.nio.charset.Charset, long, String, boolean, com.intellij.psi.search.GlobalSearchScope)} + */ + public LogConsoleImpl(Project project, + @NotNull File file, + @NotNull Charset charset, + long skippedContents, + String title, + final boolean buildInActions) { + this(project, file, charset, skippedContents, title, buildInActions, GlobalSearchScope.allScope(project)); + } + + public LogConsoleImpl(Project project, + @NotNull File file, + @NotNull Charset charset, + long skippedContents, + String title, + final boolean buildInActions, + final GlobalSearchScope searchScope) { + super(project, getReader(file, charset, skippedContents), title, buildInActions, new DefaultLogFilterModel(project), + searchScope); myPath = file.getAbsolutePath(); myFile = file; myCharset = charset; diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java index 28778252a7a6..820a8a78c352 100644 --- a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java +++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java @@ -23,12 +23,12 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComponentWithActions; import com.intellij.openapi.util.Disposer; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManagerAdapter; import com.intellij.ui.content.ContentManagerEvent; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.File; @@ -48,9 +48,18 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos private final Map myAdditionalContent = new HashMap(); private ExecutionEnvironment myEnvironment; + private GlobalSearchScope mySearchScope; + /** + * @deprecated use {@link #LogConsoleManagerBase(com.intellij.openapi.project.Project, com.intellij.psi.search.GlobalSearchScope)} + */ protected LogConsoleManagerBase(@NotNull Project project) { + this(project, GlobalSearchScope.allScope(project)); + } + + protected LogConsoleManagerBase(@NotNull Project project, @NotNull GlobalSearchScope searchScope) { myProject = project; + mySearchScope = searchScope; } protected final Project getProject() { @@ -71,7 +80,7 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos } public void addLogConsole(final String name, final String path, @NotNull Charset charset, final long skippedContent, Icon icon) { - doAddLogConsole(new LogConsoleImpl(myProject, new File(path), charset, skippedContent, name, false) { + doAddLogConsole(new LogConsoleImpl(myProject, new File(path), charset, skippedContent, name, false, mySearchScope) { @Override public boolean isActive() { @@ -90,7 +99,7 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos reader, name, false, - new DefaultLogFilterModel(myProject)) { + new DefaultLogFilterModel(myProject), mySearchScope) { @Override public boolean isActive() { diff --git a/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java b/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java index dd31ed9c2a8f..1377d5a55f6e 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java @@ -35,9 +35,7 @@ public abstract class DefaultProgramRunner extends GenericProgramRunner { ExecutionResult executionResult = state.execute(executor, this); if (executionResult == null) return null; - final RunContentBuilder contentBuilder = new RunContentBuilder(project, this, executor); - contentBuilder.setExecutionResult(executionResult); - contentBuilder.setEnvironment(env); + final RunContentBuilder contentBuilder = new RunContentBuilder(project, this, executor, executionResult, env); return contentBuilder.showRunContent(contentToReuse); } diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java b/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java index 9c26da2482ef..999417963cc2 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java @@ -19,6 +19,7 @@ import com.intellij.diagnostic.logging.LogConsoleManagerBase; import com.intellij.diagnostic.logging.LogFilesManager; import com.intellij.diagnostic.logging.OutputFileUtil; import com.intellij.execution.*; +import com.intellij.execution.configurations.ModuleRunProfile; import com.intellij.execution.configurations.RunConfigurationBase; import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.impl.ConsoleViewImpl; @@ -31,8 +32,10 @@ import com.intellij.ide.actions.ContextHelpAction; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.content.Content; import com.intellij.ui.content.tabs.PinToolwindowTabAction; import org.jetbrains.annotations.NonNls; @@ -57,6 +60,22 @@ public class RunContentBuilder extends LogConsoleManagerBase { private RunnerLayoutUi myUi; private final Executor myExecutor; + public RunContentBuilder(@NotNull Project project, + ProgramRunner runner, + Executor executor, + ExecutionResult executionResult, + @NotNull ExecutionEnvironment environment) { + super(project, createSearchScope(project, environment.getRunProfile())); + myRunner = runner; + myExecutor = executor; + myManager = new LogFilesManager(project, this, this); + myExecutionResult = executionResult; + setEnvironment(environment); + } + + /** + * @deprecated use {@link #RunContentBuilder(com.intellij.openapi.project.Project, ProgramRunner, com.intellij.execution.Executor, com.intellij.execution.ExecutionResult, ExecutionEnvironment)} + */ public RunContentBuilder(final Project project, final ProgramRunner runner, Executor executor) { super(project); myRunner = runner; @@ -64,10 +83,30 @@ public class RunContentBuilder extends LogConsoleManagerBase { myManager = new LogFilesManager(project, this, this); } + @NotNull + public static GlobalSearchScope createSearchScope(Project project, RunProfile runProfile) { + Module[] modules = null; + if (runProfile instanceof ModuleRunProfile) { + modules = ((ModuleRunProfile)runProfile).getModules(); + } + if (modules == null || modules.length == 0) { + return GlobalSearchScope.allScope(project); + } + else { + GlobalSearchScope scope = GlobalSearchScope.moduleRuntimeScope(modules[0], true); + for (int idx = 1; idx < modules.length; idx++) { + Module module = modules[idx]; + scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(module, true)); + } + return scope; + } + } + public ExecutionResult getExecutionResult() { return myExecutionResult; } + @Deprecated public void setExecutionResult(final ExecutionResult executionResult) { myExecutionResult = executionResult; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java index e3848ca9b79f..36cb5fea6aeb 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java @@ -35,6 +35,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.registry.Registry; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.AppIcon; import com.intellij.ui.content.Content; import com.intellij.xdebugger.XDebuggerBundle; @@ -56,8 +57,9 @@ public abstract class DebuggerSessionTabBase extends LogConsoleManagerBase imple protected ExecutionConsole myConsole; protected RunContentDescriptor myRunContentDescriptor; - public DebuggerSessionTabBase(Project project, @NotNull String runnerId, @NotNull final String sessionName) { - super(project); + public DebuggerSessionTabBase(@NotNull Project project, @NotNull String runnerId, @NotNull final String sessionName, + @NotNull GlobalSearchScope searchScope) { + super(project, searchScope); Disposer.register(project, this); myManager = new LogFilesManager(project, this, this); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java index a1ee9be16301..308c1cfdc46e 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java @@ -33,6 +33,7 @@ import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.content.Content; import com.intellij.ui.content.tabs.PinToolwindowTabAction; import com.intellij.xdebugger.XDebugProcess; @@ -61,7 +62,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase { public XDebugSessionTab(@NotNull final Project project, @NotNull final XDebugSessionImpl session, final @Nullable Icon icon, ExecutionEnvironment environment, ProgramRunner runner) { - super(project, "Debug", session.getSessionName()); + super(project, "Debug", session.getSessionName(), GlobalSearchScope.allScope(project)); if (environment != null) { setEnvironment(environment); } From 30e352bcdd88197b4170fec7caa0d30cbf48cc40 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Fri, 1 Mar 2013 16:59:23 +0400 Subject: [PATCH 4/7] IDEA-95711 Warning "Cannot assign Object to boolean" on valid code --- plugins/groovy/src/META-INF/plugin.xml | 7 ++-- .../plugins/groovy/gpp/GppTypeConverter.java | 4 +- .../statements/expressions/TypesUtil.java | 2 +- .../typeEnhancers/GrBooleanTypeConverter.java | 41 +++++++++++++++++++ .../GrContainerTypeConverter.java | 5 +-- .../GrStringTypeConverter.java | 5 +-- .../{ => typeEnhancers}/GrTypeConverter.java | 5 ++- .../highlighting/GrAssignabilityTest.groovy | 9 ++++ 8 files changed, 64 insertions(+), 14 deletions(-) create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrBooleanTypeConverter.java rename plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/{impl => typeEnhancers}/GrContainerTypeConverter.java (93%) rename plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/{impl/types => typeEnhancers}/GrStringTypeConverter.java (92%) rename plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/{ => typeEnhancers}/GrTypeConverter.java (94%) diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index 2b7263145350..011226e3c2ad 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -35,7 +35,7 @@ interface="org.jetbrains.plugins.groovy.lang.resolve.ClosureMissingMethodContributor"/> - + @@ -145,8 +145,9 @@ - - + + + diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java index 97cfcbd8b33a..7c8714897b5b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.dsl.toplevel.AnnotatedContextFilter; import org.jetbrains.plugins.groovy.findUsages.LiteralConstructorReference; -import org.jetbrains.plugins.groovy.lang.psi.GrTypeConverter; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap; import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature; @@ -31,6 +30,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.GrMapType; import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType; import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; +import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrTypeConverter; /** * @author peter diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java index f10a5298d06b..b390e9830766 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java @@ -35,7 +35,6 @@ import gnu.trove.TObjectIntHashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.groovy.lang.psi.GrTypeConverter; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.SpreadState; @@ -49,6 +48,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres import org.jetbrains.plugins.groovy.lang.psi.impl.*; import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureImpl; import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.ClosureParameterEnhancer; +import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrTypeConverter; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import org.jetbrains.plugins.groovy.util.LightCacheKey; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrBooleanTypeConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrBooleanTypeConverter.java new file mode 100644 index 000000000000..b8a936d9e162 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrBooleanTypeConverter.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers; + +import com.intellij.psi.CommonClassNames; +import com.intellij.psi.PsiType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; + +/** + * @author Max Medvedev + */ +public class GrBooleanTypeConverter extends GrTypeConverter { + @Override + public boolean isAllowedInMethodCall() { + return false; + } + + @Override + public Boolean isConvertible(@NotNull PsiType lType, @NotNull PsiType rType, @NotNull GroovyPsiElement context) { + if (PsiType.BOOLEAN.equals(lType) || lType.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN)) { + return !PsiType.NULL.equals(rType); + } + + + return null; + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrContainerTypeConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrContainerTypeConverter.java similarity index 93% rename from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrContainerTypeConverter.java rename to plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrContainerTypeConverter.java index f24565cbc131..c350d5b6a141 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrContainerTypeConverter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrContainerTypeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy.lang.psi.impl; +package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers; import com.intellij.psi.CommonClassNames; import com.intellij.psi.PsiArrayType; @@ -22,7 +22,6 @@ import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.groovy.lang.psi.GrTypeConverter; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrStringTypeConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrStringTypeConverter.java similarity index 92% rename from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrStringTypeConverter.java rename to plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrStringTypeConverter.java index c6d9e6a3f031..8400d59f3206 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrStringTypeConverter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrStringTypeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy.lang.psi.impl.types; +package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers; import com.intellij.psi.PsiType; import com.intellij.psi.util.InheritanceUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.config.GroovyConfigUtils; -import org.jetbrains.plugins.groovy.lang.psi.GrTypeConverter; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GrTypeConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrTypeConverter.java similarity index 94% rename from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GrTypeConverter.java rename to plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrTypeConverter.java index dfeca81ba2cd..41f8de907101 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GrTypeConverter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrTypeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy.lang.psi; +package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.psi.PsiClass; @@ -21,6 +21,7 @@ import com.intellij.psi.PsiClassType; import com.intellij.psi.PsiType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; /** diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy index c1bdd08cfa6c..739d4904612b 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy @@ -500,6 +500,15 @@ import groovy.transform.Immutable Money d = [amount: 100, currency:'USA'] +''') + } + + void testBooleanIsAssignableToAny() { + testHighlighting('''\ + boolean b1 = new Object() + boolean b2 = null + Boolean b3 = new Object() + Boolean b4 = null ''') } From c2c13ebc5bd593b9e67a56d3dd7262814fd5ba1d Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Fri, 1 Mar 2013 17:18:32 +0400 Subject: [PATCH 5/7] EA-44349 - NPE: GroovyQuoteHandler.hasNonClosedLiteral --- .../jetbrains/plugins/groovy/editor/GroovyQuoteHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyQuoteHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyQuoteHandler.java index 18078968b3d4..a3abaa200b67 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyQuoteHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyQuoteHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,7 @@ public class GroovyQuoteHandler implements MultiCharQuoteHandler { final IElementType tokenType = iterator.getTokenType(); if (tokenType == mSTRING_LITERAL || tokenType == mGSTRING_BEGIN || tokenType == mGSTRING_LITERAL || tokenType == mGSTRING_CONTENT) { final Document document = iterator.getDocument(); + if (document == null) return false; final String literal = document.getText().substring(iterator.getStart(), offset + 1); if ("'''".equals(literal) || "\"\"\"".equals(literal) || "'".equals(literal) || "\"".equals(literal)) { return true; From b1cf766efa6713cd3e2a3ab6f2373863d6b9aeb6 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Fri, 1 Mar 2013 17:23:41 +0400 Subject: [PATCH 6/7] EA-44334 - assert: GrUnresolvedAccessInspection.checkRefInner --- .../untypedUnresolvedAccess/GrUnresolvedAccessInspection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java index cc1708272f77..37bdccef199a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java @@ -224,7 +224,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo if (cannotBeDynamic || shouldHighlightAsUnresolved(ref)) { HighlightInfo info = createAnnotationForRef(ref, cannotBeDynamic, GroovyBundle.message("cannot.resolve", ref.getReferenceName())); - LOG.assertTrue(info != null); + if (info == null) return null; HighlightDisplayKey displayKey = HighlightDisplayKey.find(SHORT_NAME); if (ref.getParent() instanceof GrMethodCall) { From 26a7aa8fa9c94b80d4b52850528687fca896fb93 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Fri, 1 Mar 2013 16:49:07 +0400 Subject: [PATCH 7/7] Make key Java attributes depend on Language Defaults (CR-24) --- .../editor/colors/TextAttributesKey.java | 4 +- .../editor/SyntaxHighlighterColors.java | 50 ++++--- .../src/DefaultColorSchemesManager.xml | 137 ------------------ 3 files changed, 36 insertions(+), 155 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/editor/colors/TextAttributesKey.java b/platform/core-api/src/com/intellij/openapi/editor/colors/TextAttributesKey.java index 9c24635699a8..721f51ed7f0c 100644 --- a/platform/core-api/src/com/intellij/openapi/editor/colors/TextAttributesKey.java +++ b/platform/core-api/src/com/intellij/openapi/editor/colors/TextAttributesKey.java @@ -110,12 +110,14 @@ public final class TextAttributesKey implements Comparable, J */ public TextAttributes getDefaultAttributes() { if (myDefaultAttributes == NULL_ATTRIBUTES) { - // E.g. if one text key reuse default attributes of some other predefined key myDefaultAttributes = null; final TextAttributeKeyDefaultsProvider provider = ourDefaultsProvider.getValue(); if (provider != null) myDefaultAttributes = provider.getDefaultAttributes(this); } + else if (myDefaultAttributes == null) { + myDefaultAttributes = NULL_ATTRIBUTES; + } return myDefaultAttributes; } diff --git a/platform/lang-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java b/platform/lang-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java index 248a994459d7..fe4ee2a70a72 100644 --- a/platform/lang-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java +++ b/platform/lang-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java @@ -23,21 +23,37 @@ import com.intellij.openapi.editor.colors.TextAttributesKey; * @deprecated Use DefaultLanguageHighlighterColors to inherit default attributes. */ public class SyntaxHighlighterColors { - public static final TextAttributesKey LINE_COMMENT = TextAttributesKey.createTextAttributesKey("JAVA_LINE_COMMENT"); - public static final TextAttributesKey JAVA_BLOCK_COMMENT = TextAttributesKey.createTextAttributesKey("JAVA_BLOCK_COMMENT"); - public static final TextAttributesKey DOC_COMMENT = TextAttributesKey.createTextAttributesKey("JAVA_DOC_COMMENT"); - public static final TextAttributesKey KEYWORD = TextAttributesKey.createTextAttributesKey("JAVA_KEYWORD"); - public static final TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("JAVA_NUMBER"); - public static final TextAttributesKey STRING = TextAttributesKey.createTextAttributesKey("JAVA_STRING"); - public static final TextAttributesKey OPERATION_SIGN = TextAttributesKey.createTextAttributesKey("JAVA_OPERATION_SIGN"); - public static final TextAttributesKey PARENTHS = TextAttributesKey.createTextAttributesKey("JAVA_PARENTH"); - public static final TextAttributesKey BRACKETS = TextAttributesKey.createTextAttributesKey("JAVA_BRACKETS"); - public static final TextAttributesKey BRACES = TextAttributesKey.createTextAttributesKey("JAVA_BRACES"); - public static final TextAttributesKey COMMA = TextAttributesKey.createTextAttributesKey("JAVA_COMMA"); - public static final TextAttributesKey DOT = TextAttributesKey.createTextAttributesKey("JAVA_DOT"); - public static final TextAttributesKey JAVA_SEMICOLON = TextAttributesKey.createTextAttributesKey("JAVA_SEMICOLON"); - public static final TextAttributesKey DOC_COMMENT_TAG = TextAttributesKey.createTextAttributesKey("JAVA_DOC_TAG"); - public static final TextAttributesKey DOC_COMMENT_MARKUP = TextAttributesKey.createTextAttributesKey("JAVA_DOC_MARKUP"); - public static final TextAttributesKey VALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey("JAVA_VALID_STRING_ESCAPE"); - public static final TextAttributesKey INVALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey("JAVA_INVALID_STRING_ESCAPE"); + public static final TextAttributesKey LINE_COMMENT = + TextAttributesKey.createTextAttributesKey("JAVA_LINE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); + public static final TextAttributesKey JAVA_BLOCK_COMMENT = + TextAttributesKey.createTextAttributesKey("JAVA_BLOCK_COMMENT", DefaultLanguageHighlighterColors.BLOCK_COMMENT); + public static final TextAttributesKey DOC_COMMENT = + TextAttributesKey.createTextAttributesKey("JAVA_DOC_COMMENT", DefaultLanguageHighlighterColors.DOC_COMMENT); + public static final TextAttributesKey KEYWORD = + TextAttributesKey.createTextAttributesKey("JAVA_KEYWORD", DefaultLanguageHighlighterColors.KEYWORD); + public static final TextAttributesKey NUMBER = + TextAttributesKey.createTextAttributesKey("JAVA_NUMBER", DefaultLanguageHighlighterColors.NUMBER); + public static final TextAttributesKey STRING = + TextAttributesKey.createTextAttributesKey("JAVA_STRING", DefaultLanguageHighlighterColors.STRING); + public static final TextAttributesKey OPERATION_SIGN = + TextAttributesKey.createTextAttributesKey("JAVA_OPERATION_SIGN", DefaultLanguageHighlighterColors.OPERATION_SIGN); + public static final TextAttributesKey PARENTHS = + TextAttributesKey.createTextAttributesKey("JAVA_PARENTH", DefaultLanguageHighlighterColors.PARENTHESES); + public static final TextAttributesKey BRACKETS = + TextAttributesKey.createTextAttributesKey("JAVA_BRACKETS", DefaultLanguageHighlighterColors.BRACKETS); + public static final TextAttributesKey BRACES = + TextAttributesKey.createTextAttributesKey("JAVA_BRACES", DefaultLanguageHighlighterColors.BRACES); + public static final TextAttributesKey COMMA = + TextAttributesKey.createTextAttributesKey("JAVA_COMMA", DefaultLanguageHighlighterColors.COMMA); + public static final TextAttributesKey DOT = TextAttributesKey.createTextAttributesKey("JAVA_DOT", DefaultLanguageHighlighterColors.DOT); + public static final TextAttributesKey JAVA_SEMICOLON = + TextAttributesKey.createTextAttributesKey("JAVA_SEMICOLON", DefaultLanguageHighlighterColors.SEMICOLON); + public static final TextAttributesKey DOC_COMMENT_TAG = + TextAttributesKey.createTextAttributesKey("JAVA_DOC_TAG", DefaultLanguageHighlighterColors.DOC_COMMENT_TAG); + public static final TextAttributesKey DOC_COMMENT_MARKUP = + TextAttributesKey.createTextAttributesKey("JAVA_DOC_MARKUP", DefaultLanguageHighlighterColors.DOC_COMMENT_MARKUP); + public static final TextAttributesKey VALID_STRING_ESCAPE = + TextAttributesKey.createTextAttributesKey("JAVA_VALID_STRING_ESCAPE", DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE); + public static final TextAttributesKey INVALID_STRING_ESCAPE = + TextAttributesKey.createTextAttributesKey("JAVA_INVALID_STRING_ESCAPE", DefaultLanguageHighlighterColors.INVALID_STRING_ESCAPE); } diff --git a/platform/platform-resources/src/DefaultColorSchemesManager.xml b/platform/platform-resources/src/DefaultColorSchemesManager.xml index e7fb5070a869..8e08ee1404f7 100644 --- a/platform/platform-resources/src/DefaultColorSchemesManager.xml +++ b/platform/platform-resources/src/DefaultColorSchemesManager.xml @@ -189,78 +189,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -