Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2017-03-30 16:35:09 +02:00
38 changed files with 267 additions and 196 deletions
+1 -1
View File
@@ -75,7 +75,7 @@
</target>
<target name="test" depends="init">
<call_gant script="${project.home}/build/scripts/tests.gant"/>
<call_gant script="${project.home}/build/scripts/tests_in_community.gant"/>
</target>
<!-- The build task creates an updater.jar in ${out.dir}. This task bundles the updater and its dependencies into a single jar -->
@@ -15,6 +15,7 @@
*/
package com.intellij.debugger.engine;
import com.intellij.debugger.EvaluatingComputable;
import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.impl.DebuggerUtilsEx;
@@ -25,6 +26,7 @@ import com.intellij.psi.util.InheritanceUtil;
import com.intellij.util.Range;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
import com.sun.jdi.ObjectReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -65,7 +67,12 @@ public class BasicStepMethodFilter implements NamedMethodFilter {
return myTargetMethodName;
}
public boolean locationMatches(final DebugProcessImpl process, final Location location) throws EvaluateException {
public boolean locationMatches(DebugProcessImpl process, Location location) throws EvaluateException {
return locationMatches(process, location, () -> null);
}
public boolean locationMatches(DebugProcessImpl process, Location location, @NotNull EvaluatingComputable<ObjectReference> thisProvider)
throws EvaluateException {
Method method = location.method();
String name = method.name();
if (!myTargetMethodName.equals(name)) {
@@ -96,7 +103,15 @@ public class BasicStepMethodFilter implements NamedMethodFilter {
if (method.isBridge()) { // skip bridge methods
return false;
}
return DebuggerUtilsEx.isAssignableFrom(myDeclaringClassName.getName(process), location.declaringType());
String declaringClassNameName = myDeclaringClassName.getName(process);
boolean res = DebuggerUtilsEx.isAssignableFrom(declaringClassNameName, location.declaringType());
if (!res && !method.isStatic()) {
ObjectReference thisObject = thisProvider.compute();
if (thisObject != null) {
res = DebuggerUtilsEx.isAssignableFrom(declaringClassNameName, thisObject.referenceType());
}
}
return res;
}
private static boolean signatureMatches(Method method, final String expectedSignature) throws EvaluateException {
@@ -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.
@@ -15,13 +15,22 @@
*/
package com.intellij.debugger.engine;
import com.intellij.debugger.EvaluatingComputable;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.util.Range;
import com.sun.jdi.Location;
import com.sun.jdi.ObjectReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface MethodFilter {
boolean locationMatches(DebugProcessImpl process, Location location) throws EvaluateException;
default boolean locationMatches(DebugProcessImpl process, Location location, @NotNull EvaluatingComputable<ObjectReference> thisProvider)
throws EvaluateException {
return locationMatches(process, location);
}
@Nullable Range<Integer> getCallingExpressionLines();
default int onReached(SuspendContextImpl context, RequestHint hint) {
@@ -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.
@@ -192,7 +192,7 @@ public class RequestHint {
if (myMethodFilter != null &&
frameProxy != null &&
!(myMethodFilter instanceof BreakpointStepMethodFilter) &&
myMethodFilter.locationMatches(context.getDebugProcess(), frameProxy.location()) &&
myMethodFilter.locationMatches(context.getDebugProcess(), frameProxy.location(), frameProxy::thisObject) &&
!isTheSameFrame(context)
) {
myTargetMethodMatched = true;
@@ -226,20 +226,16 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
return Boolean.TRUE.equals(debugProcess.getUserData(BatchEvaluator.REMOTE_SESSION_KEY));
}
public interface SupplierThrowing<T, E extends Throwable> {
T get() throws E;
}
public static <T, E extends Exception> T suppressExceptions(SupplierThrowing<T, E> supplier, T defaultValue) throws E {
public static <T, E extends Exception> T suppressExceptions(ThrowableComputable<T, E> supplier, T defaultValue) throws E {
return suppressExceptions(supplier, defaultValue, true, null);
}
public static <T, E extends Exception> T suppressExceptions(SupplierThrowing<T, E> supplier,
public static <T, E extends Exception> T suppressExceptions(ThrowableComputable<T, E> supplier,
T defaultValue,
boolean ignorePCE,
Class<E> rethrow) throws E {
try {
return supplier.get();
return supplier.compute();
}
catch (ProcessCanceledException e) {
if (!ignorePCE) {
@@ -25,8 +25,8 @@ import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.jdi.VirtualMachineProxy;
import com.intellij.debugger.impl.DebuggerUtilsImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.ThreeState;
@@ -357,13 +357,13 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
return myVirtualMachine.mirrorOf(s);
}
public StringReference mirrorOfStringLiteral(String s, DebuggerUtilsImpl.SupplierThrowing<StringReference, EvaluateException> generator)
public StringReference mirrorOfStringLiteral(String s, ThrowableComputable<StringReference, EvaluateException> generator)
throws EvaluateException {
StringReference reference = myStringLiteralCache.get(s);
if (reference != null && !reference.isCollected()) {
return reference;
}
reference = generator.get();
reference = generator.compute();
myStringLiteralCache.put(s, reference);
return reference;
}
@@ -259,7 +259,7 @@ public class JUnitUtil {
return aPackage != null && aPackage.getDirectories(scope).length > 0;
};
return foundCondition.value(TEST5_PACKAGE_FQN) || foundCondition.value("org.junit.platform.engine");
return foundCondition.value(TEST5_PACKAGE_FQN);
}
public static boolean isTestAnnotated(final PsiMethod method) {
@@ -42,7 +42,6 @@ class CompilationTasksImpl extends CompilationTasks {
ensureKotlinCompilerAddedToClassPath()
context.projectBuilder.cleanOutput()
context.messages.progress("Compiling project")
try {
if (moduleNames == null) {
@@ -118,35 +118,35 @@ public class ExternalProjectsManager implements PersistentStateComponent<Externa
}
public void init() {
synchronized (isInitializationWasStarted) {
if (isInitializationWasStarted.getAndSet(true)) return;
if (isInitializationWasStarted.getAndSet(true)) return;
myWatcher = new ExternalSystemProjectsWatcher(myProject);
myWatcher.start();
myWatcher = new ExternalSystemProjectsWatcher(myProject);
myWatcher.start();
// load external projects data
ExternalProjectsDataStorage.getInstance(myProject).load();
myRunManagerListener.attach();
// load external projects data
ExternalProjectsDataStorage.getInstance(myProject).load();
myRunManagerListener.attach();
// init shortcuts manager
myShortcutsManager.init();
for (ExternalSystemManager<?, ?, ?, ?, ?> systemManager : ExternalSystemApiUtil.getAllManagers()) {
final Collection<ExternalProjectInfo> externalProjects =
ExternalProjectsDataStorage.getInstance(myProject).list(systemManager.getSystemId());
for (ExternalProjectInfo externalProject : externalProjects) {
if (externalProject.getExternalProjectStructure() == null) continue;
Collection<DataNode<TaskData>> taskData =
ExternalSystemApiUtil.findAllRecursively(externalProject.getExternalProjectStructure(), TASK);
myShortcutsManager.scheduleKeymapUpdate(taskData);
}
if (!externalProjects.isEmpty()) {
myShortcutsManager.scheduleRunConfigurationKeymapUpdate(systemManager.getSystemId());
}
// init shortcuts manager
myShortcutsManager.init();
for (ExternalSystemManager<?, ?, ?, ?, ?> systemManager : ExternalSystemApiUtil.getAllManagers()) {
final Collection<ExternalProjectInfo> externalProjects =
ExternalProjectsDataStorage.getInstance(myProject).list(systemManager.getSystemId());
for (ExternalProjectInfo externalProject : externalProjects) {
if (externalProject.getExternalProjectStructure() == null) continue;
Collection<DataNode<TaskData>> taskData =
ExternalSystemApiUtil.findAllRecursively(externalProject.getExternalProjectStructure(), TASK);
myShortcutsManager.scheduleKeymapUpdate(taskData);
}
// init task activation info
myTaskActivator.init();
if (!externalProjects.isEmpty()) {
myShortcutsManager.scheduleRunConfigurationKeymapUpdate(systemManager.getSystemId());
}
}
// init task activation info
myTaskActivator.init();
synchronized (isInitializationFinished) {
isInitializationFinished.set(true);
ApplicationManager.getApplication().executeOnPooledThread(() -> {
myPostInitializationActivities.run();
@@ -156,10 +156,13 @@ public class ExternalProjectsManager implements PersistentStateComponent<Externa
}
public void runWhenInitialized(Runnable runnable) {
if (isInitializationFinished.get()){
ApplicationManager.getApplication().executeOnPooledThread(runnable);
} else {
myPostInitializationActivities.add(runnable);
synchronized(isInitializationFinished) {
if (isInitializationFinished.get()) {
ApplicationManager.getApplication().executeOnPooledThread(runnable);
}
else {
myPostInitializationActivities.add(runnable);
}
}
}
@@ -17,10 +17,22 @@ package com.intellij.openapi.externalSystem.util;
import com.intellij.util.SmartList;
public class CompositeRunnable extends SmartList<Runnable> implements Runnable {
import java.util.List;
public class CompositeRunnable implements Runnable {
private List<Runnable> list = new SmartList<>();
public boolean add(Runnable runnable) {
return list.add(runnable);
}
public void clear() {
list = new SmartList<>();
}
@Override
public void run() {
for (Runnable runnable : this) {
for (Runnable runnable : list) {
runnable.run();
}
}
@@ -76,10 +76,16 @@ public abstract class ColorSchemeActions extends AbstractSchemeActions<EditorCol
});
if (imported != null) {
getOptions().addImportedScheme(imported);
getSchemesPanel()
.showStatus(
ApplicationBundle.message("settings.editor.scheme.import.success", importSource.getPresentableUrl(), imported.getName()),
MessageType.INFO);
}
}
catch (SchemeImportException e) {
getSchemesPanel().showStatus("Import failed: " + e.getMessage(), MessageType.ERROR);
getSchemesPanel()
.showStatus(ApplicationBundle.message("settings.editor.scheme.import.failure", importSource.getPresentableUrl()),
MessageType.ERROR);
}
}
}
@@ -129,7 +129,7 @@ public class DiffManagerImpl extends DiffManager implements PersistentStateCompo
if (!ENABLE_FILES.value(myProperties) || !ENABLE_FOLDERS.value(myProperties) || !ENABLE_MERGE.value(myProperties)) {
DiffTool[] embeddableTools = {
INTERNAL_DIFF,
new MergeTool(),
MergeTool.INSTANCE,
BinaryDiffTool.INSTANCE
};
standardTools = new DiffTool[]{
@@ -138,7 +138,7 @@ public class DiffManagerImpl extends DiffManager implements PersistentStateCompo
ExtMergeFiles.INSTANCE,
new MultiLevelDiffTool(Arrays.asList(embeddableTools)),
INTERNAL_DIFF,
new MergeTool(),
MergeTool.INSTANCE,
BinaryDiffTool.INSTANCE
};
}
@@ -148,7 +148,7 @@ public class DiffManagerImpl extends DiffManager implements PersistentStateCompo
ExtCompareFiles.INSTANCE,
ExtMergeFiles.INSTANCE,
INTERNAL_DIFF,
new MergeTool(),
MergeTool.INSTANCE,
BinaryDiffTool.INSTANCE
};
}
@@ -32,6 +32,8 @@ import java.awt.*;
public class MergeTool implements DiffTool {
public static final Logger LOG = Logger.getInstance(MergeTool.class);
public static final MergeTool INSTANCE = new MergeTool();
public void show(DiffRequest data) {
if (data instanceof MergeRequestImpl) {
showDialog((MergeRequestImpl)data);
@@ -1232,8 +1232,8 @@ action.ChangesView.NewChangeList.text=New Changelist
action.ChangesView.NewChangeList.description=Create new changelist
action.ChangesView.Revert.text=_Revert
action.ChangesView.Revert.description=Revert selected changes
action.ChangesView.RemoveChangeList.text=Delete Changelist
action.ChangesView.RemoveChangeList.description=Remove changelist and move all changes to {0}
action.ChangesView.RemoveChangeList.text=Delete Changelists
action.ChangesView.RemoveChangeList.description=Remove changelists and move all changes to {0}
action.ChangesView.SetDefault.text=Set Active Changelist
action.ChangesView.SetDefault.description=Set changelist to which new changes are placed by default
action.ChangesView.Move.text=Move to Another Changelist...
@@ -782,5 +782,7 @@ settings.editor.scheme.copy.to.ide.title=Copy Project Scheme to IDE
settings.editor.scheme.copy.to.ide.label=IDE Scheme Name:
settings.editor.scheme.copy.to.project.title=Copy Setting to Project
settings.editor.scheme.copy.to.project.message=Overwrite project settings with values from {0}?
settings.editor.scheme.import.success={0} was imported to {1} scheme.
settings.editor.scheme.import.failure=Import failed: {0} is not a valid scheme.
title.save.code.style.scheme.as=Duplicate Code Style Scheme As
title.save.color.scheme.as=Duplicate Color Scheme As
@@ -162,12 +162,4 @@ public abstract class AbstractTestProxy extends CompositePrintable {
public String getLocationUrl() {
return null;
}
@Deprecated
public interface AssertEqualsDiffChain {
DiffHyperlink getPrevious();
DiffHyperlink getCurrent();
DiffHyperlink getNext();
void setCurrent(DiffHyperlink provider);
}
}
@@ -23,7 +23,6 @@ package com.intellij.execution.testframework.stacktrace;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.filters.HyperlinkInfo;
import com.intellij.execution.filters.HyperlinkInfoBase;
import com.intellij.execution.testframework.AbstractTestProxy;
import com.intellij.execution.testframework.Printable;
import com.intellij.execution.testframework.Printer;
import com.intellij.execution.testframework.actions.ViewAssertEqualsDiffAction;
@@ -77,23 +76,6 @@ public class DiffHyperlink implements Printable {
return filePath == null ? null : filePath.replace(File.separatorChar, '/');
}
/**
* Use {@link ViewAssertEqualsDiffAction#openDiff(DataContext, DiffHyperlink)}
*/
@Deprecated
public void openDiff(Project project) {
ViewAssertEqualsDiffAction.openDiff(DataManager.getInstance().getDataContext(), this);
}
/**
* Use {@link ViewAssertEqualsDiffAction#openDiff(DataContext, DiffHyperlink)}
*/
@Deprecated
public void openMultiDiff(final Project project,
final AbstractTestProxy.AssertEqualsDiffChain chain) {
ViewAssertEqualsDiffAction.openDiff(DataManager.getInstance().getDataContext(), this);
}
protected String getTitle() {
return ExecutionBundle.message("strings.equal.failed.dialog.title");
}
@@ -54,6 +54,7 @@ public class RemoveChangeListAction extends AnAction implements DumbAware {
presentation.setDescription(ArrayUtil.isEmpty(e.getData(VcsDataKeys.CHANGES)) ? presentation.getText() : getDescription(changeLists));
}
@NotNull
private static String getDescription(@Nullable ChangeList[] changeLists) {
return ActionsBundle.message("action.ChangesView.RemoveChangeList.description",
containsActiveChangelist(changeLists) ? "another changelist" : "active one");
@@ -17,7 +17,6 @@ package com.intellij.openapi.vcs.changes.actions.migrate;
import com.intellij.diff.DiffDialogHints;
import com.intellij.diff.DiffManager;
import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diff.DiffRequest;
import com.intellij.openapi.diff.DiffTool;
@@ -39,16 +38,15 @@ public class MigrateDiffTool implements DiffTool {
@Override
public void show(DiffRequest request) {
DiffRequestChain newChain = MigrateToNewDiffUtil.convertRequestChain(request);
com.intellij.diff.requests.DiffRequest newRequest = MigrateToNewDiffUtil.convertRequest(request);
WindowWrapper.Mode mode = FrameDiffTool.shouldOpenDialog(request.getHints()) ? WindowWrapper.Mode.MODAL : WindowWrapper.Mode.FRAME;
DiffManager.getInstance().showDiff(request.getProject(), newChain, new DiffDialogHints(mode));
DiffManager.getInstance().showDiff(request.getProject(), newRequest, new DiffDialogHints(mode));
}
@Override
public boolean canShow(DiffRequest request) {
if (request instanceof MergeRequest) return false;
if (request.getContents().length != 2) return false;
if (request.getHints().contains(MigrateToNewDiffUtil.DO_NOT_TRY_MIGRATE)) return false;
if (request.getOnOkRunnable() != null) return false;
if (!DiffManagerImpl.INTERNAL_DIFF.canShow(request) && !BinaryDiffTool.INSTANCE.canShow(request)) return false;
for (DiffTool tool : DiffManagerImpl.getInstanceEx().getAdditionTools()) {
@@ -1,9 +1,7 @@
package com.intellij.openapi.vcs.changes.actions.migrate;
import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.chains.DiffRequestProducer;
import com.intellij.diff.chains.DiffRequestProducerException;
import com.intellij.diff.chains.SimpleDiffRequestChain;
import com.intellij.diff.contents.DiffContent;
import com.intellij.diff.contents.DocumentContentImpl;
import com.intellij.diff.contents.EmptyContent;
@@ -13,7 +11,6 @@ import com.intellij.diff.requests.ErrorDiffRequest;
import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.diff.util.LineCol;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.DiffNavigationContext;
import com.intellij.openapi.diff.DiffTool;
import com.intellij.openapi.editor.Document;
@@ -34,16 +31,6 @@ import java.util.List;
import static com.intellij.openapi.util.text.StringUtil.notNullize;
public class MigrateToNewDiffUtil {
private static final Logger LOG = Logger.getInstance(MigrateToNewDiffUtil.class);
@NonNls public static final Object DO_NOT_TRY_MIGRATE = "doNotTryMigrate";
@NotNull
public static DiffRequestChain convertRequestChain(@NotNull com.intellij.openapi.diff.DiffRequest oldRequest) {
DiffRequest request = convertRequest(oldRequest);
return new SimpleDiffRequestChain(request);
}
@NotNull
public static DiffRequest convertRequest(@NotNull com.intellij.openapi.diff.DiffRequest oldRequest) {
DiffRequest request = convertRequestFair(oldRequest);
@@ -431,7 +431,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
private void addNotificationAndWarn(@NotNull String errorMessage) {
LOG.warn(errorMessage);
myErrorNotificationPanel.text(errorMessage);
myErrorNotificationPanel.setText(errorMessage);
myErrorNotificationPanel.setVisible(true);
}
@@ -68,10 +68,10 @@ public class GitPushTargetPanel extends PushTargetPanel<GitPushTarget> {
private static final Comparator<GitRemoteBranch> REMOTE_BRANCH_COMPARATOR = new MyRemoteBranchComparator();
private static final String SEPARATOR = " : ";
private static final Color NEW_BRANCH_LABEL_FG = new JBColor(0x00b53d, 0x6ba65d);
private static final Color NEW_BRANCH_SELECTION_LABEL_FG = UIUtil.getTreeSelectionForeground();
private static final Color NEW_BRANCH_LABEL_SELECTION_FG = UIUtil.getTreeSelectionForeground();
private static final Color NEW_BRANCH_LABEL_BG = new JBColor(0xebfcf1, 0x313b32);
private static final Color NEW_BRANCH_SELECTION_LABEL__BG =
new JBColor(ColorUtil.toAlpha(NEW_BRANCH_SELECTION_LABEL_FG, 20), ColorUtil.toAlpha(NEW_BRANCH_SELECTION_LABEL_FG, 30));
private static final Color NEW_BRANCH_LABEL_SELECTION_BG =
new JBColor(ColorUtil.toAlpha(NEW_BRANCH_LABEL_SELECTION_FG, 20), ColorUtil.toAlpha(NEW_BRANCH_LABEL_SELECTION_FG, 30));
private static final RelativeFont NEW_BRANCH_LABEL_FONT = RelativeFont.TINY.small();
private static final TextIcon NEW_BRANCH_LABEL = new TextIcon("New", NEW_BRANCH_LABEL_FG, NEW_BRANCH_LABEL_BG, 0);
@@ -282,8 +282,8 @@ public class GitPushTargetPanel extends PushTargetPanel<GitPushTarget> {
NEW_BRANCH_LABEL.setInsets(JBUI.insets(2));
NEW_BRANCH_LABEL.setRound(JBUI.scale(4));
NEW_BRANCH_LABEL.setFont(NEW_BRANCH_LABEL_FONT.derive(renderer.getFont()));
NEW_BRANCH_LABEL.setForeground(isSelected ? NEW_BRANCH_SELECTION_LABEL_FG : NEW_BRANCH_LABEL_FG);
NEW_BRANCH_LABEL.setBackground(isSelected ? NEW_BRANCH_SELECTION_LABEL__BG : NEW_BRANCH_LABEL_BG);
NEW_BRANCH_LABEL.setForeground(isSelected ? NEW_BRANCH_LABEL_SELECTION_FG : NEW_BRANCH_LABEL_FG);
NEW_BRANCH_LABEL.setBackground(isSelected ? NEW_BRANCH_LABEL_SELECTION_BG : NEW_BRANCH_LABEL_BG);
renderer.setIcon(NEW_BRANCH_LABEL);
}
}
@@ -15,6 +15,7 @@
*/
package git4idea.repo;
import com.intellij.dvcs.DvcsUtil;
import com.intellij.dvcs.repo.RepositoryImpl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
@@ -22,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.log.util.StopWatch;
import git4idea.GitLocalBranch;
import git4idea.GitUtil;
import git4idea.GitVcs;
@@ -32,6 +34,7 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Collection;
import static com.intellij.dvcs.DvcsUtil.getShortRepositoryName;
import static com.intellij.util.ObjectUtils.assertNotNull;
public class GitRepositoryImpl extends RepositoryImpl implements GitRepository {
@@ -202,12 +205,14 @@ public class GitRepositoryImpl extends RepositoryImpl implements GitRepository {
@NotNull
private GitRepoInfo readRepoInfo() {
StopWatch sw = StopWatch.start("Reading Git repo info in " + getShortRepositoryName(this));
File configFile = myRepositoryFiles.getConfigFile();
GitConfig config = GitConfig.read(configFile);
Collection<GitRemote> remotes = config.parseRemotes();
GitBranchState state = myReader.readState(remotes);
Collection<GitBranchTrackInfo> trackInfos = config.parseTrackInfos(state.getLocalBranches().keySet(), state.getRemoteBranches().keySet());
Collection<GitSubmoduleInfo> submodules = new GitModulesFileReader().read(getSubmoduleFile());
sw.report();
return new GitRepoInfo(state.getCurrentBranch(), state.getCurrentRevision(), state.getState(), remotes,
state.getLocalBranches(), state.getRemoteBranches(), trackInfos, submodules);
}
@@ -69,7 +69,7 @@ public class GradleExtensionsSettings implements PersistentStateComponent<Gradle
public Settings getState() {
// cleanup GradleExtensions entries created by previous version from workspace file
// TODO remove PersistentStateComponent implementation in future version
return myState;
return new Settings();
}
@Override
@@ -169,13 +169,18 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
File lib = new File(PathUtil.getJarPathForClass(MultipleFailuresError.class)).getParentFile();
File[] files = lib.listFiles();
if (files != null) {
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
for (File file : files) {
String fileName = file.getName();
if (fileName.startsWith("junit-platform-") ||
fileName.startsWith("junit-jupiter-engine-") && JavaPsiFacade.getInstance(project).findClass(JUnitUtil.TEST5_ANNOTATION, globalSearchScope) != null) {
if (fileName.startsWith("junit-platform-launcher-") && !hasPackageWithDirectories(psiFacade, "org.junit.platform.launcher", globalSearchScope) ||
fileName.startsWith("junit-platform-") && !hasPackageWithDirectories(psiFacade, "org.junit.platform", globalSearchScope) ||
fileName.startsWith("junit-jupiter-engine-") && !hasPackageWithDirectories(psiFacade, "org.junit.jupiter.engine", globalSearchScope) &&
hasPackageWithDirectories(psiFacade, JUnitUtil.TEST5_PACKAGE_FQN, globalSearchScope)) {
classPath.add(file.getAbsolutePath());
}
else if (fileName.startsWith("junit-vintage-engine-")) {
else if (fileName.startsWith("junit-vintage-engine-") && !hasPackageWithDirectories(psiFacade, "org.junit.vintage", globalSearchScope)) {
try {
JUnitUtil.getTestCaseClass(sourceScope);
classPath.add(file.getAbsolutePath());
@@ -190,6 +195,13 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
return javaParameters;
}
private static boolean hasPackageWithDirectories(JavaPsiFacade psiFacade,
String packageQName,
GlobalSearchScope globalSearchScope) {
PsiPackage aPackage = psiFacade.findPackage(packageQName);
return aPackage != null && aPackage.getDirectories(globalSearchScope).length > 0;
}
public static boolean isJUnit5(@Nullable Module module, @Nullable SourceScope sourceScope, Project project) {
return JUnitUtil.isJUnit5(getScopeForJUnit(module, sourceScope, project), project);
}
@@ -0,0 +1,40 @@
/*
* 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.rt.execution.junit;
import java.util.Iterator;
import java.util.ServiceLoader;
public class JUnit5EngineDetector {
public static boolean hasCustomEngine() {
try {
Iterator iterator = ServiceLoader.load(Class.forName("org.junit.platform.engine.TestEngine")).iterator();
while (iterator.hasNext()) {
Object engine = iterator.next();
String engineClassName = engine.getClass().getName();
if (!"org.junit.jupiter.engine.JupiterTestEngine".equals(engineClassName) &&
!"org.junit.vintage.engine.VintageTestEngine".equals(engineClassName)) {
return true;
}
}
return false;
}
catch (Throwable e) {
return false;
}
}
}
@@ -177,8 +177,13 @@ public class JUnitStarter {
public static boolean isJUnit5Preferred() {
final String useJUnit5 = System.getProperty(JUNIT5_KEY);
final Boolean boolValue = useJUnit5 == null ? null : Boolean.valueOf(useJUnit5);
return boolValue != null && boolValue.booleanValue();
if (useJUnit5 == null) {
return JUnit5EngineDetector.hasCustomEngine();
}
else {
final Boolean boolValue = Boolean.valueOf(useJUnit5);
return boolValue != null && boolValue.booleanValue();
}
}
public static boolean checkVersion(String[] args, PrintStream printStream) {
@@ -15,9 +15,15 @@ import com.intellij.openapi.vfs.VirtualFileFilter;
import com.jetbrains.edu.learning.StudySerializationUtils;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.core.EduUtils;
import com.jetbrains.edu.learning.courseFormat.*;
import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
import com.jetbrains.edu.learning.courseFormat.Course;
import com.jetbrains.edu.learning.courseFormat.CourseInfo;
import com.jetbrains.edu.learning.courseFormat.Lesson;
import com.jetbrains.edu.learning.courseFormat.tasks.Task;
import com.jetbrains.edu.learning.stepic.*;
import com.jetbrains.edu.learning.stepic.EduStepicAuthorizedClient;
import com.jetbrains.edu.learning.stepic.EduStepicNames;
import com.jetbrains.edu.learning.stepic.StepicUser;
import com.jetbrains.edu.learning.stepic.StepicWrappers;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
@@ -135,7 +141,6 @@ public class CCStepicConnector {
task.setLesson(lesson);
task.setName(EduNames.PYCHARM_ADDITIONAL);
task.setIndex(1);
task.setText(EduNames.PYCHARM_ADDITIONAL);
for (VirtualFile file : files) {
try {
if (file != null) {
@@ -8,6 +8,7 @@ import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
@@ -441,11 +442,15 @@ public class StudySerializationUtils {
public static final String TASK_LIST = "task_list";
public static final String TASK_FILES = "task_files";
public static final String FILES = "files";
public static final String TESTS = "test";
public static final String TEXTS = "text";
public static final String HINTS = "hints";
public static final String SUBTASK_INFOS = "subtask_infos";
public static final String FORMAT_VERSION = "format_version";
public static final String INDEX = "index";
public static final String TASK_TYPE = "task_type";
public static final String NAME = "name";
public static final String LAST_SUBTASK = "last_subtask_index";
private Json() {
}
@@ -518,9 +523,11 @@ public class StudySerializationUtils {
switch (version) {
case 1:
stepOptionsJson = convertToSecondVersion(stepOptionsJson);
// uncomment for future versions
//case 2:
// stepOptionsJson = convertToThirdVersion(stepOptionsJson);
case 2:
stepOptionsJson = convertToThirdVersion(stepOptionsJson);
// uncomment for future versions
//case 3:
// stepOptionsJson = convertToFourthVersion(stepOptionsJson);
}
convertSubtaskInfosToMap(stepOptionsJson);
StepicWrappers.StepOptions stepOptions =
@@ -530,6 +537,37 @@ public class StudySerializationUtils {
return stepOptions;
}
private JsonObject convertToThirdVersion(JsonObject stepOptionsJson) {
if (!stepOptionsJson.has(LAST_SUBTASK)) return stepOptionsJson;
final int lastSubtaskIndex = stepOptionsJson.get(LAST_SUBTASK).getAsInt();
if (lastSubtaskIndex == 0) return stepOptionsJson;
final JsonArray tests = stepOptionsJson.getAsJsonArray(TESTS);
if (tests.size() > 0) {
final JsonObject fileWrapper = tests.get(0).getAsJsonObject();
if (fileWrapper.has(NAME)) {
replaceWithSubtask(fileWrapper);
}
}
final JsonArray descriptions = stepOptionsJson.getAsJsonArray(TEXTS);
if (descriptions.size() > 0) {
final JsonObject fileWrapper = descriptions.get(0).getAsJsonObject();
if (fileWrapper.has(NAME)) {
replaceWithSubtask(fileWrapper);
}
}
return stepOptionsJson;
}
private void replaceWithSubtask(JsonObject fileWrapper) {
final String file = fileWrapper.get(NAME).getAsString();
final String extension = FileUtilRt.getExtension(file);
final String name = FileUtil.getNameWithoutExtension(file);
if (!name.contains(EduNames.SUBTASK_MARKER)) {
fileWrapper.remove(NAME);
fileWrapper.add(NAME, new JsonPrimitive(name + "_subtask0." + extension));
}
}
private static JsonObject convertSubtaskInfosToMap(JsonObject stepOptionsJson) {
final JsonArray files = stepOptionsJson.getAsJsonArray(FILES);
if (files != null) {
@@ -64,7 +64,10 @@ import com.jetbrains.edu.learning.core.EduAnswerPlaceholderDeleteHandler;
import com.jetbrains.edu.learning.core.EduAnswerPlaceholderPainter;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.core.EduUtils;
import com.jetbrains.edu.learning.courseFormat.*;
import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
import com.jetbrains.edu.learning.courseFormat.Course;
import com.jetbrains.edu.learning.courseFormat.Lesson;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import com.jetbrains.edu.learning.courseFormat.tasks.ChoiceTask;
import com.jetbrains.edu.learning.courseFormat.tasks.Task;
import com.jetbrains.edu.learning.courseFormat.tasks.TaskWithSubtasks;
@@ -492,7 +495,7 @@ public class StudyUtils {
return null;
}
final Course course = task.getLesson().getCourse();
String text = task.getText() != null ? task.getText() : getTaskTextByTaskName(task, taskDirectory);
String text = task.getTaskDescription() != null ? task.getTaskDescription() : getTaskTextByTaskName(task, taskDirectory);
if (text == null) return null;
text = convertToHtml(text);
@@ -5,11 +5,9 @@ import com.google.gson.annotations.SerializedName;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.xmlb.XmlSerializer;
import com.intellij.util.xmlb.annotations.Transient;
import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.courseFormat.*;
import com.jetbrains.edu.learning.stepic.EduStepicConnector;
@@ -37,7 +35,6 @@ public class Task implements StudyItem {
@SerializedName("task_files")
@Expose public Map<String, TaskFile> taskFiles = new HashMap<>();
private String text;
protected Map<String, String> testsText = new HashMap<>();
protected Map<String, String> taskTexts = new HashMap<>();
@@ -73,14 +70,6 @@ public class Task implements StudyItem {
this.name = name;
}
public String getText() {
return text;
}
public void setText(final String text) {
this.text = text;
}
@Override
public int getIndex() {
return myIndex;
@@ -166,20 +155,11 @@ public class Task implements StudyItem {
return null;
}
@NotNull
public String getTaskText(@NotNull final Project project) {
if (!StringUtil.isEmptyOrSpaces(text)) return text;
final VirtualFile taskDir = getTaskDir(project);
if (taskDir != null) {
final VirtualFile file = StudyUtils.findTaskDescriptionVirtualFile(project, taskDir);
if (file == null) return "";
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (document != null) {
return document.getImmutableCharSequence().toString();
}
public String getTaskDescription() {
if (!taskTexts.isEmpty()) {
return taskTexts.get(EduNames.TASK_HTML);
}
return "";
return null;
}
@NotNull
@@ -207,7 +187,7 @@ public class Task implements StudyItem {
if (myIndex != task.myIndex) return false;
if (name != null ? !name.equals(task.name) : task.name != null) return false;
if (taskFiles != null ? !taskFiles.equals(task.taskFiles) : task.taskFiles != null) return false;
if (text != null ? !text.equals(task.text) : task.text != null) return false;
if (taskTexts != null ? !taskTexts.equals(task.taskTexts) : task.taskTexts != null) return false;
if (testsText != null ? !testsText.equals(task.testsText) : task.testsText != null) return false;
return true;
@@ -218,7 +198,7 @@ public class Task implements StudyItem {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + myIndex;
result = 31 * result + (taskFiles != null ? taskFiles.hashCode() : 0);
result = 31 * result + (text != null ? text.hashCode() : 0);
result = 31 * result + (taskTexts != null ? taskTexts.hashCode() : 0);
result = 31 * result + (testsText != null ? testsText.hashCode() : 0);
return result;
}
@@ -273,7 +253,6 @@ public class Task implements StudyItem {
setStatus(task.getStatus());
setStepId(task.getStepId());
taskFiles = task.getTaskFiles();
setText(task.getText());
testsText = task.getTestsText();
taskTexts = task.getTaskTexts();
setLesson(task.getLesson());
@@ -28,12 +28,12 @@ import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.core.EduUtils;
import com.jetbrains.edu.learning.courseFormat.Course;
import com.jetbrains.edu.learning.courseFormat.CourseInfo;
import com.jetbrains.edu.learning.courseFormat.Lesson;
import com.jetbrains.edu.learning.courseFormat.tasks.Task;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import com.jetbrains.edu.learning.courseFormat.tasks.Task;
import com.jetbrains.edu.learning.editor.StudyEditor;
import com.jetbrains.edu.learning.statistics.EduUsagesCollector;
import com.jetbrains.edu.learning.courseFormat.CourseInfo;
import com.jetbrains.edu.learning.stepic.EduStepicConnector;
import com.jetbrains.edu.learning.stepic.StepicUpdateSettings;
import com.jetbrains.edu.learning.stepic.StepicUser;
@@ -291,24 +291,7 @@ public class StudyProjectGenerator {
}
}
createFiles(taskDirectory, task.getTestsText());
if (task.getTaskTexts().isEmpty()) {
createTaskHtml(task, taskDirectory);
return;
}
task.setText(null);
createFiles(taskDirectory, task.getTaskTexts());
}
private static void createTaskHtml(@NotNull Task task, @NotNull File taskDirectory) {
final File taskText = new File(taskDirectory, EduNames.TASK_HTML);
FileUtil.createIfDoesntExist(taskText);
try {
FileUtil.writeToFile(taskText, task.getText());
}
catch (IOException e) {
LOG.error(e);
}
}
private static void createFiles(@NotNull File taskDirectory, Map<String, String> files) {
@@ -174,7 +174,8 @@ public class EduAdaptiveStepicConnector {
private static Task getTheoryTaskFromStep(@NotNull String lessonName, @NotNull StepicWrappers.Step block, int stepId) {
final Task task = new TheoryTask(lessonName);
task.setStepId(stepId);
task.setText(block.text);
task.addTaskText(EduNames.TASK_HTML, block.text);
createMockTaskFile(task, "# this is a theory task. You can use this editor as a playground");
return task;
@@ -186,7 +187,7 @@ public class EduAdaptiveStepicConnector {
int stepId, int userId) {
final ChoiceTask task = new ChoiceTask(lessonName);
task.setStepId(stepId);
task.setText(block.text);
task.addTaskText(EduNames.TASK_HTML, block.text);
final StepicWrappers.AdaptiveAttemptWrapper.Attempt attempt = getAttemptForStep(stepId, userId);
if (attempt != null) {
@@ -338,7 +339,7 @@ public class EduAdaptiveStepicConnector {
}
final StudyToolWindow window = StudyUtils.getStudyToolWindow(project);
if (window != null) {
window.setTaskText(StudyUtils.wrapTextToDisplayLatex(unsolvedTask.getText()), unsolvedTask.getTaskDir(project), project);
window.setTaskText(StudyUtils.wrapTextToDisplayLatex(unsolvedTask.getTaskDescription()), unsolvedTask.getTaskDir(project), project);
}
StudyNavigator.navigateToTask(project, lessonName, taskName);
}
@@ -425,32 +426,28 @@ public class EduAdaptiveStepicConnector {
int lessonID) {
final Task task = new CodeTask(name);
task.setStepId(lessonID);
task.setText(step.text);
task.setStatus(StudyStatus.Unchecked);
final StringBuilder taskDescription = new StringBuilder(step.text);
if (step.options.samples != null) {
final StringBuilder builder = new StringBuilder();
taskDescription.append("<br>");
for (List<String> sample : step.options.samples) {
if (sample.size() == 2) {
builder.append("<b>Sample Input:</b><br>");
builder.append(StringUtil.replace(sample.get(0), "\n", "<br>"));
builder.append("<br>");
builder.append("<b>Sample Output:</b><br>");
builder.append(StringUtil.replace(sample.get(1), "\n", "<br>"));
builder.append("<br><br>");
taskDescription.append("<b>Sample Input:</b><br>");
taskDescription.append(StringUtil.replace(sample.get(0), "\n", "<br>"));
taskDescription.append("<br>");
taskDescription.append("<b>Sample Output:</b><br>");
taskDescription.append(StringUtil.replace(sample.get(1), "\n", "<br>"));
taskDescription.append("<br><br>");
}
}
task.setText(task.getText() + "<br>" + builder.toString());
}
if (step.options.executionMemoryLimit != null && step.options.executionTimeLimit != null) {
String builder = "<b>Memory limit</b>: " +
step.options.executionMemoryLimit + " Mb" +
"<br>" +
"<b>Time limit</b>: " +
step.options.executionTimeLimit + "s" +
"<br><br>";
task.setText(task.getText() + builder);
taskDescription.append("<br>").append("<b>Memory limit</b>: ").append(step.options.executionMemoryLimit).append(" Mb").append("<br>")
.append("<b>Time limit</b>: ").append(step.options.executionTimeLimit).append("s").append("<br><br>");
}
task.addTaskText(EduNames.TASK_HTML, taskDescription.toString());
if (step.options.test != null) {
for (StepicWrappers.FileWrapper wrapper : step.options.test) {
@@ -9,7 +9,11 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.edu.learning.courseFormat.*;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.courseFormat.Course;
import com.jetbrains.edu.learning.courseFormat.CourseInfo;
import com.jetbrains.edu.learning.courseFormat.Lesson;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import com.jetbrains.edu.learning.courseFormat.tasks.Task;
import com.jetbrains.edu.learning.courseFormat.tasks.TaskWithSubtasks;
import org.apache.http.HttpEntity;
@@ -288,7 +292,7 @@ public class EduStepicConnector {
task.addTaskText(wrapper.name, wrapper.text);
}
} else {
task.setText(block.text);
task.addTaskText(EduNames.TASK_HTML, block.text);
}
task.taskFiles = new HashMap<>(); // TODO: it looks like we don't need taskFiles as map anymore
@@ -12,7 +12,10 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.core.EduUtils;
import com.jetbrains.edu.learning.courseFormat.*;
import com.jetbrains.edu.learning.courseFormat.Course;
import com.jetbrains.edu.learning.courseFormat.CourseInfo;
import com.jetbrains.edu.learning.courseFormat.Lesson;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import com.jetbrains.edu.learning.courseFormat.tasks.Task;
import com.jetbrains.edu.learning.courseFormat.tasks.TaskWithSubtasks;
import org.apache.commons.codec.binary.Base64;
@@ -39,7 +42,6 @@ public class StepicWrappers {
public static Step fromTask(Project project, @NotNull final Task task) {
final Step step = new Step();
step.text = task.getTaskText(project);
step.source = StepOptions.fromTask(project, task);
return step;
}
@@ -55,7 +57,7 @@ public class StepicWrappers {
@Expose Integer executionTimeLimit;
@Expose CodeTemplatesWrapper codeTemplates;
@SerializedName("format_version")
@Expose public int formatVersion = 2;
@Expose public int formatVersion = 3;
@SerializedName("last_subtask_index")
@Expose int lastSubtaskIndex = 0;
@@ -31,7 +31,7 @@ public class PyStudyTestRunner extends StudyTestRunner {
Course course = myTask.getLesson().getCourse();
PyEduPluginConfigurator configurator = new PyEduPluginConfigurator();
String testsFileName = configurator.getTestFileName();
if (myTask instanceof TaskWithSubtasks && ((TaskWithSubtasks)myTask).getActiveSubtaskIndex() != 0) {
if (myTask instanceof TaskWithSubtasks) {
testsFileName = FileUtil.getNameWithoutExtension(testsFileName);
int index = ((TaskWithSubtasks)myTask).getActiveSubtaskIndex();
testsFileName += EduNames.SUBTASK_MARKER + index + "." + FileUtilRt.getExtension(configurator.getTestFileName());
@@ -103,7 +103,7 @@ USE_LIB_COPY = SUPPORT_GEVENT and \
(IS_PY3K and sys.version_info[1] >= 3))
INTERACTIVE_MODE_AVAILABLE = os.getenv('DISPLAY') is not None
INTERACTIVE_MODE_AVAILABLE = sys.platform in ('darwin', 'win32') or os.getenv('DISPLAY') is not None
def protect_libraries_from_patching():
@@ -17,7 +17,6 @@ package com.intellij.psi.formatter;
import com.intellij.lang.html.HTMLLanguage;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.vfs.VirtualFile;
@@ -37,7 +36,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
public class HtmlFormatterTest extends FormatterTestCase {
public class HtmlFormatterTest extends XmlFormatterTestBase {
@Override
protected String getBasePath() {
return "psi/formatter/html";
@@ -263,11 +262,6 @@ public class HtmlFormatterTest extends FormatterTestCase {
doTestPerformance("html reformat with range", 5000, null);
}
@Override
protected String getTestDataPath() {
return PathManager.getHomePath() + "/community/xml/tests/testData";
}
public void doTestPerformance(@NotNull String message, int expectedTime, OptionsSetup optionsSetup) throws Exception {
CodeStyleSettings settings = new CodeStyleSettings();
if (optionsSetup != null) optionsSetup.setupOptions(settings);