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:
@@ -332,7 +332,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
|
||||
private final ModifiableRootModel myDelegateModel;
|
||||
@NonNls private final Set<String> myCheckedNames = new HashSet<String>(
|
||||
Arrays.asList("addOrderEntry", "addLibraryEntry", "addInvalidLibrary", "addModuleOrderEntry", "addInvalidModuleEntry",
|
||||
"removeOrderEntry", "setSdk", "inheritSdk", "inheritCompilerOutputPath", "setExcludeOutput", "replaceEntryOfType"));
|
||||
"removeOrderEntry", "setSdk", "inheritSdk", "inheritCompilerOutputPath", "setExcludeOutput", "replaceEntryOfType", "rearrangeOrderEntries"));
|
||||
|
||||
ModifiableRootModelInvocationHandler(ModifiableRootModel model) {
|
||||
myDelegateModel = model;
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public abstract class ChangeLibraryLevelActionBase extends AnAction {
|
||||
}
|
||||
}
|
||||
|
||||
final Library copied = ((LibraryTableBase.ModifiableModelEx)provider.getModifiableModel()).createLibrary(dialog.getLibraryName(), library.getKind());
|
||||
final Library copied = ((LibraryTableBase.ModifiableModelEx)provider.getModifiableModel()).createLibrary(StringUtil.nullize(dialog.getLibraryName()), library.getKind());
|
||||
final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)copied.getModifiableModel();
|
||||
LibraryEditingUtil.copyLibrary(library, copiedFiles, model);
|
||||
|
||||
|
||||
+7
-3
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots.ui.configuration.classpath;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.impl.OrderEntryUtil;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
@@ -43,15 +44,18 @@ class ChangeLibraryLevelInClasspathAction extends ChangeLibraryLevelActionBase {
|
||||
public void actionPerformed(AnActionEvent event) {
|
||||
final OrderEntry entry = myPanel.getSelectedEntry();
|
||||
if (!(entry instanceof LibraryOrderEntry)) return;
|
||||
final LibraryEx library = (LibraryEx)((LibraryOrderEntry)entry).getLibrary();
|
||||
LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entry;
|
||||
final LibraryEx library = (LibraryEx)libraryEntry.getLibrary();
|
||||
if (library == null) return;
|
||||
|
||||
final Library copied = doCopy(library);
|
||||
if (copied == null) return;
|
||||
|
||||
myPanel.getRootModel().removeOrderEntry(entry);
|
||||
if (!isConvertingToModuleLibrary()) {
|
||||
myPanel.getRootModel().addLibraryEntry(copied);
|
||||
OrderEntryUtil.replaceLibrary(myPanel.getRootModel(), library, copied);
|
||||
}
|
||||
else {
|
||||
OrderEntryUtil.replaceLibraryEntryByAdded(myPanel.getRootModel(), libraryEntry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,6 +33,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING;
|
||||
|
||||
public class ChangeStringLiteralToCharInMethodCallFix implements IntentionAction {
|
||||
private final PsiLiteralExpression myLiteral;
|
||||
private final PsiCall myCall;
|
||||
@@ -171,6 +173,6 @@ public class ChangeStringLiteralToCharInMethodCallFix implements IntentionAction
|
||||
}
|
||||
|
||||
private static boolean isString(final PsiType type) {
|
||||
return type != null && "java.lang.String".equals(type.getCanonicalText());
|
||||
return type != null && type.equalsToText(JAVA_LANG_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,9 +22,12 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiLiteralExpression;
|
||||
import com.intellij.psi.PsiType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING;
|
||||
|
||||
public class LiteralSelectioner extends BasicSelectioner {
|
||||
@Override
|
||||
public boolean canSelect(PsiElement e) {
|
||||
@@ -34,8 +37,10 @@ public class LiteralSelectioner extends BasicSelectioner {
|
||||
}
|
||||
|
||||
private static boolean isStringLiteral(PsiElement element) {
|
||||
return element instanceof PsiLiteralExpression &&
|
||||
((PsiLiteralExpression)element).getType().equalsToText("java.lang.String") && element.getText().startsWith("\"") && element.getText().endsWith("\"");
|
||||
final PsiType type = element instanceof PsiLiteralExpression ? ((PsiLiteralExpression)element).getType() : null;
|
||||
return type != null && type.equalsToText(JAVA_LANG_STRING)
|
||||
&& element.getText().startsWith("\"")
|
||||
&& element.getText().endsWith("\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RemoveAssignmentFix extends RemoveInitializerFix {
|
||||
if (!(parent instanceof PsiAssignmentExpression)) return;
|
||||
final PsiExpression rExpression = ((PsiAssignmentExpression)parent).getRExpression();
|
||||
final PsiElement gParent = parent.getParent();
|
||||
if (gParent instanceof PsiExpression && rExpression != null) {
|
||||
if ((gParent instanceof PsiExpression || gParent instanceof PsiExpressionList) && rExpression != null) {
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(gParent.getContainingFile())) return;
|
||||
if (gParent instanceof PsiParenthesizedExpression) {
|
||||
gParent.replace(rExpression);
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Remove redundant assignment" "true"
|
||||
class Test {
|
||||
void foo() {
|
||||
String var;
|
||||
this.bar("someString");
|
||||
}
|
||||
|
||||
void bar(String arg) {
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Remove redundant assignment" "true"
|
||||
class Test {
|
||||
void foo() {
|
||||
String var;
|
||||
this.bar(v<caret>ar = "someString");
|
||||
}
|
||||
|
||||
void bar(String arg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -611,5 +611,10 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
visitor.visitComponentAdapter(this);
|
||||
myDelegate.accept(visitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComponentConfigAdapter[" + getComponentKey() + "]: implementation=" + getComponentImplementation() + ", plugin=" + myConfig.getPluginId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -191,4 +191,9 @@ public class ExtensionComponentAdapter implements LoadingOrder.Orderable, Assign
|
||||
public void setNotificationSent(boolean notificationSent) {
|
||||
myNotificationSent = notificationSent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExtensionComponentAdapter[" + myImplementationClassName + "]: plugin=" + myPluginDescriptor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -152,21 +153,45 @@ public class OrderEntryUtil {
|
||||
rootModel.commit();
|
||||
}
|
||||
|
||||
public static void replaceLibrary(@NotNull ModifiableRootModel model, @NotNull Library oldLibrary, @NotNull Library newLibrary) {
|
||||
OrderEntry[] entries = model.getOrderEntries();
|
||||
private static int findLibraryOrderEntry(@NotNull OrderEntry[] entries, @NotNull Library library) {
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
OrderEntry orderEntry = entries[i];
|
||||
if (orderEntry instanceof LibraryOrderEntry && oldLibrary.equals(((LibraryOrderEntry)orderEntry).getLibrary())) {
|
||||
model.removeOrderEntry(orderEntry);
|
||||
final LibraryOrderEntry newEntry = model.addLibraryEntry(newLibrary);
|
||||
final OrderEntry[] newEntries = new OrderEntry[entries.length];
|
||||
System.arraycopy(entries, 0, newEntries, 0, i);
|
||||
newEntries[i] = newEntry;
|
||||
System.arraycopy(entries, i, newEntries, i+1, entries.length - i - 1);
|
||||
model.rearrangeOrderEntries(newEntries);
|
||||
return;
|
||||
OrderEntry entry = entries[i];
|
||||
if (entry instanceof LibraryOrderEntry && library.equals(((LibraryOrderEntry)entry).getLibrary())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void replaceLibrary(@NotNull ModifiableRootModel model, @NotNull Library oldLibrary, @NotNull Library newLibrary) {
|
||||
int i = findLibraryOrderEntry(model.getOrderEntries(), oldLibrary);
|
||||
if (i == -1) return;
|
||||
|
||||
model.addLibraryEntry(newLibrary);
|
||||
replaceLibraryByAdded(model, i);
|
||||
}
|
||||
|
||||
public static void replaceLibraryEntryByAdded(@NotNull ModifiableRootModel model, @NotNull LibraryOrderEntry entry) {
|
||||
int i = ArrayUtil.indexOf(model.getOrderEntries(), entry);
|
||||
if (i == -1) return;
|
||||
|
||||
replaceLibraryByAdded(model, i);
|
||||
}
|
||||
|
||||
private static void replaceLibraryByAdded(ModifiableRootModel model, int toReplace) {
|
||||
OrderEntry[] entries = model.getOrderEntries();
|
||||
LibraryOrderEntry newEntry = (LibraryOrderEntry)entries[entries.length - 1];
|
||||
LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entries[toReplace];
|
||||
boolean exported = libraryEntry.isExported();
|
||||
DependencyScope scope = libraryEntry.getScope();
|
||||
model.removeOrderEntry(libraryEntry);
|
||||
newEntry.setExported(exported);
|
||||
newEntry.setScope(scope);
|
||||
final OrderEntry[] newEntries = new OrderEntry[entries.length-1];
|
||||
System.arraycopy(entries, 0, newEntries, 0, toReplace);
|
||||
newEntries[toReplace] = newEntry;
|
||||
System.arraycopy(entries, toReplace + 1, newEntries, toReplace + 1, entries.length - toReplace - 2);
|
||||
model.rearrangeOrderEntries(newEntries);
|
||||
}
|
||||
|
||||
public static <T extends OrderEntry> void processOrderEntries(@NotNull Module module,
|
||||
|
||||
+5
@@ -190,5 +190,10 @@ public class ServiceManagerImpl implements BaseComponent {
|
||||
public String getAssignableToClassName() {
|
||||
return myDescriptor.getInterface();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServiceComponentAdapter[" + myDescriptor.getInterface() + "]: implementation=" + myDescriptor.getImplementation() + ", plugin=" + myPluginDescriptor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,12 @@ import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.impl.AbstractEditorTest;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.testFramework.LeakHunter;
|
||||
import com.intellij.testFramework.TestFileType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.picocontainer.ComponentAdapter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -69,6 +71,12 @@ public class BookmarkManagerTest extends AbstractEditorTest {
|
||||
}
|
||||
|
||||
public void testBookmarkLineRemove() throws IOException {
|
||||
List<ComponentAdapter> adapters = getProject().getPicoContainer().getComponentAdaptersOfType(ChangeListManagerImpl.class);
|
||||
System.out.println(adapters.size() + " adapters:");
|
||||
for (ComponentAdapter adapter : adapters) {
|
||||
System.out.println(adapter);
|
||||
}
|
||||
|
||||
@NonNls String text =
|
||||
"public class Test {\n" +
|
||||
" public void test() {\n" +
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.util.messages.impl;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -39,6 +35,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class MessageBusImpl implements MessageBus {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.messages.impl.MessageBusImpl");
|
||||
private static final Comparator<MessageBusImpl> MESSAGE_BUS_COMPARATOR = new Comparator<MessageBusImpl>() {
|
||||
@@ -224,7 +223,7 @@ public class MessageBusImpl implements MessageBus {
|
||||
}
|
||||
|
||||
private void checkNotDisposed() {
|
||||
LOG.assertTrue(!myDisposed, "Already disposed: " + myOwner);
|
||||
if (myDisposed) LOG.error("Already disposed: " + myOwner);
|
||||
}
|
||||
|
||||
private void calcSubscribers(Topic topic, List<MessageBusConnectionImpl> result) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorNotificationPanel;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.diff.FilesTooBigForDiffException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -50,14 +51,14 @@ import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* @author irengrig
|
||||
* author: lesya
|
||||
* author: lesya
|
||||
*/
|
||||
public class LineStatusTracker {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.ex.LineStatusTracker");
|
||||
private static final Key<CanNotCalculateDiffPanel> PANEL_KEY = new Key<CanNotCalculateDiffPanel>("LineStatusTracker.CanNotCalculateDiffPanel");
|
||||
private static final Key<CanNotCalculateDiffPanel> PANEL_KEY =
|
||||
new Key<CanNotCalculateDiffPanel>("LineStatusTracker.CanNotCalculateDiffPanel");
|
||||
|
||||
private final Object myLock = new Object();
|
||||
// true -> have contents
|
||||
private BaseLoadState myBaseLoaded;
|
||||
|
||||
private final Document myDocument;
|
||||
@@ -71,15 +72,17 @@ public class LineStatusTracker {
|
||||
|
||||
private boolean myBulkUpdate;
|
||||
private final Application myApplication;
|
||||
@Nullable
|
||||
private RevisionPack myBaseRevisionNumber;
|
||||
@Nullable private RevisionPack myBaseRevisionNumber;
|
||||
private String myPreviousBaseRevision;
|
||||
private boolean myAnathemaThrown;
|
||||
private FileEditorManager myFileEditorManager;
|
||||
private final VirtualFile myVirtualFile;
|
||||
private boolean myReleased = false;
|
||||
|
||||
private LineStatusTracker(final Document document, final Document upToDateDocument, final Project project, final VirtualFile virtualFile) {
|
||||
private LineStatusTracker(@NotNull final Document document,
|
||||
@NotNull final Document upToDateDocument,
|
||||
final Project project,
|
||||
@Nullable final VirtualFile virtualFile) {
|
||||
myVirtualFile = virtualFile;
|
||||
myApplication = ApplicationManager.getApplication();
|
||||
myDocument = document;
|
||||
@@ -156,7 +159,7 @@ public class LineStatusTracker {
|
||||
}
|
||||
|
||||
private void removeAnathema() {
|
||||
if (! myAnathemaThrown) return;
|
||||
if (!myAnathemaThrown) return;
|
||||
myAnathemaThrown = false;
|
||||
final FileEditor[] editors = myFileEditorManager.getEditors(myVirtualFile);
|
||||
for (FileEditor editor : editors) {
|
||||
@@ -286,8 +289,6 @@ public class LineStatusTracker {
|
||||
|
||||
private class MyDocumentListener extends DocumentAdapter {
|
||||
private int myFirstChangedLine;
|
||||
private int myUpToDateFirstLine;
|
||||
private int myUpToDateLastLine;
|
||||
private int myLastChangedLine;
|
||||
private int myLinesBeforeChange;
|
||||
private final VcsDirtyScopeManager myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
||||
@@ -302,50 +303,14 @@ public class LineStatusTracker {
|
||||
try {
|
||||
myFirstChangedLine = myDocument.getLineNumber(e.getOffset());
|
||||
myLastChangedLine = myDocument.getLineNumber(e.getOffset() + e.getOldLength());
|
||||
myLinesBeforeChange = myLastChangedLine - myFirstChangedLine;
|
||||
if (StringUtil.endsWithChar(e.getOldFragment(), '\n')) myLastChangedLine++;
|
||||
|
||||
myLinesBeforeChange = myDocument.getLineNumber(e.getOffset() + e.getOldLength()) - myDocument.getLineNumber(e.getOffset());
|
||||
|
||||
Range firstChangedRange = getLastRangeBeforeLine(myFirstChangedLine);
|
||||
|
||||
if (firstChangedRange == null) {
|
||||
myUpToDateFirstLine = myFirstChangedLine;
|
||||
}
|
||||
else if (firstChangedRange.containsLine(myFirstChangedLine)) {
|
||||
myFirstChangedLine = firstChangedRange.getOffset1();
|
||||
myUpToDateFirstLine = firstChangedRange.getUOffset1();
|
||||
}
|
||||
else {
|
||||
myUpToDateFirstLine = firstChangedRange.getUOffset2() + myFirstChangedLine - firstChangedRange.getOffset2();
|
||||
}
|
||||
|
||||
Range myLastChangedRange = getLastRangeBeforeLine(myLastChangedLine);
|
||||
|
||||
if (myLastChangedRange == null) {
|
||||
myUpToDateLastLine = myLastChangedLine;
|
||||
}
|
||||
else if (myLastChangedRange.containsLine(myLastChangedLine)) {
|
||||
myUpToDateLastLine = myLastChangedRange.getUOffset2();
|
||||
myLastChangedLine = myLastChangedRange.getOffset2();
|
||||
}
|
||||
else {
|
||||
myUpToDateLastLine = myLastChangedRange.getUOffset2() + myLastChangedLine - myLastChangedRange.getOffset2();
|
||||
}
|
||||
} catch (ProcessCanceledException ignore) {
|
||||
}
|
||||
catch (ProcessCanceledException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Range getLastRangeBeforeLine(int line) {
|
||||
Range result = null;
|
||||
for (Range range : myRanges) {
|
||||
if (range.isAfter(line)) return result;
|
||||
result = range;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void documentChanged(final DocumentEvent e) {
|
||||
myApplication.assertWriteAccessAllowed();
|
||||
@@ -354,27 +319,40 @@ public class LineStatusTracker {
|
||||
if (myReleased) return;
|
||||
if (myBulkUpdate || myAnathemaThrown || BaseLoadState.LOADED != myBaseLoaded) return;
|
||||
try {
|
||||
int upToDateFirstLine;
|
||||
int upToDateLastLine;
|
||||
|
||||
int line = myDocument.getLineNumber(e.getOffset() + e.getNewLength());
|
||||
int linesAfterChange = line - myDocument.getLineNumber(e.getOffset());
|
||||
int linesAfterChange = myDocument.getLineNumber(e.getOffset() + e.getNewLength()) - myDocument.getLineNumber(e.getOffset());
|
||||
int linesShift = linesAfterChange - myLinesBeforeChange;
|
||||
|
||||
List<Range> rangesAfterChange = getRangesAfter(myRanges, myLastChangedLine);
|
||||
List<Range> rangesBeforeChange = getRangesBefore(myRanges, myFirstChangedLine);
|
||||
List<Range> rangesBeforeChange = new ArrayList<Range>();
|
||||
List<Range> rangesAfterChange = new ArrayList<Range>();
|
||||
List<Range> changedRanges = new ArrayList<Range>();
|
||||
sortRanges(myRanges, myFirstChangedLine, myLastChangedLine, rangesBeforeChange, changedRanges, rangesAfterChange);
|
||||
|
||||
List<Range> changedRanges = getChangedRanges(myFirstChangedLine, myLastChangedLine);
|
||||
Range firstChangedRange = ContainerUtil.getFirstItem(changedRanges);
|
||||
Range lastChangedRange = ContainerUtil.getLastItem(changedRanges);
|
||||
Range lastRangeBefore = ContainerUtil.getLastItem(rangesBeforeChange);
|
||||
|
||||
int newSize = rangesBeforeChange.size() + changedRanges.size() + rangesAfterChange.size();
|
||||
if (myRanges.size() != newSize) {
|
||||
LOG.info("Ranges: " + myRanges + "; first changed line: " + myFirstChangedLine + "; last changed line: " + myLastChangedLine);
|
||||
LOG.assertTrue(false);
|
||||
if (firstChangedRange != null && firstChangedRange.getOffset1() < myFirstChangedLine) {
|
||||
myFirstChangedLine = firstChangedRange.getOffset1();
|
||||
}
|
||||
if (lastChangedRange != null && lastChangedRange.getOffset2() > myLastChangedLine) {
|
||||
myLastChangedLine = lastChangedRange.getOffset2();
|
||||
}
|
||||
|
||||
upToDateFirstLine = getUpToDateLine(lastRangeBefore, myFirstChangedLine);
|
||||
|
||||
if (lastChangedRange == null) {
|
||||
upToDateLastLine = getUpToDateLine(lastRangeBefore, myLastChangedLine);
|
||||
}
|
||||
else {
|
||||
upToDateLastLine = getUpToDateLine(lastChangedRange, myLastChangedLine);
|
||||
}
|
||||
|
||||
myLastChangedLine += linesShift;
|
||||
|
||||
|
||||
List<Range> newChangedRanges = getNewChangedRanges();
|
||||
List<Range> newChangedRanges = getNewChangedRanges(upToDateFirstLine, upToDateLastLine);
|
||||
|
||||
shiftRanges(rangesAfterChange, linesShift);
|
||||
|
||||
@@ -410,22 +388,28 @@ public class LineStatusTracker {
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (ProcessCanceledException ignore) {
|
||||
} catch (FilesTooBigForDiffException e1) {
|
||||
}
|
||||
catch (ProcessCanceledException ignore) {
|
||||
}
|
||||
catch (FilesTooBigForDiffException e1) {
|
||||
installAnathema();
|
||||
removeHighlightersFromMarkupModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Range> getNewChangedRanges() throws FilesTooBigForDiffException {
|
||||
List<String> lines = new DocumentWrapper(myDocument).getLines(myFirstChangedLine, myLastChangedLine);
|
||||
List<String> uLines = new DocumentWrapper(myUpToDateDocument)
|
||||
.getLines(myUpToDateFirstLine, myUpToDateLastLine);
|
||||
return new RangesBuilder(lines, uLines, myFirstChangedLine, myUpToDateFirstLine).getRanges();
|
||||
private int getUpToDateLine(@Nullable Range range, int line) {
|
||||
return range == null ? line : line + range.getUOffset2() - range.getOffset2();
|
||||
}
|
||||
|
||||
private List<Range> mergeRanges(List<Range> ranges) {
|
||||
private List<Range> getNewChangedRanges(int upToDateFirstLine, int upToDateLastLine) throws FilesTooBigForDiffException {
|
||||
List<String> lines = new DocumentWrapper(myDocument).getLines(myFirstChangedLine, myLastChangedLine);
|
||||
List<String> uLines = new DocumentWrapper(myUpToDateDocument).getLines(upToDateFirstLine, upToDateLastLine);
|
||||
return new RangesBuilder(lines, uLines, myFirstChangedLine, upToDateFirstLine).getRanges();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Range> mergeRanges(@NotNull List<Range> ranges) {
|
||||
ArrayList<Range> result = new ArrayList<Range>();
|
||||
Iterator<Range> iterator = ranges.iterator();
|
||||
if (!iterator.hasNext()) return result;
|
||||
@@ -450,9 +434,11 @@ public class LineStatusTracker {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void replaceRanges(List<Range> rangesInChange, List<Range> newRangesInChange) {
|
||||
private void replaceRanges(@NotNull List<Range> rangesInChange, @NotNull List<Range> newRangesInChange) {
|
||||
for (Range range : rangesInChange) {
|
||||
range.getHighlighter().dispose();
|
||||
if (range.getHighlighter() != null) {
|
||||
range.getHighlighter().dispose();
|
||||
}
|
||||
range.setHighlighter(null);
|
||||
}
|
||||
for (Range range : newRangesInChange) {
|
||||
@@ -460,25 +446,33 @@ public class LineStatusTracker {
|
||||
}
|
||||
}
|
||||
|
||||
private void shiftRanges(List<Range> rangesAfterChange, int shift) {
|
||||
private void shiftRanges(@NotNull List<Range> rangesAfterChange, int shift) {
|
||||
for (final Range aRangesAfterChange : rangesAfterChange) {
|
||||
aRangesAfterChange.shift(shift);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<Range> getChangedRanges(int from, int to) {
|
||||
return getChangedRanges(myRanges, from, to);
|
||||
}
|
||||
|
||||
public static List<Range> getChangedRanges(List<Range> ranges, int from, int to) {
|
||||
ArrayList<Range> result = new ArrayList<Range>();
|
||||
public static void sortRanges(@NotNull List<Range> ranges,
|
||||
int firstChangedLine,
|
||||
int lastChangedLine,
|
||||
@NotNull List<Range> rangesBeforeChange,
|
||||
@NotNull List<Range> changedRanges,
|
||||
@NotNull List<Range> rangesAfterChange) {
|
||||
for (Range range : ranges) {
|
||||
if (range.getOffset1() <= to && range.getOffset2() >= from) result.add(range);
|
||||
// if (range.getOffset1() > to) break;
|
||||
int offset1 = range.getType() == Range.DELETED ? range.getOffset1() - 1 : range.getOffset1();
|
||||
int offset2 = range.getOffset2();
|
||||
|
||||
if (offset2 < firstChangedLine) {
|
||||
rangesBeforeChange.add(range);
|
||||
}
|
||||
else if (offset1 > lastChangedLine) {
|
||||
rangesAfterChange.add(range);
|
||||
}
|
||||
else {
|
||||
changedRanges.add(range);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -525,7 +519,7 @@ public class LineStatusTracker {
|
||||
return getPrevRange(currentRange);
|
||||
}
|
||||
|
||||
for (ListIterator<Range> iterator = myRanges.listIterator(myRanges.size()); iterator.hasPrevious();) {
|
||||
for (ListIterator<Range> iterator = myRanges.listIterator(myRanges.size()); iterator.hasPrevious(); ) {
|
||||
final Range range = iterator.previous();
|
||||
if (range.getOffset1() > line) {
|
||||
continue;
|
||||
@@ -536,24 +530,6 @@ public class LineStatusTracker {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Range> getRangesBefore(List<Range> ranges, int line) {
|
||||
ArrayList<Range> result = new ArrayList<Range>();
|
||||
|
||||
for (Range range : ranges) {
|
||||
if (range.getOffset2() < line) result.add(range);
|
||||
//if (range.getOffset2() > line) break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<Range> getRangesAfter(List<Range> ranges, int line) {
|
||||
ArrayList<Range> result = new ArrayList<Range>();
|
||||
for (Range range : ranges) {
|
||||
if (range.getOffset1() > line) result.add(range);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Range getRangeForLine(final int line) {
|
||||
synchronized (myLock) {
|
||||
@@ -573,25 +549,33 @@ public class LineStatusTracker {
|
||||
myApplication.assertWriteAccessAllowed();
|
||||
|
||||
synchronized (myLock) {
|
||||
TextRange currentTextRange = getCurrentTextRange(range);
|
||||
TextRange currentTextRange = getCurrentTextRangeWithMagic(range);
|
||||
|
||||
int offset1 = currentTextRange.getStartOffset();
|
||||
int offset2 = Math.min(currentTextRange.getEndOffset() + 1, myDocument.getTextLength());
|
||||
if (range.getType() == Range.INSERTED) {
|
||||
myDocument
|
||||
.replaceString(currentTextRange.getStartOffset(), Math.min(currentTextRange.getEndOffset() + 1, myDocument.getTextLength()), "");
|
||||
myDocument.replaceString(offset1, offset2, "");
|
||||
}
|
||||
else if (range.getType() == Range.DELETED) {
|
||||
String upToDateContent = getUpToDateContent(range);
|
||||
myDocument.insertString(currentTextRange.getStartOffset(), upToDateContent);
|
||||
String upToDateContent = getUpToDateContentWithMagic(range);
|
||||
myDocument.insertString(offset1, upToDateContent);
|
||||
}
|
||||
else {
|
||||
|
||||
String upToDateContent = getUpToDateContent(range);
|
||||
myDocument.replaceString(currentTextRange.getStartOffset(), Math.min(currentTextRange.getEndOffset() + 1, myDocument.getTextLength()),
|
||||
upToDateContent);
|
||||
String upToDateContent = getUpToDateContentWithMagic(range);
|
||||
myDocument.replaceString(offset1, offset2, upToDateContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getUpToDateContentWithMagic(Range range) {
|
||||
synchronized (myLock) {
|
||||
TextRange textRange = getUpToDateRangeWithMagic(range);
|
||||
final int startOffset = textRange.getStartOffset();
|
||||
final int endOffset = Math.min(textRange.getEndOffset() + 1, myUpToDateDocument.getTextLength());
|
||||
return myUpToDateDocument.getCharsSequence().subSequence(startOffset, endOffset).toString();
|
||||
}
|
||||
}
|
||||
|
||||
public String getUpToDateContent(Range range) {
|
||||
synchronized (myLock) {
|
||||
TextRange textRange = getUpToDateRange(range);
|
||||
@@ -605,25 +589,28 @@ public class LineStatusTracker {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
TextRange getCurrentTextRange(Range range) {
|
||||
return getRange(range.getType(), range.getOffset1(), range.getOffset2(), Range.DELETED, myDocument, false);
|
||||
@NotNull
|
||||
TextRange getCurrentTextRangeWithMagic(@NotNull Range range) {
|
||||
return getRangeWithMagic(range.getType(), range.getOffset1(), range.getOffset2(), Range.DELETED, myDocument);
|
||||
}
|
||||
|
||||
TextRange getUpToDateRange(Range range) {
|
||||
return getRange(range.getType(), range.getUOffset1(), range.getUOffset2(), Range.INSERTED, myUpToDateDocument, false);
|
||||
@NotNull
|
||||
TextRange getUpToDateRangeWithMagic(@NotNull Range range) {
|
||||
return getRangeWithMagic(range.getType(), range.getUOffset1(), range.getUOffset2(), Range.INSERTED, myUpToDateDocument);
|
||||
}
|
||||
|
||||
TextRange getCurrentTextRangeWithEndSymbol(Range range) {
|
||||
return getRange(range.getType(), range.getOffset1(), range.getOffset2(), Range.DELETED, myDocument, true);
|
||||
@NotNull
|
||||
TextRange getCurrentTextRange(@NotNull Range range) {
|
||||
return getRange(range.getType(), range.getOffset1(), range.getOffset2(), Range.DELETED, myDocument);
|
||||
}
|
||||
|
||||
// a hack
|
||||
TextRange getUpToDateRangeWithEndSymbol(Range range) {
|
||||
return getRange(range.getType(), range.getUOffset1(), range.getUOffset2(), Range.INSERTED, myUpToDateDocument, true);
|
||||
@NotNull
|
||||
TextRange getUpToDateRange(@NotNull Range range) {
|
||||
return getRange(range.getType(), range.getUOffset1(), range.getUOffset2(), Range.INSERTED, myUpToDateDocument);
|
||||
}
|
||||
|
||||
private static TextRange getRange(byte rangeType, int offset1, int offset2, byte emptyRangeCondition, Document document,
|
||||
final boolean keepEnd) {
|
||||
@NotNull
|
||||
private static TextRange getRangeWithMagic(byte rangeType, int offset1, int offset2, byte emptyRangeCondition, Document document) {
|
||||
if (rangeType == emptyRangeCondition) {
|
||||
int lineStartOffset;
|
||||
if (offset1 == 0) {
|
||||
@@ -634,23 +621,33 @@ public class LineStatusTracker {
|
||||
}
|
||||
//if (lineStartOffset > 0) lineStartOffset--;
|
||||
return new TextRange(lineStartOffset, lineStartOffset);
|
||||
|
||||
}
|
||||
else {
|
||||
int startOffset = document.getLineStartOffset(offset1);
|
||||
int endOffset = document.getLineEndOffset(offset2 - 1);
|
||||
if (startOffset > 0) {
|
||||
-- startOffset;
|
||||
if (! keepEnd) {
|
||||
-- endOffset;
|
||||
}
|
||||
--startOffset;
|
||||
--endOffset;
|
||||
}
|
||||
return new TextRange(startOffset, endOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public static LineStatusTracker createOn(@Nullable VirtualFile virtualFile, final Document doc, final Project project) {
|
||||
final Document document = new DocumentImpl("",true);
|
||||
@NotNull
|
||||
private static TextRange getRange(byte rangeType, int offset1, int offset2, byte emptyRangeCondition, Document document) {
|
||||
if (rangeType == emptyRangeCondition) {
|
||||
int lineStartOffset = offset1 < document.getLineCount() ? document.getLineStartOffset(offset1) : document.getTextLength();
|
||||
return new TextRange(lineStartOffset, lineStartOffset);
|
||||
}
|
||||
else {
|
||||
int startOffset = document.getLineStartOffset(offset1);
|
||||
int endOffset = document.getLineEndOffset(offset2 - 1);
|
||||
return new TextRange(startOffset, endOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public static LineStatusTracker createOn(@Nullable VirtualFile virtualFile, @NotNull final Document doc, final Project project) {
|
||||
final Document document = new DocumentImpl("", true);
|
||||
return new LineStatusTracker(doc, document, project, virtualFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,22 +154,4 @@ public class Range {
|
||||
public RangeHighlighter getHighlighter() {
|
||||
return myRangeHighlighter;
|
||||
}
|
||||
|
||||
public boolean contains(int offset1, int offset2) {
|
||||
return getOffset1() <= offset1 && getOffset2() >= offset2;
|
||||
}
|
||||
|
||||
public boolean containsLine(int line) {
|
||||
if (myType == DELETED) return (myOffset1 - 1) <= line
|
||||
&& (myOffset2) >= line;
|
||||
return myOffset1 <= line && myOffset2 >= line;
|
||||
}
|
||||
|
||||
public boolean isAfter(int line) {
|
||||
if (myType == DELETED)
|
||||
return (getOffset1() - 1) > line;
|
||||
else
|
||||
return getOffset1() > line;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -56,10 +56,10 @@ public class ShowLineStatusRangeDiffAction extends BaseLineStatusRangeAction {
|
||||
public DiffContent[] getContents() {
|
||||
return new DiffContent[]{
|
||||
createDiffContent(myLineStatusTracker.getUpToDateDocument(),
|
||||
myLineStatusTracker.getUpToDateRangeWithEndSymbol(myRange),
|
||||
myLineStatusTracker.getUpToDateRange(myRange),
|
||||
null),
|
||||
createDiffContent(myLineStatusTracker.getDocument(),
|
||||
myLineStatusTracker.getCurrentTextRangeWithEndSymbol(myRange),
|
||||
myLineStatusTracker.getCurrentTextRange(myRange),
|
||||
myLineStatusTracker.getVirtualFile())};
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ public abstract class GitPlatformTest extends UsefulTestCase {
|
||||
myDialogManager.cleanup();
|
||||
myVcsNotifier.cleanup();
|
||||
myProjectFixture.tearDown();
|
||||
clearFields(this);
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
|
||||
+16
@@ -15,17 +15,21 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.gradle.execution.test.runner;
|
||||
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.TestFrameworkRunningModel;
|
||||
import com.intellij.execution.testframework.ToggleModelAction;
|
||||
import com.intellij.execution.testframework.ToggleModelActionProvider;
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration;
|
||||
import com.intellij.util.config.AbstractProperty;
|
||||
import com.intellij.util.config.BooleanProperty;
|
||||
import icons.GradleIcons;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -42,6 +46,9 @@ public class OpenGradleTestResultActionProvider implements ToggleModelActionProv
|
||||
}
|
||||
|
||||
private static class MyToggleModelAction extends ToggleModelAction {
|
||||
@Nullable
|
||||
private ProjectSystemId mySystemId;
|
||||
|
||||
public MyToggleModelAction(TestConsoleProperties properties) {
|
||||
super(GradleBundle.message("gradle.test.runner.ui.tests.actions.open.gradle.report.text"),
|
||||
GradleBundle.message("gradle.test.runner.ui.tests.actions.open.gradle.report.desc"),
|
||||
@@ -50,6 +57,10 @@ public class OpenGradleTestResultActionProvider implements ToggleModelActionProv
|
||||
|
||||
@Override
|
||||
public void setModel(TestFrameworkRunningModel model) {
|
||||
final RunConfiguration runConfiguration = model.getProperties().getConfiguration();
|
||||
if(runConfiguration instanceof ExternalSystemRunConfiguration) {
|
||||
mySystemId = ((ExternalSystemRunConfiguration)runConfiguration).getSettings().getExternalSystemId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,6 +77,11 @@ public class OpenGradleTestResultActionProvider implements ToggleModelActionProv
|
||||
return reportFilePath != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isVisible() {
|
||||
return GradleConstants.SYSTEM_ID.equals(mySystemId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getReportFilePath() {
|
||||
final AbstractProperty.AbstractPropertyContainer properties = getProperties();
|
||||
|
||||
@@ -90,8 +90,13 @@ public abstract class HgPlatformTest extends UsefulTestCase {
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myProjectFixture.tearDown();
|
||||
super.tearDown();
|
||||
try {
|
||||
myProjectFixture.tearDown();
|
||||
clearFields(this);
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setUpHgrc(@NotNull VirtualFile repositoryRoot) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user