Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2017-04-12 11:56:28 +02:00
134 changed files with 1963 additions and 1772 deletions
+2 -2
View File
@@ -158,9 +158,9 @@ VM_OPTIONS_FILE=""
if [ -n "$@@product_uc@@_VM_OPTIONS" -a -r "$@@product_uc@@_VM_OPTIONS" ]; then
# explicit
VM_OPTIONS_FILE="$@@product_uc@@_VM_OPTIONS"
elif [ -r "$HOME/.@@system_selector@@/@@vm_options@@$BITS.vmoptions" ]; then
elif [ -r "$HOME/.@@system_selector@@/config/@@vm_options@@$BITS.vmoptions" ]; then
# user-overridden
VM_OPTIONS_FILE="$HOME/.@@system_selector@@/@@vm_options@@$BITS.vmoptions"
VM_OPTIONS_FILE="$HOME/.@@system_selector@@/config/@@vm_options@@$BITS.vmoptions"
elif [ -r "$IDE_BIN_HOME/@@vm_options@@$BITS.vmoptions" ]; then
# default, standard installation
VM_OPTIONS_FILE="$IDE_BIN_HOME/@@vm_options@@$BITS.vmoptions"
+2 -2
View File
@@ -64,14 +64,14 @@ IF EXIST "%JRE%\lib\amd64" SET BITS=64
:: ---------------------------------------------------------------------
IF NOT "%@@product_uc@@_PROPERTIES%" == "" SET IDE_PROPERTIES_PROPERTY="-Didea.properties.file=%@@product_uc@@_PROPERTIES%"
SET USER_VM_OPTIONS_FILE=%USERPROFILE%\.@@system_selector@@\@@vm_options@@.vmoptions
SET USER_VM_OPTIONS_FILE=%USERPROFILE%\.@@system_selector@@\config\@@vm_options@@.vmoptions
SET VM_OPTIONS_FILE=%IDE_BIN_DIR%\@@vm_options@@.vmoptions
IF EXIST "%IDE_BIN_DIR%\win\@@vm_options@@.vmoptions" SET VM_OPTIONS_FILE=%IDE_BIN_DIR%\win\@@vm_options@@.vmoptions
IF EXIST %USER_VM_OPTIONS_FILE% SET VM_OPTIONS_FILE=%USER_VM_OPTIONS_FILE%
IF NOT "%@@product_uc@@_VM_OPTIONS%" == "" SET VM_OPTIONS_FILE=%@@product_uc@@_VM_OPTIONS%
SET ACC=
FOR /F "usebackq delims=" %%i IN ("%VM_OPTIONS_FILE%") DO CALL "%IDE_BIN_DIR%\append.bat" "%%i"
FOR /F "eol=# usebackq delims=" %%i IN ("%VM_OPTIONS_FILE%") DO CALL "%IDE_BIN_DIR%\append.bat" "%%i"
IF EXIST "%VM_OPTIONS_FILE%" SET ACC=%ACC% -Djb.vmOptionsFile="%VM_OPTIONS_FILE%"
SET COMMON_JVM_ARGS="-XX:ErrorFile=%USERPROFILE%\java_error_in_@@product_uc@@_%%p.log" "-XX:HeapDumpPath=%USERPROFILE%\java_error_in_@@product_uc@@.hprof" "-Xbootclasspath/a:%IDE_HOME%/lib/boot.jar" -Didea.paths.selector=@@system_selector@@ %IDE_PROPERTIES_PROPERTY%
-11
View File
@@ -1,6 +1,5 @@
<project name="Test gant invocation from Ant script" default="doGant" xmlns:if="ant:if">
<dirname property="build.dir" file="${ant.file}"/>
<property name="include.kotlin.jars.to.classpath" value="true"/>
<property name="project.home" value="${build.dir}/.."/>
<property name="gant.home" value="${project.home}/build/lib/gant"/>
<property name="idea.lib" value="${project.home}/lib"/>
@@ -21,16 +20,6 @@
<pathelement path="${project.home}/platform/build-scripts/groovy"/>
<pathelement path="${project.home}/build/groovy"/>
<fileset file="${project.home}/jps/lib/optimizedFileManager.jar"/>
<fileset dir="${project.home}/build/dependencies/build/Kotlin/lib/jps" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<include name="*.jar"/>
</fileset>
<fileset dir="${project.home}/build/dependencies/build/Kotlin/kotlinc/lib" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<include name="kotlin-runtime.jar"/>
<include name="kotlin-reflect.jar"/>
</fileset>
<fileset dir="${project.home}/build/dependencies/build/Kotlin/lib" erroronmissingdir="false" if:true="${include.kotlin.jars.to.classpath}">
<include name="kotlin-plugin.jar"/>
</fileset>
<fileset dir="${idea.lib}">
<include name="jdom.jar"/>
<include name="log4j.jar"/>
+11 -1
View File
@@ -42,4 +42,14 @@ target('update-from-sources': 'Update locally installed distribution from compil
//when IDEA CE is updated from IDEA UE sources project should be loaded from IDEA UE directory
String projectHome = isDefined("devIdeaHome") ? devIdeaHome : home
new IdeaCommunityBuilder(home, binding, options, projectHome).buildUnpackedDistribution(deploy)
}
}
private boolean isDefined(String key) {
try {
this[key]
return true
}
catch (MissingPropertyException ignored) {
return false
}
}
+1 -4
View File
@@ -150,12 +150,9 @@ private void setupKotlin() {
}
private boolean ensureKotlinCompilerAddedToClassPath() {
try {
Class.forName("org.jetbrains.kotlin.jps.build.KotlinBuilder")
if (getClass().getResource("/org/jetbrains/kotlin/jps/build/KotlinBuilder.class") != null) {
return true
}
catch (ClassNotFoundException ignored) {
}
def kotlinPluginLibPath = "$home/build/dependencies/build/Kotlin/lib"
if (!new File(kotlinPluginLibPath).exists()) {
@@ -160,8 +160,9 @@ public class BuildManager implements Disposable {
private final BuildProcessClasspathManager myClasspathManager = new BuildProcessClasspathManager();
private final ExecutorService myRequestsProcessor = SequentialTaskExecutor.createSequentialApplicationPoolExecutor("BuildManager requestProcessor pool");
private final Map<String, ProjectData> myProjectDataMap = Collections.synchronizedMap(new HashMap<String, ProjectData>());
private volatile int myFileChangeCounter = 0;
private final BuildManagerPeriodicTask myAutoMakeTask = new BuildManagerPeriodicTask(this) {
private final BuildManagerPeriodicTask myAutoMakeTask = new BuildManagerPeriodicTask() {
@Override
protected int getDelay() {
return Registry.intValue("compiler.automake.trigger.delay");
@@ -173,7 +174,7 @@ public class BuildManager implements Disposable {
}
};
private final BuildManagerPeriodicTask myDocumentSaveTask = new BuildManagerPeriodicTask(this) {
private final BuildManagerPeriodicTask myDocumentSaveTask = new BuildManagerPeriodicTask() {
@Override
protected int getDelay() {
return Registry.intValue("compiler.document.save.trigger.delay");
@@ -303,8 +304,14 @@ public class BuildManager implements Disposable {
conn.subscribe(BatchFileChangeListener.TOPIC, new BatchFileChangeListener.Adapter() {
@Override
public void batchChangeStarted(Project project) {
myFileChangeCounter++;
cancelAutoMakeTasks(project);
}
@Override
public void batchChangeCompleted(Project project) {
myFileChangeCounter--;
}
});
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentAdapter() {
@@ -1438,7 +1445,7 @@ public class BuildManager implements Disposable {
}
}
private abstract static class BuildManagerPeriodicTask implements Runnable {
private abstract class BuildManagerPeriodicTask implements Runnable {
private final Alarm myAlarm;
private final AtomicBoolean myInProgress = new AtomicBoolean(false);
private final Runnable myTaskRunnable = () -> {
@@ -1450,8 +1457,8 @@ public class BuildManager implements Disposable {
}
};
protected BuildManagerPeriodicTask(@NotNull Disposable disposable) {
myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, disposable);
protected BuildManagerPeriodicTask() {
myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, BuildManager.this);
}
public final void schedule() {
@@ -1470,7 +1477,7 @@ public class BuildManager implements Disposable {
@Override
public final void run() {
if (!HeavyProcessLatch.INSTANCE.isRunning() && !myInProgress.getAndSet(true)) {
if (!HeavyProcessLatch.INSTANCE.isRunning() && myFileChangeCounter <= 0 && !myInProgress.getAndSet(true)) {
try {
ApplicationManager.getApplication().executeOnPooledThread(myTaskRunnable);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,13 +21,9 @@ import org.jetbrains.annotations.NotNull;
/**
* @author Vitaliy.Bibaev
*/
@FunctionalInterface
public interface ConditionChecker {
CheckingResult check(@NotNull ObjectReference ref);
ConditionChecker ALL_MATCHED_CHECKER = new ConditionChecker() {
@Override
public CheckingResult check(@NotNull ObjectReference ref) {
return CheckingResultImpl.SUCCESS;
}
};
ConditionChecker ALL_MATCHED_CHECKER = ref -> CheckingResultImpl.SUCCESS;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
@FunctionalInterface
public interface InstancesProvider {
@NotNull
List<ObjectReference> getInstances(int limit);
@@ -32,6 +32,7 @@ import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.ui.JavaDebuggerSupport;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -42,7 +43,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
@@ -247,7 +247,7 @@ public class BreakpointManager {
public ExceptionBreakpoint addExceptionBreakpoint(@NotNull final String exceptionClassName, final String packageName) {
ApplicationManager.getApplication().assertIsDispatchThread();
final JavaExceptionBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
return ApplicationManager.getApplication().runWriteAction((Computable<ExceptionBreakpoint>)() -> {
return WriteAction.compute(() -> {
XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = XDebuggerManager.getInstance(myProject).getBreakpointManager()
.addBreakpoint(type, new JavaExceptionBreakpointProperties(exceptionClassName, packageName));
Breakpoint javaBreakpoint = getJavaBreakpoint(xBreakpoint);
@@ -279,7 +279,7 @@ public class BreakpointManager {
private <B extends XBreakpoint<?>> XLineBreakpoint addXLineBreakpoint(Class<? extends XBreakpointType<B,?>> typeCls, Document document, final int lineIndex) {
final XBreakpointType<B, ?> type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
return ApplicationManager.getApplication().runWriteAction((Computable<XLineBreakpoint>)() -> XDebuggerManager.getInstance(myProject).getBreakpointManager()
return WriteAction.compute(() -> XDebuggerManager.getInstance(myProject).getBreakpointManager()
.addLineBreakpoint((XLineBreakpointType)type, file.getUrl(), lineIndex,
((XLineBreakpointType)type).createBreakpointProperties(file, lineIndex)));
}
@@ -443,7 +443,7 @@ public class BreakpointManager {
private <B extends XBreakpoint<?>> XBreakpoint createXBreakpoint(Class<? extends XBreakpointType<B, ?>> typeCls) {
final XBreakpointType<B, ?> type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
return ApplicationManager.getApplication().runWriteAction((Computable<XBreakpoint>)() -> XDebuggerManager.getInstance(myProject).getBreakpointManager().addBreakpoint((XBreakpointType)type, type.createProperties()));
return WriteAction.compute(() -> XDebuggerManager.getInstance(myProject).getBreakpointManager().addBreakpoint((XBreakpointType)type, type.createProperties()));
}
private <B extends XBreakpoint<?>> XLineBreakpoint createXLineBreakpoint(Class<? extends XBreakpointType<B, ?>> typeCls,
@@ -479,7 +479,7 @@ public class BreakpointManager {
if (breakpoint == null) {
return;
}
ApplicationManager.getApplication().runWriteAction(() -> getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint));
WriteAction.run(() -> getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint));
}
public void writeExternal(@NotNull final Element parentNode) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import com.intellij.CommonBundle;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
@@ -146,7 +146,7 @@ public class JavaFieldBreakpointType extends JavaLineBreakpointTypeBase<JavaFiel
PsiField field = psiClass.findFieldByName(fieldName, true);
if(field != null) {
final int line = document.getLineNumber(field.getTextOffset());
ApplicationManager.getApplication().runWriteAction(() -> {
WriteAction.run(() -> {
XLineBreakpoint<JavaFieldBreakpointProperties> fieldBreakpoint = XDebuggerManager.getInstance(project).getBreakpointManager()
.addLineBreakpoint(JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(), line, new JavaFieldBreakpointProperties(fieldName, className));
result.set(fieldBreakpoint);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,9 +18,8 @@ package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
@@ -104,7 +103,7 @@ public class JavaWildcardMethodBreakpointType extends JavaBreakpointTypeBase<Jav
if (!dialog.showAndGet()) {
return null;
}
return ApplicationManager.getApplication().runWriteAction((Computable<XBreakpoint<JavaMethodBreakpointProperties>>)() -> {
return WriteAction.compute(() -> {
JavaMethodBreakpointProperties properties = new JavaMethodBreakpointProperties(dialog.getClassPattern(), dialog.getMethodName());
if (Registry.is("debugger.emulate.method.breakpoints")) {
properties.EMULATED = true; // create all new emulated
@@ -45,6 +45,7 @@ import com.intellij.platform.ProjectTemplate;
import com.intellij.platform.ProjectTemplateEP;
import com.intellij.platform.ProjectTemplatesFactory;
import com.intellij.platform.templates.*;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.ui.CollectionListModel;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ListSpeedSearch;
@@ -233,6 +234,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
}
final String groupId = PropertiesComponent.getInstance().getValue(PROJECT_WIZARD_GROUP);
LOG.debug("saved groupId=" + groupId);
if (groupId != null) {
TemplatesGroup group = ContainerUtil.find(groups, group1 -> groupId.equals(group1.getId()));
if (group != null) {
@@ -375,6 +377,9 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
if (group == null || group == myLastSelectedGroup) return;
myLastSelectedGroup = group;
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId() );
if (LOG.isDebugEnabled()) {
LOG.debug("projectTypeChanged: " + group.getId() + " " + DebugUtil.currentStackTrace());
}
ModuleBuilder groupModuleBuilder = group.getModuleBuilder();
mySettingsStep = null;
@@ -134,7 +134,7 @@
</constraints>
<properties>
<label value="Download Sources"/>
<text resource-bundle="ProjectBundle" key="maven.property.download.sources"/>
<text value="Download &amp;Sources"/>
</properties>
</component>
<hspacer id="7d6e5">
@@ -148,7 +148,7 @@
</constraints>
<properties>
<label value="Download JavaDocs"/>
<text resource-bundle="ProjectBundle" key="maven.property.download.javadocs"/>
<text value="Download &amp;JavaDocs"/>
</properties>
</component>
</children>
@@ -462,7 +462,7 @@ public class MarkerType {
return super.process(psiMethod);
}
});
if (myMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
if (ReadAction.compute(() -> myMethod.hasModifierProperty(PsiModifier.ABSTRACT))) {
PsiClass psiClass = ReadAction.compute(myMethod::getContainingClass);
FunctionalExpressionSearch.search(psiClass).forEach(new CommonProcessors.CollectProcessor<PsiFunctionalExpression>() {
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import com.intellij.codeInsight.daemon.quickFix.ExternalLibraryResolver.External
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.DumbService;
@@ -36,13 +37,15 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.source.PsiJavaModuleReference;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.ThreeState;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.uast.UAnnotation;
import org.jetbrains.uast.UImportStatement;
import org.jetbrains.uast.UastContextKt;
import java.io.File;
import java.util.*;
@@ -219,13 +222,13 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix {
}
private static ThreeState isReferenceToAnnotation(final PsiElement psiElement) {
if (!PsiUtil.isLanguageLevel5OrHigher(psiElement)) {
if (psiElement.getLanguage() == JavaLanguage.INSTANCE && !PsiUtil.isLanguageLevel5OrHigher(psiElement)) {
return ThreeState.NO;
}
if (PsiTreeUtil.getParentOfType(psiElement, PsiAnnotation.class) != null) {
if (UastContextKt.getUastParentOfType(psiElement, UAnnotation.class) != null) {
return ThreeState.YES;
}
if (PsiTreeUtil.getParentOfType(psiElement, PsiImportStatement.class) != null) {
if (UastContextKt.getUastParentOfType(psiElement, UImportStatement.class) != null) {
return ThreeState.UNSURE;
}
return ThreeState.NO;
@@ -115,7 +115,8 @@ public class JavaReflectionInvocationInspection extends BaseJavaBatchLocalInspec
final PsiExpression[] expressions = argumentList.getExpressions();
final PsiElement element = expressions.length == argumentOffset + 1 ? expressions[argumentOffset] : argumentList;
holder.registerProblem(element, InspectionsBundle.message(
"inspection.reflection.invocation.item.number.not.assignable", i, requiredType.getQualifiedName()));
"inspection.reflection.invocation.array.not.assignable", actualArguments.expressions.length));
break;
}
}
}
@@ -21,7 +21,9 @@ import com.intellij.codeInspection.*;
import com.intellij.codeInspection.reference.*;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.PsiReference;
import com.intellij.psi.util.PropertyUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
@@ -55,6 +57,7 @@ public class UnusedReturnValue extends GlobalJavaBatchInspectionTool{
final boolean isNative = psiMethod.hasModifierProperty(PsiModifier.NATIVE);
if (refMethod.isExternalOverride() && !isNative) return null;
if (RefUtil.isImplicitRead(psiMethod)) return null;
return new ProblemDescriptor[]{createProblemDescriptor(psiMethod, manager, processor, isNative)};
}
}
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil;
import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.reference.RefUtil;
import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.patterns.PsiJavaPatterns;
import com.intellij.psi.*;
@@ -57,7 +58,8 @@ public class UnusedReturnValueLocalInspection extends BaseJavaLocalInspectionToo
PsiType.VOID.equals(method.getReturnType()) ||
myGlobal.IGNORE_BUILDER_PATTERN && PropertyUtil.isSimplePropertySetter(method) ||
method.hasModifierProperty(PsiModifier.NATIVE) ||
MethodUtils.hasSuper(method)) return null;
MethodUtils.hasSuper(method) ||
RefUtil.isImplicitRead(method)) return null;
final boolean[] atLeastOneUsageExists = new boolean[]{false};
if (UnusedSymbolUtil.processUsages(manager.getProject(), method.getContainingFile(), method, new EmptyProgressIndicator(), null, u -> {
@@ -374,12 +374,15 @@ public class JavaReflectionReferenceUtil {
if (type.equals(PsiType.NULL)) {
return myPsiClass != null || myArrayDimensions != 0;
}
if (type.getArrayDimensions() != myArrayDimensions) {
return false;
PsiType otherType = type;
for (int i = 0; i < myArrayDimensions; i++) {
if (!(otherType instanceof PsiArrayType)) {
return false;
}
otherType = ((PsiArrayType)otherType).getComponentType();
}
final PsiType otherType = type.getDeepComponentType();
if (myPrimitiveType != null) {
return myPrimitiveType.isAssignableFrom(otherType) || otherType.equalsToText(myPrimitiveType.getBoxedTypeName());
return myPrimitiveType.isAssignableFrom(otherType);
}
final PsiElementFactory factory = JavaPsiFacade.getInstance(myPsiClass.getProject()).getElementFactory();
return factory.createType(myPsiClass).isAssignableFrom(otherType);
@@ -20,13 +20,11 @@ import com.intellij.codeInsight.TestFrameworks;
import com.intellij.codeInsight.intention.impl.BaseMoveInitializerToMethodAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.testIntegration.JavaTestFramework;
import com.intellij.testIntegration.TestFramework;
import com.intellij.testIntegration.TestIntegrationUtils;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
@@ -53,25 +51,23 @@ public class MoveInitializerToSetUpMethodAction extends BaseMoveInitializerToMet
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
final boolean isAvailable = super.isAvailable(project, editor, element) && TestIntegrationUtils.isTest(element);
final boolean isAvailable = super.isAvailable(project, editor, element);
if (isAvailable) {
final PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class);
LOG.assertTrue(field != null);
final PsiClass aClass = field.getContainingClass();
LOG.assertTrue(aClass != null);
TestFramework testFramework = TestFrameworks.detectFramework(aClass);
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
for (TestFramework framework : Extensions.getExtensions(TestFramework.EXTENSION_NAME)) {
if (framework instanceof JavaTestFramework && framework.isTestClass(aClass)) {
try {
((JavaTestFramework)framework).createSetUpPatternMethod(elementFactory);
return true;
}
catch (Exception e) {
return false;
}
if (testFramework instanceof JavaTestFramework) {
try {
((JavaTestFramework)testFramework).createSetUpPatternMethod(elementFactory);
return testFramework.isTestClass(aClass) || testFramework.findSetUpMethod(aClass) instanceof PsiMethod;
}
catch (Exception e) {
return false;
}
}
return true;
}
return false;
}
@@ -85,7 +81,14 @@ public class MoveInitializerToSetUpMethodAction extends BaseMoveInitializerToMet
@NotNull
@Override
protected Collection<PsiMethod> getOrCreateMethods(@NotNull Project project, @NotNull Editor editor, PsiFile file, @NotNull PsiClass aClass) {
final PsiMethod setUpMethod = TestFrameworks.getInstance().findOrCreateSetUpMethod(aClass);
return setUpMethod == null ? Collections.<PsiMethod>emptyList() : Arrays.asList(setUpMethod);
TestFramework testFramework = TestFrameworks.detectFramework(aClass);
PsiElement setUpMethod = null;
if (testFramework != null) {
setUpMethod = testFramework.findSetUpMethod(aClass);
if (setUpMethod == null) {
setUpMethod = testFramework.findOrCreateSetUpMethod(aClass);
}
}
return setUpMethod instanceof PsiMethod ? Collections.singletonList((PsiMethod)setUpMethod) : Collections.emptyList();
}
}
@@ -0,0 +1,26 @@
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.logging.Logger;
class MyTest
{
private final static Logger LOGGER = Logger.getLogger(MyTest.class.getName());
public static void test(List<List<String>> testList) {
testList.forEach( MyTest.bind(MyTest.cast(LOGGER::info), iterable -> ""));
}
private static <A1, A2> TestConsumer<A1, A2> bind(Consumer<? super A2> delegate, Function<A1, A2> function) {
return null;
}
private static <C1> Consumer<C1> cast(Consumer<C1> consumer)
{
return consumer;
}
private interface TestConsumer<T1, T2> extends Consumer<T1> { }
}
@@ -0,0 +1,10 @@
// "Move initializer to setUp method" "true"
public class X {
int i;
@org.junit.Before
public void setUp() throws Exception {
i = 7;
}
}
@@ -0,0 +1,9 @@
// "Move initializer to setUp method" "true"
public class X {
<caret>int i = 7;
@org.junit.Before
public void setUp() throws Exception {
}
}
@@ -1,3 +1,4 @@
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.util.*;
@@ -32,9 +33,9 @@ class ConstructorParamTypes {
c2.newInstance(new Object[] {"abc", Integer.valueOf(42)});
c3.newInstance(new Object[] {new int[]{42, 23}, Arrays.asList("x", "y")});
c1.newInstance(<warning descr="Array item 0 is not assignable to 'int'"><warning descr="Array item 1 is not assignable to 'java.lang.String'">a2</warning></warning>);
c2.newInstance(<warning descr="Array item 0 is not assignable to 'java.lang.String'"><warning descr="Array item 1 is not assignable to 'java.lang.Integer'">a3</warning></warning>);
c3.newInstance(<warning descr="Array item 0 is not assignable to 'int[]'"><warning descr="Array item 1 is not assignable to 'java.util.List'">a1</warning></warning>);
c1.newInstance(<warning descr="Array items have incompatible types">a2</warning>);
c2.newInstance(<warning descr="Array items have incompatible types">a3</warning>);
c3.newInstance(<warning descr="Array items have incompatible types">a1</warning>);
c1.newInstance(new Object[]{<warning descr="Array item is not assignable to 'int'">"42"</warning>, "abc"});
c2.newInstance(new Object[]{<warning descr="Array item is not assignable to 'java.lang.String'">42</warning>, 23});
@@ -46,9 +47,18 @@ class ConstructorParamTypes {
cls.getConstructor(String[].class).newInstance((Object)new String[] {"abc"});
cls.getConstructor(String[].class).newInstance(new String[] {<warning descr="Array item is not assignable to 'java.lang.String[]'">"abc"</warning>});
Constructor<?> c4 = cls.getConstructor(Cloneable.class);
Constructor<?> c5 = cls.getConstructor(Serializable.class);
c4.newInstance(new C());
c5.newInstance(new S());
c4.newInstance(<warning descr="Argument is not assignable to 'java.lang.Cloneable'">new S()</warning>);
c5.newInstance(<warning descr="Argument is not assignable to 'java.io.Serializable'">new C()</warning>);
}
void arraySignatutre() throws Exception {
void arraySignature() throws Exception {
Class<?> cls = Test.class;
Constructor c1 = cls.getConstructor(new Class[]{int.class, String.class});
@@ -73,9 +83,9 @@ class ConstructorParamTypes {
c2.newInstance(new Object[] {"abc", Integer.valueOf(42)});
c3.newInstance(new Object[] {new int[]{42, 23}, Arrays.asList("x", "y")});
c1.newInstance(<warning descr="Array item 0 is not assignable to 'int'"><warning descr="Array item 1 is not assignable to 'java.lang.String'">a2</warning></warning>);
c2.newInstance(<warning descr="Array item 0 is not assignable to 'java.lang.String'"><warning descr="Array item 1 is not assignable to 'java.lang.Integer'">a3</warning></warning>);
c3.newInstance(<warning descr="Array item 0 is not assignable to 'int[]'"><warning descr="Array item 1 is not assignable to 'java.util.List'">a1</warning></warning>);
c1.newInstance(<warning descr="Array items have incompatible types">a2</warning>);
c2.newInstance(<warning descr="Array items have incompatible types">a3</warning>);
c3.newInstance(<warning descr="Array items have incompatible types">a1</warning>);
c1.newInstance(new Object[]{<warning descr="Array item is not assignable to 'int'">"42"</warning>, "abc"});
c2.newInstance(new Object[]{<warning descr="Array item is not assignable to 'java.lang.String'">42</warning>, 23});
@@ -87,6 +97,15 @@ class ConstructorParamTypes {
cls.getConstructor(new Class[]{String[].class}).newInstance((Object)new String[] {"abc"});
cls.getConstructor(new Class[]{String[].class}).newInstance(new String[] {<warning descr="Array item is not assignable to 'java.lang.String[]'">"abc"</warning>});
Constructor<?> c4 = cls.getConstructor(new Class[]{Cloneable.class});
Constructor<?> c5 = cls.getConstructor(new Class[]{Serializable.class});
c4.newInstance(new C());
c5.newInstance(new S());
c4.newInstance(<warning descr="Argument is not assignable to 'java.lang.Cloneable'">new S()</warning>);
c5.newInstance(<warning descr="Argument is not assignable to 'java.io.Serializable'">new C()</warning>);
}
void manyArguments() throws Exception {
@@ -107,11 +126,38 @@ class ConstructorParamTypes {
Object[] a5 = {0, (short)0, 0, 0.0f, "abc"};
m0.newInstance(a0);
m1.newInstance(<warning descr="Array item 0 is not assignable to 'int'">a1</warning>);
m2.newInstance(<warning descr="Array item 1 is not assignable to 'short'">a2</warning>);
m3.newInstance(<warning descr="Array item 2 is not assignable to 'long'">a3</warning>);
m4.newInstance(<warning descr="Array item 3 is not assignable to 'float'">a4</warning>);
m5.newInstance(<warning descr="Array item 4 is not assignable to 'double'">a5</warning>);
m1.newInstance(<warning descr="Array item has incompatible type">a1</warning>);
m2.newInstance(<warning descr="Array items have incompatible types">a2</warning>);
m3.newInstance(<warning descr="Array items have incompatible types">a3</warning>);
m4.newInstance(<warning descr="Array items have incompatible types">a4</warning>);
m5.newInstance(<warning descr="Array items have incompatible types">a5</warning>);
}
void arrayArguments() throws Exception {
Class<?> cls = Test.class;
Constructor c1 = cls.getConstructor(Object.class);
Constructor c2 = cls.getConstructor(Cloneable.class);
Constructor c3 = cls.getConstructor(Serializable.class);
c1.newInstance((Object) new String[0]);
c2.newInstance((Object) new String[0]);
c3.newInstance((Object) new String[0]);
c1.newInstance((Object) new String[][]{ new String[0] });
c2.newInstance((Object) new String[][]{ new String[0] });
c3.newInstance((Object) new String[][]{ new String[0] });
Constructor c4 = cls.getConstructor(Object[].class);
Constructor c5 = cls.getConstructor(String[].class);
c4.newInstance((Object) new String[0]);
c4.newInstance((Object) new String[][]{ new String[0] });
c5.newInstance((Object) new String[0]);
c5.newInstance((Object) <warning descr="Argument is not assignable to 'java.lang.String[]'">new String[][]{ new String[0] }</warning>);
c5.newInstance(<warning descr="Argument is not assignable to 'java.lang.String[]'">"abc"</warning>);
c5.newInstance(<warning descr="Argument is not assignable to 'java.lang.String[]'">new Test(1, null)</warning>);
}
class Test {
@@ -119,6 +165,11 @@ class ConstructorParamTypes {
public Test(String s, Integer n) {}
public Test(int[] n, List<String> s) {}
public Test(String[] s) {}
public Test(Object[] s) {}
public Test(Object o) {}
public Test(Cloneable c) {}
public Test(Serializable s) {}
}
class M {
@@ -128,4 +179,10 @@ class ConstructorParamTypes {
public String m4(int a1, short a2, long a3, float a4) {return "";}
public String m5(int a1, short a2, long a3, float a4, double a5) {return "";}
}
static class S implements Serializable {
}
static class C implements Cloneable {
}
}
@@ -1,3 +1,4 @@
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.*;
@@ -33,9 +34,9 @@ class MethodParamTypes {
m2.invoke(obj, new Object[] {"abc", Integer.valueOf(42)});
m3.invoke(obj, new Object[] {new int[]{42, 23}, Arrays.asList("x", "y")});
m1.invoke(obj, <warning descr="Array item 0 is not assignable to 'int'"><warning descr="Array item 1 is not assignable to 'java.lang.String'">a2</warning></warning>);
m2.invoke(obj, <warning descr="Array item 0 is not assignable to 'java.lang.String'"><warning descr="Array item 1 is not assignable to 'java.lang.Integer'">a3</warning></warning>);
m3.invoke(obj, <warning descr="Array item 0 is not assignable to 'int[]'"><warning descr="Array item 1 is not assignable to 'java.util.List'">a1</warning></warning>);
m1.invoke(obj, <warning descr="Array items have incompatible types">a2</warning>);
m2.invoke(obj, <warning descr="Array items have incompatible types">a3</warning>);
m3.invoke(obj, <warning descr="Array items have incompatible types">a1</warning>);
m1.invoke(obj, new Object[]{<warning descr="Array item is not assignable to 'int'">"42"</warning>, "abc"});
m2.invoke(obj, new Object[]{<warning descr="Array item is not assignable to 'java.lang.String'">42</warning>, 23});
@@ -47,9 +48,18 @@ class MethodParamTypes {
cls.getMethod("str", String[].class).invoke(null, (Object)new String[] {"abc"});
cls.getMethod("str", String[].class).invoke(null, new String[] {<warning descr="Array item is not assignable to 'java.lang.String[]'">"abc"</warning>});
Method m4 = cls.getMethod("obj", Cloneable.class);
Method m5 = cls.getMethod("obj", Serializable.class);
m4.invoke(obj, new C());
m5.invoke(obj, new S());
m4.invoke(obj, <warning descr="Argument is not assignable to 'java.lang.Cloneable'">new S()</warning>);
m5.invoke(obj, <warning descr="Argument is not assignable to 'java.io.Serializable'">new C()</warning>);
}
void arraySignatutre() throws Exception {
void arraySignature() throws Exception {
Class<?> cls = Test.class;
Object obj = new Test();
@@ -75,9 +85,9 @@ class MethodParamTypes {
m2.invoke(obj, new Object[] {"abc", Integer.valueOf(42)});
m3.invoke(obj, new Object[] {new int[]{42, 23}, Arrays.asList("x", "y")});
m1.invoke(obj, <warning descr="Array item 0 is not assignable to 'int'"><warning descr="Array item 1 is not assignable to 'java.lang.String'">a2</warning></warning>);
m2.invoke(obj, <warning descr="Array item 0 is not assignable to 'java.lang.String'"><warning descr="Array item 1 is not assignable to 'java.lang.Integer'">a3</warning></warning>);
m3.invoke(obj, <warning descr="Array item 0 is not assignable to 'int[]'"><warning descr="Array item 1 is not assignable to 'java.util.List'">a1</warning></warning>);
m1.invoke(obj, <warning descr="Array items have incompatible types">a2</warning>);
m2.invoke(obj, <warning descr="Array items have incompatible types">a3</warning>);
m3.invoke(obj, <warning descr="Array items have incompatible types">a1</warning>);
m1.invoke(obj, new Object[]{<warning descr="Array item is not assignable to 'int'">"42"</warning>, "abc"});
m2.invoke(obj, new Object[]{<warning descr="Array item is not assignable to 'java.lang.String'">42</warning>, 23});
@@ -89,6 +99,15 @@ class MethodParamTypes {
cls.getMethod("str", new Class[]{String[].class}).invoke(null, (Object)new String[] {"abc"});
cls.getMethod("str", new Class[]{String[].class}).invoke(null, new String[] {<warning descr="Array item is not assignable to 'java.lang.String[]'">"abc"</warning>});
Method m4 = cls.getMethod("obj", new Class[]{Cloneable.class});
Method m5 = cls.getMethod("obj", new Class[]{Serializable.class});
m4.invoke(obj, new C());
m5.invoke(obj, new S());
m4.invoke(obj, <warning descr="Argument is not assignable to 'java.lang.Cloneable'">new S()</warning>);
m5.invoke(obj, <warning descr="Argument is not assignable to 'java.io.Serializable'">new C()</warning>);
}
void manyArguments() throws Exception {
@@ -110,11 +129,39 @@ class MethodParamTypes {
Object[] a5 = {0, (short)0, 0, 0.0f, "abc"};
m0.invoke(obj, a0);
m1.invoke(obj, <warning descr="Array item 0 is not assignable to 'int'">a1</warning>);
m2.invoke(obj, <warning descr="Array item 1 is not assignable to 'short'">a2</warning>);
m3.invoke(obj, <warning descr="Array item 2 is not assignable to 'long'">a3</warning>);
m4.invoke(obj, <warning descr="Array item 3 is not assignable to 'float'">a4</warning>);
m5.invoke(obj, <warning descr="Array item 4 is not assignable to 'double'">a5</warning>);
m1.invoke(obj, <warning descr="Array item has incompatible type">a1</warning>);
m2.invoke(obj, <warning descr="Array items have incompatible types">a2</warning>);
m3.invoke(obj, <warning descr="Array items have incompatible types">a3</warning>);
m4.invoke(obj, <warning descr="Array items have incompatible types">a4</warning>);
m5.invoke(obj, <warning descr="Array items have incompatible types">a5</warning>);
}
void arrayArguments() throws Exception {
Class<?> cls = Test.class;
Object obj = new Test();
Method m1 = cls.getMethod("obj", Object.class);
Method m2 = cls.getMethod("obj", Cloneable.class);
Method m3 = cls.getMethod("obj", Serializable.class);
m1.invoke(obj, (Object) new String[0]);
m2.invoke(obj, (Object) new String[0]);
m3.invoke(obj, (Object) new String[0]);
m1.invoke(obj, (Object) new String[][]{ new String[0] });
m2.invoke(obj, (Object) new String[][]{ new String[0] });
m3.invoke(obj, (Object) new String[][]{ new String[0] });
Method m4 = cls.getMethod("array", Object[].class);
Method m5 = cls.getMethod("array", String[].class);
m4.invoke(null, (Object) new String[0]);
m4.invoke(null, (Object) new String[][]{ new String[0] });
m5.invoke(null, (Object) new String[0]);
m5.invoke(null, (Object) <warning descr="Argument is not assignable to 'java.lang.String[]'">new String[][]{ new String[0] }</warning>);
m5.invoke(null, <warning descr="Argument is not assignable to 'java.lang.String[]'">"abc"</warning>);
m5.invoke(null, <warning descr="Argument is not assignable to 'java.lang.String[]'">obj</warning>);
}
static class Test {
@@ -123,6 +170,13 @@ class MethodParamTypes {
public void bar(int[] n, List<String> s) {}
public static void str(String[] s) {}
public void obj(Object o) {}
public void obj(Cloneable c) {}
public void obj(Serializable s) {}
public static void array(Object[] a) {}
public static void array(String[] a) {}
}
class M {
@@ -132,4 +186,10 @@ class MethodParamTypes {
public String m4(int a1, short a2, long a3, float a4) {return "";}
public String m5(int a1, short a2, long a3, float a4, double a5) {return "";}
}
static class S implements Serializable {
}
static class C implements Cloneable {
}
}
@@ -0,0 +1,9 @@
class Test {
public String <caret>implicitRead() {
return "";
}
{
implicitRead();
}
}
@@ -178,6 +178,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testTopLevelParentNoParameters() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}
@@ -16,7 +16,12 @@
package com.intellij.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
import com.intellij.codeInspection.unusedReturnValue.UnusedReturnValue;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
/**
@@ -27,11 +32,33 @@ public class UnusedReturnValueQuickFixTest extends LightCodeInsightFixtureTestCa
@Override
protected void setUp() throws Exception {
super.setUp();
PlatformTestUtil.registerExtension(Extensions.getRootArea(), ImplicitUsageProvider.EP_NAME, new ImplicitUsageProvider() {
@Override
public boolean isImplicitUsage(PsiElement element) {
return false;
}
@Override
public boolean isImplicitRead(PsiElement element) {
return element instanceof PsiMethod && ((PsiMethod)element).getName().equals("implicitRead");
}
@Override
public boolean isImplicitWrite(PsiElement element) {
return false;
}
}, getTestRootDisposable());
myFixture.enableInspections(new UnusedReturnValue());
}
public void testSideEffects() { doTest(); }
public void testRedundantReturn() { doTest(); }
public void testNoChangeForImplicitRead() {
final String name = getTestName(false);
myFixture.configureByFile(name + ".java");
assertEmpty(myFixture.filterAvailableIntentions(InspectionsBundle.message("inspection.unused.return.value.make.void.quickfix")));
}
private void doTest() {
final String name = getTestName(false);
@@ -1,734 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.execution.impl;
import com.intellij.execution.application.ApplicationConfigurationType;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.junit.JUnitConfigurationType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Trinity;
import com.intellij.testFramework.LightIdeaTestCase;
import com.intellij.ui.RowsDnDSupport;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.JdomKt;
import org.jdom.Element;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import java.util.ArrayList;
import java.util.List;
import static com.intellij.execution.impl.RunConfigurable.NodeKind.*;
import static com.intellij.ui.RowsDnDSupport.RefinedDropSupport.Position.*;
/**
* User: Vassiliy.Kudryashov
*/
public class RunConfigurableTest extends LightIdeaTestCase {
private static final RunConfigurable.NodeKind[] ORDER = {
CONFIGURATION_TYPE,//Application
FOLDER,//1
CONFIGURATION, CONFIGURATION, CONFIGURATION, CONFIGURATION, CONFIGURATION,
TEMPORARY_CONFIGURATION, TEMPORARY_CONFIGURATION,
FOLDER,//2
TEMPORARY_CONFIGURATION,
FOLDER,//3
CONFIGURATION,
TEMPORARY_CONFIGURATION,
CONFIGURATION_TYPE,//JUnit
FOLDER,//4
CONFIGURATION, CONFIGURATION,
FOLDER,//5
CONFIGURATION, CONFIGURATION,
TEMPORARY_CONFIGURATION,
UNKNOWN//Defaults
};
private MockRunConfigurable myConfigurable;
private Tree myTree;
private DefaultMutableTreeNode myRoot;
private RunConfigurable.MyTreeModel myModel;
@Override
protected void setUp() throws Exception {
super.setUp();
myConfigurable = new MockRunConfigurable(createRunManager(JdomKt.loadElement(FOLDERS_CONFIGURATION)));
myTree = myConfigurable.myTree;
myRoot = myConfigurable.myRoot;
myModel = myConfigurable.myTreeModel;
}
@Override
protected void tearDown() throws Exception {
try {
if (myConfigurable != null) myConfigurable.disposeUIResources();
myConfigurable = null;
myTree = null;
myRoot = null;
myModel = null;
}
finally {
super.tearDown();
}
}
public void testDND() throws Exception {
doExpand();
int[] never = {-1, 0, 14, 22, 23, 999};
for (int i = -1; i < 17; i++) {
for (int j : never) {
if ((j == 14 || j == 21) && i == j) {
continue;
}
assertCannot(j,i,ABOVE);
assertCannot(j,i,INTO);
assertCannot(j,i,BELOW);
}
}
assertCan(3, 3, BELOW);
assertCan(3, 3, ABOVE);
assertCannot(3, 2, BELOW);
assertCan(3, 2, ABOVE);
assertCannot(3, 1, BELOW);
assertCannot(3, 0, BELOW);
assertCan(2, 14, ABOVE);
assertCan(1, 14, ABOVE);
assertCan(1, 11, ABOVE);
assertCannot(1, 10, ABOVE);
assertCannot(1, 10, BELOW);
assertCannot(8, 6, ABOVE);
assertCan(8, 6, BELOW);
assertCannot(5, 7, BELOW);
assertCan(5, 7, ABOVE);
assertCannot(15, 11, INTO);
assertCannot(18, 21, ABOVE);
assertCan(15, 21, ABOVE);
assertTrue(myModel.isDropInto(myTree, 2, 9));
assertTrue(myModel.isDropInto(myTree, 2, 1));
assertTrue(myModel.isDropInto(myTree, 12, 9));
assertTrue(myModel.isDropInto(myTree, 12, 1));
assertFalse(myModel.isDropInto(myTree, 999, 9));
assertFalse(myModel.isDropInto(myTree, 999, 1));
assertFalse(myModel.isDropInto(myTree, 2, 999));
assertFalse(myModel.isDropInto(myTree, 2, -1));
}
private void doExpand() {
List<DefaultMutableTreeNode> toExpand = new ArrayList<>();
RunConfigurable.collectNodesRecursively(myRoot, toExpand, FOLDER);
assertEquals(5, toExpand.size());
List<DefaultMutableTreeNode> toExpand2 = new ArrayList<>();
RunConfigurable.collectNodesRecursively(myRoot, toExpand2, CONFIGURATION_TYPE);
toExpand.addAll(toExpand2);
for (DefaultMutableTreeNode node : toExpand) {
myTree.expandPath(new TreePath(node.getPath()));
}
for (int i = 0; i < ORDER.length; i++) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)myTree.getPathForRow(i).getLastPathComponent();
assertEquals("Row #" + i, RunConfigurable.getKind(node), ORDER[i]);
}
}
private void assertCan(int oldIndex, int newIndex, RowsDnDSupport.RefinedDropSupport.Position position) {
assertDrop(oldIndex, newIndex, position, true);
}
private void assertCannot(int oldIndex, int newIndex, RowsDnDSupport.RefinedDropSupport.Position position) {
assertDrop(oldIndex, newIndex, position, false);
}
private void assertDrop(int oldIndex, int newIndex, RowsDnDSupport.RefinedDropSupport.Position position, boolean canDrop) {
StringBuilder message = new StringBuilder();
message.append("(").append(oldIndex).append(")").append(myTree.getPathForRow(oldIndex)).append("->");
message.append("(").append(newIndex).append(")").append(myTree.getPathForRow(newIndex)).append(position);
if (canDrop) {
assertTrue(message.toString(), myModel.canDrop(oldIndex, newIndex, position));
}
else {
assertFalse(message.toString(), myModel.canDrop(oldIndex, newIndex, position));
}
}
public void testMoveUpDown() {
doExpand();
checkPositionToMove(0, 1, null);
checkPositionToMove(2, 1, Trinity.create(2, 3, BELOW));
checkPositionToMove(2, -1, null);
checkPositionToMove(14, 1, null);
checkPositionToMove(14, -1, null);
checkPositionToMove(15, -1, null);
checkPositionToMove(16, -1, null);
checkPositionToMove(3, -1, Trinity.create(3, 2, ABOVE));
checkPositionToMove(6, 1, Trinity.create(6, 9, BELOW));
checkPositionToMove(7, 1, Trinity.create(7, 8, BELOW));
checkPositionToMove(10, -1, Trinity.create(10, 8, BELOW));
checkPositionToMove(8, 1, Trinity.create(8, 9, BELOW));
checkPositionToMove(21, -1, Trinity.create(21, 20, BELOW));
checkPositionToMove(21, 1, null);
checkPositionToMove(20, 1, Trinity.create(20, 21, ABOVE));
checkPositionToMove(20, -1, Trinity.create(20, 19, ABOVE));
checkPositionToMove(19, 1, Trinity.create(19, 20, BELOW));
checkPositionToMove(19, -1, Trinity.create(19, 17, BELOW));
checkPositionToMove(17, -1, Trinity.create(17, 16, ABOVE));
checkPositionToMove(17, 1, Trinity.create(17, 18, BELOW));
}
private void checkPositionToMove(int selectedRow,
int direction,
Trinity<Integer, Integer, RowsDnDSupport.RefinedDropSupport.Position> expected) {
myTree.setSelectionRow(selectedRow);
assertEquals(expected, myConfigurable.getAvailableDropPosition(direction));
}
private static RunManagerImpl createRunManager(Element element) {
Project project = getProject();
RunManagerImpl runManager = new RunManagerImpl(project);
runManager.initializeConfigurationTypes(new ConfigurationType[]{ApplicationConfigurationType.getInstance(), JUnitConfigurationType.getInstance()});
runManager.loadState(element);
return runManager;
}
private static class MockRunConfigurable extends RunConfigurable {
private final RunManagerImpl myTestManager;
private MockRunConfigurable(RunManagerImpl runManager) {
super(getProject());
myTestManager = runManager;
createComponent();
}
@Override
RunManagerImpl getRunManager() {
return myTestManager;
}
}
/*
00 Application
01 1
02 CodeGenerator
03 Renamer
04 UI
05 AuTest
06 Simples
07 OutAndErr (tmp)
08 C148C_TersePrincess (tmp)
09 2
10 Periods (tmp)
11 3
12 C148E_Porcelain
13 ErrAndOut (tmp)
14 JUnit
15 4
16 All in titled
17 All in titled2
18 5
19 All in titled3
20 All in titled4
21 All in titled5
16 Defaults
...
*/
private static final String FOLDERS_CONFIGURATION = " <component name=\"RunManager\" selected=\"Application.UI\">\n" +
" <configuration default=\"false\" name=\"OutAndErr\" type=\"Application\" factoryName=\"Application\" folderName=\"1\" temporary=\"true\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"OutAndErr\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"C148C_TersePrincess\" type=\"Application\" factoryName=\"Application\" folderName=\"1\" temporary=\"true\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"C148C_TersePrincess\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"Periods\" type=\"Application\" factoryName=\"Application\" folderName=\"2\" temporary=\"true\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\">\n" +
" <pattern>\n" +
" <option name=\"PATTERN\" value=\"v.*\" />\n" +
" <option name=\"ENABLED\" value=\"true\" />\n" +
" </pattern>\n" +
" </extension>\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"v.Periods\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"ErrAndOut\" type=\"Application\" factoryName=\"Application\" folderName=\"3\" temporary=\"true\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"ErrAndOut\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"true\" type=\"MavenRunConfiguration\" factoryName=\"Maven\">\n" +
" <MavenSettings>\n" +
" <option name=\"myGeneralSettings\" />\n" +
" <option name=\"myRunnerSettings\" />\n" +
" <option name=\"myRunnerParameters\">\n" +
" <MavenRunnerParameters>\n" +
" <option name=\"profiles\">\n" +
" <set />\n" +
" </option>\n" +
" <option name=\"goals\">\n" +
" <list />\n" +
" </option>\n" +
" <option name=\"profilesMap\">\n" +
" <map />\n" +
" </option>\n" +
" <option name=\"workingDirPath\" value=\"\" />\n" +
" </MavenRunnerParameters>\n" +
" </option>\n" +
" </MavenSettings>\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"true\" type=\"JUnit\" factoryName=\"JUnit\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <module name=\"\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"PACKAGE_NAME\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
" <option name=\"METHOD_NAME\" value=\"\" />\n" +
" <option name=\"TEST_OBJECT\" value=\"class\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
" <option name=\"PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <option name=\"TEST_SEARCH_SCOPE\">\n" +
" <value defaultName=\"moduleWithDependencies\" />\n" +
" </option>\n" +
" <envs />\n" +
" <patterns />\n" +
" <method>\n" +
" <option name=\"Make\" enabled=\"false\" />\n" +
" </method>\n" +
" </configuration>\n" +
" <configuration default=\"true\" type=\"Application\" factoryName=\"Application\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"\" />\n" +
" <envs />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"CodeGenerator\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\">\n" +
" <pattern>\n" +
" <option name=\"PATTERN\" value=\"codegen.*\" />\n" +
" <option name=\"ENABLED\" value=\"true\" />\n" +
" </pattern>\n" +
" </extension>\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"codegen.CodeGenerator\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"Renamer\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"Renamer\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"UI\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"UI\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"AuTest\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\">\n" +
" <pattern>\n" +
" <option name=\"PATTERN\" value=\"au.*\" />\n" +
" <option name=\"ENABLED\" value=\"true\" />\n" +
" </pattern>\n" +
" </extension>\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"au.AuTest\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"Simples\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"Simples\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"C148E_Porcelain\" type=\"Application\" factoryName=\"Application\" folderName=\"3\">\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"C148E_Porcelain\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <module name=\"titled\" />\n" +
" <envs />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method />\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"All in titled\" type=\"JUnit\" factoryName=\"JUnit\" folderName=\"4\">\n" +
" <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <module name=\"titled\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
" <option name=\"METHOD_NAME\" value=\"\" />\n" +
" <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
" <option name=\"PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <option name=\"TEST_SEARCH_SCOPE\">\n" +
" <value defaultName=\"moduleWithDependencies\" />\n" +
" </option>\n" +
" <envs />\n" +
" <patterns />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method>\n" +
" <option name=\"Make\" enabled=\"true\" />\n" +
" </method>\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"All in titled2\" type=\"JUnit\" factoryName=\"JUnit\" folderName=\"4\">\n" +
" <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <module name=\"titled\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
" <option name=\"METHOD_NAME\" value=\"\" />\n" +
" <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
" <option name=\"PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <option name=\"TEST_SEARCH_SCOPE\">\n" +
" <value defaultName=\"moduleWithDependencies\" />\n" +
" </option>\n" +
" <envs />\n" +
" <patterns />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method>\n" +
" <option name=\"Make\" enabled=\"true\" />\n" +
" </method>\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"All in titled3\" type=\"JUnit\" factoryName=\"JUnit\" folderName=\"5\">\n" +
" <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <module name=\"titled\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
" <option name=\"METHOD_NAME\" value=\"\" />\n" +
" <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
" <option name=\"PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <option name=\"TEST_SEARCH_SCOPE\">\n" +
" <value defaultName=\"moduleWithDependencies\" />\n" +
" </option>\n" +
" <envs />\n" +
" <patterns />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method>\n" +
" <option name=\"Make\" enabled=\"true\" />\n" +
" </method>\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"All in titled4\" type=\"JUnit\" factoryName=\"JUnit\" folderName=\"5\">\n" +
" <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <module name=\"titled\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
" <option name=\"METHOD_NAME\" value=\"\" />\n" +
" <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
" <option name=\"PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <option name=\"TEST_SEARCH_SCOPE\">\n" +
" <value defaultName=\"moduleWithDependencies\" />\n" +
" </option>\n" +
" <envs />\n" +
" <patterns />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method>\n" +
" <option name=\"Make\" enabled=\"true\" />\n" +
" </method>\n" +
" </configuration>\n" +
" <configuration default=\"false\" name=\"All in titled5\" type=\"JUnit\" factoryName=\"JUnit\" temporary=\"true\">\n" +
" <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
" <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
" <module name=\"titled\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
" <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
" <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
" <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
" <option name=\"METHOD_NAME\" value=\"\" />\n" +
" <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
" <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
" <option name=\"PARAMETERS\" value=\"\" />\n" +
" <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
" <option name=\"ENV_VARIABLES\" />\n" +
" <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
" <option name=\"TEST_SEARCH_SCOPE\">\n" +
" <value defaultName=\"moduleWithDependencies\" />\n" +
" </option>\n" +
" <envs />\n" +
" <patterns />\n" +
" <RunnerSettings RunnerId=\"Debug\">\n" +
" <option name=\"DEBUG_PORT\" value=\"\" />\n" +
" <option name=\"TRANSPORT\" value=\"0\" />\n" +
" <option name=\"LOCAL\" value=\"true\" />\n" +
" </RunnerSettings>\n" +
" <RunnerSettings RunnerId=\"Run\" />\n" +
" <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
" <ConfigurationWrapper RunnerId=\"Run\" />\n" +
" <method>\n" +
" <option name=\"Make\" enabled=\"true\" />\n" +
" </method>\n" +
" </configuration>\n" +
" <list size=\"16\">\n" +
" <item index=\"0\" class=\"java.lang.String\" itemvalue=\"Application.CodeGenerator\" />\n" +
" <item index=\"1\" class=\"java.lang.String\" itemvalue=\"Application.Renamer\" />\n" +
" <item index=\"2\" class=\"java.lang.String\" itemvalue=\"Application.UI\" />\n" +
" <item index=\"3\" class=\"java.lang.String\" itemvalue=\"Application.AuTest\" />\n" +
" <item index=\"4\" class=\"java.lang.String\" itemvalue=\"Application.Simples\" />\n" +
" <item index=\"5\" class=\"java.lang.String\" itemvalue=\"Application.OutAndErr\" />\n" +
" <item index=\"6\" class=\"java.lang.String\" itemvalue=\"Application.C148C_TersePrincess\" />\n" +
" <item index=\"7\" class=\"java.lang.String\" itemvalue=\"Application.Periods\" />\n" +
" <item index=\"8\" class=\"java.lang.String\" itemvalue=\"Application.C148E_Porcelain\" />\n" +
" <item index=\"9\" class=\"java.lang.String\" itemvalue=\"Application.ErrAndOut\" />\n" +
" <item index=\"10\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled\" />\n" +
" <item index=\"11\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled2\" />\n" +
" <item index=\"12\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled3\" />\n" +
" <item index=\"13\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled4\" />\n" +
" <item index=\"14\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled5\" />\n" +
" </list>\n" +
" <recent_temporary>\n" +
" <list size=\"4\">\n" +
" <item index=\"0\" class=\"java.lang.String\" itemvalue=\"Application.ErrAndOut\" />\n" +
" <item index=\"1\" class=\"java.lang.String\" itemvalue=\"Application.Periods\" />\n" +
" <item index=\"2\" class=\"java.lang.String\" itemvalue=\"Application.OutAndErr\" />\n" +
" <item index=\"3\" class=\"java.lang.String\" itemvalue=\"Application.C148C_TersePrincess\" />\n" +
" </list>\n" +
" </recent_temporary>\n" +
" <configuration name=\"&lt;template&gt;\" type=\"WebApp\" default=\"true\" selected=\"false\">\n" +
" <Host>localhost</Host>\n" +
" <Port>5050</Port>\n" +
" </configuration>\n" +
" </component>\n";
}
@@ -0,0 +1,194 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.execution.impl
import com.intellij.execution.application.ApplicationConfigurationType
import com.intellij.execution.impl.RunConfigurable.NodeKind.*
import com.intellij.execution.junit.JUnitConfigurationType
import com.intellij.openapi.util.Trinity
import com.intellij.testFramework.LightIdeaTestCase
import com.intellij.testFramework.LightPlatformTestCase
import com.intellij.testFramework.assertions.Assertions.assertThat
import com.intellij.ui.RowsDnDSupport
import com.intellij.ui.RowsDnDSupport.RefinedDropSupport.Position.*
import com.intellij.ui.treeStructure.Tree
import com.intellij.util.loadElement
import org.jdom.Element
import java.util.*
import javax.swing.tree.DefaultMutableTreeNode
import javax.swing.tree.TreePath
import kotlin.properties.Delegates
private val ORDER = arrayOf(CONFIGURATION_TYPE, //Application
FOLDER, //1
CONFIGURATION, CONFIGURATION, CONFIGURATION, CONFIGURATION, CONFIGURATION, TEMPORARY_CONFIGURATION, TEMPORARY_CONFIGURATION, FOLDER, //2
TEMPORARY_CONFIGURATION, FOLDER, //3
CONFIGURATION, TEMPORARY_CONFIGURATION, CONFIGURATION_TYPE, //JUnit
FOLDER, //4
CONFIGURATION, CONFIGURATION, FOLDER, //5
CONFIGURATION, CONFIGURATION, TEMPORARY_CONFIGURATION, UNKNOWN//Defaults
)
private fun createRunManager(element: Element): RunManagerImpl {
val runManager = RunManagerImpl(LightPlatformTestCase.getProject())
runManager.initializeConfigurationTypes(arrayOf(ApplicationConfigurationType.getInstance(), JUnitConfigurationType.getInstance()))
runManager.loadState(element)
return runManager
}
class RunConfigurableTest : LightIdeaTestCase() {
private var configurable: MockRunConfigurable? = null
private var tree: Tree by Delegates.notNull()
private var root: DefaultMutableTreeNode? = null
private var model: RunConfigurable.MyTreeModel by Delegates.notNull()
override fun setUp() {
super.setUp()
configurable = MockRunConfigurable(createRunManager(loadElement(RunConfigurableTest::class.java.getResourceAsStream("folders.xml"))))
tree = configurable!!.myTree
root = configurable!!.myRoot
model = configurable!!.myTreeModel
}
override fun tearDown() {
try {
if (configurable != null) {
configurable!!.disposeUIResources()
}
configurable = null
root = null
}
finally {
super.tearDown()
}
}
fun testDND() {
doExpand()
val never = intArrayOf(-1, 0, 14, 22, 23, 999)
for (i in -1..16) {
for (j in never) {
if ((j == 14 || j == 21) && i == j) {
continue
}
assertCannot(j, i, ABOVE)
assertCannot(j, i, INTO)
assertCannot(j, i, BELOW)
}
}
assertCan(3, 3, BELOW)
assertCan(3, 3, ABOVE)
assertCannot(3, 2, BELOW)
assertCan(3, 2, ABOVE)
assertCannot(3, 1, BELOW)
assertCannot(3, 0, BELOW)
assertCan(2, 14, ABOVE)
assertCan(1, 14, ABOVE)
assertCan(1, 11, ABOVE)
assertCannot(1, 10, ABOVE)
assertCannot(1, 10, BELOW)
assertCannot(8, 6, ABOVE)
assertCan(8, 6, BELOW)
assertCannot(5, 7, BELOW)
assertCan(5, 7, ABOVE)
assertCannot(15, 11, INTO)
assertCannot(18, 21, ABOVE)
assertCan(15, 21, ABOVE)
assertThat(model.isDropInto(tree, 2, 9)).isTrue()
assertThat(model.isDropInto(tree, 2, 1)).isTrue()
assertThat(model.isDropInto(tree, 12, 9)).isTrue()
assertThat(model.isDropInto(tree, 12, 1)).isTrue()
assertThat(model.isDropInto(tree, 999, 9)).isFalse()
assertThat(model.isDropInto(tree, 999, 1)).isFalse()
assertThat(model.isDropInto(tree, 2, 999)).isFalse()
assertThat(model.isDropInto(tree, 2, -1)).isFalse()
}
private fun doExpand() {
val toExpand = ArrayList<DefaultMutableTreeNode>()
RunConfigurable.collectNodesRecursively(root, toExpand, FOLDER)
assertThat(toExpand).hasSize(5)
val toExpand2 = ArrayList<DefaultMutableTreeNode>()
RunConfigurable.collectNodesRecursively(root, toExpand2, CONFIGURATION_TYPE)
toExpand.addAll(toExpand2)
for (node in toExpand) {
tree.expandPath(TreePath(node.path))
}
assertThat(ORDER.mapIndexed { index, nodeKind -> RunConfigurable.getKind(tree.getPathForRow(index).lastPathComponent as DefaultMutableTreeNode) }).containsExactly(*ORDER)
}
private fun assertCan(oldIndex: Int, newIndex: Int, position: RowsDnDSupport.RefinedDropSupport.Position) {
assertDrop(oldIndex, newIndex, position, true)
}
private fun assertCannot(oldIndex: Int, newIndex: Int, position: RowsDnDSupport.RefinedDropSupport.Position) {
assertDrop(oldIndex, newIndex, position, false)
}
private fun assertDrop(oldIndex: Int, newIndex: Int, position: RowsDnDSupport.RefinedDropSupport.Position, canDrop: Boolean) {
val message = StringBuilder()
message.append("(").append(oldIndex).append(")").append(tree.getPathForRow(oldIndex)).append("->")
message.append("(").append(newIndex).append(")").append(tree.getPathForRow(newIndex)).append(position)
if (canDrop) {
// message.toString()
assertThat(model.canDrop(oldIndex, newIndex, position)).isTrue()
}
else {
// message.toString()
assertThat(model.canDrop(oldIndex, newIndex, position)).isFalse()
}
}
fun testMoveUpDown() {
doExpand()
checkPositionToMove(0, 1, null)
checkPositionToMove(2, 1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(2, 3, BELOW))
checkPositionToMove(2, -1, null)
checkPositionToMove(14, 1, null)
checkPositionToMove(14, -1, null)
checkPositionToMove(15, -1, null)
checkPositionToMove(16, -1, null)
checkPositionToMove(3, -1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(3, 2, ABOVE))
checkPositionToMove(6, 1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(6, 9, BELOW))
checkPositionToMove(7, 1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(7, 8, BELOW))
checkPositionToMove(10, -1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(10, 8, BELOW))
checkPositionToMove(8, 1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(8, 9, BELOW))
checkPositionToMove(21, -1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(21, 20, BELOW))
checkPositionToMove(21, 1, null)
checkPositionToMove(20, 1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(20, 21, ABOVE))
checkPositionToMove(20, -1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(20, 19, ABOVE))
checkPositionToMove(19, 1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(19, 20, BELOW))
checkPositionToMove(19, -1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(19, 17, BELOW))
checkPositionToMove(17, -1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(17, 16, ABOVE))
checkPositionToMove(17, 1, Trinity.create<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>(17, 18, BELOW))
}
private fun checkPositionToMove(selectedRow: Int, direction: Int, expected: Trinity<Int, Int, RowsDnDSupport.RefinedDropSupport.Position>?) {
tree.setSelectionRow(selectedRow)
assertThat(configurable!!.getAvailableDropPosition(direction)).isEqualTo(expected)
}
}
private class MockRunConfigurable(private val testManager: RunManagerImpl) : RunConfigurable(LightPlatformTestCase.getProject()) {
init {
createComponent()
}
internal override fun getRunManager() = testManager
}
@@ -0,0 +1,489 @@
<component name="RunManager" selected="Application.UI">
<configuration default="false" name="OutAndErr" type="Application" factoryName="Application" folderName="1" temporary="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<option name="MAIN_CLASS_NAME" value="OutAndErr"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="C148C_TersePrincess" type="Application" factoryName="Application" folderName="1" temporary="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<option name="MAIN_CLASS_NAME" value="C148C_TersePrincess"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="Periods" type="Application" factoryName="Application" folderName="2" temporary="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="v.*"/>
<option name="ENABLED" value="true"/>
</pattern>
</extension>
<option name="MAIN_CLASS_NAME" value="v.Periods"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="ErrAndOut" type="Application" factoryName="Application" folderName="3" temporary="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<option name="MAIN_CLASS_NAME" value="ErrAndOut"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="true" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings"/>
<option name="myRunnerSettings"/>
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set/>
</option>
<option name="goals">
<list/>
</option>
<option name="profilesMap">
<map/>
</option>
<option name="workingDirPath" value=""/>
</MavenRunnerParameters>
</option>
</MavenSettings>
<method/>
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<module name=""/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="PACKAGE_NAME"/>
<option name="MAIN_CLASS_NAME" value=""/>
<option name="METHOD_NAME" value=""/>
<option name="TEST_OBJECT" value="class"/>
<option name="VM_PARAMETERS" value="-ea"/>
<option name="PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies"/>
</option>
<envs/>
<patterns/>
<method>
<option name="Make" enabled="false"/>
</method>
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<option name="MAIN_CLASS_NAME" value=""/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name=""/>
<envs/>
<method/>
</configuration>
<configuration default="false" name="CodeGenerator" type="Application" factoryName="Application" folderName="1">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="codegen.*"/>
<option name="ENABLED" value="true"/>
</pattern>
</extension>
<option name="MAIN_CLASS_NAME" value="codegen.CodeGenerator"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="Renamer" type="Application" factoryName="Application" folderName="1">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<option name="MAIN_CLASS_NAME" value="Renamer"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="UI" type="Application" factoryName="Application" folderName="1">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<option name="MAIN_CLASS_NAME" value="UI"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="AuTest" type="Application" factoryName="Application" folderName="1">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="au.*"/>
<option name="ENABLED" value="true"/>
</pattern>
</extension>
<option name="MAIN_CLASS_NAME" value="au.AuTest"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="Simples" type="Application" factoryName="Application" folderName="1">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<option name="MAIN_CLASS_NAME" value="Simples"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="C148E_Porcelain" type="Application" factoryName="Application" folderName="3">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<option name="MAIN_CLASS_NAME" value="C148E_Porcelain"/>
<option name="VM_PARAMETERS" value=""/>
<option name="PROGRAM_PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="titled"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
<configuration default="false" name="All in titled" type="JUnit" factoryName="JUnit" folderName="4">
<output_file path="C:/tst.txt" is_save="true"/>
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<module name="titled"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="PACKAGE_NAME" value=""/>
<option name="MAIN_CLASS_NAME" value=""/>
<option name="METHOD_NAME" value=""/>
<option name="TEST_OBJECT" value="package"/>
<option name="VM_PARAMETERS" value="-ea"/>
<option name="PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies"/>
</option>
<envs/>
<patterns/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method>
<option name="Make" enabled="true"/>
</method>
</configuration>
<configuration default="false" name="All in titled2" type="JUnit" factoryName="JUnit" folderName="4">
<output_file path="C:/tst.txt" is_save="true"/>
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<module name="titled"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="PACKAGE_NAME" value=""/>
<option name="MAIN_CLASS_NAME" value=""/>
<option name="METHOD_NAME" value=""/>
<option name="TEST_OBJECT" value="package"/>
<option name="VM_PARAMETERS" value="-ea"/>
<option name="PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies"/>
</option>
<envs/>
<patterns/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method>
<option name="Make" enabled="true"/>
</method>
</configuration>
<configuration default="false" name="All in titled3" type="JUnit" factoryName="JUnit" folderName="5">
<output_file path="C:/tst.txt" is_save="true"/>
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<module name="titled"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="PACKAGE_NAME" value=""/>
<option name="MAIN_CLASS_NAME" value=""/>
<option name="METHOD_NAME" value=""/>
<option name="TEST_OBJECT" value="package"/>
<option name="VM_PARAMETERS" value="-ea"/>
<option name="PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies"/>
</option>
<envs/>
<patterns/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method>
<option name="Make" enabled="true"/>
</method>
</configuration>
<configuration default="false" name="All in titled4" type="JUnit" factoryName="JUnit" folderName="5">
<output_file path="C:/tst.txt" is_save="true"/>
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<module name="titled"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="PACKAGE_NAME" value=""/>
<option name="MAIN_CLASS_NAME" value=""/>
<option name="METHOD_NAME" value=""/>
<option name="TEST_OBJECT" value="package"/>
<option name="VM_PARAMETERS" value="-ea"/>
<option name="PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies"/>
</option>
<envs/>
<patterns/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method>
<option name="Make" enabled="true"/>
</method>
</configuration>
<configuration default="false" name="All in titled5" type="JUnit" factoryName="JUnit" temporary="true">
<output_file path="C:/tst.txt" is_save="true"/>
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea"/>
<module name="titled"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="PACKAGE_NAME" value=""/>
<option name="MAIN_CLASS_NAME" value=""/>
<option name="METHOD_NAME" value=""/>
<option name="TEST_OBJECT" value="package"/>
<option name="VM_PARAMETERS" value="-ea"/>
<option name="PARAMETERS" value=""/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies"/>
</option>
<envs/>
<patterns/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method>
<option name="Make" enabled="true"/>
</method>
</configuration>
<list size="16">
<item index="0" class="java.lang.String" itemvalue="Application.CodeGenerator"/>
<item index="1" class="java.lang.String" itemvalue="Application.Renamer"/>
<item index="2" class="java.lang.String" itemvalue="Application.UI"/>
<item index="3" class="java.lang.String" itemvalue="Application.AuTest"/>
<item index="4" class="java.lang.String" itemvalue="Application.Simples"/>
<item index="5" class="java.lang.String" itemvalue="Application.OutAndErr"/>
<item index="6" class="java.lang.String" itemvalue="Application.C148C_TersePrincess"/>
<item index="7" class="java.lang.String" itemvalue="Application.Periods"/>
<item index="8" class="java.lang.String" itemvalue="Application.C148E_Porcelain"/>
<item index="9" class="java.lang.String" itemvalue="Application.ErrAndOut"/>
<item index="10" class="java.lang.String" itemvalue="JUnit.All in titled"/>
<item index="11" class="java.lang.String" itemvalue="JUnit.All in titled2"/>
<item index="12" class="java.lang.String" itemvalue="JUnit.All in titled3"/>
<item index="13" class="java.lang.String" itemvalue="JUnit.All in titled4"/>
<item index="14" class="java.lang.String" itemvalue="JUnit.All in titled5"/>
</list>
<recent_temporary>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="Application.ErrAndOut"/>
<item index="1" class="java.lang.String" itemvalue="Application.Periods"/>
<item index="2" class="java.lang.String" itemvalue="Application.OutAndErr"/>
<item index="3" class="java.lang.String" itemvalue="Application.C148C_TersePrincess"/>
</list>
</recent_temporary>
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
<Port>5050</Port>
</configuration>
</component>
@@ -16,6 +16,7 @@
package com.intellij.psi.impl.file.impl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
@@ -814,4 +815,18 @@ public class PsiEventsTest extends PsiTestCase {
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
assertEquals(" <tag/>", getPsiManager().findFile(vFile).getText());
}
public void testCopyFile() throws Exception {
VirtualFile original = createFile(myModule, mySrcDir1, "a.xml", "<tag/>").getVirtualFile();
EventsTestListener listener = new EventsTestListener();
myPsiManager.addPsiTreeChangeListener(listener,getTestRootDisposable());
PsiDirectory psiDir2 = PsiManager.getInstance(myProject).findDirectory(mySrcDir2);
assertNotNull(psiDir2);
WriteAction.run(() -> original.copy(this, mySrcDir2, "b.xml"));
assertEquals("beforeChildAddition\n" +
"childAdded\n", listener.getEventsString());
}
}
@@ -512,7 +512,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
@Override
public ConfigurationFactory getFactory() {
return null;
return UnknownConfigurationType.FACTORY;
}
@Override
@@ -529,12 +529,6 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
return null;
}
@Override
@NotNull
public ConfigurationType getType() {
return UnknownConfigurationType.INSTANCE;
}
@Override
public RunConfiguration clone() {
return null;
@@ -49,10 +49,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.*;
/**
* @author anna
@@ -177,26 +174,32 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool {
@NotNull
public static Set<InspectionSuppressor> getSuppressors(@NotNull PsiElement element) {
FileViewProvider viewProvider = element.getContainingFile().getViewProvider();
final InspectionSuppressor elementLanguageSuppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage());
final List<InspectionSuppressor> elementLanguageSuppressor = LanguageInspectionSuppressors.INSTANCE.allForLanguage(element.getLanguage());
if (viewProvider instanceof TemplateLanguageFileViewProvider) {
Set<InspectionSuppressor> suppressors = new LinkedHashSet<>();
ContainerUtil.addIfNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.forLanguage(viewProvider.getBaseLanguage()));
ContainerUtil.addAllNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.allForLanguage(viewProvider.getBaseLanguage()));
for (Language language : viewProvider.getLanguages()) {
ContainerUtil.addIfNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.forLanguage(language));
ContainerUtil.addAllNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.allForLanguage(language));
}
ContainerUtil.addIfNotNull(suppressors, elementLanguageSuppressor);
ContainerUtil.addAllNotNull(suppressors, elementLanguageSuppressor);
return suppressors;
}
if (!element.getLanguage().isKindOf(viewProvider.getBaseLanguage())) {
// handling embedding elements {@link EmbeddingElementType
Set<InspectionSuppressor> suppressors = new LinkedHashSet<>();
ContainerUtil.addIfNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.forLanguage(viewProvider.getBaseLanguage()));
ContainerUtil.addIfNotNull(suppressors, elementLanguageSuppressor);
ContainerUtil.addAllNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.allForLanguage(viewProvider.getBaseLanguage()));
ContainerUtil.addAllNotNull(suppressors, elementLanguageSuppressor);
return suppressors;
}
return elementLanguageSuppressor != null
? Collections.singleton(elementLanguageSuppressor)
: Collections.emptySet();
int size = elementLanguageSuppressor.size();
switch (size) {
case 0:
return Collections.emptySet();
case 1:
return Collections.singleton(elementLanguageSuppressor.get(0));
default:
return new java.util.HashSet<>(elementLanguageSuppressor);
}
}
public void cleanup(@NotNull Project project) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,6 +41,7 @@ import com.intellij.psi.search.PsiFileSystemItemProcessor;
import com.intellij.refactoring.rename.BindablePsiReference;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -156,9 +157,18 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
final Collection<ResolveResult> result,
final boolean caseSensitive) {
if (isAllowedEmptyPath(text) || ".".equals(text) || "/".equals(text)) {
if (context instanceof FileReferenceResolver) {
ContainerUtil.addIfNotNull(result, resolveFileReferenceResolver((FileReferenceResolver)context, text));
return;
}
result.add(new PsiElementResolveResult(context));
}
else if ("..".equals(text)) {
if (context instanceof FileReferenceResolver) {
ContainerUtil.addIfNotNull(result, resolveFileReferenceResolver((FileReferenceResolver)context, text));
return;
}
final PsiFileSystemItem resolved = context.getParent();
if (resolved != null) {
result.add(new PsiElementResolveResult(resolved));
@@ -189,9 +199,9 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
context = ((PackagePrefixFileSystemItem)context).getDirectory();
}
else if (context instanceof FileReferenceResolver) {
PsiFileSystemItem child = ((FileReferenceResolver)context).resolveFileReference(this, decoded);
ResolveResult child = resolveFileReferenceResolver((FileReferenceResolver)context, decoded);
if (child != null) {
result.add(new PsiElementResolveResult(getOriginalFile(child)));
result.add(child);
return;
}
}
@@ -241,6 +251,12 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP
return null;
}
@Nullable
private ResolveResult resolveFileReferenceResolver(@NotNull FileReferenceResolver fileReferenceResolver, @NotNull String text) {
PsiFileSystemItem resolve = fileReferenceResolver.resolveFileReference(this, text);
return resolve != null ? new PsiElementResolveResult(getOriginalFile(resolve)) : null;
}
private static boolean caseSensitivityApplies(PsiDirectory context, boolean caseSensitive) {
VirtualFileSystem fs = context.getVirtualFile().getFileSystem();
return fs.isCaseSensitive() == caseSensitive;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -367,15 +367,23 @@ public class FileReferenceSet {
final FileReferenceHelper[] helpers = FileReferenceHelperRegistrar.getHelpers();
final ArrayList<PsiFileSystemItem> list = new ArrayList<>();
final Project project = file.getProject();
boolean hasRealContexts = false;
for (FileReferenceHelper helper : helpers) {
if (helper.isMine(project, virtualFile)) {
if (!list.isEmpty() && helper.isFallback()) {
continue;
}
list.addAll(helper.getContexts(project, virtualFile));
Collection<PsiFileSystemItem> contexts = helper.getContexts(project, virtualFile);
for (PsiFileSystemItem context : contexts) {
list.add(context);
hasRealContexts |= !(context instanceof FileReferenceResolver);
}
}
}
if (!list.isEmpty()) {
if (!hasRealContexts) {
list.addAll(getParentDirectoryContext());
}
return list;
}
return getParentDirectoryContext();
@@ -77,12 +77,9 @@ class CompilationTasksImpl extends CompilationTasks {
}
private void ensureKotlinCompilerAddedToClassPath() {
try {
Class.forName("org.jetbrains.kotlin.jps.build.KotlinBuilder")
if (getClass().getResource("/org/jetbrains/kotlin/jps/build/KotlinBuilder.class") != null) {
return
}
catch (ClassNotFoundException ignored) {
}
def kotlinPluginLibPath = "$context.paths.communityHome/build/dependencies/build/Kotlin/lib"
if (new File(kotlinPluginLibPath).exists()) {
@@ -82,7 +82,7 @@ class WindowsDistributionBuilder extends OsSpecificDistributionBuilder {
void buildArtifacts(String winDistPath) {
def arch = customizer.bundledJreArchitecture
def jreDirectoryPath64 = arch != null ? buildContext.bundledJreManager.extractWinJre(arch) : null
List<String> jreDirectoryPaths = [jreDirectoryPath64];
List<String> jreDirectoryPaths = [jreDirectoryPath64]
if (customizer.getBaseDownloadUrlForJre() != null && arch != JvmArchitecture.x32) {
File archive = buildContext.bundledJreManager.findWinJreArchive(JvmArchitecture.x32)
@@ -94,7 +94,7 @@ class WindowsDistributionBuilder extends OsSpecificDistributionBuilder {
include(name: "**/**")
}
}
jreDirectoryPaths = [jreDirectoryPath64, jreDirectoryPath];
jreDirectoryPaths = [jreDirectoryPath64, jreDirectoryPath]
}
}
@@ -178,14 +178,14 @@ class WindowsDistributionBuilder extends OsSpecificDistributionBuilder {
String vmOptions = "$buildContext.additionalJvmArguments -Didea.paths.selector=${buildContext.systemSelector}".trim()
def productName = buildContext.applicationInfo.shortProductName
String jdkEnvVarSuffix = arch == JvmArchitecture.x64 && customizer.include32BitLauncher ? "_64" : "";
String jdkEnvVarSuffix = arch == JvmArchitecture.x64 && customizer.include32BitLauncher ? "_64" : ""
String vmOptionsEnvVarSuffix = arch == JvmArchitecture.x64 && customizer.include32BitLauncher ? "64" : ""
def envVarBaseName = buildContext.productProperties.getEnvironmentVariableBaseName(buildContext.applicationInfo)
new File(launcherPropertiesPath).text = """
IDS_JDK_ONLY=$buildContext.productProperties.toolsJarRequired
IDS_JDK_ENV_VAR=${envVarBaseName}_JDK$jdkEnvVarSuffix
IDS_APP_TITLE=$productName Launcher
IDS_VM_OPTIONS_PATH=%USERPROFILE%\\\\.$buildContext.systemSelector
IDS_VM_OPTIONS_PATH=%USERPROFILE%\\\\.$buildContext.systemSelector\\\\config
IDS_VM_OPTION_ERRORFILE=-XX:ErrorFile=%USERPROFILE%\\\\java_error_in_${lowerCaseProductName}_%p.log
IDS_VM_OPTION_HEAPDUMPPATH=-XX:HeapDumpPath=%USERPROFILE%\\\\java_error_in_${lowerCaseProductName}.hprof
IDC_WINLAUNCHER=${upperCaseProductName}_LAUNCHER
@@ -31,6 +31,7 @@ public abstract class EmptyStubElementType<T extends PsiElement> extends IStubEl
super(debugName, language);
}
@NotNull
@Override
public final EmptyStub createStub(@NotNull T psi, StubElement parentStub) {
return createStub(parentStub);
@@ -22,24 +22,32 @@ package com.intellij.psi.stubs;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
public abstract class IStubElementType<StubT extends StubElement, PsiT extends PsiElement> extends IElementType implements StubSerializer<StubT> {
private static boolean ourInitializedStubs;
private static volatile boolean ourInitializedStubs;
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.stubs.IStubElementType");
public IStubElementType(@NotNull @NonNls final String debugName, @Nullable final Language language) {
super(debugName, language);
if (ourInitializedStubs) {
LOG.error("All stub element types should be created before index initialization is complete. Please add the class containing stub element type constants to \"stubElementTypeHolder\" extension.");
LOG.error("All stub element types should be created before index initialization is complete.\n" +
"Please add the class containing stub element type constants to \"stubElementTypeHolder\" extension.\n" +
"Registered extensions: " + Arrays.toString(StubElementTypeHolderEP.EP_NAME.getExtensions()));
}
}
static void markStubInitializationComplete() {
static void loadRegisteredStubElementTypes() {
for (StubElementTypeHolderEP holderEP : Extensions.getExtensions(StubElementTypeHolderEP.EP_NAME)) {
holderEP.initialize();
}
ourInitializedStubs = true;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,4 +40,9 @@ public class StubElementTypeHolderEP extends AbstractExtensionPointBean {
LOG.error(e);
}
}
@Override
public String toString() {
return holderClass;
}
}
@@ -120,7 +120,6 @@ public class DiffUtil {
@NotNull
private static List<Image> loadDiffFrameImages() {
return ContainerUtil.list(
ImageLoader.loadFromResource("/diff_frame16.png"),
ImageLoader.loadFromResource("/diff_frame32.png"),
ImageLoader.loadFromResource("/diff_frame64.png"),
ImageLoader.loadFromResource("/diff_frame128.png")
@@ -115,6 +115,18 @@ abstract class DiffTestCase : TestCase() {
}
}
fun assertSetsEquals(expected: BitSet, actual: BitSet, message: String = "") {
val sb = StringBuilder(message)
sb.append(": \"")
for (i in 0..actual.length()) {
sb.append(if (actual[i]) '-' else ' ')
}
sb.append('"')
val fullMessage = sb.toString()
assertEquals(expected, actual, fullMessage)
}
//
// Parsing
//
@@ -210,7 +222,7 @@ abstract class DiffTestCase : TestCase() {
}
}
class DebugData() {
class DebugData {
private val data: MutableList<Pair<String, Any>> = ArrayList()
fun put(key: String, value: Any) {
@@ -73,12 +73,12 @@ abstract class ComparisonMergeUtilTestBase : DiffTestCase() {
val sets = Trio(BitSet(), BitSet(), BitSet())
for (change in changes) {
sets.forEach({ set: BitSet, side: ThreeSide -> set.set(change.start(side), change.end(side)) })
sets.forEach { set: BitSet, side: ThreeSide -> set.set(change.start(side), change.end(side)) }
}
assertEquals(matchings.data1, sets.data1)
assertEquals(matchings.data2, sets.data2)
assertEquals(matchings.data3, sets.data3)
assertSetsEquals(matchings.data1, sets.data1, "Left")
assertSetsEquals(matchings.data2, sets.data2, "Base")
assertSetsEquals(matchings.data3, sets.data3, "Right")
}
private fun convertDiffFragments(fragments: List<MergeRange>): List<Change> {
@@ -198,8 +198,8 @@ class ComparisonUtilAutoTest : DiffTestCase() {
for (fragment in fragments) {
if (fragment.innerFragments != null) {
val sequence1 = text1.subsequence(fragment.startOffset1, fragment.endOffset1)
val sequence2 = text2.subsequence(fragment.startOffset2, fragment.endOffset2)
val sequence1 = text1.subSequence(fragment.startOffset1, fragment.endOffset1)
val sequence2 = text2.subSequence(fragment.startOffset2, fragment.endOffset2)
checkResultWord(sequence1, sequence2, fragment.innerFragments!!, policy)
}
@@ -538,7 +538,7 @@ class ComparisonUtilAutoTest : DiffTestCase() {
return Couple.of(firstLine, lastLine)
}
private fun Document.subsequence(start: Int, end: Int): CharSequence {
private fun Document.subSequence(start: Int, end: Int): CharSequence {
return this.charsSequence.subSequence(start, end)
}
@@ -173,8 +173,8 @@ abstract class ComparisonUtilTestBase : DiffTestCase() {
set2.set(fragment.startLine2, fragment.endLine2)
}
assertEquals(matchings.first, set1, "Before")
assertEquals(matchings.second, set2, "After")
assertSetsEquals(matchings.first, set1, "Before")
assertSetsEquals(matchings.second, set2, "After")
}
private fun checkDiffMatching(fragments: List<DiffFragment>, matchings: Couple<BitSet>) {
@@ -185,8 +185,8 @@ abstract class ComparisonUtilTestBase : DiffTestCase() {
set2.set(fragment.startOffset2, fragment.endOffset2)
}
assertEquals(matchings.first, set1, "Before")
assertEquals(matchings.second, set2, "After")
assertSetsEquals(matchings.first, set1, "Before")
assertSetsEquals(matchings.second, set2, "After")
}
private fun checkMergeMatching(fragments: List<MergeWordFragment>, matchings: Trio<BitSet>) {
@@ -199,9 +199,9 @@ abstract class ComparisonUtilTestBase : DiffTestCase() {
set3.set(fragment.getStartOffset(ThreeSide.RIGHT), fragment.getEndOffset(ThreeSide.RIGHT))
}
assertEquals(matchings.data1, set1, "Before")
assertEquals(matchings.data2, set2, "Base")
assertEquals(matchings.data3, set3, "After")
assertSetsEquals(matchings.data1, set1, "Left")
assertSetsEquals(matchings.data2, set2, "Base")
assertSetsEquals(matchings.data3, set3, "Right")
}
private fun convertDiffFragments(fragments: List<DiffFragment>): List<Couple<IntPair>> {
@@ -401,28 +401,17 @@ class IgnoreComparisonUtilTest : DiffTestCase() {
.run()
}
private inner class Test(input1: String, input2: String,
private inner class Test(val input1: String, val input2: String,
ignored1: String, ignored2: String,
result1: String, result2: String) {
private val input1: String
private val input2: String
private val ignored1: String
private val ignored2: String
private val result1: String
private val result2: String
val ignored1: String = ignored1.filterNot { it == '.' }
val ignored2: String = ignored2.filterNot { it == '.' }
val result1: String = result1.filterNot { it == '.' }
val result2: String = result2.filterNot { it == '.' }
private var inner = true
private var changedLines: IntPair? = null
init {
this.input1 = input1
this.input2 = input2
this.ignored1 = ignored1.filterNot { it == '.' }
this.ignored2 = ignored2.filterNot { it == '.' }
this.result1 = result1.filterNot { it == '.' }
this.result2 = result2.filterNot { it == '.' }
}
fun noInnerChanges(): Test {
inner = false
return this
@@ -74,6 +74,23 @@ class SplitComparisonUtilTest : ComparisonUtilTestBase() {
default(del(0, 0, 1), mod(1, 0, 1, 1), del(2, 1, 1))
testAll()
}
splitter(trim = false) {
("< i" - "<i<_i")
default(mod(0, 0, 1, 2))
testDefault()
}
splitter(trim = false) {
(".l j" - "U_._l j+")
default(ins(0, 0, 2), mod(0, 2, 1, 1))
testDefault()
}
splitter {
(" run();" - " //commentary_ while(run(true));")
default(mod(0, 0, 1, 2))
testDefault()
}
}
fun testSquash() {
@@ -140,6 +140,27 @@ class WordComparisonUtilTest : ComparisonUtilTestBase() {
(" " - " - ").default()
testAll()
}
lines_inner {
("X Y ) {_ A B C" - "X Y Z ) {_ y B C ) {")
(" - " - " -- - ----").default()
(" - " - " - - ---").ignore()
testAll()
}
// TODO
words {
("@Deprecated @NotNull" - "@NotNull")
(" ------------ " - " ").default()
testAll()
}
// TODO
words {
("@Deprecated_ @NotNull" - "@NotNull")
(" ------------- " - " ").default()
testAll()
}
}
fun testOldDiffBug() {
@@ -154,6 +175,18 @@ class WordComparisonUtilTest : ComparisonUtilTestBase() {
(" " - " -- ").default()
testAll()
}
lines_inner {
("x'>" - "x'y'>")
(" " - " -- ").default()
testAll()
}
lines_inner {
("x'y'>" - "x'>")
(" -- " - " ").default()
testAll()
}
}
fun testWhitespaceOnlyChanges() {
@@ -219,6 +252,12 @@ class WordComparisonUtilTest : ComparisonUtilTestBase() {
("- -" - "- -").ignore()
testIgnore()
}
words {
("A_B_" - "X_")
("--- " - "- ").default()
testAll()
}
}
fun testFixedBugs() {
@@ -336,6 +375,26 @@ class WordComparisonUtilTest : ComparisonUtilTestBase() {
(" ---" - "--- ").default()
testDefault()
}
lines_inner {
("A B_C D" - "A_B C_D")
(" -- - " - " -- - ").default()
(" -- - " - " -- ").trim()
(" - " - " - ").ignore()
testAll()
}
lines_inner {
("B_C_D_" - "X_Y_Z_")
("- - - " - "- - - ").default()
testAll()
}
words {
("!x_!_z" - "!_!_y z")
(" - " - " -- ").default()
testDefault()
}
}
fun `test trailing punctuation`() {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 633 B

After

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 562 B

@@ -20,7 +20,6 @@
package com.intellij.psi.stubs;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.StubFileElementType;
import org.jetbrains.annotations.NotNull;
@@ -45,10 +44,7 @@ public abstract class SerializationManager {
if (mySerializersLoaded) return;
synchronized (this) {
if (mySerializersLoaded) return;
for (StubElementTypeHolderEP holderEP : Extensions.getExtensions(StubElementTypeHolderEP.EP_NAME)) {
holderEP.initialize();
}
IStubElementType.markStubInitializationComplete();
IStubElementType.loadRegisteredStubElementTypes();
final IElementType[] stubElementTypes = IElementType.enumerate(new IElementType.Predicate() {
@Override
public boolean matches(@NotNull final IElementType type) {
@@ -176,6 +176,8 @@ abstract class RunManager {
*/
abstract fun refreshUsagesList(profile: RunProfile)
fun hasSettings(settings: RunnerAndConfigurationSettings) = allSettings.contains(settings)
fun suggestUniqueName(name: String?, type: ConfigurationType?): String {
val settingsList = if (type == null) allSettings else getConfigurationSettingsList(type)
return suggestUniqueName(name.nullize() ?: UNNAMED, settingsList.map { it.name })
@@ -31,11 +31,8 @@ import org.jetbrains.annotations.Nullable;
public interface RunnerAndConfigurationSettings {
/**
* Returns the type of the run configuration.
*
* @return the type of the run configuration, or null if the settings object was loaded from disk and no plugin corresponding to the
* stored type of the run configuration is loaded.
*/
@Nullable
@NotNull
ConfigurationType getType();
/**
@@ -44,11 +44,11 @@ public interface RunConfiguration extends RunProfile, Cloneable {
/**
* Returns the type of the run configuration.
*
* @return the configuration type.
*/
@NotNull
ConfigurationType getType();
default ConfigurationType getType() {
return getFactory().getType();
}
/**
* Returns the factory that has created the run configuration.
@@ -98,12 +98,6 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
return myProject;
}
@Override
@NotNull
public ConfigurationType getType() {
return myFactory.getType();
}
@Override
public Icon getIcon() {
return myIcon;
@@ -83,12 +83,6 @@ public class UnknownRunConfiguration implements RunConfiguration, WithoutOwnBefo
return myProject;
}
@Override
@NotNull
public ConfigurationType getType() {
return UnknownConfigurationType.INSTANCE;
}
@Override
public RunConfiguration clone() {
try {
@@ -23,11 +23,10 @@ import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.editor.event.*;
import com.intellij.openapi.editor.ex.DocumentEx;
import com.intellij.openapi.editor.ex.EditorEventMulticasterEx;
import com.intellij.openapi.editor.ex.FocusChangeListener;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.util.TextRange;
@@ -96,27 +95,20 @@ public class BraceHighlighter implements StartupActivity {
};
eventMulticaster.addDocumentListener(documentListener, project);
final FocusChangeListener myFocusChangeListener = new FocusChangeListener() {
@Override
public void focusLost(Editor editor) {
clearBraces(editor);
}
@Override
public void focusGained(Editor editor) {
updateBraces(editor, myAlarm);
}
};
((EditorEventMulticasterEx)eventMulticaster).addFocusChangeListner(myFocusChangeListener, project);
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
fileEditorManager.addFileEditorManagerListener(new FileEditorManagerListener() {
project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
@Override
public void selectionChanged(@NotNull FileEditorManagerEvent e) {
myAlarm.cancelAllRequests();
FileEditor oldEditor = e.getOldEditor();
if (oldEditor instanceof TextEditor) {
clearBraces(((TextEditor)oldEditor).getEditor());
}
FileEditor newEditor = e.getNewEditor();
if (newEditor instanceof TextEditor) {
updateBraces(((TextEditor)newEditor).getEditor(), myAlarm);
}
}
}, project);
});
}
static void updateBraces(@NotNull final Editor editor, @NotNull final Alarm alarm) {
@@ -567,6 +567,7 @@ public class BraceHighlightingHandler {
hint.hide();
myEditor.putUserData(HINT_IN_EDITOR_KEY, null);
}
removeLineMarkers();
}
private void lineMarkFragment(int startLine, int endLine, @NotNull Color color) {
@@ -97,8 +97,14 @@ public abstract class RunManagerEx extends RunManager {
public abstract Icon getConfigurationIcon(@NotNull RunnerAndConfigurationSettings settings, boolean withLiveIndicator);
/**
* @deprecated Use {@link #getAllSettings()}
*/
@NotNull
public abstract Collection<RunnerAndConfigurationSettings> getSortedConfigurations();
@Deprecated
public final Collection<RunnerAndConfigurationSettings> getSortedConfigurations() {
return getAllSettings();
}
public abstract void removeConfiguration(@Nullable RunnerAndConfigurationSettings settings);
@@ -34,6 +34,7 @@ import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.SizedIcon;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.util.IconUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
@@ -41,7 +42,6 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -225,8 +225,7 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
if (selectedConfiguration != null && selectedConfiguration.isTemporary()) {
return selectedConfiguration;
}
Iterator<RunnerAndConfigurationSettings> iterator = RunManager.getInstance(project).getTempConfigurationsList().iterator();
return iterator.hasNext() ? iterator.next() : null;
return ContainerUtil.getFirstItem(RunManager.getInstance(project).getTempConfigurationsList());
}
}
@@ -49,8 +49,7 @@ public class CopyConfigurationAction extends RunConfigurationTreeAction {
@Override
protected boolean isEnabled4(DashboardRunConfigurationNode node) {
return RunManager.getInstance(node.getProject()).getAllConfigurationsList().contains(
node.getConfigurationSettings().getConfiguration());
return RunManager.getInstance(node.getProject()).hasSettings(node.getConfigurationSettings());
}
@Override
@@ -41,8 +41,7 @@ public class EditConfigurationAction extends RunConfigurationTreeAction {
@Override
protected boolean isEnabled4(DashboardRunConfigurationNode node) {
return RunManager.getInstance(node.getProject()).getAllConfigurationsList().contains(
node.getConfigurationSettings().getConfiguration());
return RunManager.getInstance(node.getProject()).hasSettings(node.getConfigurationSettings());
}
@Override
@@ -40,8 +40,7 @@ public class RemoveConfigurationAction extends RunConfigurationTreeAction {
@Override
protected boolean isEnabled4(DashboardRunConfigurationNode node) {
return RunManager.getInstance(node.getProject()).getAllConfigurationsList().contains(
node.getConfigurationSettings().getConfiguration());
return RunManager.getInstance(node.getProject()).hasSettings(node.getConfigurationSettings());
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ class RunConfigurationNode extends AbstractTreeNode<Pair<RunnerAndConfiguration
@Override
protected void update(PresentationData presentation) {
RunnerAndConfigurationSettings configurationSettings = getConfigurationSettings();
boolean isStored = RunManager.getInstance(getProject()).getAllConfigurationsList().contains(configurationSettings.getConfiguration());
boolean isStored = RunManager.getInstance(getProject()).hasSettings(configurationSettings);
presentation.addText(configurationSettings.getName(),
isStored ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
RunDashboardContributor contributor = RunDashboardContributor.getContributor(configurationSettings.getType());
@@ -25,19 +25,16 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.ModuleListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import com.intellij.util.containers.SmartHashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@State(name = "ModuleRunConfigurationManager")
@@ -51,8 +48,6 @@ public final class ModuleRunConfigurationManager implements PersistentStateCompo
settings -> settings != null && usesMyModule(settings.getConfiguration());
@NotNull
private final RunManagerImpl myManager;
@Nullable
private List<Element> myUnloadedElements = null;
public ModuleRunConfigurationManager(@NotNull final Module module, @NotNull final RunManagerImpl runManager) {
myModule = module;
@@ -99,7 +94,7 @@ public final class ModuleRunConfigurationManager implements PersistentStateCompo
@NotNull
private Collection<? extends RunnerAndConfigurationSettings> getModuleRunConfigurationSettings() {
return ContainerUtil.filter(myManager.getConfigurationSettings(), myModuleConfigCondition);
return ContainerUtil.filter(myManager.getAllSettings(), myModuleConfigCondition);
}
private boolean usesMyModule(RunConfiguration config) {
@@ -110,11 +105,6 @@ public final class ModuleRunConfigurationManager implements PersistentStateCompo
public void writeExternal(@NotNull final Element element) throws WriteExternalException {
LOG.debug("writeExternal(" + myModule + ")");
myManager.writeConfigurations(element, getModuleRunConfigurationSettings());
if (myUnloadedElements != null) {
for (final Element unloadedElement : myUnloadedElements) {
element.addContent(unloadedElement.clone());
}
}
}
public void readExternal(@NotNull final Element element) {
@@ -125,33 +115,18 @@ public final class ModuleRunConfigurationManager implements PersistentStateCompo
private void doReadExternal(@NotNull Element element) {
LOG.debug("readExternal(" + myModule + ")");
myUnloadedElements = null;
final Set<String> existing = new HashSet<>();
final Set<String> existing = new SmartHashSet<>();
for (final Element child : element.getChildren()) {
final RunnerAndConfigurationSettings configuration = myManager.loadConfiguration(child, true);
if (configuration == null && Comparing.strEqual(element.getName(), RunManagerImpl.CONFIGURATION)) {
if (myUnloadedElements == null) myUnloadedElements = new ArrayList<>(2);
myUnloadedElements.add(element);
}
for (final Element child : element.getChildren(RunManagerImpl.CONFIGURATION)) {
existing.add(myManager.loadConfiguration(child, true).getUniqueID());
}
if (configuration != null) {
existing.add(configuration.getUniqueID());
for (RunnerAndConfigurationSettings settings : myManager.getAllSettings()) {
if (!usesMyModule(settings.getConfiguration())) {
existing.add(settings.getUniqueID());
}
}
for (final RunConfiguration configuration : myManager.getAllConfigurationsList()) {
if (!usesMyModule(configuration)) {
RunnerAndConfigurationSettings settings = myManager.getSettings(configuration);
if (settings != null) {
existing.add(settings.getUniqueID());
}
}
}
myManager.removeNotExistingSharedConfigurations(existing);
// IDEA-60004: configs may never be sorted before write, so call it manually after shared configs read
myManager.setOrdered(false);
myManager.getSortedConfigurations();
}
}
@@ -16,27 +16,22 @@
package com.intellij.execution.impl;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.configurations.UnknownRunConfiguration;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.StateSplitterEx;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.util.Pair;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@State(name = "ProjectRunConfigurationManager", storages = @Storage(value = "runConfigurations", stateSplitter = ProjectRunConfigurationManager.RunConfigurationStateSplitter.class))
public class ProjectRunConfigurationManager implements PersistentStateComponent<Element> {
private final RunManagerImpl myManager;
private List<Element> myUnloadedElements;
public ProjectRunConfigurationManager(@NotNull RunManagerImpl manager) {
myManager = manager;
@@ -46,51 +41,26 @@ public class ProjectRunConfigurationManager implements PersistentStateComponent<
public Element getState() {
Element state = new Element("state");
myManager.writeConfigurations(state, myManager.getSharedConfigurations());
if (!ContainerUtil.isEmpty(myUnloadedElements)) {
for (Element unloadedElement : myUnloadedElements) {
state.addContent(unloadedElement.clone());
}
}
return state;
}
@Override
public void loadState(Element state) {
if (myUnloadedElements != null) {
myUnloadedElements.clear();
}
Set<String> existing = new THashSet<>();
for (Iterator<Element> iterator = state.getChildren().iterator(); iterator.hasNext(); ) {
Element child = iterator.next();
RunnerAndConfigurationSettings configuration = myManager.loadConfiguration(child, true);
if (configuration != null) {
existing.add(configuration.getUniqueID());
}
else if (child.getName().equals(RunManagerImpl.CONFIGURATION)) {
if (myUnloadedElements == null) {
myUnloadedElements = new SmartList<>();
}
iterator.remove();
myUnloadedElements.add(child);
}
for (Element child : state.getChildren(RunManagerImpl.CONFIGURATION)) {
existing.add(myManager.loadConfiguration(child, true).getUniqueID());
}
myManager.removeNotExistingSharedConfigurations(existing);
if (myManager.getSelectedConfiguration() == null) {
final List<RunConfiguration> allConfigurations = myManager.getAllConfigurationsList();
for (final RunConfiguration configuration : allConfigurations) {
final RunnerAndConfigurationSettings settings = myManager.getSettings(allConfigurations.get(0));
if (!(configuration instanceof UnknownRunConfiguration)) {
for (RunnerAndConfigurationSettings settings : myManager.getAllSettings()) {
if (!(settings.getType() instanceof UnknownRunConfiguration)) {
myManager.setSelectedConfiguration(settings);
break;
}
}
}
// IDEA-60004: configs may never be sorted before write, so call it manually after shared configs read
myManager.setOrdered(false);
myManager.getSortedConfigurations();
}
static class RunConfigurationStateSplitter extends StateSplitterEx {
@@ -704,7 +704,7 @@ class RunConfigurable extends BaseConfigurable {
each.first.apply();
}
manager.saveOrder();
manager.setOrder(null);
}
finally {
getRunManager().fireEndUpdate();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableB
public RunConfigurableBeforeRunTask createTask(RunConfiguration runConfiguration) {
if (runConfiguration.getProject().isInitialized()) {
Collection<RunnerAndConfigurationSettings> configurations =
RunManagerImpl.getInstanceImpl(runConfiguration.getProject()).getSortedConfigurations();
RunManagerImpl.getInstanceImpl(runConfiguration.getProject()).getAllSettings();
if (configurations.isEmpty()
|| (configurations.size() == 1 && configurations.iterator().next().getConfiguration() == runConfiguration)) {
return null;
@@ -144,7 +144,7 @@ extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableB
return Collections.emptyList();
}
List<RunnerAndConfigurationSettings> configurations = new ArrayList<>(RunManagerImpl.getInstanceImpl(project).getSortedConfigurations());
List<RunnerAndConfigurationSettings> configurations = new ArrayList<>(RunManagerImpl.getInstanceImpl(project).getAllSettings());
String executorId = DefaultRunExecutor.getRunExecutorInstance().getId();
for (Iterator<RunnerAndConfigurationSettings> iterator = configurations.iterator(); iterator.hasNext();) {
RunnerAndConfigurationSettings settings = iterator.next();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,8 +25,6 @@ import com.intellij.refactoring.listeners.RefactoringElementListener;
import com.intellij.refactoring.listeners.RefactoringElementListenerComposite;
import com.intellij.refactoring.listeners.RefactoringElementListenerProvider;
import java.util.List;
/**
* @author spleaner
*/
@@ -36,9 +34,7 @@ public class RunConfigurationRefactoringElementListenerProvider implements Refac
@Override
public RefactoringElementListener getListener(final PsiElement element) {
RefactoringElementListenerComposite composite = null;
final List<RunConfiguration> configurations = RunManager.getInstance(element.getProject()).getAllConfigurationsList();
for (RunConfiguration configuration : configurations) {
for (RunConfiguration configuration : RunManager.getInstance(element.getProject()).getAllConfigurationsList()) {
if (configuration instanceof RefactoringListenerProvider) { // todo: perhaps better way to handle listeners?
RefactoringElementListener listener;
try {
@@ -31,7 +31,6 @@ import com.intellij.openapi.components.*
import com.intellij.openapi.diagnostic.catchAndLog
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.extensions.Extensions
import com.intellij.openapi.options.Scheme
import com.intellij.openapi.options.SchemeManagerFactory
import com.intellij.openapi.project.IndexNotReadyException
import com.intellij.openapi.project.Project
@@ -39,9 +38,7 @@ import com.intellij.openapi.roots.ModuleRootEvent
import com.intellij.openapi.roots.ModuleRootListener
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.UnknownFeaturesCollector
import com.intellij.openapi.util.InvalidDataException
import com.intellij.openapi.util.JDOMExternalizableStringList
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.Pair
import com.intellij.openapi.util.registry.Registry
import com.intellij.util.EventDispatcher
import com.intellij.util.IconUtil
@@ -111,18 +108,16 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
private val iconCache = TimedIconCache()
private val _config by lazy { RunManagerConfig(PropertiesComponent.getInstance(project)) }
@Suppress("DEPRECATION")
private val myOrder = JDOMExternalizableStringList()
private val customOrder = ArrayList<String>()
private val recentlyUsedTemporaries = ArrayList<RunConfiguration>()
private var myOrdered = true
private val myDispatcher = EventDispatcher.create(RunManagerListener::class.java)!!
private val schemeManagerProvider = SchemeManagerIprProvider("configuration")
private val schemeManager = SchemeManagerFactory.getInstance(project).create("workspace",
object : LazySchemeProcessor<RunConfigurationScheme, RunConfigurationScheme>() {
override fun createScheme(dataHolder: SchemeDataHolder<RunConfigurationScheme>, name: String, attributeProvider: Function<String, String?>, isBundled: Boolean): RunConfigurationScheme {
object : LazySchemeProcessor<RunnerAndConfigurationSettingsImpl, RunnerAndConfigurationSettingsImpl>() {
override fun createScheme(dataHolder: SchemeDataHolder<RunnerAndConfigurationSettingsImpl>, name: String, attributeProvider: Function<String, String?>, isBundled: Boolean): RunnerAndConfigurationSettingsImpl {
val settings = RunnerAndConfigurationSettingsImpl(this@RunManagerImpl)
val element = dataHolder.read()
try {
@@ -212,7 +207,7 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
*/
override fun getConfigurationsList(type: ConfigurationType): List<RunConfiguration> {
var result: MutableList<RunConfiguration>? = null
for (settings in sortedConfigurations) {
for (settings in allSettings) {
val configuration = settings.configuration
if (type.id == configuration.type.id) {
if (result == null) {
@@ -225,16 +220,11 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
}
override val allConfigurationsList: List<RunConfiguration>
get() = sortedConfigurations.mapSmart { it.configuration }
get() = allSettings.mapSmart { it.configuration }
override val allSettings: List<RunnerAndConfigurationSettings>
get() = sortedConfigurations.toList()
fun getSettings(configuration: RunConfiguration) = allSettings.firstOrNull { it.configuration === configuration } as? RunnerAndConfigurationSettingsImpl
fun getSettings(configuration: RunConfiguration) = sortedConfigurations.firstOrNull { it.configuration === configuration } as? RunnerAndConfigurationSettingsImpl
override fun getConfigurationSettingsList(type: ConfigurationType) = lock.read { sortedConfigurations.filterSmart { it.type?.id == type.id } }
fun getConfigurationSettings() = idToSettings.values.toTypedArray()
override fun getConfigurationSettingsList(type: ConfigurationType) = allSettings.filterSmart { it.type.id == type.id }
override fun getStructure(type: ConfigurationType): Map<String, List<RunnerAndConfigurationSettings>> {
val result = LinkedHashMap<String?, MutableList<RunnerAndConfigurationSettings>>()
@@ -275,6 +265,8 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
var existingSettings: RunnerAndConfigurationSettings? = null
var existingId: String? = null
lock.write {
immutableSortedSettingsList = null
existingId = findExistingConfigurationId(settings)
existingId?.let {
existingSettings = idToSettings.remove(it)
@@ -286,11 +278,11 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
idToSettings.put(newId, settings)
if (existingId == null) {
refreshUsagesList(settings.configuration)
refreshUsagesList(settings)
}
if (!settings.isShared && existingSettings !== settings) {
schemeManager.addScheme(settings as RunConfigurationScheme)
schemeManager.addScheme(settings as RunnerAndConfigurationSettingsImpl)
}
}
@@ -305,11 +297,20 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
}
override fun refreshUsagesList(profile: RunProfile) {
if (profile !is RunConfiguration) return
val settings = getSettings(profile)
if (settings != null && settings.isTemporary) {
recentlyUsedTemporaries.remove(profile)
recentlyUsedTemporaries.add(0, profile)
if (profile !is RunConfiguration) {
return
}
getSettings(profile)?.let {
refreshUsagesList(it)
}
}
fun refreshUsagesList(settings: RunnerAndConfigurationSettings) {
if (settings.isTemporary) {
val configuration = settings.configuration
recentlyUsedTemporaries.remove(configuration)
recentlyUsedTemporaries.add(0, configuration)
trimUsagesListToLimit()
}
}
@@ -322,45 +323,38 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
fun checkRecentsLimit() {
trimUsagesListToLimit()
val removed = SmartList<RunnerAndConfigurationSettings>()
var removed: MutableList<RunnerAndConfigurationSettings>? = null
lock.write {
while (tempConfigurationsList.size > config.recentsLimit) {
while (idToSettings.values.count { it.isTemporary } > config.recentsLimit) {
val it = idToSettings.values.iterator()
while (it.hasNext()) {
val settings = it.next()
if (settings.isTemporary && !recentlyUsedTemporaries.contains(settings.configuration)) {
removed.add(settings)
if (removed == null) {
immutableSortedSettingsList = null
removed = SmartList<RunnerAndConfigurationSettings>()
}
removed!!.add(settings)
it.remove()
break
}
}
}
}
fireRunConfigurationsRemoved(removed)
}
fun setOrdered(ordered: Boolean) {
myOrdered = ordered
}
fun saveOrder() {
setOrder(null)
}
private fun doSaveOrder(comparator: Comparator<RunnerAndConfigurationSettings>?) {
val sorted = idToSettings.values.filter { it.type !is UnknownConfigurationType }
if (comparator != null) {
sorted.sortedWith(comparator)
}
myOrder.clear()
sorted.mapTo(myOrder) { it.uniqueID}
removed?.let { fireRunConfigurationsRemoved(it) }
}
fun setOrder(comparator: Comparator<RunnerAndConfigurationSettings>?) {
doSaveOrder(comparator)
// force recache of configurations list
setOrdered(false)
lock.write {
val sorted = idToSettings.values.filterTo(ArrayList(idToSettings.size)) { it.type !is UnknownConfigurationType }
if (comparator != null) {
sorted.sortWith(comparator)
}
customOrder.clear()
customOrder.ensureCapacity(sorted.size)
sorted.mapTo(customOrder) { it.uniqueID }
immutableSortedSettingsList = null
}
}
override var selectedConfiguration: RunnerAndConfigurationSettings?
@@ -377,77 +371,94 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
private fun setSelectedConfigurationId(id: String?) {
selectedConfigurationId = id
if (selectedConfigurationId != null) {
if (id != null) {
loadedSelectedConfigurationUniqueName = null
}
}
override fun getSortedConfigurations(): MutableCollection<RunnerAndConfigurationSettings> {
if (myOrdered) {
return idToSettings.values
}
private data class OrderItem(val id: String, val settings: RunnerAndConfigurationSettings)
val order = ArrayList<Pair<String, RunnerAndConfigurationSettings>>(idToSettings.size)
val folderNames = SmartList<String>()
for (each in idToSettings.values) {
order.add(Pair.create(each.uniqueID, each))
val folderName = each.folderName
if (folderName != null && !folderNames.contains(folderName)) {
folderNames.add(folderName)
@Volatile
private var immutableSortedSettingsList: List<RunnerAndConfigurationSettings>? = null
override val allSettings: List<RunnerAndConfigurationSettings>
get() {
immutableSortedSettingsList?.let {
return it
}
lock.write {
immutableSortedSettingsList?.let {
return it
}
if (idToSettings.isEmpty()) {
immutableSortedSettingsList = emptyList()
return immutableSortedSettingsList!!
}
val order = ArrayList<OrderItem>(idToSettings.size)
val folderNames = SmartList<String>()
for (each in idToSettings.values) {
order.add(OrderItem(each.uniqueID, each))
val folderName = each.folderName
if (folderName != null && !folderNames.contains(folderName)) {
folderNames.add(folderName)
}
}
folderNames.add(null)
idToSettings.clear()
if (customOrder.isEmpty()) {
// IDEA-63663 Sort run configurations alphabetically if clean checkout
order.sortWith(Comparator { o1, o2 ->
val temporary1 = o1.settings.isTemporary
val temporary2 = o2.settings.isTemporary
when {
temporary1 == temporary2 -> o1.id.compareTo(o2.id)
temporary1 -> 1
else -> -1
}
})
}
else {
order.sortWith(Comparator { o1, o2 ->
val i1 = folderNames.indexOf(o1.settings.folderName)
val i2 = folderNames.indexOf(o2.settings.folderName)
if (i1 != i2) {
return@Comparator i1 - i2
}
val temporary1 = o1.settings.isTemporary
val temporary2 = o2.settings.isTemporary
when {
temporary1 == temporary2 -> {
val index1 = customOrder.indexOf(o1.id)
val index2 = customOrder.indexOf(o2.id)
if (index1 == -1 && index2 == -1) {
o1.settings.name.compareTo(o2.settings.name)
}
else {
index1 - index2
}
}
temporary1 -> 1
else -> -1
}
})
}
for (each in order) {
val setting = each.settings
idToSettings.put(setting.uniqueID, setting)
}
val result = Collections.unmodifiableList(idToSettings.values.toList())
immutableSortedSettingsList = result
return result
}
}
folderNames.add(null)
idToSettings.clear()
if (myOrder.isEmpty()) {
// IDEA-63663 Sort run configurations alphabetically if clean checkout
order.sortWith(Comparator { o1, o2 ->
val temporary1 = o1.getSecond().isTemporary
val temporary2 = o2.getSecond().isTemporary
when {
temporary1 == temporary2 -> o1.first.compareTo(o2.first)
temporary1 -> 1
else -> -1
}
})
}
else {
order.sortWith(Comparator { o1, o2 ->
val i1 = folderNames.indexOf(o1.getSecond().folderName)
val i2 = folderNames.indexOf(o2.getSecond().folderName)
if (i1 != i2) {
return@Comparator i1 - i2
}
val temporary1 = o1.getSecond().isTemporary
val temporary2 = o2.getSecond().isTemporary
when {
temporary1 == temporary2 -> {
val index1 = myOrder.indexOf(o1.first)
val index2 = myOrder.indexOf(o2.first)
if (index1 == -1 && index2 == -1) {
o1.second.name.compareTo(o2.second.name)
}
else {
index1 - index2
}
}
temporary1 -> 1
else -> -1
}
})
}
for (each in order) {
val setting = each.second
idToSettings.put(setting.uniqueID, setting)
}
myOrdered = true
return idToSettings.values
}
@Suppress("DEPRECATION")
override fun getState(): Element {
val element = Element("state")
@@ -469,23 +480,24 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
}
if (idToSettings.size > 1) {
var order: JDOMExternalizableStringList? = null
var order: MutableList<String>? = null
for (each in idToSettings.values) {
if (each.type is UnknownConfigurationType) {
continue
}
if (order == null) {
order = JDOMExternalizableStringList()
order = ArrayList()
}
order.add(each.uniqueID)
}
if (order != null) {
order.writeExternal(element)
@Suppress("DEPRECATION")
com.intellij.openapi.util.JDOMExternalizableStringList.writeList(order, element)
}
}
val recentList = JDOMExternalizableStringList()
val recentList = SmartList<String>()
for (each in recentlyUsedTemporaries) {
if (each.type is UnknownConfigurationType) {
continue
@@ -496,13 +508,18 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
if (!recentList.isEmpty()) {
val recent = Element(RECENT)
element.addContent(recent)
recentList.writeExternal(recent)
@Suppress("DEPRECATION")
com.intellij.openapi.util.JDOMExternalizableStringList.writeList(recentList, recent)
}
return element
}
fun writeContext(element: Element) {
writeConfigurations(element, lock.read { idToSettings.values.filterSmart { it.isTemporary } })
for (setting in allSettings) {
if (setting.isTemporary) {
element.addContent((setting as RunnerAndConfigurationSettingsImpl).writeScheme())
}
}
selectedConfiguration?.let {
element.setAttribute(SELECTED_ATTR, it.uniqueID)
@@ -571,16 +588,17 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
}
schemeManager.reload()
myOrder.readExternal(parentNode)
@Suppress("DEPRECATION")
com.intellij.openapi.util.JDOMExternalizableStringList.readList(customOrder, parentNode)
// migration (old ids to UUIDs)
readList(myOrder)
readList(customOrder)
recentlyUsedTemporaries.clear()
val recentNode = parentNode.getChild(RECENT)
if (recentNode != null) {
@Suppress("DEPRECATION")
val list = JDOMExternalizableStringList()
val list = com.intellij.openapi.util.JDOMExternalizableStringList()
list.readExternal(recentNode)
readList(list)
for (name in list) {
@@ -589,7 +607,7 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
}
}
}
myOrdered = false
immutableSortedSettingsList = null
loadedSelectedConfigurationUniqueName = parentNode.getAttributeValue(SELECTED_ATTR)
setSelectedConfigurationId(loadedSelectedConfigurationUniqueName)
@@ -598,7 +616,7 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
fireRunConfigurationSelected()
}
private fun readList(@Suppress("DEPRECATION") list: JDOMExternalizableStringList) {
private fun readList(list: MutableList<String>) {
for (i in list.indices) {
for (settings in idToSettings.values) {
val configuration = settings.configuration
@@ -614,12 +632,9 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
fun readContext(parentNode: Element) {
loadedSelectedConfigurationUniqueName = parentNode.getAttributeValue(SELECTED_ATTR)
for (aChildren in parentNode.children) {
val element = aChildren
for (element in parentNode.children) {
val config = loadConfiguration(element, false)
if (loadedSelectedConfigurationUniqueName == null
&& config != null
&& java.lang.Boolean.parseBoolean(element.getAttributeValue(SELECTED_ATTR))) {
if (loadedSelectedConfigurationUniqueName == null && element.getAttributeValue(SELECTED_ATTR).toBoolean()) {
loadedSelectedConfigurationUniqueName = config.uniqueID
}
}
@@ -648,39 +663,47 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
}
private fun clear(allConfigurations: Boolean) {
val configurations: MutableList<RunnerAndConfigurationSettings>
if (allConfigurations) {
this.idToSettings.clear()
selectedConfigurationId = null
configurations = ArrayList(this.idToSettings.values)
}
else {
configurations = SmartList<RunnerAndConfigurationSettings>()
val iterator = this.idToSettings.values.iterator()
while (iterator.hasNext()) {
val configuration = iterator.next()
if (configuration.isTemporary || !configuration.isShared) {
iterator.remove()
val configurations = lock.write {
immutableSortedSettingsList = null
configurations.add(configuration)
}
}
val configurations = if (allConfigurations) {
val configurations = idToSettings.values.toList()
if (selectedConfigurationId != null && this.idToSettings.containsKey(selectedConfigurationId!!)) {
idToSettings.clear()
selectedConfigurationId = null
configurations
}
else {
val configurations = SmartList<RunnerAndConfigurationSettings>()
val iterator = idToSettings.values.iterator()
while (iterator.hasNext()) {
val configuration = iterator.next()
if (configuration.isTemporary || !configuration.isShared) {
iterator.remove()
configurations.add(configuration)
}
}
if (selectedConfigurationId != null && this.idToSettings.containsKey(selectedConfigurationId!!)) {
selectedConfigurationId = null
}
configurations
}
templateIdToConfiguration.clear()
configurations
}
lock.write {
templateIdToConfiguration.clear()
}
loadedSelectedConfigurationUniqueName = null
iconCache.clear()
recentlyUsedTemporaries.clear()
fireRunConfigurationsRemoved(configurations)
}
fun loadConfiguration(element: Element, isShared: Boolean): RunnerAndConfigurationSettings? {
fun loadConfiguration(element: Element, isShared: Boolean): RunnerAndConfigurationSettings {
val settings = RunnerAndConfigurationSettingsImpl(this)
LOG.catchAndLog {
settings.readExternal(element, isShared)
@@ -763,25 +786,20 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
}
fun getSharedConfigurations(): List<RunnerAndConfigurationSettings> {
lock.read {
var result: MutableList<RunnerAndConfigurationSettings>? = null
for (configuration in idToSettings.values) {
if (configuration.isShared) {
if (result == null) {
result = ArrayList<RunnerAndConfigurationSettings>()
}
result.add(configuration)
var result: MutableList<RunnerAndConfigurationSettings>? = null
for (configuration in allSettings) {
if (configuration.isShared) {
if (result == null) {
result = ArrayList<RunnerAndConfigurationSettings>()
}
result.add(configuration)
}
return result ?: emptyList()
}
return result ?: emptyList()
}
internal val configurationSettings: Collection<RunnerAndConfigurationSettings>
get() = idToSettings.values
override val tempConfigurationsList: List<RunnerAndConfigurationSettings>
get() = idToSettings.values.filter { it.isTemporary }
get() = allSettings.filterSmart { it.isTemporary }
override fun makeStable(settings: RunnerAndConfigurationSettings) {
settings.isTemporary = false
@@ -791,8 +809,8 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
private fun doMakeStable(settings: RunnerAndConfigurationSettings) {
recentlyUsedTemporaries.remove(settings.configuration)
if (!myOrder.isEmpty()) {
setOrdered(false)
if (!customOrder.isEmpty()) {
immutableSortedSettingsList = null
}
}
@@ -807,7 +825,7 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
val tasks = SmartList<T>()
val checkedTemplates = SmartList<RunnerAndConfigurationSettings>()
lock.read {
for (settings in idToSettings.values.toTypedArray()) {
for (settings in allSettings) {
val configuration = settings.configuration
for (task in getBeforeRunTasks(configuration)) {
if (task.isEnabled && task.providerId === taskProviderId) {
@@ -852,21 +870,16 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
return icon
}
fun getConfigurationById(id: String) = idToSettings.get(id)
fun getConfigurationById(id: String) = lock.read { idToSettings.get(id) }
override fun findConfigurationByName(name: String?): RunnerAndConfigurationSettings? {
if (name == null) {
return null
}
return idToSettings.values.firstOrNull { it.name == name }
return allSettings.firstOrNull { it.name == name }
}
fun findConfigurationByTypeAndName(typeId: String, name: String): RunnerAndConfigurationSettings? {
return sortedConfigurations.firstOrNull {
val t = it.type
t != null && typeId == t.id && name == it.name
}
}
fun findConfigurationByTypeAndName(typeId: String, name: String) = allSettings.firstOrNull { typeId == it.type.id && name == it.name }
override fun <T : BeforeRunTask<*>> getBeforeRunTasks(settings: RunConfiguration, taskProviderId: Key<T>): List<T> {
if (settings is WrappingRunConfiguration<*>) {
@@ -998,7 +1011,7 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
// we must update all existing configuration tasks to ensure that effective tasks (own + template) are the same as before template configuration change
// see testTemplates test
lock.read {
for (otherSettings in idToSettings.values) {
for (otherSettings in allSettings) {
val otherConfiguration = otherSettings.configuration
if (otherConfiguration !is WrappingRunConfiguration<*> && otherConfiguration.factory === templateConfiguration.factory) {
otherConfiguration.beforeRunTasks = getEffectiveBeforeRunTasks(otherConfiguration, ownIsOnlyEnabled = false, isDisableTemplateTasks = true, newTemplateTasks = tasks)
@@ -1028,6 +1041,7 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
val settings = entry.value
if (!settings.isTemplate && settings.isShared && !existing.contains(settings.uniqueID)) {
if (removed == null) {
immutableSortedSettingsList = null
removed = SmartList<RunnerAndConfigurationSettings>()
}
removed!!.add(settings)
@@ -1080,6 +1094,8 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
val changedSettings = SmartList<RunnerAndConfigurationSettings>()
lock.write {
immutableSortedSettingsList = null
val iterator = idToSettings.values.iterator()
for (otherSettings in iterator) {
if (otherSettings === settings) {
@@ -1111,14 +1127,4 @@ class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persistent
changedSettings.forEach { myDispatcher.multicaster.runConfigurationChanged(it, null) }
}
}
internal interface RunConfigurationScheme : Scheme
//private class UnknownRunConfigurationScheme(private val name: String) : RunConfigurationScheme, SerializableScheme {
// override fun getSchemeState() = SchemeState.UNCHANGED
//
// override fun writeScheme() = throw AssertionError("Must be not called")
//
// override fun getName() = name
//}
}
@@ -26,6 +26,7 @@ import com.intellij.openapi.components.PathMacroManager
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.extensions.ExtensionException
import com.intellij.openapi.options.Scheme
import com.intellij.openapi.options.SchemeState
import com.intellij.openapi.util.*
import com.intellij.openapi.util.text.StringUtil
@@ -56,7 +57,7 @@ val SINGLETON = "singleton"
class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val manager: RunManagerImpl,
private var _configuration: RunConfiguration? = null,
private var isTemplate: Boolean = false,
private var singleton: Boolean = false) : Cloneable, RunnerAndConfigurationSettings, Comparable<Any>, RunConfigurationScheme, SerializableScheme {
private var singleton: Boolean = false) : Cloneable, RunnerAndConfigurationSettings, Comparable<Any>, Scheme, SerializableScheme {
enum class Level {
WORKSPACE, PROJECT, TEMPORARY
}
@@ -293,7 +294,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
override fun getConfigurationSettings(runner: ProgramRunner<*>) = configurationPerRunnerSettings.getOrCreateSettings(runner)
override fun getType() = _configuration?.type
override fun getType(): ConfigurationType = _configuration?.type ?: UnknownConfigurationType.INSTANCE
public override fun clone(): RunnerAndConfigurationSettings {
val copy = RunnerAndConfigurationSettingsImpl(manager, _configuration!!.clone(), false)
@@ -337,10 +338,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
override fun compareTo(other: Any) = if (other is RunnerAndConfigurationSettings) name.compareTo(other.name) else 0
override fun toString(): String {
val type = type
return "${if (type == null) "" else "${type.displayName}: "}${if (isTemplate) "<template>" else name}"
}
override fun toString() = "${type.displayName}: ${if (isTemplate) "<template>" else name} (level: $level)"
private inner class InfoProvider(override val runner: ProgramRunner<*>) : ConfigurationInfoProvider {
override val configuration: RunConfiguration
@@ -527,7 +527,7 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
relativePath
.replace(file.getName(), "<b>" + file.getName() + "</b>") + "</body></html>";
}
myUsagePreviewPanel.setBorder(IdeBorderFactory.createTitledBorder(path, false, new JBInsets(8, 0, -14, 0)).setShowLine(false));
myUsagePreviewPanel.setBorder(IdeBorderFactory.createTitledBorder(path, false, new JBInsets(8, 0, 0, 0)).setShowLine(false));
}
else {
myUsagePreviewPanel.updateLayout(null);
@@ -66,23 +66,25 @@ public class VirtualFileArrayRule implements GetDataRule {
if (fileSystemTree != null) {
result = addFiles(result, fileSystemTree.getSelectedFiles());
}
else {
Project project = PlatformDataKeys.PROJECT_CONTEXT.getData(dataProvider);
if (project != null && !project.isDisposed()) {
result = addFiles(result, ProjectRootManager.getInstance(project).getContentRoots());
}
Project project = PlatformDataKeys.PROJECT_CONTEXT.getData(dataProvider);
if (project != null && !project.isDisposed()) {
result = addFiles(result, ProjectRootManager.getInstance(project).getContentRoots());
}
Module[] selectedModules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataProvider);
if (selectedModules != null && selectedModules.length > 0) {
for (Module selectedModule : selectedModules) {
result = addFiles(result, ModuleRootManager.getInstance(selectedModule).getContentRoots());
}
}
Module[] selectedModules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataProvider);
if (selectedModules != null && selectedModules.length > 0) {
for (Module selectedModule : selectedModules) {
Module selectedModule = LangDataKeys.MODULE_CONTEXT.getData(dataProvider);
if (selectedModule != null && !selectedModule.isDisposed()) {
result = addFiles(result, ModuleRootManager.getInstance(selectedModule).getContentRoots());
}
}
Module selectedModule = LangDataKeys.MODULE_CONTEXT.getData(dataProvider);
if (selectedModule != null && !selectedModule.isDisposed()) {
result = addFiles(result, ModuleRootManager.getInstance(selectedModule).getContentRoots());
}
PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataProvider);
if (psiElements != null) {
@@ -16,6 +16,7 @@
package com.intellij.openapi.roots.impl;
import com.intellij.ProjectTopics;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationAdapter;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ProjectComponent;
@@ -62,7 +63,7 @@ import java.util.Set;
/**
* ProjectRootManager extended with ability to watch events.
*/
public class ProjectRootManagerComponent extends ProjectRootManagerImpl implements ProjectComponent {
public class ProjectRootManagerComponent extends ProjectRootManagerImpl implements ProjectComponent, Disposable {
private static final Logger LOG = Logger.getInstance(ProjectRootManagerComponent.class);
private boolean myPointerChangesDetected = false;
@@ -307,6 +308,11 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl implemen
}
}
@Override
public void dispose() {
assertListenersAreDisposed();
}
private class AppListener extends ApplicationAdapter {
@Override
public void beforeWriteActionStart(@NotNull Object action) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -176,8 +176,7 @@ public class TemplateModuleBuilder extends ModuleBuilder {
}
private void fixModuleName(Module module) {
List<RunConfiguration> configurations = RunManager.getInstance(module.getProject()).getAllConfigurationsList();
for (RunConfiguration configuration : configurations) {
for (RunConfiguration configuration : RunManager.getInstance(module.getProject()).getAllConfigurationsList()) {
if (configuration instanceof ModuleBasedConfiguration) {
((ModuleBasedConfiguration)configuration).getConfigurationModule().setModule(module);
}
@@ -133,6 +133,11 @@ public class PsiVFSListener implements VirtualFileListener {
return parent == null ? null : myFileManager.getCachedDirectory(parent);
}
@Override
public void fileCopied(@NotNull VirtualFileCopyEvent event) {
fileCreated(event);
}
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
final VirtualFile vFile = event.getFile();
@@ -160,10 +160,11 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
final RefactoringElementListener elementListener = getTransaction().getElementListener(element);
if (element instanceof PsiDirectory) {
if (mySearchForReferences) encodeDirectoryFiles(element);
MoveFilesOrDirectoriesUtil.doMoveDirectory((PsiDirectory)element, myNewParent);
for (PsiElement psiElement : element.getChildren()) {
processDirectoryFiles(movedFiles, oldToNewMap, psiElement);
}
MoveFilesOrDirectoriesUtil.doMoveDirectory((PsiDirectory)element, myNewParent);
}
else if (element instanceof PsiFile) {
final PsiFile movedFile = (PsiFile)element;
@@ -239,10 +240,20 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
return data;
}
private void processDirectoryFiles(List<PsiFile> movedFiles, Map<PsiElement, PsiElement> oldToNewMap, PsiElement psiElement) {
private static void encodeDirectoryFiles(PsiElement psiElement) {
if (psiElement instanceof PsiFile) {
FileReferenceContextUtil.encodeFileReferences(psiElement);
}
else if (psiElement instanceof PsiDirectory) {
for (PsiElement element : psiElement.getChildren()) {
encodeDirectoryFiles(element);
}
}
}
private static void processDirectoryFiles(List<PsiFile> movedFiles, Map<PsiElement, PsiElement> oldToNewMap, PsiElement psiElement) {
if (psiElement instanceof PsiFile) {
final PsiFile movedFile = (PsiFile)psiElement;
if (mySearchForReferences) FileReferenceContextUtil.encodeFileReferences(psiElement);
MoveFileHandler.forElement(movedFile).prepareMovedFile(movedFile, movedFile.getParent(), oldToNewMap);
movedFiles.add(movedFile);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,6 +41,13 @@ public class NodeRenderer extends ColoredTreeCellRenderer {
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
Object node = TreeUtil.getUserObject(value);
if (node instanceof NodeDescriptor) {
NodeDescriptor descriptor = (NodeDescriptor)node;
// TODO: use this color somewhere
Color color = descriptor.getColor();
setIcon(descriptor.getIcon());
}
PresentationData presentation =
node instanceof PresentableNodeDescriptor ? ((PresentableNodeDescriptor)node).getPresentation() :
node instanceof NavigationItem ? ObjectUtils.tryCast(((NavigationItem)node).getPresentation(), PresentationData.class) :
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -221,6 +221,10 @@ public class GuiUtils {
}
public static void replaceJSplitPaneWithIDEASplitter(JComponent root) {
replaceJSplitPaneWithIDEASplitter(root, false);
}
public static void replaceJSplitPaneWithIDEASplitter(JComponent root, boolean useOnePixelDivider) {
final Container parent = root.getParent();
if (root instanceof JSplitPane) {
// we can painlessly replace only splitter which is the only child in container
@@ -231,7 +235,8 @@ public class GuiUtils {
final Component component1 = pane.getTopComponent();
final Component component2 = pane.getBottomComponent();
final int orientation = pane.getOrientation();
final Splitter splitter = new JBSplitter(orientation == JSplitPane.VERTICAL_SPLIT);
boolean vertical = orientation == JSplitPane.VERTICAL_SPLIT;
final Splitter splitter = useOnePixelDivider ? new OnePixelSplitter(vertical) : new JBSplitter(vertical);
splitter.setFirstComponent((JComponent) component1);
splitter.setSecondComponent((JComponent) component2);
splitter.setShowDividerControls(pane.isOneTouchExpandable());
@@ -265,14 +270,14 @@ public class GuiUtils {
parent.setLayout(new BorderLayout());
parent.add(splitter, BorderLayout.CENTER);
}
replaceJSplitPaneWithIDEASplitter((JComponent) component1);
replaceJSplitPaneWithIDEASplitter((JComponent) component2);
replaceJSplitPaneWithIDEASplitter((JComponent) component1, useOnePixelDivider);
replaceJSplitPaneWithIDEASplitter((JComponent) component2, useOnePixelDivider);
}
else {
final Component[] components = root.getComponents();
for (Component component : components) {
if (component instanceof JComponent) {
replaceJSplitPaneWithIDEASplitter((JComponent)component);
replaceJSplitPaneWithIDEASplitter((JComponent)component, useOnePixelDivider);
}
}
}
@@ -561,7 +561,7 @@ public class JBScrollPane extends JScrollPane {
if (hsbOpaque) {
Component corner = hsbOnTop ? (vsbOnLeft ? upperRight : upperLeft) : (vsbOnLeft ? lowerRight : lowerLeft);
fillLowerCorner = corner == null && UIManager.getBoolean("ScrollPane.fillLowerCorner");
if (!fillLowerCorner && ScrollSettings.isHeaderOverCorner()) {
if (!fillLowerCorner && ScrollSettings.isHeaderOverCorner(rowHead)) {
if (hsbOnTop) rowHeadBounds.y -= hsbBounds.height;
rowHeadBounds.height += hsbBounds.height;
}
@@ -577,7 +577,7 @@ public class JBScrollPane extends JScrollPane {
if (vsbOpaque) {
Component corner = vsbOnLeft ? (hsbOnTop ? lowerLeft : upperLeft) : (hsbOnTop ? lowerRight : upperRight);
fillUpperCorner = corner == null && UIManager.getBoolean("ScrollPane.fillUpperCorner");
if (!fillUpperCorner && ScrollSettings.isHeaderOverCorner()) {
if (!fillUpperCorner && ScrollSettings.isHeaderOverCorner(colHead)) {
if (vsbOnLeft) colHeadBounds.x -= vsbBounds.width;
colHeadBounds.width += vsbBounds.width;
}
@@ -471,7 +471,7 @@ public class JBViewport extends JViewport implements ZoomableViewport {
if (vsb != null && vsb.isVisible()) {
boolean opaque = vsb.isOpaque();
if (viewport == pane.getColumnHeader()
? (!opaque || ScrollSettings.isHeaderOverCorner())
? (!opaque || ScrollSettings.isHeaderOverCorner(viewport))
: (!opaque && viewport == pane.getViewport())) {
Alignment va = UIUtil.getClientProperty(vsb, Alignment.class);
if (va == Alignment.LEFT) {
@@ -487,7 +487,7 @@ public class JBViewport extends JViewport implements ZoomableViewport {
if (hsb != null && hsb.isVisible()) {
boolean opaque = hsb.isOpaque();
if (viewport == pane.getRowHeader()
? (!opaque || ScrollSettings.isHeaderOverCorner())
? (!opaque || ScrollSettings.isHeaderOverCorner(viewport))
: (!opaque && viewport == pane.getViewport())) {
Alignment ha = UIUtil.getClientProperty(hsb, Alignment.class);
if (ha == Alignment.TOP) {
@@ -24,6 +24,8 @@ import com.intellij.openapi.util.registry.RegistryValue;
import javax.swing.JDialog;
import javax.swing.JScrollBar;
import javax.swing.JViewport;
import javax.swing.table.JTableHeader;
import javax.swing.RootPaneContainer;
import java.awt.Component;
import java.awt.Container;
@@ -72,7 +74,8 @@ final class ScrollSettings {
return BACKGROUND_FROM_VIEW.asBoolean();
}
static boolean isHeaderOverCorner() {
static boolean isHeaderOverCorner(JViewport viewport) {
if (viewport.getView() instanceof JTableHeader) return false;
return HEADER_OVER_CORNER.asBoolean();
}
@@ -157,7 +157,7 @@ public class InstalledPluginsManagerMain extends PluginManagerMain {
PluginInstaller.install(file, file.getName(), false, pluginDescriptor);
ourState.onPluginInstall(pluginDescriptor);
checkInstalledPluginDependencies(model, pluginDescriptor, parent);
callback.consume(pair(file, (IdeaPluginDescriptor)pluginDescriptor));
callback.consume(pair(file, pluginDescriptor));
}
catch (IOException ex) {
MessagesEx.showErrorDialog(parent, ex.getMessage(), CommonBundle.getErrorTitle());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.OnePixelDivider;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.updateSettings.impl.UpdateChecker;
import com.intellij.openapi.util.text.StringUtil;
@@ -62,7 +63,6 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.*;
import javax.swing.plaf.BorderUIResource;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;
@@ -85,7 +85,7 @@ import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces;
public abstract class PluginManagerMain implements Disposable {
public static final String JETBRAINS_VENDOR = "JetBrains";
public static Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.PluginManagerMain");
public static final Logger LOG = Logger.getInstance(PluginManagerMain.class);
@NonNls private static final String TEXT_SUFFIX = "</body></html>";
@@ -138,7 +138,7 @@ public abstract class PluginManagerMain implements Disposable {
}
protected void init() {
GuiUtils.replaceJSplitPaneWithIDEASplitter(main);
GuiUtils.replaceJSplitPaneWithIDEASplitter(main, true);
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet sheet = kit.getStyleSheet();
sheet.addRule("ul {margin-left: 16px}"); // list-style-type: none;
@@ -147,6 +147,7 @@ public abstract class PluginManagerMain implements Disposable {
myDescriptionTextArea.addHyperlinkListener(new MyHyperlinkListener());
JScrollPane installedScrollPane = createTable();
installedScrollPane.setBorder(JBUI.Borders.customLine(OnePixelDivider.BACKGROUND, 1, 1, 1, 0));
myPluginHeaderPanel = new PluginHeaderPanel(this);
myHeader.setBackground(UIUtil.getTextFieldBackground());
myPluginHeaderPanel.getPanel().setBackground(UIUtil.getTextFieldBackground());
@@ -159,17 +160,17 @@ public abstract class PluginManagerMain implements Disposable {
UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, myPanelDescription);
myPanelDescription.setBorder(JBUI.Borders.emptyLeft(7));
final JPanel header = new JPanel(new BorderLayout()) {
JPanel header = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
final Color bg = UIUtil.getTableBackground(false);
Color bg = UIUtil.getTableBackground(false);
((Graphics2D)g).setPaint(new GradientPaint(0, 0, ColorUtil.shift(bg, 1.4), 0, getHeight(), ColorUtil.shift(bg, 0.9)));
g.fillRect(0,0, getWidth(), getHeight());
}
};
header.setBorder(new CustomLineBorder(1, 1, 0, 1));
final JLabel mySortLabel = new JLabel();
header.setBorder(new CustomLineBorder(1, 1, 0, 0));
JLabel mySortLabel = new JLabel();
mySortLabel.setForeground(UIUtil.getLabelDisabledForeground());
mySortLabel.setBorder(JBUI.Borders.empty(1, 1, 1, 5));
mySortLabel.setIcon(AllIcons.General.SplitDown);
@@ -178,7 +179,7 @@ public abstract class PluginManagerMain implements Disposable {
myTablePanel.add(header, BorderLayout.NORTH);
myToolbarPanel.setLayout(new BorderLayout());
myActionToolbar = ActionManager.getInstance().createActionToolbar("PluginManager", getActionGroup(true), true);
final JComponent component = myActionToolbar.getComponent();
JComponent component = myActionToolbar.getComponent();
myToolbarPanel.add(component, BorderLayout.CENTER);
myToolbarPanel.add(myFilter, BorderLayout.WEST);
new ClickListener() {
@@ -189,7 +190,7 @@ public abstract class PluginManagerMain implements Disposable {
return true;
}
}.installOn(mySortLabel);
final TableModelListener modelListener = new TableModelListener() {
TableModelListener modelListener = new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
String text = "Sort by:";
@@ -213,7 +214,7 @@ public abstract class PluginManagerMain implements Disposable {
modelListener.tableChanged(null);
myDescriptionScrollPane.setBackground(UIUtil.getTextFieldBackground());
Border border = new BorderUIResource.LineBorderUIResource(new JBColor(Gray._220, Gray._55), 1);
Border border = JBUI.Borders.customLine(OnePixelDivider.BACKGROUND, 1, 0, 1, 1);
myInfoPanel.setBorder(border);
}
@@ -244,9 +245,9 @@ public abstract class PluginManagerMain implements Disposable {
}
private static String getTextPrefix() {
final int fontSize = JBUI.scale(12);
final int m1 = JBUI.scale(2);
final int m2 = JBUI.scale(5);
int fontSize = JBUI.scale(12);
int m1 = JBUI.scale(2);
int m2 = JBUI.scale(5);
return String.format(
"<html><head>" +
" <style type=\"text/css\">" +
@@ -280,7 +281,7 @@ public abstract class PluginManagerMain implements Disposable {
IdeaPluginDescriptor plugin = descriptors != null && descriptors.length == 1 ? descriptors[0] : null;
pluginInfoUpdate(plugin, myFilter.getFilter(), myDescriptionTextArea, myPluginHeaderPanel);
myActionToolbar.updateActionsImmediately();
final JComponent parent = (JComponent)myHeader.getParent();
JComponent parent = (JComponent)myHeader.getParent();
parent.revalidate();
parent.repaint();
}
@@ -323,8 +324,8 @@ public abstract class PluginManagerMain implements Disposable {
setDownloadStatus(true);
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final List<IdeaPluginDescriptor> list = ContainerUtil.newArrayList();
final Map<String, String> errors = ContainerUtil.newLinkedHashMap();
List<IdeaPluginDescriptor> list = ContainerUtil.newArrayList();
Map<String, String> errors = ContainerUtil.newLinkedHashMap();
ProgressIndicator indicator = new EmptyProgressIndicator();
List<String> hosts = RepositoryHelper.getPluginHosts();
@@ -406,10 +407,10 @@ public abstract class PluginManagerMain implements Disposable {
/**
* @deprecated use {@link #downloadPlugins(List, List, Runnable, PluginEnabler, Runnable)} instead
*/
public static boolean downloadPlugins(final List<PluginNode> plugins,
final List<PluginId> allPlugins,
final Runnable onSuccess,
@Nullable final Runnable cleanup) throws IOException {
public static boolean downloadPlugins(List<PluginNode> plugins,
List<PluginId> allPlugins,
Runnable onSuccess,
@Nullable Runnable cleanup) throws IOException {
return downloadPlugins(plugins,
allPlugins.stream().map(p -> new PluginNode(p, p.getIdString(), "-1")).collect(Collectors.toList()),
onSuccess,
@@ -417,12 +418,12 @@ public abstract class PluginManagerMain implements Disposable {
cleanup);
}
public static boolean downloadPlugins(final List<PluginNode> plugins,
final List<IdeaPluginDescriptor> allPlugins,
final Runnable onSuccess,
public static boolean downloadPlugins(List<PluginNode> plugins,
List<IdeaPluginDescriptor> allPlugins,
Runnable onSuccess,
PluginEnabler pluginEnabler,
@Nullable final Runnable cleanup) throws IOException {
final boolean[] result = new boolean[1];
@Nullable Runnable cleanup) throws IOException {
boolean[] result = new boolean[1];
try {
ProgressManager.getInstance().run(new Task.Backgroundable(null, IdeBundle.message("progress.download.plugins"), true, PluginManagerUISettings.getInstance()) {
@Override
@@ -539,7 +540,7 @@ public abstract class PluginManagerMain implements Disposable {
}
public String apply() {
final String applyMessage = canApply();
String applyMessage = canApply();
if (applyMessage != null) return applyMessage;
setRequireShutdown(true);
return null;
@@ -641,19 +642,19 @@ public abstract class PluginManagerMain implements Disposable {
public static boolean suggestToEnableInstalledDependantPlugins(PluginEnabler pluginEnabler,
List<PluginNode> list) {
final Set<IdeaPluginDescriptor> disabled = new HashSet<>();
final Set<IdeaPluginDescriptor> disabledDependants = new HashSet<>();
Set<IdeaPluginDescriptor> disabled = new HashSet<>();
Set<IdeaPluginDescriptor> disabledDependants = new HashSet<>();
for (PluginNode node : list) {
final PluginId pluginId = node.getPluginId();
PluginId pluginId = node.getPluginId();
if (pluginEnabler.isDisabled(pluginId)) {
disabled.add(node);
}
final List<PluginId> depends = node.getDepends();
List<PluginId> depends = node.getDepends();
if (depends != null) {
final Set<PluginId> optionalDeps = new HashSet<>(Arrays.asList(node.getOptionalDependentPluginIds()));
Set<PluginId> optionalDeps = new HashSet<>(Arrays.asList(node.getOptionalDependentPluginIds()));
for (PluginId dependantId : depends) {
if (optionalDeps.contains(dependantId)) continue;
final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(dependantId);
IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(dependantId);
if (pluginDescriptor != null && pluginEnabler.isDisabled(dependantId)) {
disabledDependants.add(pluginDescriptor);
}
@@ -773,7 +774,7 @@ public abstract class PluginManagerMain implements Disposable {
}
public static void notifyPluginsUpdated(@Nullable Project project) {
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
ApplicationEx app = ApplicationManagerEx.getApplicationEx();
String title = IdeBundle.message("update.notifications.title");
String action = IdeBundle.message(app.isRestartCapable() ? "ide.restart.action" : "ide.shutdown.action");
String message = IdeBundle.message("ide.restart.required.notification", action, ApplicationNamesInfo.getInstance().getFullProductName());
@@ -818,7 +819,7 @@ public abstract class PluginManagerMain implements Disposable {
}
protected DefaultActionGroup createSortersGroup() {
final DefaultActionGroup group = new DefaultActionGroup("Sort by", true);
DefaultActionGroup group = new DefaultActionGroup("Sort by", true);
group.addAction(new SortByStatusAction(pluginTable, pluginsModel));
return group;
}
@@ -203,7 +203,10 @@ public class StartupManagerImpl extends StartupManagerEx {
dumbService.runWhenSmart(this);
}
else {
myPostStartupActivitiesPassed = true;
//noinspection SynchronizeOnThis
synchronized (this) {
myPostStartupActivitiesPassed = true;
}
}
}
});
@@ -362,28 +365,23 @@ public class StartupManagerImpl extends StartupManagerEx {
final Application application = ApplicationManager.getApplication();
if (application == null) return;
//noinspection SynchronizeOnThis
synchronized (this) {
// in tests which simulate project opening, post-startup activities could have been run already.
// Then we should act as if the project was initialized
boolean initialized = myProject.isInitialized() || myProject.isDefault() || application.isUnitTestMode() && myPostStartupActivitiesPassed;
if (!initialized) {
registerPostStartupActivity(action);
return;
}
}
Runnable runnable = () -> {
if (!myProject.isDisposed()) {
action.run();
if (myProject.isDisposed()) return;
//noinspection SynchronizeOnThis
synchronized (this) {
// in tests which simulate project opening, post-startup activities could have been run already.
// Then we should act as if the project was initialized
boolean initialized = myProject.isInitialized() || myProject.isDefault() || application.isUnitTestMode() && myPostStartupActivitiesPassed;
if (!initialized) {
registerPostStartupActivity(action);
return;
}
}
action.run();
};
if (application.isDispatchThread()) {
runnable.run();
}
else {
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
GuiUtils.invokeLaterIfNeeded(runnable, ModalityState.NON_MODAL);
}
@TestOnly
@@ -18,17 +18,26 @@ package com.intellij.ide.ui.laf.darcula;
import com.intellij.ide.IdeEventQueue;
import com.intellij.ide.ui.laf.IntelliJLaf;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.MacUIUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.text.JTextComponent;
import javax.swing.text.Position;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
import java.util.Arrays;
import java.util.List;
import static com.intellij.util.ui.MacUIUtil.MAC_FILL_BORDER;
import static javax.swing.SwingConstants.EAST;
import static javax.swing.SwingConstants.WEST;
@@ -184,4 +193,76 @@ public class DarculaUIUtil {
}
return -1;
}
public static class EditorTextFieldBorder implements Border {
private final JComponent myEnabledComponent;
public EditorTextFieldBorder(JComponent enabledComponent) {
myEnabledComponent = enabledComponent;
}
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2 = (Graphics2D)g.create();
try {
if (c.isOpaque() || (c instanceof JComponent && ((JComponent)c).getClientProperty(MAC_FILL_BORDER) == Boolean.TRUE)) {
g2.setColor(UIUtil.getPanelBackground());
g2.fillRect(x, y, width, height);
}
Rectangle2D rect = new Rectangle2D.Double(x + JBUI.scale(3), y + JBUI.scale(3), width - JBUI.scale(6), height - JBUI.scale(6));
g2.setColor(c.getBackground());
g2.fill(rect);
if (!myEnabledComponent.isEnabled()) {
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
}
double bw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
Path2D outline = new Path2D.Double(Path2D.WIND_EVEN_ODD);
outline.append(rect, false);
outline.append(new Rectangle2D.Double(rect.getX() + bw,
rect.getY() + bw,
rect.getWidth() - 2*bw,
rect.getHeight() - 2*bw), false);
g2.setColor(Gray.xBC);
g2.fill(outline);
if (myEnabledComponent.isEnabled() && myEnabledComponent.isVisible() && hasFocus(myEnabledComponent)) {
g2.translate(x, y);
paintFocusBorder(g2, width, height, 0, true);
}
} finally {
g2.dispose();
}
}
@Override
public Insets getBorderInsets(Component c) {
return new JBInsets(6, 7, 6, 7);
}
@Override
public boolean isBorderOpaque() {
return true;
}
}
private static boolean hasFocus(@NotNull Component component) {
if (component.hasFocus()) return true;
if (!(component instanceof JComponent)) return false;
List<Component> children;
synchronized (component.getTreeLock()) {
children = Arrays.asList(((Container)component).getComponents());
}
for (Component c : children) {
if (hasFocus(c)) {
return true;
}
}
return false;
}
}
@@ -581,8 +581,8 @@ public class GlassPaneDialogWrapperPeer extends DialogWrapperPeer implements Foc
@Override
public void dispose() {
setVisible(false);
remove(getContentPane());
setVisible(false);
DialogWrapper.unregisterKeyboardActions(myWrapperPane);
myRootPane = null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,14 +20,14 @@ import com.intellij.ide.plugins.PluginHeaderPanel;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.ide.plugins.PluginManagerMain;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.ui.OnePixelDivider;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Comparing;
import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.ui.OrderPanel;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -48,45 +48,45 @@ public class DetectedPluginsPanel extends OrderPanel<PluginDownloader> {
public DetectedPluginsPanel() {
super(PluginDownloader.class);
final JTable entryTable = getEntryTable();
JTable entryTable = getEntryTable();
myHeader = new PluginHeaderPanel(null);
entryTable.setTableHeader(null);
entryTable.setDefaultRenderer(PluginDownloader.class, new ColoredTableCellRenderer() {
protected void customizeCellRenderer(final JTable table,
final Object value,
final boolean selected,
final boolean hasFocus,
final int row,
final int column) {
protected void customizeCellRenderer(JTable table,
Object value,
boolean selected,
boolean hasFocus,
int row,
int column) {
setBorder(null);
final PluginDownloader downloader = (PluginDownloader)value;
PluginDownloader downloader = (PluginDownloader)value;
if (downloader != null) {
final String pluginName = downloader.getPluginName();
String pluginName = downloader.getPluginName();
append(pluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(PluginId.getId(downloader.getPluginId()));
IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(PluginId.getId(downloader.getPluginId()));
if (ideaPluginDescriptor != null) {
final String oldPluginName = ideaPluginDescriptor.getName();
String oldPluginName = ideaPluginDescriptor.getName();
if (!Comparing.strEqual(pluginName, oldPluginName)) {
append(" - " + oldPluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
final String loadedVersion = downloader.getPluginVersion();
String loadedVersion = downloader.getPluginVersion();
if (loadedVersion != null || (ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null)) {
final String installedVersion = ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null
? "v. " + ideaPluginDescriptor.getVersion() + (loadedVersion != null ? " -> " : "")
String installedVersion = ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null
? ideaPluginDescriptor.getVersion() + (loadedVersion != null ? " " + UIUtil.rightArrow() + " " : "")
: "";
final String availableVersion = loadedVersion != null ? loadedVersion : "";
append(" (" + installedVersion + availableVersion + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
String availableVersion = loadedVersion != null ? loadedVersion : "";
append(" " + installedVersion + availableVersion, SimpleTextAttributes.GRAYED_SMALL_ATTRIBUTES);
}
}
}
});
entryTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
final int selectedRow = entryTable.getSelectedRow();
int selectedRow = entryTable.getSelectedRow();
if (selectedRow != -1) {
final PluginDownloader selection = getValueAt(selectedRow);
final IdeaPluginDescriptor descriptor = selection.getDescriptor();
PluginDownloader selection = getValueAt(selectedRow);
IdeaPluginDescriptor descriptor = selection.getDescriptor();
if (descriptor != null) {
PluginManagerMain.pluginInfoUpdate(descriptor, null, myDescriptionPanel, myHeader);
}
@@ -100,25 +100,32 @@ public class DetectedPluginsPanel extends OrderPanel<PluginDownloader> {
myDescriptionPanel.addHyperlinkListener(new PluginManagerMain.MyHyperlinkListener());
removeAll();
final Splitter splitter = new Splitter(false);
splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(entryTable));
splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myDescriptionPanel));
Splitter splitter = new OnePixelSplitter(false);
splitter.setFirstComponent(wrapWithPane(entryTable, 1, 0));
splitter.setSecondComponent(wrapWithPane(myDescriptionPanel, 0, 1));
add(splitter, BorderLayout.CENTER);
}
@NotNull
private static JScrollPane wrapWithPane(@NotNull JComponent c, int left, int right) {
JScrollPane pane = ScrollPaneFactory.createScrollPane(c);
pane.setBorder(JBUI.Borders.customLine(OnePixelDivider.BACKGROUND, 1, left, 1, right));
return pane;
}
public String getCheckboxColumnName() {
return "";
}
public boolean isCheckable(final PluginDownloader downloader) {
public boolean isCheckable(PluginDownloader downloader) {
return true;
}
public boolean isChecked(final PluginDownloader downloader) {
public boolean isChecked(PluginDownloader downloader) {
return !getSkippedPlugins().contains(downloader.getPluginId());
}
public void setChecked(final PluginDownloader downloader, final boolean checked) {
public void setChecked(PluginDownloader downloader, boolean checked) {
if (checked) {
getSkippedPlugins().remove(downloader.getPluginId());
}
@@ -17,6 +17,7 @@ package com.intellij.ui;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.ide.ui.UISettings;
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
import com.intellij.ide.ui.laf.darcula.ui.DarculaEditorTextFieldBorder;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -52,7 +53,6 @@ import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.util.IJSwingUtilities;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.MacUIUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -545,7 +545,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
protected void setupBorder(@NotNull EditorEx editor) {
if (UIUtil.isUnderAquaLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
editor.setBorder(UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF() ? new DarculaEditorTextFieldBorder() : new MacUIUtil.EditorTextFieldBorder(this));
editor.setBorder(UIUtil.isUnderDefaultMacTheme() ? new DarculaUIUtil.EditorTextFieldBorder(this) : new DarculaEditorTextFieldBorder());
editor.addFocusListener(new FocusChangeListener() {
@Override
public void focusGained(Editor editor) {
@@ -132,13 +132,6 @@ public interface PopupComponent {
myDialog.setBackground(UIUtil.getPanelBackground());
myDialog.pack();
myDialog.setLocation(x, y);
myDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
super.windowClosed(e);
//A11YFix.invokeFocusGained(myDialog);
}
});
}
public Window getWindow() {
@@ -155,13 +148,20 @@ public interface PopupComponent {
public void show() {
UIUtil.suppressFocusStealing(getWindow());
UIUtil.suppressFocusStealing(getWindow());
if (!myRequestFocus) {
myDialog.setFocusableWindowState(false);
}
AwtPopupWrapper.fixFlickering(myDialog, false);
myDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
//A11YFix.invokeFocusGained(myDialog);
myDialog.removeWindowListener(this);
}
});
myDialog.setVisible(true);
AwtPopupWrapper.fixFlickering(myDialog, true);
@@ -819,4 +819,4 @@ inspection.reflection.invocation.argument.count={0,choice,0#No arguments are|1#O
inspection.reflection.invocation.item.count={0,choice,0#Empty array is|1#Single-item array is|1<{0} array items are} expected
inspection.reflection.invocation.argument.not.assignable=Argument is not assignable to ''{0}''
inspection.reflection.invocation.item.not.assignable=Array item is not assignable to ''{0}''
inspection.reflection.invocation.item.number.not.assignable=Array item {0} is not assignable to ''{1}''
inspection.reflection.invocation.array.not.assignable=Array {0,choice,1#item has|1<items have} incompatible {0,choice,1#type|1<types}
@@ -152,8 +152,8 @@ variable.of.type=Variable of &type:
convert.to.instance.method.title=Convert To Instance Method
convertToInstanceMethod.method.is.not.static=Cannot perform the refactoring\nMethod {0} is not static
convertToInstanceMethod.no.parameters.with.reference.type=There are no parameters that have reference type
convertToInstanceMethod.all.reference.type.parametres.have.unknown.types=All reference type parameters have unknown types
convertToInstanceMethod.all.reference.type.parameters.are.not.in.project=All reference type parameters have types that are not in project
convertToInstanceMethod.all.reference.type.parametres.have.unknown.types=No target class for the instance method is found: all referenced types are unknown
convertToInstanceMethod.all.reference.type.parameters.are.not.in.project=No target class for the instance method is found: all referenced types are not in project
cannot.perform.refactoring=Cannot perform refactoring.
move.instance.method.title=Move Instance Method
move.method.is.not.supported.for.constructors=Move method is not supported for constructors
@@ -629,6 +629,22 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
myJdkTableMultiListener.removeListener(jdkTableListener);
}
protected void assertListenersAreDisposed() {
if (!myRegisteredRootProviders.isEmpty()) {
StringBuilder details = new StringBuilder();
for (Map.Entry<RootProvider, Set<OrderEntry>> entry : myRegisteredRootProviders.entrySet()) {
details.append(" ").append(entry.getKey()).append(" referenced by ").append(entry.getValue().size()).append(" order entries:\n");
for (OrderEntry orderEntry : entry.getValue()) {
details.append(" ").append(orderEntry).append("\n");
}
}
LOG.error("Listeners for " + myRegisteredRootProviders.size() + " root providers aren't disposed:" + details);
for (RootProvider provider : myRegisteredRootProviders.keySet()) {
provider.removeRootSetChangedListener(myRootProviderChangeListener);
}
}
}
private class RootProviderChangeListener implements RootProvider.RootSetChangedListener {
private boolean myInsideRootsChange;
@@ -107,10 +107,6 @@ class MockRunManager : RunManagerEx() {
return null
}
override fun getSortedConfigurations(): Collection<RunnerAndConfigurationSettings> {
return emptyList()
}
override fun removeConfiguration(settings: RunnerAndConfigurationSettings?) {}
override fun addRunManagerListener(listener: RunManagerListener) {}
@@ -309,16 +309,20 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
targetFile.putUserData(VfsTestUtil.TEST_DATA_FILE_PATH, sourceFile.getAbsolutePath());
}
final File _source = sourceFile;
final VirtualFile _target = targetFile;
copyContent(sourceFile, targetFile);
return targetFile;
}
private static void copyContent(File sourceFile, VirtualFile targetFile) {
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws IOException {
_target.setBinaryContent(FileUtil.loadFileBytes(_source));
targetFile.setBinaryContent(FileUtil.loadFileBytes(sourceFile));
// update the document now, otherwise MemoryDiskConflictResolver will do it later at unexpected moment of time
FileDocumentManager.getInstance().reloadFiles(targetFile);
}
}.execute();
return targetFile;
}
@NotNull
@@ -265,10 +265,6 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
public void clear() {
}
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
}
///////////////////////////////////Delegates
@Override
public void readExternal(final Element element) throws InvalidDataException {
@@ -15,4 +15,13 @@
<item name="com.intellij.util.containers.ContainerUtil java.util.Map&lt;K, V&gt; newHashMap(com.intellij.openapi.util.Pair&lt;K, ? extends V&gt;, com.intellij.openapi.util.Pair&lt;K, ? extends V&gt;...)">
<annotation name="java.lang.SafeVarargs" />
</item>
<item name="com.intellij.util.containers.Convertor">
<annotation name="java.lang.FunctionalInterface" />
</item>
<item name="com.intellij.util.containers.InternalIterator">
<annotation name="java.lang.FunctionalInterface" />
</item>
<item name="com.intellij.util.containers.Predicate">
<annotation name="java.lang.FunctionalInterface" />
</item>
</root>

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