mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 06:39:38 +07:00
IDEA-352769 T: LocalFileSystemBase.convertToNIOFileAndCheck
GitOrigin-RevId: 9899253e22374bedbc2a60d50deeb1133a2f2faf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
767451f08f
commit
28bd79084b
@@ -2104,14 +2104,14 @@ com.intellij.xdebugger.impl.inline.InlineValuePopupProvider
|
||||
- sf:EP_NAME:com.intellij.openapi.extensions.ExtensionPointName
|
||||
- a:accepts(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl):Z
|
||||
- a:showPopup(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl,com.intellij.xdebugger.XDebugSession,com.intellij.xdebugger.XSourcePosition,com.intellij.xdebugger.impl.evaluate.quick.XDebuggerTreeCreator,com.intellij.openapi.editor.Editor,java.awt.Point,java.lang.Runnable):V
|
||||
c:com.intellij.xdebugger.impl.inline.InlineWatch
|
||||
f:com.intellij.xdebugger.impl.inline.InlineWatch
|
||||
- <init>(com.intellij.xdebugger.XExpression,com.intellij.xdebugger.XSourcePosition):V
|
||||
- getExpression():com.intellij.xdebugger.XExpression
|
||||
- getLine():I
|
||||
- getPosition():com.intellij.xdebugger.XSourcePosition
|
||||
- isValid():Z
|
||||
- setMarker():Z
|
||||
- updatePosition():V
|
||||
- f:getExpression():com.intellij.xdebugger.XExpression
|
||||
- f:getLine():I
|
||||
- f:getPosition():com.intellij.xdebugger.XSourcePosition
|
||||
- f:setMarker():Z
|
||||
- f:setPosition(com.intellij.xdebugger.XSourcePosition):V
|
||||
- f:updatePosition():Z
|
||||
c:com.intellij.xdebugger.impl.inline.InlineWatchInplaceEditor
|
||||
- com.intellij.xdebugger.impl.ui.InplaceEditor
|
||||
- <init>(com.intellij.xdebugger.XSourcePosition,com.intellij.xdebugger.XDebugSession,com.intellij.openapi.editor.Editor):V
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xdebugger.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
@@ -10,10 +9,11 @@ import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.event.DocumentListener;
|
||||
import com.intellij.openapi.editor.event.EditorEventMulticaster;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManagerListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.concurrency.ThreadingAssertions;
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
@@ -40,6 +40,12 @@ public final class XDebuggerWatchesManager {
|
||||
myProject = project;
|
||||
EditorEventMulticaster editorEventMulticaster = EditorFactory.getInstance().getEventMulticaster();
|
||||
editorEventMulticaster.addDocumentListener(new MyDocumentListener(), project);
|
||||
myProject.getMessageBus().connect().subscribe(FileDocumentManagerListener.TOPIC, new FileDocumentManagerListener() {
|
||||
@Override
|
||||
public void fileContentLoaded(@NotNull VirtualFile file, @NotNull Document document) {
|
||||
getDocumentInlines(document).forEach(InlineWatch::setMarker);
|
||||
}
|
||||
});
|
||||
myInlinesUpdateQueue = new MergingUpdateQueue("XInlineWatches", 300, true, null, project);
|
||||
}
|
||||
|
||||
@@ -103,14 +109,13 @@ public final class XDebuggerWatchesManager {
|
||||
inlineWatches.computeIfAbsent(inlineWatchState.getFileUrl(), (k) -> new HashSet<>()).add(watch);
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
List<InlineWatch> allInlines = inlineWatches.values().stream().flatMap(set -> set.stream()).toList();
|
||||
for (InlineWatch i : allInlines) {
|
||||
ReadAction.run(() -> {
|
||||
for (InlineWatch i : ContainerUtil.flatten(inlineWatches.values())) {
|
||||
if (!i.setMarker()) {
|
||||
inlineWatches.get(i.getPosition().getFile().getUrl()).remove(i);
|
||||
}
|
||||
}
|
||||
}, ModalityState.nonModal(), myProject.getDisposed());
|
||||
});
|
||||
}
|
||||
|
||||
public void showInplaceEditor(@NotNull XSourcePosition presentationPosition,
|
||||
@@ -142,9 +147,8 @@ public final class XDebuggerWatchesManager {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
public void addInlineWatchExpression(@NotNull XExpression expression, int index, XSourcePosition position, boolean navigateToWatchNode) {
|
||||
ThreadingAssertions.assertEventDispatchThread();
|
||||
|
||||
InlineWatch watch = new InlineWatch(expression, position);
|
||||
watch.setMarker();
|
||||
String fileUrl = position.getFile().getUrl();
|
||||
@@ -160,8 +164,7 @@ public final class XDebuggerWatchesManager {
|
||||
|
||||
Set<InlineWatch> toRemove = new HashSet<>();
|
||||
for (InlineWatch inlineWatch : inlines) {
|
||||
inlineWatch.updatePosition();
|
||||
if (!inlineWatch.isValid()) {
|
||||
if (!inlineWatch.updatePosition()) {
|
||||
toRemove.add(inlineWatch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +1,57 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.xdebugger.impl.inline;
|
||||
package com.intellij.xdebugger.impl.inline
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.DocumentUtil;
|
||||
import com.intellij.xdebugger.XDebuggerUtil;
|
||||
import com.intellij.xdebugger.XExpression;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.intellij.openapi.editor.RangeMarker
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.util.DocumentUtil
|
||||
import com.intellij.util.concurrency.annotations.RequiresReadLock
|
||||
import com.intellij.xdebugger.XDebuggerUtil
|
||||
import com.intellij.xdebugger.XExpression
|
||||
import com.intellij.xdebugger.XSourcePosition
|
||||
|
||||
import java.util.Objects;
|
||||
class InlineWatch(val expression: XExpression, var position: XSourcePosition) {
|
||||
private val myFile = position.file
|
||||
|
||||
public class InlineWatch {
|
||||
private final @NotNull XExpression myExpression;
|
||||
private final @NotNull VirtualFile myFile;
|
||||
private @NotNull XSourcePosition myPosition;
|
||||
private @Nullable RangeMarker myRangeMarker;
|
||||
@Volatile
|
||||
private var myRangeMarker: RangeMarker? = null
|
||||
|
||||
public InlineWatch(@NotNull XExpression expression, @NotNull XSourcePosition position) {
|
||||
myExpression = expression;
|
||||
myFile = position.getFile();
|
||||
myPosition = position;
|
||||
}
|
||||
val line: Int
|
||||
get() = position.line
|
||||
|
||||
public @NotNull XExpression getExpression() {
|
||||
return myExpression;
|
||||
}
|
||||
|
||||
public @NotNull XSourcePosition getPosition() {
|
||||
return myPosition;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return myRangeMarker != null && myRangeMarker.isValid();
|
||||
}
|
||||
|
||||
public int getLine() {
|
||||
return myPosition.getLine();
|
||||
}
|
||||
|
||||
public void updatePosition() {
|
||||
if (myRangeMarker != null && myRangeMarker.isValid()) {
|
||||
int line = myRangeMarker.getDocument().getLineNumber(myRangeMarker.getStartOffset());
|
||||
if (line != myPosition.getLine()) {
|
||||
myPosition = Objects.requireNonNull(XDebuggerUtil.getInstance().createPosition(myFile, line));
|
||||
fun updatePosition(): Boolean {
|
||||
val rangeMarker = myRangeMarker
|
||||
if (rangeMarker?.isValid == true) {
|
||||
val line = rangeMarker.document.getLineNumber(rangeMarker.startOffset)
|
||||
if (line != position.line) {
|
||||
position = XDebuggerUtil.getInstance().createPosition(myFile, line)!!
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if marker was added successfully
|
||||
*/
|
||||
public boolean setMarker() {
|
||||
Document document = FileDocumentManager.getInstance().getDocument(myFile);
|
||||
|
||||
@RequiresReadLock
|
||||
/**
|
||||
* @return true if marker was added successfully
|
||||
*/
|
||||
fun setMarker(): Boolean {
|
||||
if (myRangeMarker != null) return true
|
||||
// try not to decompile files
|
||||
var document = FileDocumentManager.getInstance().getCachedDocument(myFile)
|
||||
if (document == null) {
|
||||
if (myFile.fileType.isBinary()) return true
|
||||
document = FileDocumentManager.getInstance().getDocument(myFile)
|
||||
}
|
||||
if (myRangeMarker != null) return true // an extra check for myRangeMarker because we call setMarker from fileContentLoaded
|
||||
if (document != null) {
|
||||
int line = myPosition.getLine();
|
||||
val line = position.line
|
||||
if (DocumentUtil.isValidLine(line, document)) {
|
||||
int offset = document.getLineEndOffset(line);
|
||||
myRangeMarker = document.createRangeMarker(offset, offset, true);
|
||||
return true;
|
||||
val offset = document.getLineEndOffset(line)
|
||||
myRangeMarker = document.createRangeMarker(offset, offset, true)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user