Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2014-08-12 20:58:23 +02:00
93 changed files with 825 additions and 499 deletions
+6 -6
View File
@@ -553,9 +553,9 @@
</option>
<option name="ERRORS_ATTRIBUTES">
<value>
<option name="EFFECT_COLOR" value="dc3737" />
<option name="EFFECT_COLOR" value="bc3f3c" />
<option name="EFFECT_TYPE" value="2" />
<option name="ERROR_STRIPE_COLOR" value="dc3737" />
<option name="ERROR_STRIPE_COLOR" value="bc3f3c" />
</value>
</option>
<option name="EXECUTIONPOINT_ATTRIBUTES">
@@ -578,9 +578,9 @@
</option>
<option name="GENERIC_SERVER_ERROR_OR_WARNING">
<value>
<option name="EFFECT_COLOR" value="fa8c00" />
<option name="EFFECT_COLOR" value="f49810" />
<option name="EFFECT_TYPE" value="1" />
<option name="ERROR_STRIPE_COLOR" value="fa8c00" />
<option name="ERROR_STRIPE_COLOR" value="f49810" />
</value>
</option>
<option name="GRADLE_CHANGE_CONFLICT">
@@ -1565,9 +1565,9 @@
</option>
<option name="WARNING_ATTRIBUTES">
<value>
<option name="BACKGROUND" value="ffd900" />
<option name="BACKGROUND" value="52503a" />
<option name="EFFECT_TYPE" value="2" />
<option name="ERROR_STRIPE_COLOR" value="ffd900" />
<option name="ERROR_STRIPE_COLOR" value="8c8c00" />
</value>
</option>
<option name="WRITE_IDENTIFIER_UNDER_CARET_ATTRIBUTES">
@@ -24,6 +24,7 @@ import com.intellij.debugger.ui.breakpoints.BreakpointManager;
import com.intellij.execution.ExecutionException;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
@@ -42,5 +43,6 @@ public abstract class DebuggerManagerEx extends DebuggerManager {
public abstract void addDebuggerManagerListener(DebuggerManagerListener debuggerManagerListener);
public abstract void removeDebuggerManagerListener(DebuggerManagerListener debuggerManagerListener);
@Nullable
public abstract DebuggerSession attachVirtualMachine(@NotNull DebugEnvironment environment) throws ExecutionException;
}
@@ -44,10 +44,7 @@ public class DefaultDebugUIEnvironment implements DebugUIEnvironment {
RemoteConnection remoteConnection,
boolean pollConnection) {
myExecutionEnvironment = environment;
myModelEnvironment = new DefaultDebugEnvironment(environment,
state,
remoteConnection,
pollConnection);
myModelEnvironment = new DefaultDebugEnvironment(environment, state, remoteConnection, pollConnection);
}
@Override
@@ -205,6 +205,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
@Override
@Nullable
public DebuggerSession attachVirtualMachine(@NotNull DebugEnvironment environment) throws ExecutionException {
ApplicationManager.getApplication().assertIsDispatchThread();
final DebugProcessEvents debugProcess = new DebugProcessEvents(myProject);
@@ -282,7 +283,6 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
return session;
}
@Override
public DebugProcessImpl getDebugProcess(final ProcessHandler processHandler) {
synchronized (mySessions) {
@@ -59,56 +59,43 @@ public class GenericDebuggerRunner extends JavaPatchableProgramRunner<GenericDeb
}
@Override
protected RunContentDescriptor doExecute(@NotNull final Project project,
@NotNull final RunProfileState state,
final RunContentDescriptor contentToReuse,
@NotNull final ExecutionEnvironment env) throws ExecutionException {
protected RunContentDescriptor doExecute(@NotNull Project project,
@NotNull RunProfileState state,
@Nullable RunContentDescriptor contentToReuse,
@NotNull ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
return createContentDescriptor(project, state, contentToReuse, env);
return createContentDescriptor(state, contentToReuse == null || env.getContentToReuse() == contentToReuse
? env
: new ExecutionEnvironmentBuilder(env).contentToReuse(contentToReuse).build());
}
@Nullable
protected RunContentDescriptor createContentDescriptor(Project project, RunProfileState state,
RunContentDescriptor contentToReuse,
ExecutionEnvironment environment) throws ExecutionException {
environment = ExecutionEnvironmentBuilder.fix(environment, contentToReuse);
protected RunContentDescriptor createContentDescriptor(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
if (state instanceof JavaCommandLine) {
final JavaParameters parameters = ((JavaCommandLine)state).getJavaParameters();
runCustomPatchers(parameters, environment.getExecutor(), environment.getRunProfile());
RemoteConnection connection = DebuggerManagerImpl.createDebugParameters(parameters, true, DebuggerSettings.getInstance().DEBUGGER_TRANSPORT, "", false);
return attachVirtualMachine(project, state, environment, connection, true);
return attachVirtualMachine(state, environment, connection, true);
}
if (state instanceof PatchedRunnableState) {
final RemoteConnection connection = doPatch(new JavaParameters(), environment.getRunnerSettings());
return attachVirtualMachine(project, state, environment, connection, true);
return attachVirtualMachine(state, environment, connection, true);
}
if (state instanceof RemoteState) {
final RemoteConnection connection = createRemoteDebugConnection((RemoteState)state, environment.getRunnerSettings());
return attachVirtualMachine(project, state, environment, connection, false);
return attachVirtualMachine(state, environment, connection, false);
}
return null;
}
@Nullable
@Deprecated
protected RunContentDescriptor attachVirtualMachine(@NotNull Project project,
RunProfileState state,
RunContentDescriptor contentToReuse,
ExecutionEnvironment environment,
RemoteConnection connection,
boolean pollConnection) throws ExecutionException {
return attachVirtualMachine(project, state, ExecutionEnvironmentBuilder.fix(environment, contentToReuse), connection, pollConnection);
}
@Nullable
protected RunContentDescriptor attachVirtualMachine(@NotNull Project project,
RunProfileState state,
ExecutionEnvironment env,
protected RunContentDescriptor attachVirtualMachine(RunProfileState state,
@NotNull ExecutionEnvironment env,
RemoteConnection connection,
boolean pollConnection) throws ExecutionException {
DebugEnvironment environment = new DefaultDebugUIEnvironment(env, state, connection, pollConnection).getEnvironment();
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(project).attachVirtualMachine(environment);
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
if (debuggerSession == null) {
return null;
}
@@ -124,7 +111,7 @@ public class GenericDebuggerRunner extends JavaPatchableProgramRunner<GenericDeb
debugProcess.putUserData(BatchEvaluator.REMOTE_SESSION_KEY, Boolean.TRUE);
}
return XDebuggerManager.getInstance(project).startSession(env, new XDebugProcessStarter() {
return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull XDebugSession session) {
@@ -108,13 +108,11 @@ public class DebuggerPanelsManager implements ProjectComponent {
RunContentDescriptor reuseContent,
RemoteConnection remoteConnection,
boolean pollConnection) throws ExecutionException {
if (executor != environment.getExecutor()) {
// fix invalid environment
environment = new ExecutionEnvironmentBuilder(environment).executor(executor).build();
}
environment = ExecutionEnvironmentBuilder.fix(environment, runner);
environment = ExecutionEnvironmentBuilder.fix(environment, reuseContent);
return attachVirtualMachine(environment, state, remoteConnection, pollConnection);
return attachVirtualMachine(new ExecutionEnvironmentBuilder(environment)
.executor(executor)
.runner(runner)
.contentToReuse(reuseContent)
.build(), state, remoteConnection, pollConnection);
}
@Nullable
@@ -72,7 +72,7 @@ import javax.swing.tree.TreePath;
import java.util.List;
public class DebuggerSessionTab extends DebuggerSessionTabBase implements Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.DebuggerSessionTab");
private static final Logger LOG = Logger.getInstance(DebuggerSessionTab.class);
private final VariablesPanel myVariablesPanel;
private final MainWatchPanel myWatchPanel;
@@ -90,6 +90,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
public DebuggerSessionTab(final Project project, final String sessionName, @NotNull final DebugUIEnvironment environment,
@NotNull DebuggerSession debuggerSession) {
super(project, "JavaDebugger", sessionName, debuggerSession.getSearchScope());
myDebuggerSession = debuggerSession;
myDebugUIEnvironment = environment;
@@ -129,11 +130,9 @@ 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());
final AlertIcon breakpointAlert = new AlertIcon(AllIcons.Debugger.BreakpointAlert);
// watches
@@ -348,7 +347,6 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
if (action != null) group.add(action);
}
@Override
public void dispose() {
disposeSession();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,6 +72,7 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator {
onChange();
}
@NotNull
public ValidationResult check() {
if (myRequiredLibraries == null) {
return ValidationResult.OK;
@@ -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.
@@ -27,6 +27,7 @@ import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescri
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
import com.intellij.openapi.util.Ref;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Set;
@@ -50,6 +51,7 @@ public class FrameworkLibraryValidatorImpl extends FrameworkLibraryValidator {
myLibraryCategoryName = libraryCategoryName;
}
@NotNull
@Override
public ValidationResult check() {
final Set<? extends LibraryKind> libraryKinds = myLibraryDescription.getSuitableLibraryKinds();
@@ -541,8 +541,17 @@ public class RedundantCastUtil {
}
}
}
if (parent instanceof PsiInstanceOfExpression || (TypeConversionUtil.isAssignable(castTo, opType, false) &&
(expectedTypeByParent == null || TypeConversionUtil.isAssignable(expectedTypeByParent, opType, false)))) {
if (parent instanceof PsiInstanceOfExpression) {
//15.20.2. Type Comparison Operator instanceof:
//If a cast (§15.16) of the RelationalExpression to the ReferenceType would be rejected as a compile-time error,
//then the instanceof relational expression likewise produces a compile-time error.
final PsiTypeElement checkTypeElement = ((PsiInstanceOfExpression)parent).getCheckType();
if (checkTypeElement != null && TypeConversionUtil.areTypesConvertible(opType, checkTypeElement.getType())) {
addToResults(typeCast);
}
}
else if (TypeConversionUtil.isAssignable(castTo, opType, false) &&
(expectedTypeByParent == null || TypeConversionUtil.isAssignable(expectedTypeByParent, opType, false))) {
addToResults(typeCast);
}
}
@@ -27,6 +27,7 @@ import com.intellij.psi.util.*;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.Function;
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -220,8 +221,9 @@ public class InferenceSession {
return prepareSubstitution();
}
if (parameters != null && args != null && !MethodCandidateInfo.isOverloadCheck()) {
final Set<ConstraintFormula> additionalConstraints = new HashSet<ConstraintFormula>();
if (parameters != null && args != null &&
!MethodCandidateInfo.ourOverloadGuard.currentStack().contains(PsiUtil.skipParenthesizedExprUp(parent.getParent()))) {
final Set<ConstraintFormula> additionalConstraints = new LinkedHashSet<ConstraintFormula>();
if (parameters.length > 0) {
collectAdditionalConstraints(parameters, args, properties.getMethod(), PsiSubstitutor.EMPTY, additionalConstraints, properties.isVarargs(), true);
}
@@ -881,7 +883,7 @@ public class InferenceSession {
private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints) {
final Set<ConstraintFormula> subset = new HashSet<ConstraintFormula>();
final Set<ConstraintFormula> subset = new LinkedHashSet<ConstraintFormula>();
final Set<InferenceVariable> outputVariables = new HashSet<InferenceVariable>();
for (ConstraintFormula constraint : additionalConstraints) {
if (constraint instanceof InputOutputConstraintFormula) {
@@ -899,8 +901,19 @@ public class InferenceSession {
if (inputVariables != null) {
boolean dependsOnOutput = false;
for (InferenceVariable inputVariable : inputVariables) {
if (dependsOnOutput) break;
if (inputVariable.hasInstantiation(this)) continue;
final Set<InferenceVariable> dependencies = inputVariable.getDependencies(this);
dependencies.add(inputVariable);
if (!hasCapture(inputVariable)) {
for (InferenceVariable outputVariable : outputVariables) {
if (ContainerUtil.intersects(outputVariable.getDependencies(this), dependencies)) {
dependsOnOutput = true;
break;
}
}
}
dependencies.retainAll(outputVariables);
if (!dependencies.isEmpty()) {
dependsOnOutput = true;
@@ -115,6 +115,16 @@ public class InferenceVariable extends LightTypeParameter {
return dependencies;
}
public boolean hasInstantiation(InferenceSession session) {
List<PsiType> bounds = getBounds(InferenceBound.EQ);
if (bounds != null) {
for (PsiType bound : bounds) {
if (session.isProperType(bound)) return true;
}
}
return false;
}
public boolean isThrownBound() {
return myThrownBound;
}
@@ -92,7 +92,7 @@ public class PsiConditionalExpressionImpl extends ExpressionPsiElement implement
if (PsiUtil.isLanguageLevel8OrHigher(this) &&
PsiPolyExpressionUtil.isPolyExpression(this) &&
!MethodCandidateInfo.ourOverloadGuard.currentStack().contains(this.getParent())) {
!MethodCandidateInfo.ourOverloadGuard.currentStack().contains(PsiUtil.skipParenthesizedExprUp(this.getParent()))) {
//15.25.3 Reference Conditional Expressions
// The type of a poly reference conditional expression is the same as its target type.
return InferenceSession.getTargetType(this);
@@ -0,0 +1,13 @@
@SuppressWarnings({"UnusedDeclaration"})
class C {
boolean foo(final ConfigurableField<String> nameField) {
return (Formatter<?>)nameField.getFormatter() instanceof DefaultFormatter;
}
}
@SuppressWarnings({"UnusedDeclaration"})
interface Formatter<V>{}
class DefaultFormatter implements Formatter<Object>{}
interface ConfigurableField<V> {
Formatter<V> getFormatter();
}
@@ -0,0 +1,12 @@
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
class Main {
void bar(final Stream<Object> objectStream) {
foo(objectStream.map(o -> "str").collect(toList()));
}
void foo(Iterable<?> k){}
void foo(String s){}
}
@@ -0,0 +1,30 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
class Test {
private static class Thing {
final String val;
public Thing(String val) {
this.val = val;
}
}
public static Optional<List<String>> highlights() {
return Optional.of(Collections.singletonList(new Thing("Hello")))
.map(l -> l
.stream()
.map(t -> t.val + " world!")
.collect(Collectors.toList()));
}
public static Optional<List<String>> works() {
return Optional.of(Collections.singletonList(new Thing("Hello")))
.map(l -> l
.stream()
.map(t -> t.val + " world!")
.collect(Collectors.toList()));
}
}
@@ -145,6 +145,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
public void testPreciseRethrow() { doTest(false, false); }
public void testImprovedCatchAnalysis() { doTest(true, false); }
public void testPolymorphicTypeCast() { doTest(true, false); }
public void testTypeCastInInstanceof() { doTest(true, false); }
public void testErasureClashConfusion() { doTest(true, false, UnusedDeclarationInspection.class); }
public void testUnused() { doTest(true, false, UnusedDeclarationInspection.class); }
public void testSuperBound() { doTest(false, false); }
@@ -16,11 +16,14 @@
package com.intellij.codeInsight.daemon.lambda;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.idea.Bombed;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import java.util.Calendar;
public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase {
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/graphInference";
@@ -44,10 +47,12 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
@Bombed(day = 20, month = Calendar.AUGUST)
public void testInferenceFromSiblings() throws Exception {
doTest();
}
@Bombed(day = 20, month = Calendar.AUGUST)
public void testChainedInferenceTypeParamsOrderIndependent() throws Exception {
doTest();
}
@@ -92,6 +92,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA124961() { doTest(); }
public void testIDEA126109() { doTest(); }
public void testIDEA126809() { doTest(); }
public void testIDEA124424() { doTest(); }
public void testIDEA127596() throws Exception {
doTest();
@@ -102,7 +103,6 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
@Bombed(day = 20, month = Calendar.AUGUST)
public void testIDEA123951() throws Exception {
doTest();
}
@@ -110,6 +110,9 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA124190() throws Exception {
doTest();
}
public void testIDEA127124comment() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
@@ -670,6 +670,18 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
assertTrue(findResult.getStartOffset() > prefix.length());
}
public void testFindExceptComments2() {
FindModel findModel = FindManagerTestUtils.configureFindModel("oo");
String text = "//oooo";
findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS);
LightVirtualFile file = new LightVirtualFile("A.java", text);
FindResult findResult = myFindManager.findString(text, 0, findModel, file);
assertFalse(findResult.isStringFound());
}
public void testFindExceptLiterals() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
@@ -38,7 +38,7 @@ public class HighlightDisplayLevel {
createIconByMask(CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING));
public static final HighlightDisplayLevel ERROR = new HighlightDisplayLevel(HighlightSeverity.ERROR, createIconByMask(CodeInsightColors.ERRORS_ATTRIBUTES));
public static final HighlightDisplayLevel WARNING = new HighlightDisplayLevel(HighlightSeverity.WARNING, createIconByMask(CodeInsightColors.WARNINGS_ATTRIBUTES));
public static final HighlightDisplayLevel DO_NOT_SHOW = new HighlightDisplayLevel(HighlightSeverity.INFORMATION, createIconByMask(new Color(110, 180, 65)));
public static final HighlightDisplayLevel DO_NOT_SHOW = new HighlightDisplayLevel(HighlightSeverity.INFORMATION, createIconByMask(new Color(30, 160, 0)));
/**
* use #WEAK_WARNING instead
*/
@@ -17,12 +17,12 @@ package com.intellij.psi.search.scope;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.NonPhysicalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.search.scope.packageSet.AbstractPackageSet;
import com.intellij.psi.search.scope.packageSet.NamedScope;
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.ui.Colored;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
@@ -45,7 +45,7 @@ public class NonProjectFilesScope extends NamedScope {
@Override
public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) {
// do not include fake-files e.g. fragment-editors, database consoles, etc.
if (file == null || file instanceof LightVirtualFile) return false;
if (file == null || file.getFileSystem() instanceof NonPhysicalFileSystem) return false;
if (!file.isInLocalFileSystem()) return true;
if (isInsideProjectContent(project, file)) return false;
return !ProjectScope.getProjectScope(project).contains(file);
@@ -87,7 +87,7 @@ public class PsiElementResolveResult implements ResolveResult{
}
@NotNull
public static ResolveResult[] createResults(@Nullable PsiElement[] elements) {
public static ResolveResult[] createResults(@Nullable PsiElement... elements) {
if (elements == null || elements.length == 0) return EMPTY_ARRAY;
final ResolveResult[] results = new ResolveResult[elements.length];
@@ -63,6 +63,10 @@ public abstract class PsiFileFactory {
public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text);
public PsiFile createFileFromText(@NotNull Language language, @NotNull CharSequence text) {
return createFileFromText("foo.bar", language, text);
}
public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text,
boolean eventSystemEnabled, boolean markAsCopy);
@@ -19,10 +19,7 @@ import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.CharsetUtil;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.openapi.vfs.*;
import com.intellij.util.LocalTimeCounter;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -113,7 +110,7 @@ public class LightVirtualFile extends VirtualFile {
myOriginalFile = originalFile;
}
private static class MyVirtualFileSystem extends DeprecatedVirtualFileSystem {
private static class MyVirtualFileSystem extends DeprecatedVirtualFileSystem implements NonPhysicalFileSystem{
@NonNls private static final String PROTOCOL = "mock";
private MyVirtualFileSystem() {
@@ -41,7 +41,6 @@ public class LoadingTreeNode extends DefaultMutableTreeNode implements CustomRen
myLoadingIcon = new ImageIcon(loadingIconPath.getPath());
}
@Override
public void render(@NotNull ColoredTreeCellRenderer renderer) {
renderer.setIcon(myLoadingIcon);
@@ -0,0 +1,22 @@
/*
* 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.openapi.actionSystem;
/**
* @author Konstantin Bulenkov
*/
public interface RightAlignedToolbarAction {
}
@@ -25,7 +25,6 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,8 +33,7 @@ import org.jetbrains.annotations.Nullable;
* @since 6/7/13 11:18 AM
*/
public class ExternalSystemTaskDebugRunner extends GenericDebuggerRunner {
private static final Logger LOG = Logger.getInstance("#" + ExternalSystemTaskDebugRunner.class.getName());
private static final Logger LOG = Logger.getInstance(ExternalSystemTaskDebugRunner.class);
@NotNull
@Override
@@ -50,16 +48,12 @@ public class ExternalSystemTaskDebugRunner extends GenericDebuggerRunner {
@Nullable
@Override
protected RunContentDescriptor createContentDescriptor(Project project,
RunProfileState state,
RunContentDescriptor contentToReuse,
ExecutionEnvironment environment) throws ExecutionException
{
protected RunContentDescriptor createContentDescriptor(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
if (state instanceof ExternalSystemRunConfiguration.MyRunnableState) {
int port = ((ExternalSystemRunConfiguration.MyRunnableState)state).getDebugPort();
if (port > 0) {
RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", String.valueOf(port), true);
return attachVirtualMachine(project, state, contentToReuse, environment, connection, true);
return attachVirtualMachine(state, environment, connection, true);
}
else {
LOG.warn("Can't attach debugger to external system task execution. Reason: target debug port is unknown");
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

@@ -38,7 +38,7 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.intellij.openapi.actionSystem.LangDataKeys.*;
public class ExecutionEnvironment extends UserDataHolderBase {
public class ExecutionEnvironment extends UserDataHolderBase implements Disposable {
private static final AtomicLong myIdHolder = new AtomicLong(1L);
@NotNull private final Project myProject;
@@ -52,7 +52,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
@Nullable private final RunnerAndConfigurationSettings myRunnerAndConfigurationSettings;
@Nullable private RunContentDescriptor myContentToReuse;
@Nullable private String myRunnerId;
@Nullable final ProgramRunner<?> runner;
@Nullable final ProgramRunner<?> myRunner;
private long myExecutionId = 0;
@Nullable private DataContext myDataContext;
@@ -62,7 +62,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
myContentToReuse = null;
myRunnerAndConfigurationSettings = null;
myExecutor = null;
runner = null;
myRunner = null;
}
public ExecutionEnvironment(@NotNull Executor executor,
@@ -133,20 +133,16 @@ public class ExecutionEnvironment extends UserDataHolderBase {
myRunnerSettings = runnerSettings;
myConfigurationSettings = configurationSettings;
myProject = project;
myContentToReuse = contentToReuse;
setContentToReuse(contentToReuse);
myRunnerAndConfigurationSettings = settings;
this.runner = runner;
myRunner = runner;
myRunnerId = runner == null ? runnerId : runner.getRunnerId();
}
if (myContentToReuse != null) {
Disposer.register(myContentToReuse, new Disposable() {
@Override
public void dispose() {
myContentToReuse = null;
}
});
}
@Override
public void dispose() {
myContentToReuse = null;
}
@NotNull
@@ -174,6 +170,14 @@ public class ExecutionEnvironment extends UserDataHolderBase {
return myContentToReuse;
}
public void setContentToReuse(@Nullable RunContentDescriptor contentToReuse) {
myContentToReuse = contentToReuse;
if (contentToReuse != null) {
Disposer.register(contentToReuse, this);
}
}
@Nullable
public String getRunnerId() {
return myRunnerId;
@@ -181,7 +185,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
@Nullable
public ProgramRunner<?> getRunner() {
return runner == null ? RunnerRegistry.getInstance().findRunnerById(getRunnerId()) : runner;
return myRunner == null ? RunnerRegistry.getInstance().findRunnerById(getRunnerId()) : myRunner;
}
@Nullable
@@ -39,7 +39,7 @@ public final class ExecutionEnvironmentBuilder {
@Nullable private RunContentDescriptor myContentToReuse;
@Nullable private RunnerAndConfigurationSettings myRunnerAndConfigurationSettings;
@Nullable private String myRunnerId;
private ProgramRunner<?> runner;
private ProgramRunner<?> myRunner;
private boolean myAssignNewId;
@NotNull private Executor myExecutor;
@Nullable private DataContext myDataContext;
@@ -61,7 +61,7 @@ public final class ExecutionEnvironmentBuilder {
@NotNull
public static ExecutionEnvironmentBuilder create(@NotNull Executor executor, @NotNull RunnerAndConfigurationSettings settings) throws ExecutionException {
ExecutionEnvironmentBuilder builder = create(settings.getConfiguration().getProject(), executor, settings.getConfiguration());
return builder.runnerAndSettings(builder.runner, settings);
return builder.runnerAndSettings(builder.myRunner, settings);
}
@NotNull
@@ -82,31 +82,11 @@ public final class ExecutionEnvironmentBuilder {
myRunnerSettings = copySource.getRunnerSettings();
myConfigurationSettings = copySource.getConfigurationSettings();
myRunnerId = copySource.getRunnerId();
runner = copySource.runner;
myRunner = copySource.myRunner;
myContentToReuse = copySource.getContentToReuse();
myExecutor = copySource.getExecutor();
}
@NotNull
public static ExecutionEnvironment fix(@NotNull ExecutionEnvironment environment, @Nullable RunContentDescriptor contentToReuse) {
if (contentToReuse == null || environment.getContentToReuse() == contentToReuse) {
return environment;
}
else {
return new ExecutionEnvironmentBuilder(environment).contentToReuse(contentToReuse).build();
}
}
@NotNull
public static ExecutionEnvironment fix(@NotNull ExecutionEnvironment environment, @Nullable ProgramRunner runner) {
if (runner == null || runner.getRunnerId().equals(environment.getRunnerId())) {
return environment;
}
else {
return new ExecutionEnvironmentBuilder(environment).runner(runner).build();
}
}
@SuppressWarnings("UnusedDeclaration")
@Deprecated
/**
@@ -144,7 +124,7 @@ public final class ExecutionEnvironmentBuilder {
myRunProfile = settings.getConfiguration();
myRunnerSettings = settings.getRunnerSettings(runner);
myConfigurationSettings = settings.getConfigurationSettings(runner);
this.runner = runner;
myRunner = runner;
return this;
}
@@ -208,7 +188,7 @@ public final class ExecutionEnvironmentBuilder {
}
public ExecutionEnvironmentBuilder runner(@NotNull ProgramRunner<?> runner) {
this.runner = runner;
myRunner = runner;
return this;
}
@@ -247,12 +227,12 @@ public final class ExecutionEnvironmentBuilder {
@NotNull
public ExecutionEnvironment build() {
if (runner == null && myRunnerId == null) {
runner = RunnerRegistry.getInstance().getRunner(myExecutor.getId(), myRunProfile);
if (myRunner == null && myRunnerId == null) {
myRunner = RunnerRegistry.getInstance().getRunner(myExecutor.getId(), myRunProfile);
}
ExecutionEnvironment environment = new ExecutionEnvironment(myRunProfile, myExecutor, myTarget, myProject, myRunnerSettings, myConfigurationSettings, myContentToReuse,
myRunnerAndConfigurationSettings, myRunnerId, runner);
myRunnerAndConfigurationSettings, myRunnerId, myRunner);
if (myAssignNewId) {
environment.assignNewExecutionId();
}
@@ -19,7 +19,6 @@ package com.intellij.execution.runners;
import com.intellij.execution.*;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.process.ProcessNotCreatedException;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationListener;
@@ -113,12 +112,8 @@ public class ExecutionUtil {
}
public static void restart(@NotNull ExecutionEnvironment environment) {
restart(environment, null);
}
public static void restart(@NotNull ExecutionEnvironment environment, @Nullable RunContentDescriptor contentDescriptor) {
if (!ExecutorRegistry.getInstance().isStarting(environment)) {
ExecutionManager.getInstance(environment.getProject()).restartRunProfile(ExecutionEnvironmentBuilder.fix(environment, contentDescriptor));
ExecutionManager.getInstance(environment.getProject()).restartRunProfile(environment);
}
}
@@ -39,9 +39,11 @@ public interface RunContentManager {
@NotNull
List<RunContentDescriptor> getAllDescriptors();
/**
* to reduce number of open contents RunContentManager reuses
* some of them during showRunContent (for ex. if a process was stopped)
* some of them during showRunContent (for ex. if a process was stopped)
*
* @return content that will be reused by showRunContent
* @deprecated use {@link #getReuseContent(com.intellij.execution.Executor, ExecutionEnvironment)}
*/
@@ -68,15 +70,20 @@ public interface RunContentManager {
@Nullable
RunContentDescriptor findContentDescriptor(Executor requestor, ProcessHandler handler);
void showRunContent(@NotNull Executor executor, RunContentDescriptor descriptor, RunContentDescriptor contentToReuse);
void showRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
void showRunContent(@NotNull Executor executor, @NotNull RunContentDescriptor descriptor, @Nullable RunContentDescriptor contentToReuse);
void showRunContent(@NotNull Executor executor, @NotNull RunContentDescriptor descriptor);
void hideRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
boolean removeRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
void toFrontRunContent(Executor requestor, RunContentDescriptor descriptor);
void toFrontRunContent(Executor requestor, ProcessHandler handler);
void addRunContentListener(RunContentListener listener);
void removeRunContentListener(RunContentListener listener);
void addRunContentListener(RunContentListener myContentListener, Executor executor);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.facet.ui;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public abstract class FacetEditorValidator {
@NotNull
public abstract ValidationResult check();
}
@@ -113,21 +113,20 @@ public class ProgramRunnerUtil {
public static void executeConfiguration(@NotNull Project project,
@NotNull RunnerAndConfigurationSettings configuration,
@NotNull Executor executor) {
ProgramRunner runner = getRunner(executor.getId(), configuration);
if (runner == null) {
LOG.error("Runner MUST not be null! Cannot find runner for " +
executor.getId() +
" and " +
configuration.getConfiguration().getFactory().getName());
ExecutionEnvironmentBuilder builder;
try {
builder = ExecutionEnvironmentBuilder.create(executor, configuration);
}
catch (ExecutionException e) {
LOG.error(e);
return;
}
ExecutionEnvironment environment = new ExecutionEnvironmentBuilder(project, executor)
.runnerAndSettings(runner, configuration)
.contentToReuse(null)
.dataContext(null)
.target(ExecutionTargetManager.getActiveTarget(project))
.build();
executeConfiguration(environment, true, true);
executeConfiguration(builder
.contentToReuse(null)
.dataContext(null)
.activeTarget()
.build(), true, true);
}
public static Icon getConfigurationIcon(final RunnerAndConfigurationSettings settings,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.execution.impl;
import com.intellij.CommonBundle;
@@ -42,6 +41,7 @@ import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Trinity;
@@ -51,12 +51,11 @@ import com.intellij.ui.docking.DockManager;
import com.intellij.util.Alarm;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Predicate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@@ -199,7 +198,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
@NotNull final RunProfileState state,
@NotNull final ExecutionEnvironment environment) {
final Project project = environment.getProject();
final RunContentDescriptor reuseContent = ExecutionManager.getInstance(project).getContentManager().getReuseContent(environment);
final RunContentDescriptor reuseContent = getContentManager().getReuseContent(environment);
if (reuseContent != null) {
reuseContent.setExecutionId(environment.getExecutionId());
}
@@ -220,8 +219,8 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStarting(executor.getId(), environment);
final RunContentDescriptor descriptor = starter.execute(project, executor, state, reuseContent, environment);
if (descriptor != null) {
environment.setContentToReuse(descriptor);
final Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor> trinity =
Trinity.create(descriptor, environment.getRunnerAndConfigurationSettings(), executor);
myRunningConfigurations.add(trinity);
@@ -231,7 +230,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
myRunningConfigurations.remove(trinity);
}
});
ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor, reuseContent);
getContentManager().showRunContent(executor, descriptor, reuseContent);
final ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null) {
if (!processHandler.isStartNotified()) {
@@ -325,53 +324,60 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
restartRunProfile(builder.build());
}
public static boolean isProcessRunning(@Nullable RunContentDescriptor descriptor) {
ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
return processHandler != null && !processHandler.isProcessTerminated();
}
@Override
public void restartRunProfile(@NotNull final ExecutionEnvironment environment) {
final List<RunContentDescriptor> runningConfigurationsOfTheSameType = new ArrayList<RunContentDescriptor>();
final List<RunContentDescriptor> runningIncompatibleConfigurations = new ArrayList<RunContentDescriptor>();
RunnerAndConfigurationSettings configuration = environment.getRunnerAndConfigurationSettings();
if (configuration != null) {
runningIncompatibleConfigurations.addAll(getIncompatibleRunningDescriptors(configuration));
List<RunContentDescriptor> runningIncompatible;
if (configuration == null) {
runningIncompatible = Collections.emptyList();
}
if (configuration != null && configuration.isSingleton()) {
runningConfigurationsOfTheSameType.addAll(getRunningDescriptorsOfTheSameConfigType(configuration));
}
else if (environment.getContentToReuse() != null) {
runningConfigurationsOfTheSameType.add(environment.getContentToReuse());
else {
runningIncompatible = getIncompatibleRunningDescriptors(configuration);
}
final List<RunContentDescriptor> runningConfigurationsToStop = ContainerUtil.concat(runningConfigurationsOfTheSameType,
runningIncompatibleConfigurations);
if (!runningConfigurationsToStop.isEmpty()) {
RunContentDescriptor contentToReuse = environment.getContentToReuse();
final List<RunContentDescriptor> runningOfTheSameType = new SmartList<RunContentDescriptor>();
if (configuration != null && configuration.isSingleton()) {
runningOfTheSameType.addAll(getRunningDescriptorsOfTheSameConfigType(configuration));
}
else if (isProcessRunning(contentToReuse)) {
runningOfTheSameType.add(contentToReuse);
}
List<RunContentDescriptor> runningToStop = ContainerUtil.concat(runningOfTheSameType, runningIncompatible);
if (!runningToStop.isEmpty()) {
if (configuration != null) {
if (!runningConfigurationsOfTheSameType.isEmpty()
&& (runningConfigurationsOfTheSameType.size() > 1 ||
environment.getContentToReuse() == null ||
runningConfigurationsOfTheSameType.get(0) != environment.getContentToReuse()) &&
!userApprovesStopForSameTypeConfigurations(environment.getProject(), configuration.getName(), runningConfigurationsOfTheSameType.size())) {
if (!runningOfTheSameType.isEmpty()
&& (runningOfTheSameType.size() > 1 || contentToReuse == null || runningOfTheSameType.get(0) != contentToReuse) &&
!userApprovesStopForSameTypeConfigurations(environment.getProject(), configuration.getName(), runningOfTheSameType.size())) {
return;
}
if (!runningIncompatibleConfigurations.isEmpty()
&& !userApprovesStopForIncompatibleConfigurations(myProject, configuration.getName(), runningIncompatibleConfigurations)) {
if (!runningIncompatible.isEmpty()
&& !userApprovesStopForIncompatibleConfigurations(myProject, configuration.getName(), runningIncompatible)) {
return;
}
}
for (RunContentDescriptor descriptor : runningConfigurationsToStop) {
for (RunContentDescriptor descriptor : runningToStop) {
stop(descriptor);
}
}
Runnable runnable = new Runnable() {
ProgramRunner runner = environment.getRunner();
awaitingTerminationAlarm.addRequest(new Runnable() {
@Override
public void run() {
if (runner != null && ExecutorRegistry.getInstance().isStarting(environment)) {
if (environment.getRunner() != null && ExecutorRegistry.getInstance().isStarting(environment)) {
awaitingTerminationAlarm.addRequest(this, 100);
return;
}
for (RunContentDescriptor descriptor : runningConfigurationsOfTheSameType) {
for (RunContentDescriptor descriptor : runningOfTheSameType) {
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null && !processHandler.isProcessTerminated()) {
awaitingTerminationAlarm.addRequest(this, 100);
@@ -380,25 +386,20 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
}
start(environment);
}
};
awaitingTerminationAlarm.addRequest(runnable, 50);
}, 50);
}
private static void start(@NotNull ExecutionEnvironment environment) {
if (environment.getRunner() != null) {
ProgramRunnerUtil.executeConfiguration(environment,
environment.getRunnerAndConfigurationSettings() != null && environment.getRunnerAndConfigurationSettings().isEditBeforeRun(),
false);
}
else if (environment.getRunnerAndConfigurationSettings() != null) {
ProgramRunnerUtil.executeConfiguration(environment, true, true);
}
else {
if (environment.getRunner() == null) {
Runnable restarter = environment.getContentToReuse() == null ? null : environment.getContentToReuse().getRestarter();
if (restarter != null) {
restarter.run();
}
}
else {
RunnerAndConfigurationSettings settings = environment.getRunnerAndConfigurationSettings();
ProgramRunnerUtil.executeConfiguration(environment, settings != null && settings.isEditBeforeRun(), true);
}
}
private static boolean userApprovesStopForSameTypeConfigurations(Project project, String configName, int instancesCount) {
@@ -498,35 +499,36 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
Messages.getQuestionIcon(), option) == Messages.OK;
}
private List<RunContentDescriptor> getRunningDescriptorsOfTheSameConfigType(
@NotNull final RunnerAndConfigurationSettings configurationAndSettings) {
return getRunningDescriptors(new Predicate<RunnerAndConfigurationSettings>() {
@NotNull
private List<RunContentDescriptor> getRunningDescriptorsOfTheSameConfigType(@NotNull final RunnerAndConfigurationSettings configurationAndSettings) {
return getRunningDescriptors(new Condition<RunnerAndConfigurationSettings>() {
@Override
public boolean apply(@Nullable RunnerAndConfigurationSettings runningConfigurationAndSettings) {
public boolean value(@Nullable RunnerAndConfigurationSettings runningConfigurationAndSettings) {
return configurationAndSettings == runningConfigurationAndSettings;
}
});
}
private List<RunContentDescriptor> getIncompatibleRunningDescriptors(
@NotNull final RunnerAndConfigurationSettings configurationAndSettings) {
@NotNull
private List<RunContentDescriptor> getIncompatibleRunningDescriptors(@NotNull RunnerAndConfigurationSettings configurationAndSettings) {
final RunConfiguration configurationToCheckCompatibility = configurationAndSettings.getConfiguration();
return getRunningDescriptors(new Predicate<RunnerAndConfigurationSettings>() {
return getRunningDescriptors(new Condition<RunnerAndConfigurationSettings>() {
@Override
public boolean apply(@Nullable RunnerAndConfigurationSettings runningConfigurationAndSettings) {
if (runningConfigurationAndSettings == null) return false;
RunConfiguration runningConfiguration = runningConfigurationAndSettings.getConfiguration();
if (runningConfiguration == null || !(runningConfiguration instanceof CompatibilityAwareRunProfile)) return false;
public boolean value(@Nullable RunnerAndConfigurationSettings runningConfigurationAndSettings) {
RunConfiguration runningConfiguration = runningConfigurationAndSettings == null ? null : runningConfigurationAndSettings.getConfiguration();
if (runningConfiguration == null || !(runningConfiguration instanceof CompatibilityAwareRunProfile)) {
return false;
}
return ((CompatibilityAwareRunProfile)runningConfiguration).mustBeStoppedToRun(configurationToCheckCompatibility);
}
});
}
private List<RunContentDescriptor> getRunningDescriptors(
Predicate<RunnerAndConfigurationSettings> condition) {
List<RunContentDescriptor> result = new ArrayList<RunContentDescriptor>();
@NotNull
private List<RunContentDescriptor> getRunningDescriptors(@NotNull Condition<RunnerAndConfigurationSettings> condition) {
List<RunContentDescriptor> result = new SmartList<RunContentDescriptor>();
for (Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor> trinity : myRunningConfigurations) {
if (condition.apply(trinity.getSecond())) {
if (condition.value(trinity.getSecond())) {
ProcessHandler processHandler = trinity.getFirst().getProcessHandler();
if (processHandler != null && !processHandler.isProcessTerminating() && !processHandler.isProcessTerminated()) {
result.add(trinity.getFirst());
@@ -536,21 +538,24 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
return result;
}
private static void stop(RunContentDescriptor runContentDescriptor) {
ProcessHandler processHandler = runContentDescriptor != null ? runContentDescriptor.getProcessHandler() : null;
private static void stop(@Nullable RunContentDescriptor descriptor) {
ProcessHandler processHandler = descriptor != null ? descriptor.getProcessHandler() : null;
if (processHandler == null) {
return;
}
if (processHandler instanceof KillableProcess && processHandler.isProcessTerminating()) {
((KillableProcess)processHandler).killProcess();
return;
}
if (processHandler.detachIsDefault()) {
processHandler.detachProcess();
}
else {
processHandler.destroyProcess();
if (!processHandler.isProcessTerminated()) {
if (processHandler.detachIsDefault()) {
processHandler.detachProcess();
}
else {
processHandler.destroyProcess();
}
}
}
@@ -173,7 +173,7 @@ public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsole
return false;
}
protected void showConsole(Executor defaultExecutor, RunContentDescriptor contentDescriptor) {
protected void showConsole(Executor defaultExecutor, @NotNull RunContentDescriptor contentDescriptor) {
// Show in run toolwindow
ExecutionManager.getInstance(myProject).getContentManager().showRunContent(defaultExecutor, contentDescriptor);
}
@@ -17,6 +17,7 @@ package com.intellij.execution.runners;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.ExecutorRegistry;
import com.intellij.execution.impl.ExecutionManagerImpl;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.icons.AllIcons;
@@ -49,10 +50,7 @@ class FakeRerunAction extends AnAction implements DumbAware {
ExecutionEnvironment environment = getEnvironment(event);
if (environment != null) {
presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", environment.getRunProfile().getName()));
RunContentDescriptor descriptor = getDescriptor(event);
ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
presentation.setIcon(processHandler != null && !processHandler.isProcessTerminated() ? AllIcons.Actions.Restart : environment.getExecutor().getIcon());
presentation.setIcon(ExecutionManagerImpl.isProcessRunning(getDescriptor(event)) ? AllIcons.Actions.Restart : environment.getExecutor().getIcon());
presentation.setEnabledAndVisible(isEnabled(event));
return;
}
@@ -66,7 +64,7 @@ class FakeRerunAction extends AnAction implements DumbAware {
public void actionPerformed(AnActionEvent event) {
ExecutionEnvironment environment = getEnvironment(event);
if (environment != null) {
ExecutionUtil.restart(environment, getDescriptor(event));
ExecutionUtil.restart(environment);
return;
}
@@ -3,9 +3,9 @@ package com.intellij.execution.runners;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -23,34 +23,28 @@ import java.util.List;
* @author Sergey Simonchik
*/
public class RerunTestsAction extends DumbAwareAction implements AnAction.TransparentUpdate {
public static final String ID = "RerunTests";
private static final List<RerunInfo> REGISTRY = ContainerUtil.createLockFreeCopyOnWriteList();
private static final List<ExecutionEnvironment> REGISTRY = ContainerUtil.createLockFreeCopyOnWriteList();
public static void register(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment) {
final RerunInfo rerunInfo = new RerunInfo(descriptor, environment);
REGISTRY.add(rerunInfo);
Disposer.register(descriptor, new Disposable() {
public static void register(@NotNull final ExecutionEnvironment environment) {
assert environment.getContentToReuse() != null;
REGISTRY.add(environment);
Disposer.register(environment, new Disposable() {
@Override
public void dispose() {
REGISTRY.remove(rerunInfo);
REGISTRY.remove(environment);
}
});
}
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
for (RerunInfo rerunInfo : REGISTRY) {
RunContentDescriptor descriptor = rerunInfo.getDescriptor();
if (!Disposer.isDisposed(descriptor)) {
ProcessHandler processHandler = descriptor.getProcessHandler();
for (ExecutionEnvironment environment : REGISTRY) {
if (!Disposer.isDisposed(environment)) {
RunContentDescriptor descriptor = environment.getContentToReuse();
ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
if (processHandler != null && processHandler.isProcessTerminated()) {
ExecutionUtil.restart(rerunInfo.getEnvironment(), descriptor);
ExecutionUtil.restart(environment);
}
}
}
@@ -58,25 +52,6 @@ public class RerunTestsAction extends DumbAwareAction implements AnAction.Transp
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setEnabled(true);
}
private static class RerunInfo {
private final RunContentDescriptor myDescriptor;
private final ExecutionEnvironment myEnv;
public RerunInfo(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment env) {
myDescriptor = descriptor;
myEnv = env;
}
private RunContentDescriptor getDescriptor() {
return myDescriptor;
}
private ExecutionEnvironment getEnvironment() {
return myEnv;
}
e.getPresentation().setEnabled(true);
}
}
@@ -35,8 +35,8 @@ import javax.swing.*;
* to remove in IDEA 15
*/
public class RestartAction extends FakeRerunAction implements DumbAware, AnAction.TransparentUpdate, Disposable {
private final RunContentDescriptor descriptor;
private final ExecutionEnvironment environment;
private final RunContentDescriptor myDescriptor;
private final ExecutionEnvironment myEnvironment;
public RestartAction(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment) {
//noinspection deprecation
@@ -55,9 +55,9 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
Disposer.register(descriptor, this);
FakeRerunAction.registry.add(this);
this.environment = runner == null ? environment : ExecutionEnvironmentBuilder.fix(environment, runner);
myEnvironment = runner == null ? environment : RunContentBuilder.fix(environment, runner);
getTemplatePresentation().setEnabled(false);
this.descriptor = descriptor;
myDescriptor = descriptor;
}
@Override
@@ -68,13 +68,13 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
@Override
@NotNull
protected RunContentDescriptor getDescriptor(AnActionEvent event) {
return descriptor;
return myDescriptor;
}
@Override
@NotNull
protected ExecutionEnvironment getEnvironment(AnActionEvent event) {
return environment;
return myEnvironment;
}
public void registerShortcut(JComponent component) {
@@ -78,7 +78,7 @@ public class RunContentBuilder extends LogConsoleManagerBase {
public RunContentBuilder(ProgramRunner runner,
ExecutionResult executionResult,
@NotNull ExecutionEnvironment environment) {
this(executionResult, ExecutionEnvironmentBuilder.fix(environment, runner));
this(executionResult, fix(environment, runner));
}
public RunContentBuilder(ExecutionResult executionResult, @NotNull ExecutionEnvironment environment) {
@@ -89,6 +89,16 @@ public class RunContentBuilder extends LogConsoleManagerBase {
setEnvironment(environment);
}
@NotNull
public static ExecutionEnvironment fix(@NotNull ExecutionEnvironment environment, @Nullable ProgramRunner runner) {
if (runner == null || runner.getRunnerId().equals(environment.getRunnerId())) {
return environment;
}
else {
return new ExecutionEnvironmentBuilder(environment).runner(runner).build();
}
}
@Deprecated
@NotNull
public static GlobalSearchScope createSearchScope(Project project, RunProfile runProfile) {
@@ -195,7 +205,7 @@ public class RunContentBuilder extends LogConsoleManagerBase {
consoleContent.setActions(consoleActions, ActionPlaces.UNKNOWN, console.getComponent());
}
private ActionGroup createActionToolbar(final RunContentDescriptor contentDescriptor, final JComponent component) {
private ActionGroup createActionToolbar(RunContentDescriptor contentDescriptor, final JComponent component) {
final DefaultActionGroup actionGroup = new DefaultActionGroup();
final RestartAction restartAction = new RestartAction(contentDescriptor, getEnvironment());
@@ -204,7 +214,7 @@ public class RunContentBuilder extends LogConsoleManagerBase {
contentDescriptor.setRestarter(new Runnable() {
@Override
public void run() {
ExecutionUtil.restart(getEnvironment(), contentDescriptor);
ExecutionUtil.restart(getEnvironment());
}
});
@@ -255,12 +265,7 @@ public class RunContentBuilder extends LogConsoleManagerBase {
*/
public RunContentDescriptor showRunContent(@Nullable RunContentDescriptor reuseContent) {
RunContentDescriptor descriptor = createDescriptor();
if (reuseContent != null) {
descriptor.setAttachedContent(reuseContent.getAttachedContent());
if (reuseContent.isReuseToolWindowActivation()) {
descriptor.setActivateToolWindowWhenAdded(reuseContent.isActivateToolWindowWhenAdded());
}
}
RunContentManagerImpl.copyContentAndBehavior(descriptor, reuseContent);
return descriptor;
}
@@ -269,32 +269,30 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
@Override
public void showRunContent(@NotNull final Executor executor, final RunContentDescriptor descriptor) {
showRunContent(executor, descriptor, descriptor != null ? descriptor.getExecutionId() : 0L);
public void showRunContent(@NotNull Executor executor, @NotNull RunContentDescriptor descriptor) {
showRunContent(executor, descriptor, descriptor.getExecutionId());
}
public void showRunContent(@NotNull final Executor executor, final RunContentDescriptor descriptor, long executionId) {
if (ApplicationManager.getApplication().isUnitTestMode()) return;
public void showRunContent(@NotNull final Executor executor, @NotNull final RunContentDescriptor descriptor, long executionId) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
return;
}
final ContentManager contentManager = getContentManagerForRunner(executor);
RunContentDescriptor oldDescriptor =
chooseReuseContentForDescriptor(contentManager, descriptor, executionId, descriptor != null ? descriptor.getDisplayName() : null);
RunContentDescriptor oldDescriptor = chooseReuseContentForDescriptor(contentManager, descriptor, executionId, descriptor.getDisplayName());
final Content content;
Content oldAttachedContent = oldDescriptor == null ? null : oldDescriptor.getAttachedContent();
if (oldDescriptor != null) {
if (oldDescriptor == null) {
content = createNewContent(contentManager, descriptor, executor);
Icon icon = descriptor.getIcon();
content.setIcon(icon == null ? executor.getToolWindowIcon() : icon);
}
else {
content = oldAttachedContent;
getSyncPublisher().contentRemoved(oldDescriptor, executor);
Disposer.dispose(oldDescriptor); // is of the same category, can be reused
}
else if (oldAttachedContent == null || !oldAttachedContent.isValid() /*|| oldAttachedContent.getUserData(MARKED_TO_BE_REUSED) != null */) {
content = createNewContent(contentManager, descriptor, executor);
final Icon icon = descriptor.getIcon();
content.setIcon(icon == null ? executor.getToolWindowIcon() : icon);
} else {
content = oldAttachedContent;
}
content.setExecutionId(executionId);
content.setComponent(descriptor.getComponent());
content.setPreferredFocusedComponent(descriptor.getPreferredFocusComputable());
@@ -342,10 +340,10 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
if (!descriptor.isActivateToolWindowWhenAdded()) {
return;
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(executor.getToolWindowId());
// let's activate tool window, but don't move focus
//
@@ -356,7 +354,7 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
descriptor.getPreferredFocusComputable();
window.activate(null, descriptor.isAutoFocusContent(), descriptor.isAutoFocusContent());
}
});
}, myProject.getDisposed());
}
@Override
@@ -406,14 +404,21 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
@Override
public void showRunContent(@NotNull Executor info, RunContentDescriptor descriptor, @Nullable RunContentDescriptor contentToReuse) {
public void showRunContent(@NotNull Executor info, @NotNull RunContentDescriptor descriptor, @Nullable RunContentDescriptor contentToReuse) {
copyContentAndBehavior(descriptor, contentToReuse);
showRunContent(info, descriptor, descriptor.getExecutionId());
}
public static void copyContentAndBehavior(@NotNull RunContentDescriptor descriptor, @Nullable RunContentDescriptor contentToReuse) {
if (contentToReuse != null) {
Content attachedContent = contentToReuse.getAttachedContent();
if (attachedContent.getManager() != null) {
if (attachedContent.isValid()) {
descriptor.setAttachedContent(attachedContent);
}
if (contentToReuse.isReuseToolWindowActivation()) {
descriptor.setActivateToolWindowWhenAdded(contentToReuse.isActivateToolWindowWhenAdded());
}
}
showRunContent(info, descriptor, descriptor != null ? descriptor.getExecutionId(): 0L);
}
@Nullable
@@ -429,7 +434,9 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
//Stage two: try to get content from descriptor itself
final Content attachedContent = descriptor.getAttachedContent();
if (attachedContent != null && attachedContent.isValid() && contentManager.getIndexOfContent(attachedContent) != -1) content = attachedContent;
if (attachedContent != null && attachedContent.isValid() && contentManager.getIndexOfContent(attachedContent) != -1) {
content = attachedContent;
}
}
//Stage three: choose the content with name we prefer
if (content == null) {
@@ -77,7 +77,7 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
textChunks.setBorder(null);
if (usage == null || usageNode instanceof ShowUsagesAction.StringNode) {
textChunks.append(value.toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
textChunks.append(value != null ? value.toString() : "", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
return textComponentSpanningWholeRow(textChunks, panelBackground, panelForeground, column, list, row);
}
if (usage == ShowUsagesAction.MORE_USAGES_SEPARATOR) {
@@ -387,7 +387,8 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
if (input == null || !input.isStringFound()) return true;
NavigableMap<Integer, Integer> map = mySkipRangesSet.headMap(input.getStartOffset(), true);
for(Map.Entry<Integer, Integer> e:map.descendingMap().entrySet()) {
if (e.getKey() <= input.getStartOffset() && e.getValue() >= input.getEndOffset()) return false;
// [e.key, e.value] intersect with [input.start, input.end]
if (e.getKey() <= input.getStartOffset() && (input.getStartOffset() <= e.getValue() || e.getValue() >= input.getEndOffset())) return false;
if (e.getValue() <= input.getStartOffset()) break;
}
return true;
@@ -118,7 +118,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author Konstantin Bulenkov
*/
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
public class SearchEverywhereAction extends AnAction implements CustomComponentAction, DumbAware, DataProvider {
public class SearchEverywhereAction extends AnAction implements CustomComponentAction, DumbAware, DataProvider, RightAlignedToolbarAction {
public static final String SE_HISTORY_KEY = "SearchEverywhereHistoryKey";
public static final int SEARCH_FIELD_COLUMNS = 25;
private static final int MAX_CLASSES = 6;
@@ -176,9 +176,6 @@ public class DownloadUtil {
URLConnection urlConnection = HttpConfigurable.getInstance().openConnection(location);
HttpURLConnection httpURLConnection = ObjectUtils.tryCast(urlConnection, HttpURLConnection.class);
try {
int timeout = (int) TimeUnit.MINUTES.toMillis(2);
urlConnection.setConnectTimeout(timeout);
urlConnection.setReadTimeout(timeout);
urlConnection.connect();
InputStream in = urlConnection.getInputStream();
int contentLength = urlConnection.getContentLength();
@@ -62,7 +62,6 @@ public class MultiScopeSeverityIcon implements Icon {
final Collection<HighlightSeverity> values = myScopeToAverageSeverityMap.values();
int idx = 0;
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
for (final HighlightSeverity severity : values) {
final Icon icon = HighlightDisplayLevel.find(severity).getIcon();
g.setColor(icon instanceof HighlightDisplayLevel.SingleColorIconWithMask ?
@@ -71,6 +70,7 @@ public class MultiScopeSeverityIcon implements Icon {
g.fillRect(x, j, partWidth, getIconHeight());
idx++;
}
g.drawImage(HighlightDisplayLevel.ImageHolder.ourErrorMaskImage, i, j, null);
}
@Override
@@ -19,80 +19,105 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.regex.Pattern;
/**
* See <a href="http://en.wikipedia.org/wiki/ANSI_escape_code">ANSI escape code</a>.
*
* @author traff
*/
public class AnsiEscapeDecoder {
private static final char TEXT_ATTRS_PREFIX_CH = '\u001B';
private static final String TEXT_ATTRS_PREFIX = Character.toString(TEXT_ATTRS_PREFIX_CH) + "[";
private static final String TEXT_ATTRS_PATTERN = "m" + TEXT_ATTRS_PREFIX_CH + "\\[";
private static final char ESC_CHAR = '\u001B'; // Escape sequence start character
private static final String CSI = ESC_CHAR + "["; // "Control Sequence Initiator"
private static final Pattern INNER_PATTERN = Pattern.compile(Pattern.quote("m" + CSI));
private Key myCurrentColor;
private Key myCurrentTextAttributes;
/**
* Parses ansi-color codes from text and sends text fragments with color attributes to textAcceptor
*
* @param text
* @param outputType
* @param textAcceptor if implements ColoredTextAcceptor then it will receive text fragments with color attributes
* if implements ColoredChunksAcceptor then it will receive list of pairs <text, attribute>
* @param text a string with ANSI escape sequences
* @param outputType stdout/stderr/system (from {@link ProcessOutputTypes})
* @param textAcceptor receives text fragments with color attributes.
* It can implement ColoredChunksAcceptor to receive list of pairs (text, attribute).
*/
public void escapeText(String text, Key outputType, ColoredTextAcceptor textAcceptor) {
final List<Pair<String, Key>> textChunks = ContainerUtil.newArrayList();
public void escapeText(@NotNull String text, @NotNull Key outputType, @NotNull ColoredTextAcceptor textAcceptor) {
List<Pair<String, Key>> chunks = null;
int pos = 0;
while (true) {
int macroPos = text.indexOf(TEXT_ATTRS_PREFIX, pos);
if (macroPos < 0) break;
if (pos != macroPos) {
textChunks.add(Pair.create(text.substring(pos, macroPos), getCurrentOutputAttributes(outputType)));
}
final int macroEndPos = getEndMacroPos(text, macroPos);
if (macroEndPos < 0) {
int escSeqBeginInd = text.indexOf(CSI, pos);
if (escSeqBeginInd < 0) {
break;
}
if (pos < escSeqBeginInd) {
chunks = processTextChunk(chunks, text.substring(pos, escSeqBeginInd), outputType, textAcceptor);
}
final int escSeqEndInd = findEscSeqEndIndex(text, escSeqBeginInd);
if (escSeqEndInd < 0) {
break;
}
String escSeq = text.substring(escSeqBeginInd, escSeqEndInd);
// this is a simple fix for RUBY-8996:
// we replace several consecutive escape sequences with one which contains all these sequences
final String colorAttribute = text.substring(macroPos, macroEndPos).replaceAll(TEXT_ATTRS_PATTERN, ";");
myCurrentColor = ColoredOutputTypeRegistry.getInstance().getOutputKey(colorAttribute);
pos = macroEndPos;
String colorAttribute = INNER_PATTERN.matcher(escSeq).replaceAll(";");
myCurrentTextAttributes = ColoredOutputTypeRegistry.getInstance().getOutputKey(colorAttribute);
pos = escSeqEndInd;
}
if (pos < text.length()) {
textChunks.add(Pair.create(text.substring(pos), getCurrentOutputAttributes(outputType)));
chunks = processTextChunk(chunks, text.substring(pos), outputType, textAcceptor);
}
if (textAcceptor instanceof ColoredChunksAcceptor) {
((ColoredChunksAcceptor)textAcceptor).coloredChunksAvailable(textChunks);
}
else {
coloredTextAvailable(textChunks, textAcceptor);
if (chunks != null && textAcceptor instanceof ColoredChunksAcceptor) {
((ColoredChunksAcceptor)textAcceptor).coloredChunksAvailable(chunks);
}
}
// selects all consecutive escape sequences
private static int getEndMacroPos(final String text, int macroPos) {
int endMacroPos = text.indexOf('m', macroPos);
while (endMacroPos >= 0) {
endMacroPos += 1;
macroPos = text.indexOf(TEXT_ATTRS_PREFIX, endMacroPos);
if (macroPos != endMacroPos) {
/*
* Selects all consecutive escape sequences and returns escape sequence end index (exclusive).
* If the escape sequence isn't finished, returns -1.
*/
private static int findEscSeqEndIndex(@NotNull String text, int escSeqBeginInd) {
escSeqBeginInd = text.indexOf('m', escSeqBeginInd);
while (escSeqBeginInd >= 0) {
escSeqBeginInd++;
if (!text.regionMatches(escSeqBeginInd, CSI, 0, CSI.length())) {
break;
}
endMacroPos = text.indexOf('m', macroPos);
escSeqBeginInd = text.indexOf('m', escSeqBeginInd);
}
return endMacroPos;
return escSeqBeginInd;
}
protected Key getCurrentOutputAttributes(final Key outputType) {
@Nullable
private List<Pair<String, Key>> processTextChunk(@Nullable List<Pair<String, Key>> buffer,
@NotNull String text,
@NotNull Key outputType,
@NotNull ColoredTextAcceptor textAcceptor) {
Key attributes = getCurrentOutputAttributes(outputType);
if (textAcceptor instanceof ColoredChunksAcceptor) {
if (buffer == null) {
buffer = ContainerUtil.newArrayListWithCapacity(1);
}
buffer.add(Pair.create(text, attributes));
}
else {
textAcceptor.coloredTextAvailable(text, attributes);
}
return buffer;
}
@NotNull
protected Key getCurrentOutputAttributes(@NotNull Key outputType) {
if (outputType == ProcessOutputTypes.STDERR || outputType == ProcessOutputTypes.SYSTEM) {
return outputType;
}
return myCurrentColor != null ? myCurrentColor : outputType;
return myCurrentTextAttributes != null ? myCurrentTextAttributes : outputType;
}
public void coloredTextAvailable(@NotNull final List<Pair<String, Key>> textChunks, ColoredTextAcceptor textAcceptor) {
for (final Pair<String, Key> textChunk : textChunks) {
public void coloredTextAvailable(@NotNull List<Pair<String, Key>> textChunks, ColoredTextAcceptor textAcceptor) {
for (Pair<String, Key> textChunk : textChunks) {
textAcceptor.coloredTextAvailable(textChunk.getFirst(), textChunk.getSecond());
}
}
@@ -44,7 +44,8 @@ public class CapturingAnsiEscapesAwareProcessHandler extends CapturingProcessHan
private static class AnsiEscapesAwareAdapter extends CapturingProcessAdapter implements AnsiEscapeDecoder.ColoredTextAcceptor {
private final AnsiEscapeDecoder myAnsiEscapeDecoder = new AnsiEscapeDecoder() {
@Override
protected Key getCurrentOutputAttributes(Key outputType) {
@NotNull
protected Key getCurrentOutputAttributes(@NotNull Key outputType) {
return outputType; //we don't need color information - only stdout and stderr keys are added to output in CapturingProcessAdapter
}
};
@@ -8,6 +8,7 @@ import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.HashMap;
@@ -73,6 +74,7 @@ public class ColoredOutputTypeRegistry {
see full doc at http://en.wikipedia.org/wiki/ANSI_escape_code
*/
@NotNull
public Key getOutputKey(@NonNls String attribute) {
final Key key = myRegisteredKeys.get(attribute);
if (key != null) {
@@ -350,8 +350,6 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
final URLConnection connection = openConnection(url);
try {
connection.setConnectTimeout(CONNECTION_TIMEOUT);
connection.setReadTimeout(CONNECTION_TIMEOUT);
connection.connect();
connection.getInputStream();
}
@@ -387,6 +385,10 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
throw ioe;
}
}
if (urlConnection != null) {
urlConnection.setReadTimeout(CONNECTION_TIMEOUT);
urlConnection.setConnectTimeout(CONNECTION_TIMEOUT);
}
return urlConnection;
}
@@ -181,8 +181,6 @@ public class ITNProxy {
private static HttpURLConnection post(URL url, byte[] bytes) throws IOException {
HttpURLConnection connection = (HttpURLConnection)HttpConfigurable.getInstance().openConnection(url.toString());
connection.setReadTimeout(10 * 1000);
connection.setConnectTimeout(10 * 1000);
connection.setRequestMethod(HTTP_POST);
connection.setDoInput(true);
connection.setDoOutput(true);
@@ -45,7 +45,7 @@ import static java.util.Arrays.asList;
*/
public class CreateLauncherScriptAction extends DumbAwareAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.CreateLauncherScriptAction");
public static final String CONTENTS = "/Contents";
private static final String CONTENTS = "/Contents";
public static boolean isAvailable() {
return SystemInfo.isUnix;
@@ -181,11 +181,11 @@ public class PluginGroups {
featuredPlugins.put("Scala", "Custom Languages:Plugin for Scala language support:org.intellij.scala");
featuredPlugins.put("Live Edit Tool",
"Web Development:Provides live edit HTML/CSS/JavaScript:com.intellij.plugins.html.instantEditing");
"Web Development:Provides live edit HTML/CSS/JavaScript:com.intellij.plugins.html.instantEditing");
addVimPlugin(featuredPlugins);
featuredPlugins.put("NodeJS", "JavaScript:Node.js integration:NodeJS");
featuredPlugins.put("Atlassian Connector",
"Tools Integration:Integration for Atlassian JIRA, Bamboo, Cricible, FishEye:atlassian-idea-plugin");
"Tools Integration:Integration for Atlassian JIRA, Bamboo, Cricible, FishEye:atlassian-idea-plugin");
}
protected static void addVcsGroup(Map<String, Pair<Icon, List<String>>> tree) {
@@ -205,6 +205,24 @@ public class PluginGroups {
featuredPlugins.put("IdeaVIM", "Editor:Vim emulation plug-in for IDEs based on the IntelliJ platform:IdeaVIM");
}
protected static void addLuaPlugin(Map<String, String> featuredPlugins) {
featuredPlugins.put("Lua", "Custom Languages:Lua language integration:Lua");
}
protected static void addMarkdownPlugin(Map<String, String> featuredPlugins) {
featuredPlugins.put("Markdown", "Custom Languages:Markdown language integration:net.nicoulaj.idea.markdown");
}
protected static void addConfigurationServerPlugin(Map<String, String> featuredPlugins) {
featuredPlugins.put("Configuration Server",
"Team Work:Supports sharing settings between installations of IntelliJ Platform based products used by the same developer on different computers:IdeaServerPlugin");
}
protected static void addTeamCityPlugin(Map<String, String> featuredPlugins) {
featuredPlugins.put("TeamCity Integration",
"Tools Integration:Integration with JetBrains TeamCity - innovative solution for continuous integration and build management:Jetbrains TeamCity Plugin");
}
private void initIfNeed() {
if (myInitialized) return;
myInitialized = true;
@@ -307,7 +325,8 @@ public class PluginGroups {
void setFeaturedPluginEnabled(String pluginId, boolean enabled) {
if (enabled) {
myFeaturedIds.add(pluginId);
} else {
}
else {
myFeaturedIds.remove(pluginId);
}
StartupUtil.setFeaturedPluginsToInstall(myFeaturedIds);
@@ -30,10 +30,7 @@ import com.intellij.ui.GuiUtils;
import com.intellij.util.ArrayUtil;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author stathik
@@ -45,6 +42,19 @@ public class PluginInstaller {
private PluginInstaller() { }
public static boolean prepareToInstall(List<PluginNode> pluginsToInstall, List<IdeaPluginDescriptor> allPlugins) {
HashSet<PluginNode> dependant = new HashSet<PluginNode>();
boolean install = prepareToInstall(pluginsToInstall, allPlugins, dependant);
for (PluginNode node : dependant) {
if (!pluginsToInstall.contains(node)) {
pluginsToInstall.add(node);
}
}
return install;
}
private static boolean prepareToInstall(List<PluginNode> pluginsToInstall,
List<IdeaPluginDescriptor> allPlugins,
Set<PluginNode> installedDependant) {
ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
final List<PluginId> pluginIds = new ArrayList<PluginId>();
@@ -58,7 +68,7 @@ public class PluginInstaller {
if (pi != null) pi.setText(pluginNode.getName());
try {
result |= prepareToInstall(pluginNode, pluginIds, allPlugins);
result |= prepareToInstall(pluginNode, pluginIds, allPlugins, installedDependant);
}
catch (IOException e) {
String title = IdeBundle.message("title.plugin.error");
@@ -72,7 +82,9 @@ public class PluginInstaller {
private static boolean prepareToInstall(final PluginNode pluginNode,
final List<PluginId> pluginIds,
List<IdeaPluginDescriptor> allPlugins) throws IOException {
List<IdeaPluginDescriptor> allPlugins,
Set<PluginNode> installedDependant) throws IOException {
installedDependant.add(pluginNode);
// check for dependent plugins at first.
if (pluginNode.getDepends() != null && pluginNode.getDepends().size() > 0) {
// prepare plugins list for install
@@ -122,7 +134,7 @@ public class PluginInstaller {
return false;
}
if (proceed[0]) {
if (!prepareToInstall(depends, allPlugins)) {
if (!prepareToInstall(depends, allPlugins, installedDependant)) {
return false;
}
}
@@ -152,7 +164,7 @@ public class PluginInstaller {
return false;
}
if (proceed[0]) {
if (!prepareToInstall(optionalDeps, allPlugins)) {
if (!prepareToInstall(optionalDeps, allPlugins, installedDependant)) {
return false;
}
}
@@ -65,6 +65,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.actionSystem.impl.ActionToolbarImpl");
private static final List<ActionToolbarImpl> ourToolbars = new LinkedList<ActionToolbarImpl>();
private static final String RIGHT_ALIGN_KEY = "RIGHT_ALIGN";
public static void updateAllToolbarsImmediately() {
for (ActionToolbarImpl toolbar : new ArrayList<ActionToolbarImpl>(ourToolbars)) {
toolbar.updateActionsImmediately();
@@ -272,11 +274,16 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
private void fillToolBar(final List<AnAction> actions, boolean layoutSecondaries) {
final List<AnAction> rightAligned = new ArrayList<AnAction>();
if (myAddSeparatorFirst) {
add(new MySeparator());
}
for (int i = 0; i < actions.size(); i++) {
final AnAction action = actions.get(i);
if (action instanceof RightAlignedToolbarAction) {
rightAligned.add(action);
continue;
}
// if (action instanceof Separator && isNavBar()) {
// continue;
// }
@@ -311,18 +318,23 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
add(mySecondaryActionsButton);
}
if ((ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || ActionPlaces.NAVIGATION_BAR_TOOLBAR.equals(myPlace))) {
final AnAction searchEverywhereAction = ActionManager.getInstance().getAction("SearchEverywhere");
if (searchEverywhereAction != null) {
try {
final CustomComponentAction searchEveryWhereAction = (CustomComponentAction)searchEverywhereAction;
final JComponent searchEverywhere = searchEveryWhereAction.createCustomComponent(searchEverywhereAction.getTemplatePresentation());
searchEverywhere.putClientProperty("SEARCH_EVERYWHERE", Boolean.TRUE);
add(searchEverywhere);
}
catch (Exception ignore) {}
}
for (AnAction action : rightAligned) {
JComponent button = action instanceof CustomComponentAction ? getCustomComponent(action) : createToolbarButton(action);
button.putClientProperty(RIGHT_ALIGN_KEY, Boolean.TRUE);
add(button);
}
//if ((ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || ActionPlaces.NAVIGATION_BAR_TOOLBAR.equals(myPlace))) {
// final AnAction searchEverywhereAction = ActionManager.getInstance().getAction("SearchEverywhere");
// if (searchEverywhereAction != null) {
// try {
// final CustomComponentAction searchEveryWhereAction = (CustomComponentAction)searchEverywhereAction;
// final JComponent searchEverywhere = searchEveryWhereAction.createCustomComponent(searchEverywhereAction.getTemplatePresentation());
// searchEverywhere.putClientProperty("SEARCH_EVERYWHERE", Boolean.TRUE);
// add(searchEverywhere);
// }
// catch (Exception ignore) {}
// }
//}
}
private JComponent getCustomComponent(AnAction action) {
@@ -730,14 +742,18 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
throw new IllegalStateException("unknown layoutPolicy: " + myLayoutPolicy);
}
if (getComponentCount() > 0 && size2Fit.width < Integer.MAX_VALUE) {
final Component component = getComponent(getComponentCount() - 1);
if (component instanceof JComponent && ((JComponent)component).getClientProperty("SEARCH_EVERYWHERE") == Boolean.TRUE) {
int max = 0;
for (int i = 0; i < bounds.size() - 2; i++) {
max = Math.max(max, bounds.get(i).height);
int maxHeight = 0;
for (int i = 0; i < bounds.size() - 2; i++) {
maxHeight = Math.max(maxHeight, bounds.get(i).height);
}
for (int i = getComponentCount() - 1, j = 1; i > 0; i--, j++) {
final Component component = getComponent(i);
if (component instanceof JComponent && ((JComponent)component).getClientProperty(RIGHT_ALIGN_KEY) == Boolean.TRUE) {
bounds.set(bounds.size() - j, new Rectangle(size2Fit.width - j * 25, 0, 25, maxHeight));
}
bounds.set(bounds.size() - 1, new Rectangle(size2Fit.width - 25, 0, 25, max));
}
}
}
@@ -21,6 +21,7 @@ import com.intellij.ide.ui.UISettings;
import com.intellij.ide.ui.search.SearchUtil;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.QuickList;
import com.intellij.openapi.actionSystem.impl.ActionMenu;
import com.intellij.openapi.keymap.KeyMapBundle;
import com.intellij.openapi.keymap.Keymap;
import com.intellij.openapi.keymap.KeymapUtil;
@@ -40,12 +41,15 @@ import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.util.ui.tree.WideSelectionTreeUI;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Set;
@@ -91,7 +95,7 @@ public class ActionsTree {
}
}
}
}
};
myTree.setRootVisible(false);
@@ -99,6 +103,36 @@ public class ActionsTree {
myTree.putClientProperty(WideSelectionTreeUI.STRIPED_CLIENT_PROPERTY, Boolean.TRUE);
myTree.setCellRenderer(new KeymapsRenderer());
myTree.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
String description = getDescription(e);
if (description != null) {
ActionMenu.showDescriptionInStatusBar(true, myTree, description);
}
else {
ActionMenu.showDescriptionInStatusBar(false, myTree, null);
}
}
@Nullable
private String getDescription(@NotNull MouseEvent e) {
TreePath path = myTree.getPathForLocation(e.getX(), e.getY());
if (path == null) return null;
DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
if (node == null) return null;
Object userObject = node.getUserObject();
if (!(userObject instanceof String)) return null;
String actionId = (String)userObject;
AnAction action = ActionManager.getInstance().getActionOrStub(actionId);
if (action == null) return null;
return action.getTemplatePresentation().getDescription();
}
});
myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
@@ -447,6 +481,7 @@ public class ActionsTree {
Icon icon = null;
String text;
boolean bound = false;
setToolTipText(null);
if (value instanceof DefaultMutableTreeNode) {
Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
@@ -474,6 +509,7 @@ public class ActionsTree {
if (actionIcon != null) {
icon = actionIcon;
}
setToolTipText(action.getTemplatePresentation().getDescription());
}
else {
text = actionId;
@@ -521,7 +557,7 @@ public class ActionsTree {
}
}
}
private void paintRowData(Tree tree, Object data, Rectangle bounds, Graphics2D g) {
Shortcut[] shortcuts = null;
Set<String> abbreviations = null;
@@ -552,7 +588,7 @@ public class ActionsTree {
Color c2 = new Color(208, 200, 66);
g.translate(0, bounds.y - 1);
for (Shortcut shortcut : shortcuts) {
int width = metrics.stringWidth(KeymapUtil.getShortcutText(shortcut));
UIUtil.drawSearchMatch(g, x, x + width, bounds.height, c1, c2);
@@ -296,9 +296,15 @@ public class PluginDownloader {
}
private URLConnection openConnection(final String url) throws IOException {
final URLConnection connection = ApplicationManager.getApplication() != null
? HttpConfigurable.getInstance().openConnection(url)
: new URL(url).openConnection();
final URLConnection connection;
if (ApplicationManager.getApplication() != null) {
connection = HttpConfigurable.getInstance().openConnection(url);
}
else {
connection = new URL(url).openConnection();
connection.setConnectTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
connection.setReadTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
}
if (connection instanceof HttpURLConnection) {
final int responseCode = ((HttpURLConnection)connection).getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
@@ -624,11 +624,15 @@ public final class UpdateChecker {
urlToCheck = url;
}
HttpURLConnection connection = ApplicationManager.getApplication() != null ?
HttpConfigurable.getInstance().openHttpConnection(urlToCheck) :
(HttpURLConnection)new URL(urlToCheck).openConnection();
connection.setReadTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
connection.setConnectTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
HttpURLConnection connection;
if (ApplicationManager.getApplication() != null) {
connection = HttpConfigurable.getInstance().openHttpConnection(urlToCheck);
}
else {
connection = (HttpURLConnection)new URL(urlToCheck).openConnection();
connection.setReadTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
connection.setConnectTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
}
connection.connect();
inputStreams[0] = connection.getInputStream();
@@ -32,6 +32,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
@@ -67,7 +68,10 @@ public class UpdatesXmlLoader {
URL requestUrl = prepareRequestUrl(updateUrl);
final InputStream inputStream = requestUrl.openStream();
URLConnection connection = requestUrl.openConnection();
connection.setConnectTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
connection.setReadTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
final InputStream inputStream = connection.getInputStream();
Reader reader = new InputStreamReader(inputStream);
try {
return new UpdatesInfo(JDOMUtil.loadDocument(inputStream).getRootElement());
@@ -741,7 +741,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
myActiveStack.push(id);
}
if (autoFocusContents) {
if (autoFocusContents && ApplicationManager.getApplication().isActive()) {
appendRequestFocusInToolWindowCmd(id, commandsList, forcedFocusRequest);
}
}
@@ -44,7 +44,7 @@ public class ContentImpl extends UserDataHolderBase implements Content {
private JComponent myComponent;
private Icon myIcon;
private final PropertyChangeSupport myChangeSupport = new PropertyChangeSupport(this);
private ContentManager myManager = null;
private ContentManager myManager;
private boolean myIsLocked = false;
private boolean myPinnable = true;
private Icon myLayeredIcon = new LayeredIcon(2);
@@ -239,9 +239,9 @@
<value>
<option name="FOREGROUND"/>
<option name="BACKGROUND"/>
<option name="EFFECT_COLOR" value="dc3737"/>
<option name="EFFECT_COLOR" value="ff0000"/>
<option name="EFFECT_TYPE" value="2"/>
<option name="ERROR_STRIPE_COLOR" value="dc3737" />
<option name="ERROR_STRIPE_COLOR" value="ff0000" />
</value>
</option>
<option name="BLINKING_HIGHLIGHTS_ATTRIBUTES">
@@ -281,19 +281,19 @@
<option name="WARNING_ATTRIBUTES">
<value>
<option name="FOREGROUND"/>
<option name="BACKGROUND" value="ffd900"/>
<option name="BACKGROUND" value="f6ebbc"/>
<option name="EFFECT_COLOR"/>
<option name="EFFECT_TYPE" value="1"/>
<option name="ERROR_STRIPE_COLOR" value="ffd900" />
<option name="ERROR_STRIPE_COLOR" value="ffff00" />
</value>
</option>
<option name="GENERIC_SERVER_ERROR_OR_WARNING">
<value>
<option name="FOREGROUND"/>
<option name="BACKGROUND"/>
<option name="EFFECT_COLOR" value="fa8c00"/>
<option name="EFFECT_COLOR" value="f49810"/>
<option name="EFFECT_TYPE" value="2"/>
<option name="ERROR_STRIPE_COLOR" value="fa8c00" />
<option name="ERROR_STRIPE_COLOR" value="f49810" />
</value>
</option>
<option name="DUPLICATE_FROM_SERVER">
@@ -364,6 +364,7 @@
<separator/>
<reference id="NavBarToolBarOthers"/>
<separator/>
<reference ref="SearchEverywhere"/>
</group>
<group id="Bookmarks">
@@ -457,6 +457,7 @@
</group>
<separator/>
<reference ref="HelpTopics"/>
<reference ref="SearchEverywhere"/>
</group>
<group id="NavBarVcsGroup"/>
@@ -0,0 +1,55 @@
package com.intellij.execution.process;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import java.util.List;
public class AnsiEscapeDecoderTest extends PlatformTestCase {
public void testTextWithoutColors() throws Exception {
AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
decoder.escapeText("", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
Pair.create("", ProcessOutputTypes.STDOUT)
)));
decoder.escapeText("simple text", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
Pair.create("simple text", ProcessOutputTypes.STDOUT)
)));
}
public void testSingleColoredChunk() throws Exception {
AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
decoder.escapeText("Chrome 35.0.1916 (Linux): Executed 0 of 1\u001B[32m SUCCESS\u001B[39m (0 secs / 0 secs)\n", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
Pair.create("Chrome 35.0.1916 (Linux): Executed 0 of 1", ProcessOutputTypes.STDOUT),
Pair.create(" SUCCESS", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[32m")),
Pair.create(" (0 secs / 0 secs)\n", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[39m"))
)));
}
public void testCompoundEscSeq() throws Exception {
AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
decoder.escapeText("E\u001B[41m\u001B[37mE\u001B[0mE", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
Pair.create("E", ProcessOutputTypes.STDOUT),
Pair.create("E", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[41;37m")),
Pair.create("E", ProcessOutputTypes.STDOUT)
)));
}
private static AnsiEscapeDecoder.ColoredChunksAcceptor createExpectedAcceptor(@NotNull final List<Pair<String, Key>> expected) {
return new AnsiEscapeDecoder.ColoredChunksAcceptor() {
@Override
public void coloredChunksAvailable(List<Pair<String, Key>> chunks) {
Assert.assertEquals(expected, chunks);
}
@Override
public void coloredTextAvailable(String text, Key attributes) {
throw new RuntimeException(); // shouldn't be called
}
};
}
}
@@ -344,11 +344,8 @@ public class PatternCompiler {
@Override
public String getPrefix(int varIndex) {
try {
return myPrefixes[varIndex];
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
if (varIndex >= myPrefixes.length) return null;
return myPrefixes[varIndex];
}
}
@@ -1113,6 +1113,10 @@ public class ContainerUtil extends ContainerUtilRt {
*/
@NotNull
public static <T> List<T> concat(@NotNull final List<? extends T> list1, @NotNull final List<? extends T> list2) {
if (list1.isEmpty() && list2.isEmpty()) {
return Collections.emptyList();
}
final int size1 = list1.size();
final int size = size1 + list2.size();
@@ -58,8 +58,8 @@ public abstract class XDebuggerManager {
public abstract XDebugSession getCurrentSession();
/**
* Start a new debugging session. Use this method only if debugging is started by using standard 'Debug' action i.e. this methods is called
* from {@link com.intellij.execution.runners.ProgramRunner#execute} method. Otherwise use {@link #startSessionAndShowTab} method
* @deprecated use {@link #startSession(com.intellij.execution.runners.ExecutionEnvironment, XDebugProcessStarter)} instead
* to remove in IDEA 15
*/
@NotNull
@Deprecated
@@ -22,8 +22,8 @@ import com.intellij.execution.Executor;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunContentManagerImpl;
@@ -174,7 +174,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager
@NotNull ExecutionEnvironment environment,
@Nullable RunContentDescriptor contentToReuse,
@NotNull XDebugProcessStarter processStarter) throws ExecutionException {
return startSession(contentToReuse, processStarter, new XDebugSessionImpl(ExecutionEnvironmentBuilder.fix(environment, runner), this));
return startSession(contentToReuse, processStarter, new XDebugSessionImpl(RunContentBuilder.fix(environment, runner), this));
}
@Override
@@ -77,22 +77,21 @@ public class XDebugSessionTab extends DebuggerSessionTabBase implements DataProv
if (component != null) {
XDebugSessionTab oldTab = TAB_KEY.getData(DataManager.getInstance().getDataContext(component));
if (oldTab != null) {
oldTab.setSession(session, environment, contentToReuse, icon);
oldTab.setSession(session, environment, icon);
oldTab.attachToSession();
return oldTab;
}
}
}
return new XDebugSessionTab(session, icon, environment, contentToReuse);
return new XDebugSessionTab(session, icon, environment);
}
private XDebugSessionTab(@NotNull XDebugSessionImpl session,
@Nullable Icon icon,
@Nullable ExecutionEnvironment environment,
@Nullable RunContentDescriptor contentToReuse) {
@Nullable Icon icon,
@Nullable ExecutionEnvironment environment) {
super(session.getProject(), "Debug", session.getSessionName(), GlobalSearchScope.allScope(session.getProject()));
setSession(session, environment, contentToReuse, icon);
setSession(session, environment, icon);
myUi.addContent(createFramesContent(), 0, PlaceInGrid.left, false);
myUi.addContent(createVariablesContent(), 0, PlaceInGrid.center, false);
@@ -126,7 +125,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase implements DataProv
rebuildViews();
}
private void setSession(@NotNull XDebugSessionImpl session, @Nullable ExecutionEnvironment environment, @Nullable RunContentDescriptor contentToReuse, @Nullable Icon icon) {
private void setSession(@NotNull XDebugSessionImpl session, @Nullable ExecutionEnvironment environment, @Nullable Icon icon) {
if (environment != null) {
setEnvironment(environment);
}
@@ -134,9 +133,6 @@ public class XDebugSessionTab extends DebuggerSessionTabBase implements DataProv
this.session = session;
myConsole = session.getConsoleView();
myRunContentDescriptor = new RunContentDescriptor(myConsole, session.getDebugProcess().getProcessHandler(), myUi.getComponent(), session.getSessionName(), icon);
if (contentToReuse != null && contentToReuse.isReuseToolWindowActivation()) {
myRunContentDescriptor.setActivateToolWindowWhenAdded(contentToReuse.isActivateToolWindowWhenAdded());
}
}
@Nullable
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,14 +44,29 @@ class VariablePassedAsArgumentExcludedVisitor extends JavaRecursiveElementVisito
}
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
public void visitCallExpression(PsiCallExpression callExpression) {
if (passed) {
return;
}
super.visitMethodCallExpression(call);
super.visitCallExpression(callExpression);
visitCall(callExpression);
}
@Override
public void visitEnumConstant(PsiEnumConstant enumConstant) {
if (passed) {
return;
}
super.visitEnumConstant(enumConstant);
visitCall(enumConstant);
}
private void visitCall(PsiCall call) {
final PsiExpressionList argumentList = call.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
if (argumentList == null) {
return;
}
for (PsiExpression argument : argumentList.getExpressions()) {
if (!VariableAccessUtils.mayEvaluateToVariable(argument, variable, myBuilderPattern)) {
continue;
}
@@ -69,35 +84,6 @@ class VariablePassedAsArgumentExcludedVisitor extends JavaRecursiveElementVisito
}
}
@Override
public void visitNewExpression(@NotNull PsiNewExpression newExpression) {
if (passed) {
return;
}
super.visitNewExpression(newExpression);
final PsiExpressionList argumentList = newExpression.getArgumentList();
if (argumentList == null) {
return;
}
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
if (!VariableAccessUtils.mayEvaluateToVariable(argument, variable, myBuilderPattern)) {
continue;
}
final PsiMethod constructor = newExpression.resolveConstructor();
if (constructor != null) {
final PsiClass aClass = constructor.getContainingClass();
if (aClass != null) {
final String name = aClass.getQualifiedName();
if (excludes.contains(name)) {
continue;
}
}
}
passed = true;
}
}
public boolean isPassed() {
return passed;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,33 +37,29 @@ class VariablePassedAsArgumentVisitor extends JavaRecursiveElementVisitor {
}
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
public void visitCallExpression(PsiCallExpression callExpression) {
super.visitCallExpression(callExpression);
if (passed) {
return;
}
super.visitMethodCallExpression(call);
final PsiExpressionList argumentList = call.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
if (VariableAccessUtils.mayEvaluateToVariable(argument, variable)) {
passed = true;
break;
}
}
visitCall(callExpression);
}
@Override
public void visitNewExpression(@NotNull PsiNewExpression newExpression) {
public void visitEnumConstant(PsiEnumConstant enumConstant) {
if (passed) {
return;
}
super.visitNewExpression(newExpression);
final PsiExpressionList argumentList = newExpression.getArgumentList();
super.visitEnumConstant(enumConstant);
visitCall(enumConstant);
}
private void visitCall(PsiCall call) {
final PsiExpressionList argumentList = call.getArgumentList();
if (argumentList == null) {
return;
}
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
for (PsiExpression argument : argumentList.getExpressions()) {
if (VariableAccessUtils.mayEvaluateToVariable(argument, variable)) {
passed = true;
break;
@@ -275,4 +275,18 @@ class SimpleAdd {
return null;
}
}
class EnumConstant {
private static final List<String> CONSTANT_ARRAY = new ArrayList();
static {
CONSTANT_ARRAY.add("asdf");
}
enum SomeEnum {
ITEM(CONSTANT_ARRAY); // passed as argument
private final List<String> myPatterns;
SomeEnum(List<String> patterns) {
myPatterns = patterns;
}
}
}
@@ -31,3 +31,15 @@ interface List<T> {
interface Consumer<T> {
void accept(T t);
}
class EnumConstant {
private static final StringBuilder sb = new StringBuilder();
static {
sb.append("");
}
enum SomeEnum {
ITEM(sb); // passed as argument
SomeEnum(StringBuilder sb) {}
}
}
@@ -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.
@@ -60,6 +60,7 @@ public class AppEngineFacetEditor extends FacetEditorTab {
myContext = context;
mySdkEditor = new AppEngineSdkEditor(myContext.getProject());
validatorsManager.registerValidator(new FacetEditorValidator() {
@NotNull
@Override
public ValidationResult check() {
return AppEngineSdkUtil.checkPath(mySdkEditor.getPath());
@@ -22,7 +22,6 @@ import com.intellij.execution.configurations.*;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
/**
@@ -42,10 +41,7 @@ public class GriffonDebuggerRunner extends GenericDebuggerRunner {
@Override
protected RunContentDescriptor createContentDescriptor(Project project,
RunProfileState state,
RunContentDescriptor contentToReuse,
ExecutionEnvironment environment) throws ExecutionException {
protected RunContentDescriptor createContentDescriptor(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
final JavaCommandLine javaCommandLine = (JavaCommandLine)state;
final JavaParameters params = javaCommandLine.getJavaParameters();
@@ -68,11 +64,8 @@ public class GriffonDebuggerRunner extends GenericDebuggerRunner {
}
if (address == null) {
return super.createContentDescriptor(project, state, contentToReuse, environment);
return super.createContentDescriptor(state, environment);
}
RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", address, false);
return attachVirtualMachine(project, state, contentToReuse, environment, connection, true);
return attachVirtualMachine(state, environment, new RemoteConnection(true, "127.0.0.1", address, false), true);
}
}
}
@@ -44,6 +44,7 @@ public class HgOutgoingCommand extends HgRemoteChangesetsCommand {
boolean doNotShowAuthorizationRequest) {
List<String> arguments = new LinkedList<String>();
arguments.add("-n");
arguments.add("--template");
arguments.add(template);
arguments.add(HgHistoryUtil.prepareParameter("rev", source));
@@ -110,19 +110,19 @@ public class HgHistoryUtil {
final HgVersion version = hgvcs.getVersion();
String[] templates = HgBaseLogParser.constructFullTemplateArgument(true, version);
HgCommandResult result = getLogResult(project, root, version, limit, parameters, HgChangesetUtil.makeTemplate(templates));
return createFullCommitsFromResult(project, root, result, version);
return createFullCommitsFromResult(project, root, result, version, false);
}
public static List<? extends VcsFullCommitDetails> createFullCommitsFromResult(@NotNull Project project,
@NotNull VirtualFile root,
@Nullable HgCommandResult result,
@NotNull HgVersion version) {
@NotNull HgVersion version, boolean silent) {
final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
if (factory == null) {
return Collections.emptyList();
}
List<HgFileRevision> hgRevisions =
getCommitRecords(project, result, new HgFileRevisionLogParser(project, getOriginalHgFile(project, root), version));
getCommitRecords(project, result, new HgFileRevisionLogParser(project, getOriginalHgFile(project, root), version), silent);
List<VcsFullCommitDetails> vcsFullCommitDetailsList = new ArrayList<VcsFullCommitDetails>();
for (HgFileRevision revision : hgRevisions) {
@@ -194,6 +194,13 @@ public class HgHistoryUtil {
public static <CommitInfo> List<CommitInfo> getCommitRecords(@NotNull Project project,
@Nullable HgCommandResult result,
@NotNull Function<String, CommitInfo> converter) {
return getCommitRecords(project, result, converter, false);
}
@NotNull
public static <CommitInfo> List<CommitInfo> getCommitRecords(@NotNull Project project,
@Nullable HgCommandResult result,
@NotNull Function<String, CommitInfo> converter, boolean silent) {
final List<CommitInfo> revisions = new LinkedList<CommitInfo>();
if (result == null) {
return revisions;
@@ -202,7 +209,12 @@ public class HgHistoryUtil {
List<String> errors = result.getErrorLines();
if (errors != null && !errors.isEmpty()) {
if (result.getExitValue() != 0) {
VcsNotifier.getInstance(project).notifyError(HgVcsMessages.message("hg4idea.error.log.command.execution"), errors.toString());
if (silent) {
LOG.warn(errors.toString());
}
else {
VcsNotifier.getInstance(project).notifyError(HgVcsMessages.message("hg4idea.error.log.command.execution"), errors.toString());
}
return Collections.emptyList();
}
LOG.warn(errors.toString());
@@ -21,7 +21,6 @@ import com.intellij.dvcs.repo.Repository;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.VcsFullCommitDetails;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.HgVcs;
@@ -99,7 +98,6 @@ public class HgOutgoingCommitsProvider extends OutgoingCommitsProvider {
}
LOG.warn(resultErrors.toString());
}
return new OutgoingResult(
ContainerUtil.reverse(HgHistoryUtil.createFullCommitsFromResult(project, repository.getRoot(), result, version)), errors);
return new OutgoingResult(HgHistoryUtil.createFullCommitsFromResult(project, repository.getRoot(), result, version, true), errors);
}
}
@@ -59,10 +59,12 @@ public class MavenRunConfigurationType implements ConfigurationType {
*/
MavenRunConfigurationType() {
myFactory = new ConfigurationFactory(this) {
@Override
public RunConfiguration createTemplateConfiguration(Project project) {
return new MavenRunConfiguration(project, this, "");
}
@Override
public RunConfiguration createTemplateConfiguration(Project project, RunManager runManager) {
return new MavenRunConfiguration(project, this, "");
}
@@ -99,22 +101,27 @@ public class MavenRunConfigurationType implements ConfigurationType {
};
}
@Override
public String getDisplayName() {
return RunnerBundle.message("maven.run.configuration.name");
}
@Override
public String getConfigurationTypeDescription() {
return RunnerBundle.message("maven.run.configuration.description");
}
@Override
public Icon getIcon() {
return MavenIcons.Phase;
}
@Override
public ConfigurationFactory[] getConfigurationFactories() {
return new ConfigurationFactory[]{myFactory};
}
@Override
@NonNls
@NotNull
public String getId() {
@@ -187,29 +194,26 @@ public class MavenRunConfigurationType implements ConfigurationType {
ProgramRunner runner = DefaultJavaProgramRunner.getInstance();
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, configSettings, project);
try {
runner.execute(env, callback);
runner.execute(new ExecutionEnvironment(executor, runner, configSettings, project), callback);
}
catch (ExecutionException e) {
MavenUtil.showError(project, "Failed to execute Maven goal", e);
}
}
@NotNull
public static RunnerAndConfigurationSettings createRunnerAndConfigurationSettings(@Nullable MavenGeneralSettings generalSettings,
@Nullable MavenRunnerSettings runnerSettings,
MavenRunnerParameters params,
Project project) {
@Nullable MavenRunnerSettings runnerSettings,
MavenRunnerParameters params,
Project project) {
MavenRunConfigurationType type = ConfigurationTypeUtil.findConfigurationType(MavenRunConfigurationType.class);
final RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project)
.createConfiguration(generateName(project, params), type.myFactory);
RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration(generateName(project, params), type.myFactory);
MavenRunConfiguration runConfiguration = (MavenRunConfiguration)settings.getConfiguration();
runConfiguration.setRunnerParameters(params);
runConfiguration.setGeneralSettings(generalSettings);
runConfiguration.setRunnerSettings(runnerSettings);
return settings;
}
}
@@ -57,9 +57,9 @@ public class MavenRunConfigurationMenu extends DefaultActionGroup implements Dum
@Override
public void actionPerformed(AnActionEvent event) {
if (!myEnabled) return;
ProgramRunnerUtil.executeConfiguration(myProject, mySettings, myExecutor);
if (myEnabled) {
ProgramRunnerUtil.executeConfiguration(myProject, mySettings, myExecutor);
}
}
@Override
@@ -155,8 +155,7 @@ public abstract class AbstractTerminalRunner<T extends Process> {
return new CloseAction(defaultExecutor, myDescriptor, myProject);
}
protected void showConsole(Executor defaultExecutor, RunContentDescriptor myDescriptor, final Component toFocus) {
protected void showConsole(Executor defaultExecutor, @NotNull RunContentDescriptor myDescriptor, final Component toFocus) {
// Show in run toolwindow
ExecutionManager.getInstance(myProject).getContentManager().showRunContent(defaultExecutor, myDescriptor);
@@ -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.
@@ -81,6 +81,7 @@ public class BuildoutConfigPanel extends JPanel {
myErrorPanel.add(facetErrorPanel.getComponent(), BorderLayout.CENTER);
facetErrorPanel.getValidatorsManager().registerValidator(new FacetEditorValidator() {
@NotNull
@Override
public ValidationResult check() {
if (!myFacetEnabled) {
@@ -36,6 +36,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.jetbrains.python.psi.PyUtil.as;
/**
* @author yole
*/
@@ -132,6 +134,23 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase {
}
}
}
else if ("__builtin__.tuple.__add__".equals(qname) && callSite instanceof PyBinaryExpression) {
final PyBinaryExpression expression = (PyBinaryExpression)callSite;
final PyTupleType leftTupleType = as(context.getType(expression.getLeftExpression()), PyTupleType.class);
if (expression.getRightExpression() != null) {
final PyTupleType rightTupleType = as(context.getType(expression.getRightExpression()), PyTupleType.class);
if (leftTupleType != null && rightTupleType != null) {
final PyType[] elementTypes = new PyType[leftTupleType.getElementCount() + rightTupleType.getElementCount()];
for (int i = 0; i < leftTupleType.getElementCount(); i++) {
elementTypes[i] = leftTupleType.getElementType(i);
}
for (int i = 0; i < rightTupleType.getElementCount(); i++) {
elementTypes[i + leftTupleType.getElementCount()] = rightTupleType.getElementType(i);
}
return PyTupleType.create(function, elementTypes);
}
}
}
}
return null;
}
@@ -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.
@@ -120,6 +120,7 @@ public class PyIntegratedToolsConfigurable implements SearchableConfigurable, No
myErrorPanel.add(facetErrorPanel.getComponent(), BorderLayout.CENTER);
facetErrorPanel.getValidatorsManager().registerValidator(new FacetEditorValidator() {
@NotNull
@Override
public ValidationResult check() {
final Sdk sdk = PythonSdkType.findPythonSdk(myModule);
@@ -54,7 +54,7 @@ public class PythonToolWindowConsoleRunner extends PydevConsoleRunner {
}
@Override
protected void showConsole(Executor defaultExecutor, RunContentDescriptor contentDescriptor) {
protected void showConsole(Executor defaultExecutor, @NotNull RunContentDescriptor contentDescriptor) {
PythonConsoleToolWindow terminalView = PythonConsoleToolWindow.getInstance(getProject());
terminalView.init(getToolWindow(), contentDescriptor);
}
@@ -239,8 +239,6 @@ public class PyPIPackageUtil {
if (connection instanceof HttpsURLConnection) {
((HttpsURLConnection)connection).setSSLSocketFactory(sslContext.getSocketFactory());
}
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
InputStream is = connection.getInputStream();
Reader reader = new InputStreamReader(is);
try{
@@ -160,4 +160,20 @@
<line>99</line>
<description>Too few arguments for format string</description>
</problem>
<problem>
<file>string-format.py</file>
<line>103</line>
<description>Unexpected type</description>
</problem>
<problem>
<file>string-format.py</file>
<line>104</line>
<description>Too few arguments for format string</description>
</problem>
<problem>
<file>string-format.py</file>
<line>105</line>
<description>Too many arguments for format string</description>
</problem>
</problems>
@@ -96,4 +96,10 @@ print '%d' % string[:2]
my_tuple = (1,2,3,4,5,6,7,8)
print '%d, %d' % my_tuple[:7:3]
print '%d, %d, %d' % my_tuple[:7:3]
print '%d, %d, %d, %d' % my_tuple[:7:3]
print '%d, %d, %d, %d' % my_tuple[:7:3]
# PY-12801
print '%d %s' % ((42,) + ('spam',))
print '%d %s' % (('ham',) + ('spam',))
print '%d %s' % ((42,) + ())
print '%d' % ((42,) + ('spam',))
@@ -829,6 +829,12 @@ public class PyTypeTest extends PyTestCase {
" pass\n");
}
// PY-12801
public void testTupleConcatenation() {
doTest("(int, bool, str)",
"expr = (1,) + (True, 'spam') + ()");
}
private static TypeEvalContext getTypeEvalContext(@NotNull PyExpression element) {
return TypeEvalContext.userInitiated(element.getContainingFile()).withTracing();
}