EA-35269 - assert: EditorUtil.calcColumnNumber

It looks like the document has incorrect data (line feed symbol inside the line range). Debug info has been added
This commit is contained in:
Denis.Zhdanov
2012-04-10 08:08:55 +04:00
parent b5165da3b5
commit 3de716a0dd
8 changed files with 92 additions and 21 deletions
@@ -0,0 +1,28 @@
/*
* Copyright 2000-2012 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.diagnostic;
import org.jetbrains.annotations.NotNull;
/**
* @author Denis Zhdanov
* @since 4/9/12 2:10 PM
*/
public interface Dumpable {
@NotNull
String dumpState();
}
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.editor.impl;
import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.util.ArrayUtil;
@@ -37,7 +38,7 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* @author cdr
*/
abstract class CharArray implements CharSequenceBackedByArray {
abstract class CharArray implements CharSequenceBackedByArray, Dumpable {
private static final Logger LOG = Logger.getInstance("#" + CharArray.class.getName());
@SuppressWarnings("UseOfArchaicSystemPropertyAccessors")
@@ -669,7 +670,7 @@ abstract class CharArray implements CharSequenceBackedByArray {
@NonNls
@NotNull
private String dumpState() {
public String dumpState() {
return "deferred changes mode: " + isDeferredChangeMode()+", length: " + length()+" (data array length: " + myCount+
", deferred shift: " + myDeferredShift+"); view offsets: [" + myStart+"; "+myCount+"]; deferred changes: "+myDeferredChangesStorage;
}
@@ -15,6 +15,8 @@
*/
package com.intellij.openapi.editor.ex.util;
import com.intellij.diagnostic.Dumpable;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.diagnostic.Logger;
@@ -398,10 +400,20 @@ public class EditorUtil {
char c = text.charAt(i);
if (c == '\n' || c == '\r') {
String editorInfo = editor instanceof EditorImpl ? ". Editor info: " + ((EditorImpl)editor).dumpState() : "";
LOG.error(String.format(
"Symbol: '%c', its index: %d, given start: %d, given offset: %d, given tab size: %d. Text holder class: %s%s",
c, i, start, offset, tabSize, text.getClass(), editorInfo
));
String documentInfo;
if (text instanceof Dumpable) {
documentInfo = ((Dumpable)text).dumpState();
}
else {
documentInfo = "Text holder class: " + text.getClass();
}
LogMessageEx.error(
LOG, "detected incorrect offset -> column number calculation",
String.format(
"Symbol: '%c', its index: %d, given start: %d, given offset: %d, given tab size: %d. %s%s",
c, i, start, offset, tabSize, documentInfo, editorInfo
)
);
}
if (c == '\t') {
shift += getTabLength(i + shift - start, tabSize) - 1;
@@ -22,6 +22,7 @@ import com.intellij.codeInsight.hint.EditorFragmentComponent;
import com.intellij.codeInsight.hint.TooltipController;
import com.intellij.codeInsight.hint.TooltipGroup;
import com.intellij.concurrency.JobScheduler;
import com.intellij.diagnostic.Dumpable;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.ide.*;
import com.intellij.ide.dnd.DnDManager;
@@ -127,7 +128,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public final class EditorImpl extends UserDataHolderBase implements EditorEx, HighlighterClient, Queryable {
public final class EditorImpl extends UserDataHolderBase implements EditorEx, HighlighterClient, Queryable, Dumpable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.EditorImpl");
private static final Key DND_COMMAND_KEY = Key.create("DndCommand");
public static final Key<JComponent> PERMANENT_HEADER = Key.create("PERMANENT_HEADER");
@@ -562,7 +563,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
@Override
@NotNull
public FoldingModelEx getFoldingModel() {
public FoldingModelImpl getFoldingModel() {
return myFoldingModel;
}
@@ -2609,8 +2610,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
+ "', allow caret inside tab: " + mySettings.isCaretInsideTabs()
+ ", allow caret after line end: " + mySettings.isVirtualSpace()
+ ", soft wraps: " + (mySoftWrapModel.isSoftWrappingEnabled() ? "on" : "off")
+ ", soft wraps data: " + getSoftWrapModel()
+ "\n\nfolding data: " + getFoldingModel()
+ ", soft wraps data: " + getSoftWrapModel().dumpState()
+ "\n\nfolding data: " + getFoldingModel().dumpState()
+ "\n\ndocument info: " + myDocument.dumpState();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -24,6 +24,7 @@
*/
package com.intellij.openapi.editor.impl;
import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.FoldRegion;
@@ -46,7 +47,7 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
public class FoldingModelImpl implements FoldingModelEx, PrioritizedDocumentListener {
public class FoldingModelImpl implements FoldingModelEx, PrioritizedDocumentListener, Dumpable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.EditorFoldingModelImpl");
private final Set<FoldingListener> myListeners = new CopyOnWriteArraySet<FoldingListener>();
@@ -526,8 +527,14 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedDocumentList
}
}
@NotNull
@Override
public String toString() {
public String dumpState() {
return Arrays.toString(myFoldTree.fetchTopLevel());
}
@Override
public String toString() {
return dumpState();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 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,6 +15,7 @@
*/
package com.intellij.openapi.editor.impl;
import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -51,7 +52,7 @@ import java.util.List;
* @author Denis Zhdanov
* @since Jun 8, 2010 12:47:32 PM
*/
public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentListener, FoldingListener, PropertyChangeListener {
public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentListener, FoldingListener, PropertyChangeListener, Dumpable {
/**
* Holds name of JVM property which presence should trigger debug-aware soft wraps processing.
@@ -686,9 +687,16 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedDocumentLi
}
}
@NotNull
@Override
public String dumpState() {
return String.format("appliance manager state: %s; soft wraps mapping info: %s",
myApplianceManager.dumpState(), myDataMapper.dumpState());
}
@Override
public String toString() {
return String.format("appliance manager state: %s; soft wraps mapping info: %s", myApplianceManager, myDataMapper);
return dumpState();
}
/**
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.editor.impl.softwrap.mapping;
import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.ex.EditorEx;
@@ -55,7 +56,7 @@ import java.util.List;
* @author Denis Zhdanov
* @since Aug 31, 2010 10:24:47 AM
*/
public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAwareDocumentParsingListener {
public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAwareDocumentParsingListener, Dumpable {
private static final Logger LOG = Logger.getInstance("#" + CachingSoftWrapDataMapper.class.getName());
private static final boolean DEBUG_SOFT_WRAP_PROCESSING = false;
@@ -617,9 +618,15 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
}
}
@NotNull
@Override
public String dumpState() {
return myCache.toString();
}
@Override
public String toString() {
return myCache.toString();
return dumpState();
}
/**
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.editor.impl.softwrap.mapping;
import com.intellij.diagnostic.Dumpable;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.diagnostic.Logger;
@@ -53,7 +54,7 @@ import java.util.List;
* @author Denis Zhdanov
* @since Jul 5, 2010 10:01:27 AM
*/
public class SoftWrapApplianceManager implements SoftWrapFoldingListener, DocumentListener {
public class SoftWrapApplianceManager implements SoftWrapFoldingListener, DocumentListener, Dumpable {
private static final Logger LOG = Logger.getInstance("#" + SoftWrapApplianceManager.class.getName());
@@ -925,15 +926,21 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
public void setWidthProvider(VisibleAreaWidthProvider widthProvider) {
myWidthProvider = widthProvider;
}
@NotNull
@Override
public String toString() {
public String dumpState() {
return String.format(
"recalculation in progress: %b; stored update events: %s; active update events: %s, event being processed: %s",
myInProgress, myEventsStorage, myActiveEvents, myEventBeingProcessed
);
}
@Override
public String toString() {
return dumpState();
}
/**
* We need to use correct indent for soft-wrapped lines, i.e. they should be indented to the start of the logical line.
* This class stores information about logical line start indent.