Use WIP preview to compute object presentation

This commit is contained in:
Vladimir Krivosheev
2017-03-20 17:14:35 +01:00
parent b7abd825fe
commit 1c961b06db
5 changed files with 32 additions and 213 deletions
@@ -31,8 +31,7 @@ inline fun <T> runUndoTransparentWriteAction(crossinline runnable: () -> T): T {
return result as T
}
inline fun <T> runReadAction(crossinline runnable: () -> T): T = ApplicationManager.getApplication().runReadAction(
Computable { runnable() })
inline fun <T> runReadAction(crossinline runnable: () -> T): T = ApplicationManager.getApplication().runReadAction(Computable { runnable() })
/**
* @exclude Internal use only
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.debugger.values
/**
@@ -10,4 +25,4 @@ interface Value {
* @return a string representation of this value
*/
val valueString: String?
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,4 +48,8 @@ open class BasicDebuggerViewSupport : MemberFilter, DebuggerViewSupport {
node.addChildren(XValueChildrenList.EMPTY, true)
}
}
}
interface PresentationProvider {
fun computePresentation(node: XValueNode, icon: Icon): Boolean
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -463,16 +463,18 @@ fun getObjectValueDescription(value: ObjectValue): String {
}
internal fun trimFunctionDescription(value: Value): String {
val presentableValue = value.valueString ?: return ""
return trimFunctionDescription(value.valueString ?: return "")
}
fun trimFunctionDescription(value: String): String {
var endIndex = 0
while (endIndex < presentableValue.length && !StringUtil.isLineBreak(presentableValue[endIndex])) {
while (endIndex < value.length && !StringUtil.isLineBreak(value[endIndex])) {
endIndex++
}
while (endIndex > 0 && Character.isWhitespace(presentableValue[endIndex - 1])) {
while (endIndex > 0 && Character.isWhitespace(value[endIndex - 1])) {
endIndex--
}
return presentableValue.substring(0, endIndex)
return value.substring(0, endIndex)
}
private fun createNumberPresentation(value: String): XValuePresentation {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,27 +15,13 @@
*/
package com.intellij.mock;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.editor.event.DocumentListener;
import com.intellij.openapi.editor.ex.DocumentEx;
import com.intellij.openapi.editor.ex.EditReadOnlyListener;
import com.intellij.openapi.editor.ex.LineIterator;
import com.intellij.openapi.editor.ex.RangeMarkerEx;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.editor.StandaloneDocumentEx;
import com.intellij.openapi.util.TextRange;
import com.intellij.util.LocalTimeCounter;
import com.intellij.util.Processor;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
import java.beans.PropertyChangeListener;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class MockDocument implements DocumentEx {
private final Map myUserData = new HashMap();
public class MockDocument extends StandaloneDocumentEx {
private StringBuffer myText = new StringBuffer();
private long myModStamp = LocalTimeCounter.currentTime();
@@ -71,18 +57,6 @@ public class MockDocument implements DocumentEx {
return getText().toCharArray();
}
@Override
@NotNull
public CharSequence getCharsSequence() {
return getText();
}
@NotNull
@Override
public CharSequence getImmutableCharSequence() {
return getText();
}
@Override
public int getTextLength() {
return myText.length();
@@ -124,204 +98,29 @@ public class MockDocument implements DocumentEx {
myModStamp = LocalTimeCounter.currentTime();
}
@Override
public void moveText(int srcStart, int srcEnd, int dstOffset) {
// TODO den implement
throw new UnsupportedOperationException();
}
@Override
public boolean isWritable() {
return false;
}
@Override
public long getModificationStamp() {
return myModStamp;
}
@Override
public void fireReadOnlyModificationAttempt() {
}
@Override
public void addDocumentListener(@NotNull DocumentListener listener) {
}
@Override
public void addDocumentListener(@NotNull DocumentListener listener, @NotNull Disposable parentDisposable) {
}
@Override
public void removeDocumentListener(@NotNull DocumentListener listener) {
}
@Override
@NotNull
public RangeMarker createRangeMarker(int startOffset, int endOffset) {
throw new UnsupportedOperationException();
}
@Override
@NotNull
public RangeMarker createRangeMarker(int startOffset, int endOffset, boolean surviveOnExternalChange) {
throw new UnsupportedOperationException();
}
@Override
public void addPropertyChangeListener(@NotNull PropertyChangeListener listener) {
}
@Override
public void removePropertyChangeListener(@NotNull PropertyChangeListener listener) {
}
@Override
@SuppressWarnings("unchecked")
public <T> T getUserData(@NotNull Key<T> key) {
return (T)myUserData.get(key);
}
@Override
@SuppressWarnings("unchecked")
public <T> void putUserData(@NotNull Key<T> key, T value) {
myUserData.put(key, value);
}
@Override
public void setStripTrailingSpacesEnabled(boolean isEnabled) {
}
@Override
public int getLineSeparatorLength(int line) {
return 0;
}
@Override
@NotNull
public LineIterator createLineIterator() {
throw new UnsupportedOperationException();
}
@Override
public void setModificationStamp(long modificationStamp) {
myModStamp = modificationStamp;
}
@Override
public void setReadOnly(boolean isReadOnly) {
}
@Override
public RangeMarker getRangeGuard(int start, int end) {
return null;
}
@Override
public void startGuardedBlockChecking() {
}
@Override
public void stopGuardedBlockChecking() {
}
@Override
@NotNull
public RangeMarker createGuardedBlock(int startOffset, int endOffset) {
throw new UnsupportedOperationException();
}
@Override
public void removeGuardedBlock(@NotNull RangeMarker block) {
}
@Override
public RangeMarker getOffsetGuard(int offset) {
return null;
}
@Override
public void addEditReadOnlyListener(@NotNull EditReadOnlyListener listener) {
}
@Override
public void removeEditReadOnlyListener(@NotNull EditReadOnlyListener listener) {
}
@Override
public void suppressGuardedExceptions() {
}
@Override
public void unSuppressGuardedExceptions() {
}
@Override
public boolean isInEventsHandling() {
return false;
}
@Override
public void clearLineModificationFlags() {
}
@Override
public boolean removeRangeMarker(@NotNull RangeMarkerEx rangeMarker) {
return false;
}
@Override
public void registerRangeMarker(@NotNull RangeMarkerEx rangeMarker,
int start,
int end,
boolean greedyToLeft,
boolean greedyToRight,
int layer) {
}
@Override
public boolean isInBulkUpdate() {
return false;
}
@Override
public void setInBulkUpdate(boolean value) {
}
@Override
public void setCyclicBufferSize(int bufferSize) {
}
@Override
public void setText(@NotNull final CharSequence text) {
}
@Override
@NotNull
public RangeMarker createRangeMarker(@NotNull final TextRange textRange) {
return createRangeMarker(textRange.getStartOffset(), textRange.getEndOffset());
}
@Override
@NotNull
public List<RangeMarker> getGuardedBlocks() {
return Collections.emptyList();
}
@Override
public boolean processRangeMarkers(@NotNull Processor<? super RangeMarker> processor) {
return false;
}
@Override
public boolean processRangeMarkersOverlappingWith(int start, int end, @NotNull Processor<? super RangeMarker> processor) {
return false;
}
@Override
public int getModificationSequence() {
return 0;
}
}