mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -88,3 +88,10 @@ com.android.tools.idea.wizard.DynamicWizardStepTest
|
||||
com.android.tools.idea.rendering.FlagManagerTest
|
||||
com.android.tools.idea.rendering.ResourceFolderRepositoryTest
|
||||
|
||||
[GRADLE_INTEGRATION_TESTS]
|
||||
org.jetbrains.plugins.gradle.importing.*
|
||||
org.jetbrains.plugins.gradle.compiler.*
|
||||
|
||||
[MAVEN_INTEGRATION_TESTS]
|
||||
org.jetbrains.idea.maven.importing.*
|
||||
org.jetbrains.idea.maven.compiler.*
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.intellij.debugger.settings.NodeRendererSettings;
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.impl.FrameVariablesTree;
|
||||
import com.intellij.debugger.ui.impl.watch.*;
|
||||
import com.intellij.debugger.ui.tree.render.ClassRenderer;
|
||||
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -38,6 +37,7 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ColoredTextContainer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
|
||||
@@ -209,25 +209,8 @@ public class JavaStackFrame extends XStackFrame {
|
||||
}
|
||||
}
|
||||
|
||||
final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer();
|
||||
if (classRenderer.SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES) {
|
||||
if (thisObjectReference != null && debugProcess.getVirtualMachineProxy().canGetSyntheticAttribute()) {
|
||||
final ReferenceType thisRefType = thisObjectReference.referenceType();
|
||||
if (thisRefType instanceof ClassType && location != null
|
||||
&& thisRefType.equals(location.declaringType()) && thisRefType.name().contains("$")) { // makes sense for nested classes only
|
||||
final ClassType clsType = (ClassType)thisRefType;
|
||||
for (Field field : clsType.fields()) {
|
||||
if (DebuggerUtils.isSynthetic(field) && StringUtil.startsWith(field.name(), FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX)) {
|
||||
final FieldDescriptorImpl fieldDescriptor = myNodeManager.getFieldDescriptor(myDescriptor, thisObjectReference, field);
|
||||
children.add(JavaValue.create(fieldDescriptor, evaluationContext, myNodeManager));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
buildVariables(debuggerContext, evaluationContext, children, node);
|
||||
buildVariables(debuggerContext, evaluationContext, debugProcess, children, thisObjectReference, location);
|
||||
//if (classRenderer.SORT_ASCENDING) {
|
||||
// Collections.sort(myChildren, NodeManagerImpl.getNodeComparator());
|
||||
//}
|
||||
@@ -255,7 +238,29 @@ public class JavaStackFrame extends XStackFrame {
|
||||
}
|
||||
|
||||
// copied from FrameVariablesTree
|
||||
private void buildVariables(DebuggerContextImpl debuggerContext, EvaluationContextImpl evaluationContext, XValueChildrenList children, XCompositeNode node) throws EvaluateException {
|
||||
private void buildVariables(DebuggerContextImpl debuggerContext,
|
||||
EvaluationContextImpl evaluationContext,
|
||||
@NotNull DebugProcessImpl debugProcess,
|
||||
XValueChildrenList children,
|
||||
ObjectReference thisObjectReference,
|
||||
Location location) throws EvaluateException {
|
||||
final Set<String> visibleLocals = new HashSet<String>();
|
||||
if (NodeRendererSettings.getInstance().getClassRenderer().SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES) {
|
||||
if (thisObjectReference != null && debugProcess.getVirtualMachineProxy().canGetSyntheticAttribute()) {
|
||||
final ReferenceType thisRefType = thisObjectReference.referenceType();
|
||||
if (thisRefType instanceof ClassType && location != null
|
||||
&& thisRefType.equals(location.declaringType()) && thisRefType.name().contains("$")) { // makes sense for nested classes only
|
||||
for (Field field : thisRefType.fields()) {
|
||||
if (DebuggerUtils.isSynthetic(field) && StringUtil.startsWith(field.name(), FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX)) {
|
||||
final FieldDescriptorImpl fieldDescriptor = myNodeManager.getFieldDescriptor(myDescriptor, thisObjectReference, field);
|
||||
children.add(JavaValue.create(fieldDescriptor, evaluationContext, myNodeManager));
|
||||
visibleLocals.add(fieldDescriptor.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean myAutoWatchMode = DebuggerSettings.getInstance().AUTO_VARIABLES_MODE;
|
||||
if (evaluationContext == null) {
|
||||
return;
|
||||
@@ -277,14 +282,16 @@ public class JavaStackFrame extends XStackFrame {
|
||||
ApplicationManager.getApplication().runReadAction(new Computable<Pair<Set<String>, Set<TextWithImports>>>() {
|
||||
@Override
|
||||
public Pair<Set<String>, Set<TextWithImports>> compute() {
|
||||
return FrameVariablesTree.findReferencedVars(visibleVariables.keySet(), sourcePosition, evalContext);
|
||||
return FrameVariablesTree.findReferencedVars(ContainerUtil.union(visibleVariables.keySet(), visibleLocals), sourcePosition, evalContext);
|
||||
}
|
||||
});
|
||||
// add locals
|
||||
if (myAutoWatchMode) {
|
||||
for (String var : usedVars.first) {
|
||||
final LocalVariableDescriptorImpl descriptor = myNodeManager.getLocalVariableDescriptor(null, visibleVariables.get(var));
|
||||
children.add(JavaValue.create(descriptor, evaluationContext, myNodeManager));
|
||||
LocalVariableProxyImpl local = visibleVariables.get(var);
|
||||
if (local != null) {
|
||||
children.add(JavaValue.create(myNodeManager.getLocalVariableDescriptor(null, local), evaluationContext, myNodeManager));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -625,6 +625,9 @@ public class FrameVariablesTree extends DebuggerTree {
|
||||
if (myVisibleLocals.contains(var.getName())) {
|
||||
myVars.add(var.getName());
|
||||
}
|
||||
else if (var instanceof PsiLocalVariable) {
|
||||
myExpressions.add(new TextWithImportsImpl(reference));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class SourcePositionHighlighter {
|
||||
public static final ExtensionPointName<SourcePositionHighlighter> EP_NAME = ExtensionPointName.create("com.intellij.debugger.sourcePositionHighlighter");
|
||||
|
||||
abstract TextRange getHighlightRange(SourcePosition sourcePosition);
|
||||
public abstract TextRange getHighlightRange(SourcePosition sourcePosition);
|
||||
|
||||
@Nullable
|
||||
public static TextRange getHighlightRangeFor(SourcePosition sourcePosition) {
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.core.JavaCoreBundle;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.ide.util.BrowseFilesListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
@@ -131,7 +131,7 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurable<Pro
|
||||
myPanel = new JPanel(new GridBagLayout());
|
||||
myPanel.setPreferredSize(JBUI.size(700, 500));
|
||||
|
||||
if (((ProjectEx)myProject).getStateStore().getStorageScheme().equals(StorageScheme.DIRECTORY_BASED)) {
|
||||
if (ProjectUtil.isDirectoryBased(myProject)) {
|
||||
final JPanel namePanel = new JPanel(new BorderLayout());
|
||||
final JLabel label =
|
||||
new JLabel("<html><body><b>Project name:</b></body></html>", SwingConstants.LEFT);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,12 +19,12 @@ import com.intellij.CommonBundle;
|
||||
import com.intellij.codeInspection.defaultFileTemplateUsage.FileHeaderChecker;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.ide.util.projectWizard.ProjectTemplateFileProcessor;
|
||||
import com.intellij.ide.util.projectWizard.ProjectTemplateParameterFactory;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -33,7 +33,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.roots.ContentIterator;
|
||||
import com.intellij.openapi.roots.FileIndex;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
@@ -74,8 +73,7 @@ public class SaveProjectAsTemplateAction extends AnAction {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = getEventProject(e);
|
||||
assert project != null;
|
||||
StorageScheme scheme = ((ProjectEx)project).getStateStore().getStorageScheme();
|
||||
if (scheme != StorageScheme.DIRECTORY_BASED) {
|
||||
if (!ProjectUtil.isDirectoryBased(project)) {
|
||||
Messages.showErrorDialog(project, "Project templates do not support old .ipr (file-based) format.\n" +
|
||||
"Please convert your project via File->Save as Directory-Based format.", CommonBundle.getErrorTitle());
|
||||
return;
|
||||
@@ -111,7 +109,7 @@ public class SaveProjectAsTemplateAction extends AnAction {
|
||||
}
|
||||
|
||||
public static VirtualFile getDescriptionFile(Project project, String path) {
|
||||
return VfsUtil.findRelativeFile(path, project.getBaseDir());
|
||||
return VfsUtilCore.findRelativeFile(path, project.getBaseDir());
|
||||
}
|
||||
|
||||
public static void saveProject(final Project project,
|
||||
|
||||
@@ -17,12 +17,9 @@ package com.intellij.openapi.roots;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Segment;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -42,71 +39,6 @@ public abstract class GeneratedSourcesFilter {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect original elements from all filters.
|
||||
*/
|
||||
@NotNull
|
||||
public static List<? extends PsiElement> collectAllOriginalElements(@NotNull PsiElement element) {
|
||||
List<PsiElement> result = null;
|
||||
for (GeneratedSourcesFilter filter : EP_NAME.getExtensions()) {
|
||||
result = addAll(filter.getOriginalElements(element), result);
|
||||
}
|
||||
return orEmpty(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect generated elements from all filters.
|
||||
*/
|
||||
@NotNull
|
||||
public static List<? extends PsiElement> collectAllGeneratedElements(@NotNull PsiElement element) {
|
||||
List<PsiElement> result = null;
|
||||
for (GeneratedSourcesFilter filter : EP_NAME.getExtensions()) {
|
||||
result = addAll(filter.getGeneratedElements(element), result);
|
||||
}
|
||||
return orEmpty(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect original locations from all filters.
|
||||
*/
|
||||
@NotNull
|
||||
public static List<? extends LocationInFile> collectAllOriginalLocations(@NotNull Project project,
|
||||
@NotNull VirtualFile file,
|
||||
@Nullable Segment segment) {
|
||||
List<LocationInFile> result = null;
|
||||
for (GeneratedSourcesFilter filter : EP_NAME.getExtensions()) {
|
||||
result = addAll(filter.getOriginalLocations(project, file, segment), result);
|
||||
}
|
||||
return orEmpty(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect generated locations from all filters.
|
||||
*/
|
||||
@NotNull
|
||||
public static List<? extends LocationInFile> collectAllGeneratedLocations(@NotNull Project project,
|
||||
@NotNull VirtualFile file,
|
||||
@Nullable Segment segment) {
|
||||
List<LocationInFile> result = null;
|
||||
for (GeneratedSourcesFilter filter : EP_NAME.getExtensions()) {
|
||||
result = addAll(filter.getGeneratedLocations(project, file, segment), result);
|
||||
}
|
||||
return orEmpty(result);
|
||||
}
|
||||
|
||||
private static <T> List<T> addAll(List<? extends T> elements, List<T> result) {
|
||||
if (result == null) {
|
||||
return ContainerUtil.newArrayList(elements);
|
||||
}
|
||||
result.addAll(elements);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static <T> List<T> orEmpty(List<T> elements) {
|
||||
if (elements != null) return elements;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public abstract boolean isGeneratedSource(@NotNull VirtualFile file, @NotNull Project project);
|
||||
|
||||
/**
|
||||
@@ -119,88 +51,4 @@ public abstract class GeneratedSourcesFilter {
|
||||
public List<? extends PsiElement> getOriginalElements(@NotNull PsiElement element) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all elements that have been generated from the given element.
|
||||
*
|
||||
* @param element the generated element
|
||||
* @return a list of generated elements. An empty result indicates that no elements are known to be generated from the given element.
|
||||
*/
|
||||
@NotNull
|
||||
public List<? extends PsiElement> getGeneratedElements(@NotNull PsiElement element) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all locations that have been processed by a code generator to generate the given location.
|
||||
*
|
||||
* @return a list of locations. An empty result indicates that the given segment is not considered to be generated by the filter.
|
||||
*/
|
||||
@NotNull
|
||||
public List<? extends LocationInFile> getOriginalLocations(@NotNull Project project,
|
||||
@NotNull VirtualFile file,
|
||||
@Nullable Segment segment) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all locations that have been generated from the given location.
|
||||
*
|
||||
* @return a list of locations. An empty result indicates that no locations are known to be generated from the given segments.
|
||||
*/
|
||||
@NotNull
|
||||
public List<? extends LocationInFile> getGeneratedLocations(@NotNull Project project,
|
||||
@NotNull VirtualFile file,
|
||||
@Nullable Segment segment) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static class LocationInFile {
|
||||
|
||||
@NotNull private final VirtualFile myFile;
|
||||
@Nullable private final Segment mySegment;
|
||||
|
||||
public LocationInFile(@NotNull VirtualFile file, @Nullable Segment segment) {
|
||||
myFile = file;
|
||||
mySegment = segment;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Segment getSegment() {
|
||||
return mySegment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LocationInFile{" +
|
||||
"myFile=" + myFile +
|
||||
", mySegment=" + mySegment +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
LocationInFile that = (LocationInFile)o;
|
||||
|
||||
if (!myFile.equals(that.myFile)) return false;
|
||||
if (mySegment != null ? !mySegment.equals(that.mySegment) : that.mySegment != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myFile.hashCode();
|
||||
result = 31 * result + (mySegment != null ? mySegment.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
* Class for the text comparison
|
||||
* CharSequences should to have '\n' as line separator
|
||||
* <p/>
|
||||
* It's good idea not to compare String due to expensive subSequence() implementation. Try to wrap into CharSequenceSubSequence.
|
||||
* It's good idea not to compare String due to expensive subSequence() implementation. Use CharSequenceSubSequence.
|
||||
*/
|
||||
public abstract class ComparisonManager {
|
||||
@NotNull
|
||||
@@ -35,12 +35,18 @@ public abstract class ComparisonManager {
|
||||
return ServiceManager.getService(ComparisonManager.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two texts by-line
|
||||
*/
|
||||
@NotNull
|
||||
public abstract List<LineFragment> compareLines(@NotNull CharSequence text1,
|
||||
@NotNull CharSequence text2,
|
||||
@NotNull ComparisonPolicy policy,
|
||||
@NotNull ProgressIndicator indicator) throws DiffTooBigException;
|
||||
|
||||
/**
|
||||
* Compare two texts by-line and then compare changed fragments by-word
|
||||
*/
|
||||
@NotNull
|
||||
public abstract List<LineFragment> compareLinesInner(@NotNull CharSequence text1,
|
||||
@NotNull CharSequence text2,
|
||||
@@ -54,27 +60,46 @@ public abstract class ComparisonManager {
|
||||
@NotNull ComparisonPolicy policy,
|
||||
@NotNull ProgressIndicator indicator) throws DiffTooBigException;
|
||||
|
||||
/**
|
||||
* Compare two texts by-word
|
||||
*/
|
||||
@NotNull
|
||||
public abstract List<DiffFragment> compareWords(@NotNull CharSequence text1,
|
||||
@NotNull CharSequence text2,
|
||||
@NotNull ComparisonPolicy policy,
|
||||
@NotNull ProgressIndicator indicator) throws DiffTooBigException;
|
||||
|
||||
/**
|
||||
* Compare two texts by-char
|
||||
*/
|
||||
@NotNull
|
||||
public abstract List<DiffFragment> compareChars(@NotNull CharSequence text1,
|
||||
@NotNull CharSequence text2,
|
||||
@NotNull ComparisonPolicy policy,
|
||||
@NotNull ProgressIndicator indicator) throws DiffTooBigException;
|
||||
|
||||
/**
|
||||
* Check if two texts are equal using ComparisonPolicy
|
||||
*/
|
||||
public abstract boolean isEquals(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull ComparisonPolicy policy);
|
||||
|
||||
//
|
||||
// Post process line fragments
|
||||
//
|
||||
|
||||
/**
|
||||
* compareLinesInner() comparison can produce adjustment line chunks. This method allows to squash shem.
|
||||
*
|
||||
* ex: "A\nB" vs "A X\nB Y" will result to two LineFragments: [0, 1) - [0, 1) and [1, 2) - [1, 2)
|
||||
* squash will produce a single fragment: [0, 2) - [0, 2)
|
||||
*/
|
||||
@NotNull
|
||||
public abstract List<LineFragment> squash(@NotNull List<LineFragment> oldFragments);
|
||||
|
||||
/**
|
||||
* @see #squash
|
||||
* @param trim - if leading/trailing LineFragments with equal contents should be skipped
|
||||
*/
|
||||
@NotNull
|
||||
public abstract List<LineFragment> processBlocks(@NotNull List<LineFragment> oldFragments,
|
||||
@NotNull final CharSequence text1, @NotNull final CharSequence text2,
|
||||
|
||||
@@ -28,7 +28,10 @@ public interface LineFragment extends DiffFragment {
|
||||
|
||||
int getEndLine2();
|
||||
|
||||
/*
|
||||
/**
|
||||
* High-granularity changes inside line fragment (ex: detected by ByWord)
|
||||
* Offsets of inner changes are relative to the start of LineFragment.
|
||||
*
|
||||
* null - no inner similarities was found
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.diff.FilesTooBigForDiffException;
|
||||
import com.intellij.util.text.CharSequenceSubSequence;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -153,7 +154,7 @@ public class ComparisonManagerImpl extends ComparisonManager {
|
||||
case DEFAULT:
|
||||
return StringUtil.equals(text1, text2);
|
||||
case TRIM_WHITESPACES:
|
||||
return StringUtil.equalsTrimWhitespaces(text1, text2);
|
||||
return equalsTrimWhitespaces(text1, text2);
|
||||
case IGNORE_WHITESPACES:
|
||||
return StringUtil.equalsIgnoreWhitespaces(text1, text2);
|
||||
default:
|
||||
@@ -161,6 +162,37 @@ public class ComparisonManagerImpl extends ComparisonManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
private static boolean equalsTrimWhitespaces(@NotNull CharSequence s1, @NotNull CharSequence s2) {
|
||||
int index1 = 0;
|
||||
int index2 = 0;
|
||||
|
||||
while (true) {
|
||||
boolean lastLine1 = false;
|
||||
boolean lastLine2 = false;
|
||||
|
||||
int end1 = StringUtil.indexOf(s1, '\n', index1) + 1;
|
||||
int end2 = StringUtil.indexOf(s2, '\n', index2) + 1;
|
||||
if (end1 == 0) {
|
||||
end1 = s1.length();
|
||||
lastLine1 = true;
|
||||
}
|
||||
if (end2 == 0) {
|
||||
end2 = s2.length();
|
||||
lastLine2 = true;
|
||||
}
|
||||
if (lastLine1 ^ lastLine2) return false;
|
||||
|
||||
CharSequence line1 = s1.subSequence(index1, end1);
|
||||
CharSequence line2 = s2.subSequence(index2, end2);
|
||||
if (!StringUtil.equalsTrimWhitespaces(line1, line2)) return false;
|
||||
|
||||
index1 = end1;
|
||||
index2 = end2;
|
||||
if (lastLine1) return true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Post process line fragments
|
||||
//
|
||||
|
||||
-2
@@ -22,8 +22,6 @@ import java.util.Iterator;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
abstract class ChangeDiffIterableBase extends DiffIterableBase {
|
||||
// TODO: non-abstract implementation could be faster
|
||||
|
||||
private final int myLength1;
|
||||
private final int myLength2;
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ public class DiffIterableUtil {
|
||||
|
||||
@NotNull
|
||||
public static FairDiffIterable fair(@NotNull DiffIterable iterable) {
|
||||
if (iterable instanceof FairDiffIterable) return (FairDiffIterable)iterable;
|
||||
FairDiffIterable wrapper = new FairDiffIterableWrapper(iterable);
|
||||
verifyFair(wrapper);
|
||||
return wrapper;
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package com.intellij.diff.comparison.iterables;
|
||||
|
||||
/*
|
||||
* Matched fragments are guaranteed to have same length
|
||||
/**
|
||||
* Elements are compared one-by-one.
|
||||
* If range [a, b) is equal to [a', b'), than element(a + i) is equal to element(a' + i) for all i in [0, b-a)
|
||||
*
|
||||
* Matched fragments are guaranteed to have same length.
|
||||
*/
|
||||
public interface FairDiffIterable extends DiffIterable {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.diff.comparison;
|
||||
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
|
||||
public class ComparisonUtilTest extends UsefulTestCase {
|
||||
private static final ComparisonManager manager = new ComparisonManagerImpl();
|
||||
|
||||
public void testTrimEquals() {
|
||||
assertTrue(manager.isEquals("", "", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("", " ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals(" ", " ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("\n ", " \n", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("asd ", "asd ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals(" asd", "asd", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("\n\n\n", "\n\n\n", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("\n \n \n ", " \n \n\n ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("\n\n", "\n\n\n", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
|
||||
assertFalse(manager.isEquals("\nasd ", "asd\n ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("\nasd \n", "\n asd\n ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("x", "y", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("\n", " ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
|
||||
assertTrue(manager.isEquals("\t ", "", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("", "\t\n \n\t", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("\t", "\n", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
|
||||
assertTrue(manager.isEquals("x", " x", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("x", "x ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("x\n", "x", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
|
||||
assertFalse(manager.isEquals("abc", "a\nb\nc\n", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("\nx y x\n", "\nx y x\n", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("\nxyx\n", "\nx y x\n", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("\nx y x", "\nx y x", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("\nxyx", "\nx y x", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals("x y x", "x y x", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("xyx", "x y x", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertTrue(manager.isEquals(" x y x ", "x y x", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
|
||||
assertFalse(manager.isEquals("x", "\t\n ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("", " x ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("", "x ", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("", " x", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("xyx", "xxx", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
assertFalse(manager.isEquals("xyx", "xYx", ComparisonPolicy.TRIM_WHITESPACES));
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,9 @@ action.attach.external.project.description=Attach {0} project to the current ide
|
||||
action.detach.external.project.text=Detach {0} project
|
||||
action.detach.external.project.description=Detach selected external project
|
||||
action.ignore.external.project.text=Ignore {0} project
|
||||
action.ignore.external.project.description=Ignore selected external project
|
||||
action.ignore.external.project.description=Ignore selected {0} project
|
||||
action.unignore.external.project.text=Unignore {0} project
|
||||
action.unignore.external.project.description=Unignore selected {0} project
|
||||
action.open.config.text=Open {0} config
|
||||
action.open.config.description=Allows to open project file of the linked {0} project at the editor
|
||||
|
||||
|
||||
+4
-1
@@ -47,7 +47,7 @@ public abstract class ExternalSystemToggleAction extends ToggleAction implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSelected(AnActionEvent e) {
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
if (!isEnabled(e)) return false;
|
||||
return doIsSelected(e);
|
||||
}
|
||||
@@ -77,4 +77,7 @@ public abstract class ExternalSystemToggleAction extends ToggleAction implements
|
||||
protected void setText(AnActionEvent e, String message) {
|
||||
e.getPresentation().setText(message);
|
||||
}
|
||||
protected void setDescription(AnActionEvent e, String message) {
|
||||
e.getPresentation().setDescription(message);
|
||||
}
|
||||
}
|
||||
|
||||
+17
-5
@@ -24,7 +24,6 @@ import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
|
||||
import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
@@ -48,15 +47,13 @@ public class IgnoreExternalProjectAction extends ExternalSystemToggleAction {
|
||||
private static final Logger LOG = Logger.getInstance(IgnoreExternalProjectAction.class);
|
||||
|
||||
public IgnoreExternalProjectAction() {
|
||||
setText(ExternalSystemBundle.message("action.ignore.external.project.text", "external"));
|
||||
setDescription(ExternalSystemBundle.message("action.ignore.external.project.description"));
|
||||
getTemplatePresentation().setText(ExternalSystemBundle.message("action.ignore.external.project.text", "external"));
|
||||
getTemplatePresentation().setDescription(ExternalSystemBundle.message("action.ignore.external.project.description", "external"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
final ProjectSystemId projectSystemId = getSystemId(e);
|
||||
setText(e, ExternalSystemBundle.message("action.ignore.external.project.text", projectSystemId.getReadableName()));
|
||||
|
||||
final ExternalSystemNode<ExternalConfigPathAware> projectNode = getProjectNode(e);
|
||||
if (projectNode == null || projectNode.getData() == null) return;
|
||||
|
||||
@@ -88,6 +85,21 @@ public class IgnoreExternalProjectAction extends ExternalSystemToggleAction {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
boolean selected = super.isSelected(e);
|
||||
final ProjectSystemId projectSystemId = getSystemId(e);
|
||||
if (selected) {
|
||||
setText(e, ExternalSystemBundle.message("action.unignore.external.project.text", projectSystemId.getReadableName()));
|
||||
setDescription(e, ExternalSystemBundle.message("action.unignore.external.project.description", projectSystemId.getReadableName()));
|
||||
}
|
||||
else {
|
||||
setText(e, ExternalSystemBundle.message("action.ignore.external.project.text", projectSystemId.getReadableName()));
|
||||
setDescription(e, ExternalSystemBundle.message("action.ignore.external.project.description", projectSystemId.getReadableName()));
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(AnActionEvent e) {
|
||||
if (!super.isEnabled(e)) return false;
|
||||
|
||||
+4
-3
@@ -57,16 +57,17 @@ class ExternalProjectBuilder extends BuilderSupport {
|
||||
|
||||
@Override
|
||||
protected Object createNode(Object name, Map attributes) {
|
||||
def projectPath = ExternalSystemApiUtil.normalizePath(projectDir.path)
|
||||
switch (name) {
|
||||
case 'project':
|
||||
ProjectSystemId projectSystemId = attributes.projectSystemId ?: TEST_EXTERNAL_SYSTEM_ID
|
||||
ProjectData projectData = new ProjectData(projectSystemId, attributes.name ?: 'project', projectDir.path, projectDir.path)
|
||||
ProjectData projectData = new ProjectData(projectSystemId, attributes.name ?: 'project', projectPath, projectPath)
|
||||
projectNode = new DataNode<ProjectData>(ProjectKeys.PROJECT, projectData, null)
|
||||
return projectNode
|
||||
case 'module':
|
||||
ProjectSystemId projectSystemId = attributes.projectSystemId ?: TEST_EXTERNAL_SYSTEM_ID
|
||||
String moduleFilePath = attributes.moduleFilePath ?: projectDir.path
|
||||
String externalConfigPath = attributes.externalConfigPath ?: projectDir.path
|
||||
String moduleFilePath = attributes.moduleFilePath ?: projectPath
|
||||
String externalConfigPath = attributes.externalConfigPath ?: projectPath
|
||||
ModuleData moduleData = new ModuleData(attributes.name ?: name as String,
|
||||
projectSystemId,
|
||||
ModuleTypeId.JAVA_MODULE,
|
||||
|
||||
@@ -32,7 +32,7 @@ com.intellij.hibernate
|
||||
W3Validators
|
||||
CFML Support
|
||||
org.jetbrains.plugins.github
|
||||
GuiceyIDEA
|
||||
Guice
|
||||
org.intellij.groovy
|
||||
IdeaServerPlugin
|
||||
com.intellij.spring.webflow
|
||||
|
||||
@@ -28,19 +28,24 @@ import com.intellij.pom.PomTargetPsiElement;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EditSourceUtil {
|
||||
private EditSourceUtil() { }
|
||||
|
||||
@Nullable
|
||||
public static Navigatable getDescriptor(PsiElement element) {
|
||||
public static Navigatable getDescriptor(@NotNull PsiElement element) {
|
||||
PsiElement original = getNavigatableOriginalElement(element);
|
||||
if (original != null) {
|
||||
element = original;
|
||||
} else if (!canNavigate(element)) {
|
||||
}
|
||||
else if (!canNavigate(element)) {
|
||||
return null;
|
||||
}
|
||||
if (element instanceof PomTargetPsiElement) {
|
||||
@@ -60,8 +65,8 @@ public class EditSourceUtil {
|
||||
return desc;
|
||||
}
|
||||
|
||||
private static PsiElement getNavigatableOriginalElement(PsiElement element) {
|
||||
final List<? extends PsiElement> originalElements = GeneratedSourcesFilter.collectAllOriginalElements(element);
|
||||
private static PsiElement getNavigatableOriginalElement(@NotNull PsiElement element) {
|
||||
final List<? extends PsiElement> originalElements = collectAllOriginalElements(element);
|
||||
for (PsiElement original: originalElements) {
|
||||
if (canNavigate(original)) {
|
||||
return original;
|
||||
@@ -79,7 +84,7 @@ public class EditSourceUtil {
|
||||
return file != null && file.isValid() && !file.is(VFileProperty.SPECIAL) && !VfsUtilCore.isBrokenLink(file);
|
||||
}
|
||||
|
||||
public static void navigate(NavigationItem item, boolean requestFocus, boolean useCurrentWindow) {
|
||||
public static void navigate(@NotNull NavigationItem item, boolean requestFocus, boolean useCurrentWindow) {
|
||||
if (item instanceof UserDataHolder) {
|
||||
((UserDataHolder)item).putUserData(FileEditorManager.USE_CURRENT_WINDOW, useCurrentWindow);
|
||||
}
|
||||
@@ -88,4 +93,25 @@ public class EditSourceUtil {
|
||||
((UserDataHolder)item).putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect original elements from all filters.
|
||||
*/
|
||||
@NotNull
|
||||
private static List<? extends PsiElement> collectAllOriginalElements(@NotNull PsiElement element) {
|
||||
List<PsiElement> result = null;
|
||||
for (GeneratedSourcesFilter filter : GeneratedSourcesFilter.EP_NAME.getExtensions()) {
|
||||
result = addAll(filter.getOriginalElements(element), result);
|
||||
}
|
||||
return ObjectUtils.notNull(result, Collections.<PsiElement>emptyList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static <T> List<T> addAll(@NotNull List<? extends T> elements, List<T> result) {
|
||||
if (result == null) {
|
||||
return ContainerUtil.newArrayList(elements);
|
||||
}
|
||||
result.addAll(elements);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,10 +21,8 @@ import com.intellij.conversion.impl.ui.ConvertProjectDialog;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.impl.ProjectImpl;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -307,8 +305,7 @@ public class ConversionServiceImpl extends ConversionService {
|
||||
@Override
|
||||
@NotNull
|
||||
public ConversionResult convertModule(@NotNull final Project project, @NotNull final File moduleFile) {
|
||||
final IProjectStore stateStore = ((ProjectImpl)project).getStateStore();
|
||||
final String url = stateStore.getPresentableUrl();
|
||||
final String url = project.getPresentableUrl();
|
||||
assert url != null : project;
|
||||
final String projectPath = FileUtil.toSystemDependentName(url);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,12 +17,11 @@
|
||||
package com.intellij.ide.impl.convert;
|
||||
|
||||
import com.intellij.conversion.impl.ConversionServiceImpl;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
@@ -71,22 +70,17 @@ public class ProjectFileVersionImpl extends ProjectFileVersion implements Projec
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
if (myProject.isDefault() || ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
final IProjectStore stateStore = ((ProjectEx)myProject).getStateStore();
|
||||
final String filePath;
|
||||
if (stateStore.getStorageScheme() == StorageScheme.DEFAULT) {
|
||||
filePath = stateStore.getProjectFilePath();
|
||||
if (myProject.isDefault() || ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
final VirtualFile baseDir = stateStore.getProjectBaseDir();
|
||||
filePath = baseDir != null ? baseDir.getPath() : null;
|
||||
}
|
||||
if (filePath != null) {
|
||||
ConversionServiceImpl.saveConversionResult(FileUtil.toSystemDependentName(filePath));
|
||||
}
|
||||
else {
|
||||
|
||||
VirtualFile file = ProjectUtil.isDirectoryBased(myProject) ? myProject.getBaseDir() : myProject.getProjectFile();
|
||||
if (file == null) {
|
||||
LOG.info("Cannot save conversion result: filePath == null");
|
||||
}
|
||||
else {
|
||||
ConversionServiceImpl.saveConversionResult(FileUtil.toSystemDependentName(file.getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-4
@@ -38,6 +38,7 @@ import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.ex.VirtualFileManagerAdapter;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerListener;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FileBasedIndexImpl;
|
||||
@@ -227,10 +228,7 @@ public class ProjectRootManagerComponent extends ProjectRootManagerImpl {
|
||||
else {
|
||||
flat.add(projectFilePath);
|
||||
// may be not existing yet
|
||||
final String workspaceFile = ((ProjectImpl)myProject).getStateStore().getWorkspaceFilePath();
|
||||
if (workspaceFile != null) {
|
||||
flat.add(workspaceFile);
|
||||
}
|
||||
ContainerUtil.addIfNotNull(flat, ((ProjectImpl)myProject).getStateStore().getWorkspaceFilePath());
|
||||
}
|
||||
|
||||
for (WatchedRootsProvider extension : Extensions.getExtensions(WatchedRootsProvider.EP_NAME, myProject)) {
|
||||
|
||||
+26
-33
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,7 +18,6 @@ package com.intellij.ide.actions;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.components.impl.stores.StateStorageManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
@@ -39,34 +38,34 @@ import java.util.ArrayList;
|
||||
public class SaveAsDirectoryBasedFormatAction extends AnAction implements DumbAware {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
if (project instanceof ProjectEx) {
|
||||
if (project == null || ProjectUtil.isDirectoryBased(project) || Messages.showOkCancelDialog(project,
|
||||
"Project will be saved and reopened in new Directory-Based format.\nAre you sure you want to continue?",
|
||||
"Save project to Directory-Based format",
|
||||
Messages.getWarningIcon()) != Messages.OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualFile baseDir = project.getBaseDir();
|
||||
assert baseDir != null;
|
||||
|
||||
File ideaDir = new File(baseDir.getPath(), Project.DIRECTORY_STORE_FOLDER + File.separatorChar);
|
||||
if ((ideaDir.exists() && ideaDir.isDirectory()) || createDir(ideaDir)) {
|
||||
IProjectStore projectStore = ((ProjectEx)project).getStateStore();
|
||||
if (StorageScheme.DIRECTORY_BASED != projectStore.getStorageScheme()) {
|
||||
if (Messages.showOkCancelDialog(project,
|
||||
"Project will be saved and reopened in new Directory-Based format.\nAre you sure you want to continue?",
|
||||
"Save project to Directory-Based format", Messages.getWarningIcon()) == Messages.OK) {
|
||||
VirtualFile baseDir = project.getBaseDir();
|
||||
assert baseDir != null;
|
||||
|
||||
File ideaDir = new File(baseDir.getPath(), Project.DIRECTORY_STORE_FOLDER + File.separatorChar);
|
||||
if ((ideaDir.exists() && ideaDir.isDirectory()) || createDir(ideaDir)) {
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ideaDir);
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ideaDir);
|
||||
|
||||
final StateStorageManager storageManager = projectStore.getStateStorageManager();
|
||||
for (String file : new ArrayList<String>(storageManager.getStorageFileNames())) {
|
||||
storageManager.clearStateStorage(file);
|
||||
}
|
||||
|
||||
projectStore.setProjectFilePath(baseDir.getPath());
|
||||
project.save();
|
||||
ProjectUtil.closeAndDispose(project);
|
||||
ProjectUtil.openProject(baseDir.getPath(), null, false);
|
||||
}
|
||||
else {
|
||||
Messages.showErrorDialog(project, String.format("Unable to create '.idea' directory (%s)", ideaDir), "Error saving project!");
|
||||
}
|
||||
}
|
||||
final StateStorageManager storageManager = projectStore.getStateStorageManager();
|
||||
for (String file : new ArrayList<String>(storageManager.getStorageFileNames())) {
|
||||
storageManager.clearStateStorage(file);
|
||||
}
|
||||
|
||||
projectStore.setProjectFilePath(baseDir.getPath());
|
||||
project.save();
|
||||
ProjectUtil.closeAndDispose(project);
|
||||
ProjectUtil.openProject(baseDir.getPath(), null, false);
|
||||
}
|
||||
else {
|
||||
Messages.showErrorDialog(project, String.format("Unable to create '.idea' directory (%s)", ideaDir), "Error saving project!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,12 +82,6 @@ public class SaveAsDirectoryBasedFormatAction extends AnAction implements DumbAw
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
boolean visible = project != null;
|
||||
|
||||
if (project instanceof ProjectEx) {
|
||||
visible = ((ProjectEx)project).getStateStore().getStorageScheme() != StorageScheme.DIRECTORY_BASED;
|
||||
}
|
||||
|
||||
e.getPresentation().setVisible(visible);
|
||||
e.getPresentation().setVisible(project != null && !ProjectUtil.isDirectoryBased(project));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -285,4 +285,8 @@ public class ProjectUtil {
|
||||
return userHome.replace('/', File.separatorChar) + File.separator + ApplicationNamesInfo.getInstance().getLowercaseProductName() +
|
||||
"Projects";
|
||||
}
|
||||
|
||||
public static boolean isDirectoryBased(@NotNull Project project) {
|
||||
return project instanceof ProjectEx && StorageScheme.DIRECTORY_BASED.equals(((ProjectEx)project).getStateStore().getStorageScheme());
|
||||
}
|
||||
}
|
||||
|
||||
+4
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -16,8 +16,8 @@
|
||||
package com.intellij.openapi.fileEditor.impl;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -154,14 +154,13 @@ public class NonProjectFileWritingAccessProvider extends WritingAccessProvider {
|
||||
if (!Registry.is("ide.hide.excluded.files") && fileIndex.isExcluded(file) && !fileIndex.isUnderIgnored(file)) return true;
|
||||
|
||||
if (project instanceof ProjectEx) {
|
||||
IProjectStore store = ((ProjectEx)project).getStateStore();
|
||||
|
||||
if (store.getStorageScheme() == StorageScheme.DIRECTORY_BASED) {
|
||||
if (ProjectUtil.isDirectoryBased(project)) {
|
||||
VirtualFile baseDir = project.getBaseDir();
|
||||
VirtualFile dotIdea = baseDir == null ? null : baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
|
||||
if (dotIdea != null && VfsUtilCore.isAncestor(dotIdea, file, false)) return true;
|
||||
}
|
||||
|
||||
IProjectStore store = ((ProjectEx)project).getStateStore();
|
||||
if (file.equals(store.getWorkspaceFile()) || file.equals(store.getProjectFile())) return true;
|
||||
for (Module each : ModuleManager.getInstance(project).getModules()) {
|
||||
if (file.equals(each.getModuleFile())) return true;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class KeyStrokeAdapter implements KeyListener {
|
||||
if (event != null && !event.isConsumed()) {
|
||||
int id = event.getID();
|
||||
if (id == KeyEvent.KEY_TYPED) {
|
||||
return extended ? null : getKeyStroke(event.getKeyChar(), event.getModifiers());
|
||||
return extended ? null : getKeyStroke(event.getKeyChar(), 0);
|
||||
}
|
||||
boolean released = id == KeyEvent.KEY_RELEASED;
|
||||
if (released || id == KeyEvent.KEY_PRESSED) {
|
||||
@@ -133,7 +133,7 @@ public class KeyStrokeAdapter implements KeyListener {
|
||||
* @return a key stroke or {@code null} if {@code ch} is undefined
|
||||
*/
|
||||
private static KeyStroke getKeyStroke(char ch, int modifiers) {
|
||||
return KeyEvent.CHAR_UNDEFINED == ch ? null : KeyStroke.getKeyStroke(ch/*TODO:MAC, modifiers*/);
|
||||
return KeyEvent.CHAR_UNDEFINED == ch ? null : KeyStroke.getKeyStroke(Character.valueOf(ch), modifiers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,6 +292,7 @@ public class KeyStrokeAdapter implements KeyListener {
|
||||
append(sb, "released", stroke.isOnKeyRelease());
|
||||
String name = LazyVirtualKeys.myCodeToName.get(code);
|
||||
if (name == null) {
|
||||
sb.append('#');
|
||||
name = Integer.toHexString(code);
|
||||
}
|
||||
return sb.append(name).toString();
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.components.impl;
|
||||
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -37,11 +36,10 @@ public class ProjectStoreImplIdeaDirTest extends ProjectStoreBaseTestCase {
|
||||
}
|
||||
|
||||
public void testLoadFromDirectoryStorage() throws Exception {
|
||||
final IProjectStore projectStore = ((ProjectEx)myProject).getStateStore();
|
||||
((ProjectEx)myProject).setOptimiseTestLoadSpeed(false);
|
||||
|
||||
final TestIprComponent testIprComponent = new TestIprComponent();
|
||||
projectStore.initComponent(testIprComponent, false);
|
||||
((ProjectEx)myProject).getStateStore().initComponent(testIprComponent, false);
|
||||
assertNotNull(testIprComponent.myState);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.components.impl;
|
||||
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
|
||||
@@ -31,12 +30,11 @@ public class ProjectStoreImplIprFileTest extends ProjectStoreBaseTestCase {
|
||||
}
|
||||
|
||||
public void testLoadFromOldStorage() throws Exception {
|
||||
final IProjectStore projectStore = ((ProjectEx)myProject).getStateStore();
|
||||
|
||||
((ProjectEx)myProject).setOptimiseTestLoadSpeed(false);
|
||||
|
||||
final TestIprComponent testIprComponent = new TestIprComponent();
|
||||
projectStore.initComponent(testIprComponent, false);
|
||||
((ProjectEx)myProject).getStateStore().initComponent(testIprComponent, false);
|
||||
assertNotNull(testIprComponent.myState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.ModuleAdapter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.project.impl.ProjectManagerImpl;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
@@ -786,7 +785,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
|
||||
if (!ourProject.isDisposed()) {
|
||||
VirtualFile projectFile = ((ProjectEx)ourProject).getStateStore().getProjectFile();
|
||||
VirtualFile projectFile = ourProject.getProjectFile();
|
||||
File ioFile = projectFile == null ? null : VfsUtilCore.virtualToIoFile(projectFile);
|
||||
Disposer.dispose(ourProject);
|
||||
if (ioFile != null) {
|
||||
|
||||
+25
-24
@@ -143,7 +143,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
|
||||
private final TempDirTestFixture myTempDirFixture;
|
||||
protected final IdeaProjectTestFixture myProjectFixture;
|
||||
private VirtualFileFilter myFileTreeAccessFilter = new FileTreeAccessFilter();
|
||||
private VirtualFileFilter myVirtualFileFilter = new FileTreeAccessFilter();
|
||||
private boolean myAllowDirt;
|
||||
private boolean myCaresAboutInjection = true;
|
||||
|
||||
@@ -462,6 +462,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
@NotNull final InspectionToolWrapper... toolWrappers) {
|
||||
final InspectionProfileImpl profile = InspectionProfileImpl.createSimple("test", project, toolWrappers);
|
||||
GlobalInspectionContextForTests context = new GlobalInspectionContextForTests(project, inspectionManager.getContentManager()) {
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<Tools> getUsedTools() {
|
||||
return InspectionProfileImpl.initAndDo(new Computable<List<Tools>>() {
|
||||
@@ -1510,9 +1511,10 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
}
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
final VirtualFileFilter fileTreeAccessFilter = myFileTreeAccessFilter;
|
||||
final VirtualFileFilter fileTreeAccessFilter = myVirtualFileFilter;
|
||||
Disposable disposable = Disposer.newDisposable();
|
||||
if (fileTreeAccessFilter != null) {
|
||||
((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(fileTreeAccessFilter, myTestRootDisposable);
|
||||
((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(fileTreeAccessFilter, disposable);
|
||||
}
|
||||
|
||||
// ProfilingUtil.startCPUProfiling();
|
||||
@@ -1522,9 +1524,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
removeDuplicatedRangesForInjected(infos);
|
||||
}
|
||||
finally {
|
||||
if (fileTreeAccessFilter != null) {
|
||||
((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myTestRootDisposable);
|
||||
}
|
||||
Disposer.dispose(disposable);
|
||||
}
|
||||
// ProfilingUtil.captureCPUSnapshot("testing");
|
||||
final long elapsed = System.currentTimeMillis() - start;
|
||||
@@ -1534,14 +1534,14 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
public void setFileTreeAccessFilterForHighlighting(@Nullable VirtualFileFilter fileTreeAccessFilter) {
|
||||
myFileTreeAccessFilter = fileTreeAccessFilter;
|
||||
public void setVirtualFileFilter(@Nullable VirtualFileFilter filter) {
|
||||
myVirtualFileFilter = filter;
|
||||
}
|
||||
|
||||
private static void removeDuplicatedRangesForInjected(@NotNull List<HighlightInfo> infos) {
|
||||
Collections.sort(infos, new Comparator<HighlightInfo>() {
|
||||
@Override
|
||||
public int compare(HighlightInfo o1, HighlightInfo o2) {
|
||||
public int compare(@NotNull HighlightInfo o1, @NotNull HighlightInfo o2) {
|
||||
final int i = o2.startOffset - o1.startOffset;
|
||||
return i != 0 ? i : o1.getSeverity().myVal - o2.getSeverity().myVal;
|
||||
}
|
||||
@@ -1691,7 +1691,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
final IntentionAction action = actionInGroup.getAction();
|
||||
|
||||
if (ShowIntentionActionsHandler.availableFor(file, editor, action)
|
||||
|| (injectedElement != null && hostElement != injectedElement && ShowIntentionActionsHandler.availableFor(injectedFile, injectedEditor, action))) {
|
||||
||
|
||||
injectedElement != null && hostElement != injectedElement && ShowIntentionActionsHandler.availableFor(injectedFile, injectedEditor, action)) {
|
||||
descriptors.add(actionInGroup);
|
||||
}
|
||||
}
|
||||
@@ -1728,23 +1729,23 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
|
||||
@Override
|
||||
public void allowTreeAccessForFile(@NotNull final VirtualFile file) {
|
||||
assert myFileTreeAccessFilter instanceof FileTreeAccessFilter : "configured filter does not support this method";
|
||||
((FileTreeAccessFilter)myFileTreeAccessFilter).allowTreeAccessForFile(file);
|
||||
assert myVirtualFileFilter instanceof FileTreeAccessFilter : "configured filter does not support this method";
|
||||
((FileTreeAccessFilter)myVirtualFileFilter).allowTreeAccessForFile(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowTreeAccessForAllFiles() {
|
||||
assert myFileTreeAccessFilter instanceof FileTreeAccessFilter : "configured filter does not support this method";
|
||||
((FileTreeAccessFilter)myFileTreeAccessFilter).allowTreeAccessForAllFiles();
|
||||
assert myVirtualFileFilter instanceof FileTreeAccessFilter : "configured filter does not support this method";
|
||||
((FileTreeAccessFilter)myVirtualFileFilter).allowTreeAccessForAllFiles();
|
||||
}
|
||||
|
||||
private static class SelectionAndCaretMarkupLoader {
|
||||
final String filePath;
|
||||
final String newFileText;
|
||||
final EditorTestUtil.CaretAndSelectionState caretState;
|
||||
private final String filePath;
|
||||
private final String newFileText;
|
||||
private final EditorTestUtil.CaretAndSelectionState caretState;
|
||||
|
||||
@NotNull
|
||||
static SelectionAndCaretMarkupLoader fromFile(@NotNull String path, String charset) throws IOException {
|
||||
private static SelectionAndCaretMarkupLoader fromFile(@NotNull String path, String charset) throws IOException {
|
||||
return new SelectionAndCaretMarkupLoader(StringUtil.convertLineSeparators(FileUtil.loadFile(new File(path), charset)), path);
|
||||
}
|
||||
|
||||
@@ -1848,12 +1849,12 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
private static final String END_FOLD = "</fold>";
|
||||
|
||||
private static class Border implements Comparable<Border> {
|
||||
public static final boolean LEFT = true;
|
||||
public static final boolean RIGHT = false;
|
||||
public boolean mySide;
|
||||
public int myOffset;
|
||||
public String myText;
|
||||
public boolean myIsExpanded;
|
||||
private static final boolean LEFT = true;
|
||||
private static final boolean RIGHT = false;
|
||||
private final boolean mySide;
|
||||
private final int myOffset;
|
||||
private final String myText;
|
||||
private final boolean myIsExpanded;
|
||||
|
||||
private Border(boolean side, int offset, String text, boolean isExpanded) {
|
||||
mySide = side;
|
||||
|
||||
+7
-10
@@ -22,12 +22,12 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.changes.shelf;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.lifecycle.PeriodicalTasksCloser;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.impl.patch.*;
|
||||
import com.intellij.openapi.diff.impl.patch.apply.ApplyFilePatchBase;
|
||||
@@ -37,7 +37,6 @@ import com.intellij.openapi.progress.AsynchronousExecution;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
@@ -94,15 +93,13 @@ public class ShelveChangesManager extends AbstractProjectComponent implements JD
|
||||
if (project.isDefault()) {
|
||||
myFileProcessor = new CompoundShelfFileProcessor(null, PathManager.getConfigPath() + File.separator + SHELF_DIR_NAME);
|
||||
}
|
||||
else if (ProjectUtil.isDirectoryBased(project)) {
|
||||
VirtualFile dir = project.getBaseDir();
|
||||
String shelfBaseDirPath = dir == null ? "" : dir.getPath() + File.separator + Project.DIRECTORY_STORE_FOLDER;
|
||||
myFileProcessor = new CompoundShelfFileProcessor(shelfBaseDirPath);
|
||||
}
|
||||
else {
|
||||
if (project instanceof ProjectEx && ((ProjectEx)project).getStateStore().getStorageScheme() == StorageScheme.DIRECTORY_BASED) {
|
||||
VirtualFile dir = project.getBaseDir();
|
||||
String shelfBaseDirPath = dir == null ? "" : dir.getPath() + File.separator + Project.DIRECTORY_STORE_FOLDER;
|
||||
myFileProcessor = new CompoundShelfFileProcessor(shelfBaseDirPath);
|
||||
}
|
||||
else {
|
||||
myFileProcessor = new CompoundShelfFileProcessor();
|
||||
}
|
||||
myFileProcessor = new CompoundShelfFileProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,10 +15,9 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.checkin;
|
||||
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.projectRoots.OutOfSourcesChecker;
|
||||
import com.intellij.openapi.roots.GeneratedSourcesFilter;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
@@ -56,8 +55,7 @@ public class CheckinHandlerUtil {
|
||||
PsiManager psiManager = PsiManager.getInstance(project);
|
||||
|
||||
VirtualFile projectFileDir = null;
|
||||
final StorageScheme storageScheme = ((ProjectEx) project).getStateStore().getStorageScheme();
|
||||
if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) {
|
||||
if (ProjectUtil.isDirectoryBased(project)) {
|
||||
VirtualFile baseDir = project.getBaseDir();
|
||||
if (baseDir != null) {
|
||||
projectFileDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,10 +15,9 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.impl;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.lifecycle.PeriodicalTasksCloser;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.vcs.changes.DirtBuilder;
|
||||
import com.intellij.openapi.vcs.changes.VcsGuess;
|
||||
import com.intellij.openapi.vcs.impl.projectlevelman.NewMappings;
|
||||
@@ -49,8 +48,7 @@ public abstract class DefaultVcsRootPolicy {
|
||||
public abstract void markDefaultRootsDirty(final DirtBuilder builder, VcsGuess vcsGuess);
|
||||
|
||||
public String getProjectConfigurationMessage(final Project project) {
|
||||
final StorageScheme storageScheme = ((ProjectEx) project).getStateStore().getStorageScheme();
|
||||
boolean isDirectoryBased = StorageScheme.DIRECTORY_BASED.equals(storageScheme);
|
||||
boolean isDirectoryBased = ProjectUtil.isDirectoryBased(project);
|
||||
final String[] parts = new String[] {"Content roots of all modules", "all immediate descendants of project base directory",
|
||||
Project.DIRECTORY_STORE_FOLDER + " directory contents"};
|
||||
final StringBuilder sb = new StringBuilder(parts[0]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -16,14 +16,13 @@
|
||||
|
||||
package com.intellij.openapi.vcs.impl;
|
||||
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.lifecycle.PeriodicalTasksCloser;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.roots.FileIndexFacade;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
@@ -66,8 +65,7 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy {
|
||||
result.add(myBaseDir);
|
||||
}
|
||||
}
|
||||
final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme();
|
||||
if (StorageScheme.DIRECTORY_BASED.equals(storageScheme) && (myBaseDir != null)) {
|
||||
if (ProjectUtil.isDirectoryBased(myProject) && myBaseDir != null) {
|
||||
final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
|
||||
if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
|
||||
final AbstractVcs vcsFor = vcsManager.getVcsFor(ideaDir);
|
||||
@@ -122,8 +120,7 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy {
|
||||
if (contentRoot != null) {
|
||||
return contentRoot;
|
||||
}
|
||||
final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme();
|
||||
if (StorageScheme.DIRECTORY_BASED.equals(storageScheme) && (myBaseDir != null)) {
|
||||
if (ProjectUtil.isDirectoryBased(myProject) && (myBaseDir != null)) {
|
||||
final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
|
||||
if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
|
||||
if (VfsUtilCore.isAncestor(ideaDir, file, false)) {
|
||||
@@ -140,8 +137,7 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy {
|
||||
@Override
|
||||
public void run() {
|
||||
final Module[] modules = myModuleManager.getModules();
|
||||
final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme();
|
||||
if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) {
|
||||
if (ProjectUtil.isDirectoryBased(myProject)) {
|
||||
FilePath fp = VcsUtil.getFilePath(myBaseDir, Project.DIRECTORY_STORE_FOLDER, true);
|
||||
final AbstractVcs vcs = vcsGuess.getVcsForDirty(fp);
|
||||
if (vcs != null) {
|
||||
|
||||
+8
-10
@@ -16,10 +16,10 @@
|
||||
package com.intellij.openapi.vcs.impl;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
@@ -30,7 +30,6 @@ import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.roots.FileIndexFacade;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.*;
|
||||
@@ -883,14 +882,13 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInDirectoryBasedRoot(final VirtualFile file) {
|
||||
if (file == null) return false;
|
||||
final StorageScheme storageScheme = ((ProjectEx)myProject).getStateStore().getStorageScheme();
|
||||
if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) {
|
||||
final VirtualFile baseDir = myProject.getBaseDir();
|
||||
if (baseDir == null) return false;
|
||||
final VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
|
||||
return ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory() && VfsUtilCore.isAncestor(ideaDir, file, false);
|
||||
private boolean isInDirectoryBasedRoot(@Nullable VirtualFile file) {
|
||||
if (file != null && ProjectUtil.isDirectoryBased(myProject)) {
|
||||
VirtualFile baseDir = myProject.getBaseDir();
|
||||
if (baseDir != null) {
|
||||
VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
|
||||
return ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory() && VfsUtilCore.isAncestor(ideaDir, file, false);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@ package org.jetbrains.idea.devkit.run;
|
||||
import com.intellij.execution.JUnitPatcher;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.execution.configurations.ParametersList;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -43,11 +46,20 @@ import java.io.IOException;
|
||||
public class JUnitDevKitPatcher extends JUnitPatcher{
|
||||
public static final String JAVA_SYSTEM_CLASS_LOADER_PROPERTY = "java.system.class.loader";
|
||||
|
||||
public void patchJavaParameters(@Nullable Module module, JavaParameters javaParameters) {
|
||||
if (module != null && PsiUtil.isIdeaProject(module.getProject()) &&
|
||||
!javaParameters.getVMParametersList().hasParameter(JAVA_SYSTEM_CLASS_LOADER_PROPERTY) &&
|
||||
JavaPsiFacade.getInstance(module.getProject()).findClass(UrlClassLoader.class.getName(), GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)) != null) {
|
||||
javaParameters.getVMParametersList().add("-D" + JAVA_SYSTEM_CLASS_LOADER_PROPERTY + "=" + UrlClassLoader.class.getName());
|
||||
public void patchJavaParameters(@Nullable final Module module, JavaParameters javaParameters) {
|
||||
if (module != null && PsiUtil.isIdeaProject(module.getProject()) &&
|
||||
!javaParameters.getVMParametersList().hasParameter(JAVA_SYSTEM_CLASS_LOADER_PROPERTY)) {
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(module.getProject());
|
||||
final String qualifiedName = UrlClassLoader.class.getName();
|
||||
final PsiClass urlLoaderClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
|
||||
@Override
|
||||
public PsiClass compute() {
|
||||
return psiFacade.findClass(qualifiedName, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module));
|
||||
}
|
||||
});
|
||||
if (urlLoaderClass != null) {
|
||||
javaParameters.getVMParametersList().add("-D" + JAVA_SYSTEM_CLASS_LOADER_PROPERTY + "=" + UrlClassLoader.class.getName());
|
||||
}
|
||||
}
|
||||
Sdk jdk = javaParameters.getJdk();
|
||||
jdk = IdeaJdk.findIdeaJdk(jdk);
|
||||
|
||||
@@ -104,6 +104,16 @@ class TestDirectory extends TestPackage {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GlobalSearchScope filterScope(JUnitConfiguration.Data data) throws CantRunException {
|
||||
return GlobalSearchScope.allScope(getConfiguration().getProject());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPackageName(JUnitConfiguration.Data data) throws CantRunException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiPackage getPackage(JUnitConfiguration.Data data) throws CantRunException {
|
||||
final String dirName = data.getDirName();
|
||||
@@ -115,11 +125,7 @@ class TestDirectory extends TestPackage {
|
||||
if (directory == null) {
|
||||
throw new CantRunException("Directory \'" + dirName + "\' is not found");
|
||||
}
|
||||
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory);
|
||||
if (aPackage == null) {
|
||||
throw new CantRunException("Package not found in directory");
|
||||
}
|
||||
return aPackage;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+86
@@ -188,6 +188,41 @@ public class JUnitTreeByDescriptionHierarchyTest {
|
||||
"##teamcity[testSuiteFinished name='|[0|]']\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParameterizedClassWithParamsWithDots() throws Exception {
|
||||
final String className = "a.TestA";
|
||||
final Description aTestClassDescription = Description.createSuiteDescription(className);
|
||||
final ArrayList<Description> tests = new ArrayList<Description>();
|
||||
for (String paramName : new String[]{"[0: with - 1.1]", "[1: with - 2.1]"}) {
|
||||
final Description param1 = Description.createSuiteDescription(paramName);
|
||||
aTestClassDescription.addChild(param1);
|
||||
final Description testDescription = Description.createTestDescription(className, "testName" + paramName);
|
||||
tests.add(testDescription);
|
||||
param1.addChild(testDescription);
|
||||
}
|
||||
doTest(aTestClassDescription, tests,
|
||||
//tree
|
||||
"##teamcity[suiteTreeStarted name='|[0: with - 1.1|]' locationHint='java:suite://a.TestA.|[0: with - 1.1|]']\n" +
|
||||
"##teamcity[suiteTreeNode name='testName|[0: with - 1.1|]' locationHint='java:test://a.TestA.testName|[0: with - 1.1|]']\n" +
|
||||
"##teamcity[suiteTreeEnded name='|[0: with - 1.1|]']\n" +
|
||||
"##teamcity[suiteTreeStarted name='|[1: with - 2.1|]' locationHint='java:suite://a.TestA.|[1: with - 2.1|]']\n" +
|
||||
"##teamcity[suiteTreeNode name='testName|[1: with - 2.1|]' locationHint='java:test://a.TestA.testName|[1: with - 2.1|]']\n" +
|
||||
"##teamcity[suiteTreeEnded name='|[1: with - 2.1|]']\n",
|
||||
//start
|
||||
"##teamcity[enteredTheMatrix]\n" +
|
||||
"##teamcity[rootName name = 'TestA' comment = 'a' location = 'java:suite://a.TestA']\n" +
|
||||
"##teamcity[testSuiteStarted name='|[0: with - 1.1|]']\n" +
|
||||
"##teamcity[testStarted name='testName|[0: with - 1.1|]' locationHint='java:test://a.TestA.testName|[0: with - 1.1|]']\n" +
|
||||
"\n" +
|
||||
"##teamcity[testFinished name='testName|[0: with - 1.1|]']\n" +
|
||||
"##teamcity[testSuiteFinished name='|[0: with - 1.1|]']\n" +
|
||||
"##teamcity[testSuiteStarted name='|[1: with - 2.1|]']\n" +
|
||||
"##teamcity[testStarted name='testName|[1: with - 2.1|]' locationHint='java:test://a.TestA.testName|[1: with - 2.1|]']\n" +
|
||||
"\n" +
|
||||
"##teamcity[testFinished name='testName|[1: with - 2.1|]']\n" +
|
||||
"##teamcity[testSuiteFinished name='|[1: with - 2.1|]']\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2SuitesWithTheSameTest() throws Exception {
|
||||
final Description root = Description.createSuiteDescription("root");
|
||||
@@ -288,6 +323,57 @@ public class JUnitTreeByDescriptionHierarchyTest {
|
||||
"##teamcity[testFinished name='TestA.testName']\n" +
|
||||
"##teamcity[testSuiteFinished name='TestA']\n", StringUtil.convertLineSeparators(buf.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetupClassFailureForParameterizedClass() throws Exception {
|
||||
final Description root = Description.createSuiteDescription("root");
|
||||
final Description testA = Description.createSuiteDescription("TestA");
|
||||
root.addChild(testA);
|
||||
final Description paramDescription = Description.createSuiteDescription("param");
|
||||
testA.addChild(paramDescription);
|
||||
final Description testName = Description.createTestDescription("TestA", "testName");
|
||||
paramDescription.addChild(testName);
|
||||
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
final JUnit4TestListener sender = createListener(buf);
|
||||
sender.sendTree(root);
|
||||
|
||||
Assert.assertEquals("output: " + buf, "##teamcity[suiteTreeStarted name='TestA' locationHint='java:suite://TestA']\n" +
|
||||
"##teamcity[suiteTreeStarted name='param' locationHint='java:suite://param']\n" +
|
||||
"##teamcity[suiteTreeNode name='TestA.testName' locationHint='java:test://TestA.testName']\n" +
|
||||
"##teamcity[suiteTreeEnded name='param']\n" +
|
||||
"##teamcity[suiteTreeEnded name='TestA']\n", StringUtil.convertLineSeparators(buf.toString()));
|
||||
|
||||
buf.setLength(0);
|
||||
|
||||
sender.testRunStarted(testA);
|
||||
final Exception exception = new Exception();
|
||||
exception.setStackTrace(new StackTraceElement[0]);
|
||||
sender.testAssumptionFailure(new Failure(testA, exception));
|
||||
sender.testRunFinished(new Result());
|
||||
|
||||
Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" +
|
||||
"##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
|
||||
"##teamcity[testSuiteStarted name='TestA']\n" +
|
||||
"##teamcity[testSuiteStarted name='param']\n" +
|
||||
"##teamcity[testStarted name='TestA.testName' locationHint='java:test://TestA.testName']\n" +
|
||||
"##teamcity[testIgnored name='TestA.testName' details='java.lang.Exception|n' error='true' message='']\n" +
|
||||
"\n" +
|
||||
"##teamcity[testFinished name='TestA.testName']\n" +
|
||||
"##teamcity[testSuiteFinished name='param']\n" +
|
||||
"##teamcity[testSuiteFinished name='TestA']\n", StringUtil.convertLineSeparators(buf.toString()));
|
||||
buf.setLength(0);
|
||||
|
||||
//testStarted and testFinished are called by the framework
|
||||
sender.testRunStarted(testA);
|
||||
sender.testAssumptionFailure(new Failure(testName, exception));
|
||||
sender.testRunFinished(new Result());
|
||||
|
||||
Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" +
|
||||
"##teamcity[rootName name = 'root' location = 'java:suite://root']\n" +
|
||||
"##teamcity[testIgnored name='TestA.testName' details='java.lang.Exception|n' error='true' message='']\n", StringUtil.convertLineSeparators(buf.toString()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleMethod() throws Exception {
|
||||
|
||||
@@ -141,16 +141,20 @@ public class JUnit4TestListener extends RunListener {
|
||||
}
|
||||
|
||||
public void testFailure(Failure failure) throws Exception {
|
||||
final Description description = failure.getDescription();
|
||||
testFailure(failure, failure.getDescription(), MapSerializerUtil.TEST_FAILED, true);
|
||||
}
|
||||
|
||||
private void testFailure(Failure failure, Description description, String messageName, boolean local) throws Exception {
|
||||
final String methodName = getFullMethodName(description);
|
||||
//class setUp failed
|
||||
if (methodName == null) {
|
||||
if (methodName == null) { //class setUp failed
|
||||
for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext(); ) {
|
||||
testFailure(failure, MapSerializerUtil.TEST_FAILED, getFullMethodName((Description)iterator.next()));
|
||||
testFailure(failure, (Description)iterator.next(), messageName, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
testFailure(failure, MapSerializerUtil.TEST_FAILED, methodName);
|
||||
if (!local) testStarted(description);
|
||||
testFailure(failure, messageName, methodName);
|
||||
if (!local) testFinished(description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,17 +189,7 @@ public class JUnit4TestListener extends RunListener {
|
||||
public void testAssumptionFailure(Failure failure) {
|
||||
final Description description = failure.getDescription();
|
||||
try {
|
||||
final String methodName = getFullMethodName(description);
|
||||
//class setUp failed
|
||||
if (methodName == null) {
|
||||
for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext(); ) {
|
||||
final Description testDescription = (Description)iterator.next();
|
||||
testAssumptionFailure(failure, testDescription, getFullMethodName(testDescription));
|
||||
}
|
||||
}
|
||||
else {
|
||||
testAssumptionFailure(failure, description, methodName);
|
||||
}
|
||||
testFailure(failure, description, MapSerializerUtil.TEST_IGNORED, true);
|
||||
}
|
||||
catch (Exception ignore) {}
|
||||
}
|
||||
@@ -215,13 +209,7 @@ public class JUnit4TestListener extends RunListener {
|
||||
}
|
||||
return methodName;
|
||||
}
|
||||
|
||||
private void testAssumptionFailure(Failure failure, Description testDescription, String name) throws Exception {
|
||||
testStarted(testDescription);
|
||||
testFailure(failure, MapSerializerUtil.TEST_IGNORED, name);
|
||||
testFinished(testDescription);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void testIgnored(Description description) throws Exception {
|
||||
final String methodName = getFullMethodName(description);
|
||||
if (methodName == null) {
|
||||
@@ -382,11 +370,15 @@ public class JUnit4TestListener extends RunListener {
|
||||
|
||||
private static String getShortName(String fqName) {
|
||||
if (fqName == null) return null;
|
||||
if (fqName.startsWith("[")) {
|
||||
final int idx = fqName.indexOf("[");
|
||||
if (idx == 0) {
|
||||
//param name
|
||||
return fqName;
|
||||
}
|
||||
int lastPointIdx = fqName.lastIndexOf('.');
|
||||
if (idx > 0 && fqName.endsWith("]")) {
|
||||
lastPointIdx = fqName.substring(0, idx).lastIndexOf('.');
|
||||
}
|
||||
if (lastPointIdx >= 0) {
|
||||
return fqName.substring(lastPointIdx + 1);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,9 @@ public abstract class TestNGTestObject {
|
||||
classes.put(psiClass, psiMethods);
|
||||
}
|
||||
for (PsiMethod method : methods) {
|
||||
psiMethods.put(method, Collections.<String>emptyList());
|
||||
if (!psiMethods.containsKey(method)) {
|
||||
psiMethods.put(method, Collections.<String>emptyList());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+44
@@ -140,6 +140,50 @@ public class DetectClassesToRunTest extends LightCodeInsightFixtureTestCase {
|
||||
assertEquals(1, paramsToRerun.size());
|
||||
assertContainsElements(paramsToRerun, "a");
|
||||
}
|
||||
|
||||
public void testRerunFailedParameterized() throws Exception {
|
||||
final PsiClass aClass =
|
||||
myFixture.addClass("package a; " +
|
||||
"import org.testng.annotations.DataProvider;\n" +
|
||||
"import org.testng.annotations.Test;\n" +
|
||||
"\n" +
|
||||
"import static org.testng.Assert.assertEquals;\n" +
|
||||
"\n" +
|
||||
"public class ATest {\n" +
|
||||
"\n" +
|
||||
" @DataProvider\n" +
|
||||
" public Object[][] testData() {\n" +
|
||||
" return new Object[][]{\n" +
|
||||
" {1},\n" +
|
||||
" {2},\n" +
|
||||
" };\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" @Test(dataProvider = \"testData\")\n" +
|
||||
" public void test(int in) {\n" +
|
||||
" assertEquals(in, 0);\n" +
|
||||
" }\n" +
|
||||
"}\n");
|
||||
|
||||
final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>>();
|
||||
classes.put(aClass, new HashMap<PsiMethod, List<String>>());
|
||||
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject());
|
||||
final SMTestProxy testProxy = new SMTestProxy("test", false, "java:test://a.ATest.test[0]");
|
||||
testProxy.setLocator(new JavaTestLocator());
|
||||
RerunFailedTestsAction.includeFailedTestWithDependencies(classes, projectScope, getProject(), testProxy);
|
||||
|
||||
final SMTestProxy testProxy2 = new SMTestProxy("test", false, "java:test://a.ATest.test[1]");
|
||||
testProxy2.setLocator(new JavaTestLocator());
|
||||
RerunFailedTestsAction.includeFailedTestWithDependencies(classes, projectScope, getProject(), testProxy2);
|
||||
|
||||
assertEquals(1, classes.size());
|
||||
final Map<PsiMethod, List<String>> params = classes.get(aClass);
|
||||
final PsiMethod[] tests = aClass.findMethodsByName("test", false);
|
||||
assertContainsElements(params.keySet(), tests);
|
||||
final List<String> paramsToRerun = params.get(tests[0]);
|
||||
assertEquals(2, paramsToRerun.size());
|
||||
assertContainsElements(paramsToRerun, "0", "1");
|
||||
}
|
||||
|
||||
private void doTestMethodConfiguration(PsiClass aClass, PsiMethod... expectedMethods) throws CantRunException {
|
||||
final TestNGConfiguration configuration =
|
||||
|
||||
@@ -481,6 +481,16 @@ class MultiValueDictResolver(DictResolver):
|
||||
return ret
|
||||
|
||||
|
||||
#=======================================================================================================================
|
||||
# DequeResolver
|
||||
#=======================================================================================================================
|
||||
class DequeResolver(TupleResolver):
|
||||
def getDictionary(self, var):
|
||||
d = TupleResolver.getDictionary(self, var)
|
||||
d['maxlen'] = getattr(var, 'maxlen', None)
|
||||
return d
|
||||
|
||||
|
||||
#=======================================================================================================================
|
||||
# FrameResolver
|
||||
#=======================================================================================================================
|
||||
@@ -539,4 +549,5 @@ jyArrayResolver = JyArrayResolver()
|
||||
setResolver = SetResolver()
|
||||
ndarrayResolver = NdArrayResolver()
|
||||
multiValueDictResolver = MultiValueDictResolver()
|
||||
dequeResolver = DequeResolver()
|
||||
frameResolver = FrameResolver()
|
||||
|
||||
@@ -77,6 +77,12 @@ if not sys.platform.startswith("java"):
|
||||
except:
|
||||
pass #django may not be installed
|
||||
|
||||
try:
|
||||
from collections import deque
|
||||
typeMap.append((deque, pydevd_resolver.dequeResolver))
|
||||
except:
|
||||
pass
|
||||
|
||||
if frame_type is not None:
|
||||
typeMap.append((frame_type, pydevd_resolver.frameResolver))
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class XmlSlashTypedHandler extends TypedHandlerDelegate {
|
||||
@Override
|
||||
public Result charTyped(final char c, final Project project, @NotNull final Editor editor, @NotNull final PsiFile editedFile) {
|
||||
if (!WebEditorOptions.getInstance().isAutoCloseTag()) return Result.CONTINUE;
|
||||
if ((editedFile.getLanguage() instanceof XMLLanguage || editedFile.getViewProvider().getBaseLanguage() instanceof XMLLanguage) && c == '/') {
|
||||
if ((XmlGtTypedHandler.fileContainsXmlLanguage(editedFile)) && c == '/') {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||
|
||||
Reference in New Issue
Block a user