Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Dmitry Lomov
2012-11-28 16:26:39 +01:00
18 changed files with 157 additions and 151 deletions
@@ -24,6 +24,7 @@ import com.intellij.debugger.DebuggerBundle;
import com.intellij.ide.util.ClassFilter;
import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -48,6 +49,9 @@ public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPane
myNotifyCaughtCheckBox = new JCheckBox(DebuggerBundle.message("label.exception.breakpoint.properties.panel.caught.exception"));
myNotifyUncaughtCheckBox = new JCheckBox(DebuggerBundle.message("label.exception.breakpoint.properties.panel.uncaught.exception"));
DialogUtil.registerMnemonic(myNotifyCaughtCheckBox);
DialogUtil.registerMnemonic(myNotifyUncaughtCheckBox);
Box notificationsBox = Box.createVerticalBox();
JPanel _panel = new JPanel(new BorderLayout());
@@ -23,6 +23,7 @@ package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -43,6 +44,8 @@ public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
JPanel _panel0;
myWatchAccessCheckBox = new JCheckBox(DebuggerBundle.message("label.filed.breakpoint.properties.panel.field.access"));
myWatchModificationCheckBox = new JCheckBox(DebuggerBundle.message("label.filed.breakpoint.properties.panel.field.modification"));
DialogUtil.registerMnemonic(myWatchAccessCheckBox);
DialogUtil.registerMnemonic(myWatchModificationCheckBox);
Box watchBox = Box.createVerticalBox();
@@ -23,6 +23,7 @@ package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ui.DialogUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -43,6 +44,9 @@ public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
myWatchEntryCheckBox = new JCheckBox(DebuggerBundle.message("label.method.breakpoint.properties.panel.method.entry"));
myWatchExitCheckBox = new JCheckBox(DebuggerBundle.message("label.method.breakpoint.properties.panel.method.exit"));
DialogUtil.registerMnemonic(myWatchEntryCheckBox);
DialogUtil.registerMnemonic(myWatchExitCheckBox);
Box watchBox = Box.createVerticalBox();
_panel = new JPanel(new BorderLayout());
@@ -101,7 +101,7 @@ public class LanguageLevelProjectExtensionImpl extends LanguageLevelProjectExten
}
myLanguageLevel = languageLevel;
if (!willReload() && DirectoryIndex.getInstance(myProject).isInitialized()) {
if (!willReload() && !myProject.isDefault() && DirectoryIndex.getInstance(myProject).isInitialized()) {
JavaLanguageLevelPusher.pushLanguageLevel(myProject);
}
}
@@ -30,7 +30,6 @@ import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.ThreeState;
import com.intellij.util.containers.ConcurrentSoftHashMap;
import com.intellij.util.containers.ConcurrentSoftValueHashMap;
@@ -72,33 +71,28 @@ public class BaseExternalAnnotationsManager extends ExternalAnnotationsManager {
@Nullable
protected static String getNormalizedExternalName(@NotNull PsiModifierListOwner owner) {
String externalName = getExternalName(owner, true);
if (externalName != null) {
if (owner instanceof PsiParameter && owner.getParent() instanceof PsiParameterList) {
final PsiMethod method = PsiTreeUtil.getParentOfType(owner, PsiMethod.class);
if (method != null) {
externalName =
externalName.substring(0, externalName.lastIndexOf(' ') + 1) + method.getParameterList().getParameterIndex((PsiParameter)owner);
}
}
final int idx = externalName.indexOf('(');
if (idx == -1) return externalName;
final StringBuilder buf = StringBuilderSpinAllocator.alloc();
try {
final int rightIdx = externalName.indexOf(')');
final String[] params = externalName.substring(idx + 1, rightIdx).split(",");
buf.append(externalName.substring(0, idx + 1));
for (String param : params) {
param = param.trim();
final int spaceIdx = param.indexOf(' ');
buf.append(spaceIdx > -1 ? param.substring(0, spaceIdx) : param).append(", ");
}
return StringUtil.trimEnd(buf.toString(), ", ") + externalName.substring(rightIdx);
}
finally {
StringBuilderSpinAllocator.dispose(buf);
if (externalName == null) {
return null;
}
if (owner instanceof PsiParameter && owner.getParent() instanceof PsiParameterList) {
final PsiMethod method = PsiTreeUtil.getParentOfType(owner, PsiMethod.class);
if (method != null) {
externalName =
externalName.substring(0, externalName.lastIndexOf(' ') + 1) + method.getParameterList().getParameterIndex((PsiParameter)owner);
}
}
return externalName;
final int idx = externalName.indexOf('(');
if (idx == -1) return externalName;
StringBuilder buf = new StringBuilder();
int rightIdx = externalName.indexOf(')');
String[] params = externalName.substring(idx + 1, rightIdx).split(",");
buf.append(externalName.substring(0, idx + 1));
for (String param : params) {
param = param.trim();
final int spaceIdx = param.indexOf(' ');
buf.append(spaceIdx > -1 ? param.substring(0, spaceIdx) : param).append(", ");
}
return StringUtil.trimEnd(buf.toString(), ", ") + externalName.substring(rightIdx);
}
protected boolean hasAnyAnnotationsRoots() {
@@ -151,56 +145,54 @@ public class BaseExternalAnnotationsManager extends ExternalAnnotationsManager {
return map;
}
private static final MultiMap<String, AnnotationData> EMPTY = new MultiMap<String, AnnotationData>();
private ConcurrentMap<PsiFile, Pair<MultiMap<String, AnnotationData>, Long>> annotationsFileToDataAndModificationStamp = new ConcurrentSoftHashMap<PsiFile, Pair<MultiMap<String, AnnotationData>, Long>>();
private final ConcurrentMap<PsiFile, Pair<MultiMap<String, AnnotationData>, Long>> annotationsFileToDataAndModificationStamp = new ConcurrentSoftHashMap<PsiFile, Pair<MultiMap<String, AnnotationData>, Long>>();
@NotNull
private MultiMap<String, AnnotationData> getDataFromFile(@NotNull PsiFile file) {
Pair<MultiMap<String, AnnotationData>, Long> cached = annotationsFileToDataAndModificationStamp.get(file);
if (cached != null && cached.getSecond() == file.getModificationStamp()) {
return cached.getFirst();
}
Document document;
MultiMap<String, AnnotationData> data = new MultiMap<String, AnnotationData>();
try {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) return EMPTY;
document = JDOMUtil.loadDocument(escapeAttributes(StreamUtil.readText(virtualFile.getInputStream())));
if (virtualFile != null) {
Document document = JDOMUtil.loadDocument(escapeAttributes(StreamUtil.readText(virtualFile.getInputStream())));
Element rootElement = document.getRootElement();
if (rootElement != null) {
//noinspection unchecked
for (Element element : (List<Element>) rootElement.getChildren()) {
String ownerName = element.getAttributeValue("name");
if (ownerName == null) continue;
//noinspection unchecked
for (Element annotationElement : (List<Element>) element.getChildren()) {
String annotationFQN = annotationElement.getAttributeValue("name");
if (StringUtil.isEmpty(annotationFQN)) continue;
StringBuilder buf = new StringBuilder();
//noinspection unchecked
for (Element annotationParameter : (List<Element>) annotationElement.getChildren()) {
buf.append(",");
String nameValue = annotationParameter.getAttributeValue("name");
if (nameValue != null) {
buf.append(nameValue).append("=");
}
buf.append(annotationParameter.getAttributeValue("val"));
}
String annotationText = "@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : "");
data.putValue(ownerName, new AnnotationData(annotationFQN, annotationText));
}
}
}
}
}
catch (IOException e) {
LOG.error(e);
return EMPTY;
}
catch (JDOMException e) {
LOG.error(e);
return EMPTY;
}
Element rootElement = document.getRootElement();
if (rootElement == null) return EMPTY;
MultiMap<String, AnnotationData> data = new MultiMap<String, AnnotationData>();
//noinspection unchecked
for (Element element : (List<Element>) rootElement.getChildren()) {
String ownerName = element.getAttributeValue("name");
if (ownerName == null) continue;
//noinspection unchecked
for (Element annotationElement : (List<Element>) element.getChildren()) {
String annotationFQN = annotationElement.getAttributeValue("name");
if (StringUtil.isEmpty(annotationFQN)) continue;
StringBuilder buf = new StringBuilder();
//noinspection unchecked
for (Element annotationParameter : (List<Element>) annotationElement.getChildren()) {
buf.append(",");
String nameValue = annotationParameter.getAttributeValue("name");
if (nameValue != null) {
buf.append(nameValue).append("=");
}
buf.append(annotationParameter.getAttributeValue("val"));
}
String annotationText = "@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : "");
data.putValue(ownerName, new AnnotationData(annotationFQN, annotationText));
}
if (data.isEmpty()) {
data = MultiMap.emptyInstance();
}
Pair<MultiMap<String, AnnotationData>, Long> pair = Pair.create(data, file.getModificationStamp());
pair = ConcurrencyUtil.cacheOrGet(annotationsFileToDataAndModificationStamp, file, pair);
data = pair.first;
@@ -37,7 +37,7 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ui.configuration.actions.ModuleDeleteProvider;
import com.intellij.openapi.ui.Queryable;
@@ -47,7 +47,7 @@ import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ToolWindowManager;
@@ -105,7 +105,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
private boolean myDisposed = false;
private RelativePoint myLocationCache;
public NavBarPanel(final Project project, boolean docked) {
public NavBarPanel(@NotNull Project project, boolean docked) {
super(new FlowLayout(FlowLayout.LEFT, 0 , 0));
myProject = project;
myModel = createModel();
@@ -119,6 +119,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
setBorder(new LineBorder(Gray._120, 1));
}
myCopyPasteDelegator = new CopyPasteDelegator(myProject, NavBarPanel.this) {
@Override
@NotNull
protected PsiElement[] getSelectedElements() {
final PsiElement element = getSelectedElement(PsiElement.class);
@@ -251,10 +252,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
}
boolean isSelectedInPopup(Object object) {
if (isNodePopupActive()) {
return Arrays.asList(myNodePopup.getSelectedValues()).contains(object);
}
return false;
return isNodePopupActive() && Arrays.asList(myNodePopup.getSelectedValues()).contains(object);
}
static Object optimizeTarget(Object target) {
@@ -393,12 +391,14 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
//installDnD(index, component);
ListenerUtil.addMouseListener(component, new MouseAdapter() {
@Override
public void mouseReleased(final MouseEvent e) {
if (SystemInfo.isWindows) {
click(e);
}
}
@Override
public void mousePressed(final MouseEvent e) {
if (!SystemInfo.isWindows) {
click(e);
@@ -532,6 +532,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
myUpdateQueue.queueRebuildUi();
myUpdateQueue.queueAfterAll(new Runnable() {
@Override
public void run() {
int index = myModel.indexOf(obj);
if (index >= 0) {
@@ -587,6 +588,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
}
}
@Override
@Nullable
public Object getData(String dataId) {
if (PlatformDataKeys.PROJECT.is(dataId)) {
@@ -597,7 +599,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
if (module != null && !module.isDisposed()) return module;
final PsiElement element = getSelectedElement(PsiElement.class);
if (element != null) {
return ModuleUtil.findModuleForPsiElement(element);
return ModuleUtilCore.findModuleForPsiElement(element);
}
return null;
}
@@ -606,7 +608,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
if (directory != null) {
final VirtualFile dir = directory.getVirtualFile();
if (ProjectRootsUtil.isModuleContentRoot(dir, myProject)) {
return ModuleUtil.findModuleForPsiElement(directory);
return ModuleUtilCore.findModuleForPsiElement(directory);
}
}
return null;
@@ -642,7 +644,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
files.add(((PsiFileSystemItem)element).getVirtualFile());
}
}
return files.size() > 0 ? VfsUtil.toVirtualFileArray(files) : null;
return !files.isEmpty() ? VfsUtilCore.toVirtualFileArray(files) : null;
}
if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
@@ -712,6 +714,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
}
@Override
public Point getBestPopupPosition() {
int index = myModel.getSelectedIndex();
final int modelSize = myModel.size();
@@ -727,11 +730,13 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
return null;
}
@Override
public void addNotify() {
super.addNotify();
NavBarListener.subscribeTo(this);
}
@Override
public void removeNotify() {
super.removeNotify();
Disposer.dispose(this);
@@ -754,6 +759,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
panel.setBackground(UIUtil.isUnderGTKLookAndFeel() ? Color.WHITE : UIUtil.getListBackground());
myHint = new LightweightHint(panel) {
@Override
public void hide() {
super.hide();
cancelPopup();
@@ -25,7 +25,7 @@ public class CaretEvent extends EventObject {
private final LogicalPosition myOldPosition;
private final LogicalPosition myNewPosition;
public CaretEvent(@NotNull Editor editor, LogicalPosition oldPosition, LogicalPosition newPosition) {
public CaretEvent(@NotNull Editor editor, @NotNull LogicalPosition oldPosition, @NotNull LogicalPosition newPosition) {
super(editor);
myOldPosition = oldPosition;
myNewPosition = newPosition;
@@ -36,10 +36,12 @@ public class CaretEvent extends EventObject {
return (Editor) getSource();
}
@NotNull
public LogicalPosition getOldPosition() {
return myOldPosition;
}
@NotNull
public LogicalPosition getNewPosition() {
return myNewPosition;
}
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.IdeaLoggingEvent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ExceptionUtil;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -132,7 +133,7 @@ public class LogMessageEx extends LogMessage {
};
}
public static void error(@NotNull Logger logger, @NotNull String message, @NotNull String... attachmentText) {
public static void error(@NotNull Logger logger, @NonNls @NotNull String message, @NotNull String... attachmentText) {
error(logger, message, new Throwable(), attachmentText);
}
@@ -43,9 +43,10 @@ import com.intellij.openapi.editor.impl.event.DocumentEventImpl;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapHelper;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.EventDispatcher;
import com.intellij.util.diff.FilesTooBigForDiffException;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -53,12 +54,10 @@ import java.awt.*;
import java.util.List;
public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.CaretModelImpl");
private final EditorImpl myEditor;
private final List<CaretListener> myCaretListeners = ContainerUtil.createEmptyCOWList();
private final EventDispatcher<CaretListener> myCaretListeners = EventDispatcher.create(CaretListener.class);
private LogicalPosition myLogicalCaret;
private VerticalInfo myCaretInfo;
private VisualPosition myVisibleCaret;
@@ -114,6 +113,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
if (doc != myEditor.getDocument() || myOffset >= doc.getTextLength() || savedBeforeBulkCaretMarker != null) return;
savedBeforeBulkCaretMarker = doc.createRangeMarker(myOffset, myOffset);
}
@Override
public void updateFinished(@NotNull Document doc) {
if (doc != myEditor.getDocument() || myIsInUpdate) return;
@@ -193,12 +193,9 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
myEditor.updateCaretCursor();
requestRepaint(oldInfo);
if (oldPosition.column != myLogicalCaret.column || oldPosition.line != myLogicalCaret.line) {
if (!oldPosition.equals(myLogicalCaret)) {
CaretEvent event = new CaretEvent(myEditor, oldPosition, myLogicalCaret);
for (CaretListener listener : myCaretListeners) {
listener.caretPositionChanged(event);
}
myCaretListeners.getMulticaster().caretPositionChanged(event);
}
}
@@ -219,11 +216,11 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
return;
}
final LogicalPosition logicalPosition = myEditor.offsetToLogicalPosition(offset);
final CaretEvent event = moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, null, true);
CaretEvent event = moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, null, false);
final LogicalPosition positionByOffsetAfterMove = myEditor.offsetToLogicalPosition(myOffset);
if (!myIgnoreWrongMoves && !positionByOffsetAfterMove.equals(logicalPosition)) {
StringBuilder debugBuffer = new StringBuilder();
moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, debugBuffer, false);
moveToLogicalPosition(logicalPosition, locateBeforeSoftWrap, debugBuffer, true);
int textStart = Math.max(0, Math.min(offset, myOffset) - 1);
final DocumentEx document = myEditor.getDocument();
int textEnd = Math.min(document.getTextLength() - 1, Math.max(offset, myOffset) + 1);
@@ -237,12 +234,10 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
+ "interested text [%d;%d): '%s'%n debug trace: %s%nLogical position -> offset ('%s'->'%d') trace: %s",
offset, logicalPosition, myOffset, myLogicalCaret, positionByOffsetAfterMove, myEditor.dumpState(),
textStart, textEnd, text, debugBuffer, logicalPosition, inverseOffset, positionToOffsetTrace
));
));
}
if (event != null) {
for (CaretListener listener : myCaretListeners) {
listener.caretPositionChanged(event);
}
myCaretListeners.getMulticaster().caretPositionChanged(event);
EditorActionUtil.selectNonexpandableFold(myEditor);
}
}
@@ -256,8 +251,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
int lineShift,
boolean withSelection,
boolean blockSelection,
boolean scrollToCaret)
{
boolean scrollToCaret) {
assertIsDispatchThread();
if (mySkipChangeRequests) {
return;
@@ -399,7 +393,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
if (scrollToCaret) {
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
if (desiredX >= 0) {
myDesiredX = desiredX;
}
@@ -409,14 +403,14 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
@Override
public void moveToLogicalPosition(@NotNull LogicalPosition pos) {
moveToLogicalPosition(pos, false, null, false);
moveToLogicalPosition(pos, false, null, true);
}
@Nullable
private CaretEvent moveToLogicalPosition(@NotNull LogicalPosition pos,
boolean locateBeforeSoftWrap,
@Nullable StringBuilder debugBuffer,
boolean delayListenersNotification) {
boolean fireListeners) {
if (mySkipChangeRequests) {
return null;
}
@@ -425,7 +419,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
}
myReportCaretMoves = true;
try {
return doMoveToLogicalPosition(pos, locateBeforeSoftWrap, debugBuffer, delayListenersNotification);
return doMoveToLogicalPosition(pos, locateBeforeSoftWrap, debugBuffer, fireListeners);
}
finally {
myReportCaretMoves = false;
@@ -434,14 +428,11 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
private CaretEvent doMoveToLogicalPosition(@NotNull LogicalPosition pos,
boolean locateBeforeSoftWrap,
@Nullable StringBuilder debugBuffer,
boolean delayListenersNotification)
{
@NonNls @Nullable StringBuilder debugBuffer,
boolean fireListeners) {
assertIsDispatchThread();
if (debugBuffer != null) {
debugBuffer.append(String.format(
"Start moveToLogicalPosition(). Locate before soft wrap: %b, position: %s%n", locateBeforeSoftWrap, pos
));
debugBuffer.append("Start moveToLogicalPosition(). Locate before soft wrap: " + locateBeforeSoftWrap + ", position: " + pos + "\n");
}
myDesiredX = -1;
validateCallContext();
@@ -478,9 +469,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
}
else if (line > lineCount - 1) {
if (debugBuffer != null) {
debugBuffer.append(String.format(
"Resetting target logical line (%d) to %d as it is greater than total document lines number%n", line, lineCount - 1
));
debugBuffer.append("Resetting target logical line (" + line + ") to " + (lineCount - 1) + " as it is greater than total document lines number\n");
}
line = lineCount - 1;
softWrapLinesBefore = 0;
@@ -500,11 +489,10 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
softWrapColumns -= column - lineEndColumnNumber;
}
if (debugBuffer != null) {
debugBuffer.append(String.format(
"Resetting target logical column (%d) to %d because caret is not allowed to be located after line end (offset: %d, "
+ "logical position: %s). Current soft wrap columns value: %d%n",
oldColumn, lineEndColumnNumber, lineEndOffset, endLinePosition, softWrapColumns
));
debugBuffer.append(
"Resetting target logical column (" + oldColumn + ") to " + lineEndColumnNumber +
" because caret is not allowed to be located after line end (offset: " +lineEndOffset + ", "
+ "logical position: " + endLinePosition+ "). Current soft wrap columns value: " + softWrapColumns+ "\n");
}
}
}
@@ -526,7 +514,8 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
setCurrentLogicalCaret(logicalPositionToUse);
final int offset = myEditor.logicalPositionToOffset(myLogicalCaret);
if (debugBuffer != null) {
debugBuffer.append(String.format("Resulting logical position to use: %s. It's mapped to offset %d%n", myLogicalCaret, offset));
debugBuffer.append("Resulting logical position to use: " + myLogicalCaret+
". It's mapped to offset " + offset+ "\n");
}
FoldRegion collapsedAt = myEditor.getFoldingModel().getCollapsedRegionAtOffset(offset);
@@ -559,7 +548,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
myOffset = myEditor.logicalPositionToOffset(myLogicalCaret);
if (debugBuffer != null) {
debugBuffer.append(String.format("Storing offset %d (mapped from logical position %s)%n", myOffset, myLogicalCaret));
debugBuffer.append("Storing offset " + myOffset + " (mapped from logical position " + myLogicalCaret + ")\n");
}
LOG.assertTrue(myOffset >= 0 && myOffset <= myEditor.getDocument().getTextLength());
@@ -574,9 +563,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
if (lineToUse >= 0) {
final VisualPosition visualPosition = new VisualPosition(lineToUse, EditorUtil.getLastVisualLineColumnNumber(myEditor, lineToUse));
if (debugBuffer != null) {
debugBuffer.append(String.format(
"Adjusting caret position by moving it before soft wrap. Moving to visual position %s%n", visualPosition
));
debugBuffer.append("Adjusting caret position by moving it before soft wrap. Moving to visual position "+ visualPosition+"\n");
}
final LogicalPosition logicalPosition = myEditor.visualToLogicalPosition(visualPosition);
final int tmpOffset = myEditor.logicalPositionToOffset(logicalPosition);
@@ -597,19 +584,16 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
+ "State: %s", visualPosition, myOffset, logicalPosition, tmpOffset, myEditor.dumpState()
));
}
}
}
if (!oldCaretPosition.toVisualPosition().equals(myLogicalCaret.toVisualPosition())) {
CaretEvent event = new CaretEvent(myEditor, oldCaretPosition, myLogicalCaret);
if (delayListenersNotification) {
return event;
if (fireListeners) {
myCaretListeners.getMulticaster().caretPositionChanged(event);
}
else {
for (CaretListener listener : myCaretListeners) {
listener.caretPositionChanged(event);
}
return event;
}
}
return null;
@@ -677,13 +661,12 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
@Override
public void addCaretListener(@NotNull CaretListener listener) {
myCaretListeners.add(listener);
myCaretListeners.addListener(listener);
}
@Override
public void removeCaretListener(@NotNull CaretListener listener) {
boolean success = myCaretListeners.remove(listener);
LOG.assertTrue(success);
myCaretListeners.removeListener(listener);
}
@Override
@@ -707,9 +690,9 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
DocumentEventImpl event = (DocumentEventImpl)e;
final DocumentEx document = myEditor.getDocument();
boolean performSoftWrapAdjustment = e.getNewLength() > 0 // We want to put caret just after the last added symbol
// There is a possible case that the user removes text just before the soft wrap. We want to keep caret
// on a visual line with soft wrap start then.
|| myEditor.getSoftWrapModel().getSoftWrap(e.getOffset()) != null;
// There is a possible case that the user removes text just before the soft wrap. We want to keep caret
// on a visual line with soft wrap start then.
|| myEditor.getSoftWrapModel().getSoftWrap(e.getOffset()) != null;
if (event.isWholeTextReplaced()) {
int newLength = document.getTextLength();
@@ -719,7 +702,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
else {
try {
final int line = event.translateLineViaDiff(myLogicalCaret.line);
moveToLogicalPosition(new LogicalPosition(line, myLogicalCaret.column), performSoftWrapAdjustment, null, false);
moveToLogicalPosition(new LogicalPosition(line, myLogicalCaret.column), performSoftWrapAdjustment, null, true);
}
catch (FilesTooBigForDiffException e1) {
LOG.info(e1);
@@ -744,7 +727,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
newOffset = Math.min(newOffset, document.getTextLength());
// if (newOffset != myOffset) {
moveToOffset(newOffset, performSoftWrapAdjustment);
moveToOffset(newOffset, performSoftWrapAdjustment);
//}
//else {
// moveToVisualPosition(oldPosition);
@@ -760,9 +743,9 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
}
private boolean needToShiftWhiteSpaces(final DocumentEvent e) {
if(!CharArrayUtil.containsOnlyWhiteSpaces(e.getNewFragment()) || CharArrayUtil.containLineBreaks(e.getNewFragment()))
if (!CharArrayUtil.containsOnlyWhiteSpaces(e.getNewFragment()) || CharArrayUtil.containLineBreaks(e.getNewFragment()))
return e.getOldLength() > 0;
if(e.getOffset() == 0) return false;
if (e.getOffset() == 0) return false;
final char charBefore = myEditor.getDocument().getCharsSequence().charAt(e.getOffset() - 1);
//final char charAfter = myEditor.getDocument().getCharsSequence().charAt(e.getOffset() + e.getNewLength());
return Character.isWhitespace(charBefore)/* || !Character.isWhitespace(charAfter)*/;
@@ -3262,10 +3262,11 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
int lineHeight = myLineHeight;
if (lineHeight == -1) {
FontMetrics fontMetrics = myEditorComponent.getFontMetrics(myScheme.getFont(EditorFontType.PLAIN));
lineHeight = (int)(fontMetrics.getHeight() * (isOneLineMode() ? 1 : myScheme.getLineSpacing()));
if (lineHeight == 0) {
lineHeight = fontMetrics.getHeight();
if (lineHeight == 0) {
int fontMetricsHeight = fontMetrics.getHeight();
lineHeight = (int)(fontMetricsHeight * (isOneLineMode() ? 1 : myScheme.getLineSpacing()));
if (lineHeight <= 0) {
lineHeight = fontMetricsHeight;
if (lineHeight <= 0) {
lineHeight = 12;
}
}
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.TestOnly;
public abstract class DirectoryIndex {
public static DirectoryIndex getInstance(Project project) {
assert !project.isDefault() : "Must not call DirectoryIndex for default project";
return ServiceManager.getService(project, DirectoryIndex.class);
}
@@ -99,9 +99,15 @@ public class UsageInfo2UsageAdapter implements UsageInModule,
lineNumber = -1;
}
else {
offset = -1;
int startOffset = myUsageInfo.getNavigationOffset();
lineNumber = getLineNumber(document, startOffset);
if (startOffset == -1) {
offset = element == null ? 0 : element.getTextOffset();
lineNumber = -1;
}
else {
offset = -1;
lineNumber = getLineNumber(document, startOffset);
}
}
return Pair.create(offset, lineNumber);
}
@@ -219,7 +219,11 @@ public abstract class ProcessHandler extends UserDataHolderBase {
}
private boolean isCanceledException(Throwable e) {
return e instanceof InvocationTargetException && e.getCause() instanceof ProcessCanceledException;
final boolean value = e instanceof InvocationTargetException && e.getCause() instanceof ProcessCanceledException;
if (value) {
LOG.info(e);
}
return value;
}
private final class TasksRunner extends ProcessAdapter {
@@ -51,11 +51,10 @@ public class LimitHistoryCheck {
public void checkNumber() {
if (myLimit <= 0) return;
++ myCnt;
if (myCnt >= myLimit) {
if (isOver()) {
if (! myWarningShown) {
VcsBalloonProblemNotifier.showOverChangesView(myProject, "History loading for file " + myFilePath +
"\nwas interrupted. Only " + myLimit + " rows were loaded (allowed maximum).\n" +
"To change the history limit setting, go to Version Control settings.", MessageType.WARNING);
VcsBalloonProblemNotifier.showOverChangesView(myProject, "File History: only " + myLimit + " revisions were loaded for " + myFilePath +
"\nTo change the history limit, go to Settings | Version Control.", MessageType.WARNING);
myWarningShown = true;
}
throw new ProcessCanceledException();
@@ -67,6 +66,6 @@ public class LimitHistoryCheck {
}
public boolean isOver() {
return myLimit > 0 && myLimit <= myCnt;
return myLimit > 0 && myLimit < myCnt;
}
}
@@ -140,13 +140,10 @@ public class VcsHistoryProviderBackgroundableProxy {
if (full != null) {
if (myConfiguration.LIMIT_HISTORY) {
if (myConfiguration.MAXIMUM_HISTORY_ROWS < full.getRevisionList().size()) {
if (myConfiguration.MAXIMUM_HISTORY_ROWS < 2000) {
full = (VcsAbstractHistorySession) full.copy();
}
final List<VcsFileRevision> list = full.getRevisionList();
final List<VcsFileRevision> part = new ArrayList<VcsFileRevision>(list.subList(0, myConfiguration.MAXIMUM_HISTORY_ROWS));
final List<VcsFileRevision> was = new ArrayList<VcsFileRevision>(list.subList(0, myConfiguration.MAXIMUM_HISTORY_ROWS));
list.clear();
list.addAll(part);
list.addAll(was);
}
}
}
@@ -17,6 +17,7 @@ package org.jetbrains.android.dom;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.impl.DirectoryIndex;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiFile;
@@ -43,7 +44,8 @@ public class AndroidXmlExtension extends DefaultXmlExtension {
@Override
public boolean isAvailable(final PsiFile file) {
if (file instanceof XmlFile) {
if (!DirectoryIndex.getInstance(file.getProject()).isInitialized()) {
Project project = file.getProject();
if (!project.isDefault() && !DirectoryIndex.getInstance(project).isInitialized()) {
return false;
}
@@ -15,6 +15,7 @@
*/
package git4idea;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsException;
@@ -47,6 +48,8 @@ public class GitRevisionNumber implements ShortVcsRevisionNumber {
*/
@NotNull private final Date myTimestamp;
private static final Logger LOG = Logger.getInstance(GitRevisionNumber.class);
/**
* A constructor from version. The current date is used.
*
@@ -217,7 +220,7 @@ public class GitRevisionNumber implements ShortVcsRevisionNumber {
@NotNull
public static GitRevisionNumber parseRevlistOutputAsRevisionNumber(@NotNull GitSimpleHandler h, @NotNull String output) {
StringTokenizer tokenizer = new StringTokenizer(output, "\n\r \t", false);
assert tokenizer.hasMoreTokens() : "No required tokens in the output: \n" + output;
LOG.assertTrue(tokenizer.hasMoreTokens(), "No required tokens in the output: \n" + output);
Date timestamp = GitUtil.parseTimestampWithNFEReport(tokenizer.nextToken(), h, output);
return new GitRevisionNumber(tokenizer.nextToken(), timestamp);
}
@@ -21,7 +21,6 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.annotate.ShowAllAffectedGenericAction;
import com.intellij.openapi.vcs.changes.Change;
@@ -505,7 +504,6 @@ public class SvnHistoryProvider
final ThrowableConsumer<VcsFileRevision, SVNException> result,
SVNURL repoRootURL, Charset charset)
throws SVNException, VcsException {
final VcsConfiguration configuration = VcsConfiguration.getInstance(vcs.getProject());
myVcs = vcs;
myLastPathCorrector = new SvnPathThroughHistoryCorrection(lastPath);
myCharset = charset;