Skip to content
Open

V4 #49

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jingtrang/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>consulo</groupId>
<artifactId>arch.managment</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<relativePath/>
</parent>

Expand All @@ -38,7 +38,7 @@

<groupId>consulo.plugin</groupId>
<artifactId>com.intellij.xml.jingtrang</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<packaging>jar</packaging>

<build>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>consulo</groupId>
<artifactId>arch.managment</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<relativePath/>
</parent>

Expand All @@ -38,7 +38,7 @@

<groupId>consulo.plugin</groupId>
<artifactId>com.intellij.xml.parent</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
Expand Down
4 changes: 2 additions & 2 deletions rngom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>consulo</groupId>
<artifactId>arch.managment</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<relativePath/>
</parent>

Expand All @@ -38,7 +38,7 @@

<groupId>consulo.plugin</groupId>
<artifactId>com.intellij.xml.rngom</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions xml-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<parent>
<groupId>consulo</groupId>
<artifactId>arch.ide-api-provided</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<relativePath/>
</parent>

<groupId>consulo.plugin</groupId>
<artifactId>com.intellij.xml</artifactId>
<version>3-SNAPSHOT</version>
<version>4-SNAPSHOT</version>
<packaging>consulo-plugin</packaging>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import consulo.language.psi.PsiFile;
import consulo.language.psi.PsiManager;
import consulo.project.Project;
import consulo.ui.UIAccess;
import consulo.ui.annotation.RequiredUIAccess;
import consulo.ui.ex.action.ActionPlaces;
import consulo.ui.ex.action.AnAction;
Expand Down Expand Up @@ -80,7 +81,7 @@ public void actionPerformed(AnActionEvent e) {

@RequiredUIAccess
private void doAction(Project project, GenerateInstanceDocumentFromSchemaDialog dialog) {
FileDocumentManager.getInstance().saveAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments(UIAccess.current());

List<String> parameters = new LinkedList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import consulo.fileEditor.FileEditorManager;
import consulo.language.editor.PlatformDataKeys;
import consulo.project.Project;
import consulo.ui.UIAccess;
import consulo.ui.annotation.RequiredUIAccess;
import consulo.ui.ex.action.ActionPlaces;
import consulo.ui.ex.action.AnAction;
Expand Down Expand Up @@ -86,7 +87,7 @@ public void actionPerformed(AnActionEvent e) {

@RequiredUIAccess
private static void doAction(Project project, GenerateSchemaFromInstanceDocumentDialog dialog) {
FileDocumentManager.getInstance().saveAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments(UIAccess.current());

String url = dialog.getUrl().getText();
VirtualFile relativeFile =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ public class XmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, TAG_TREE_HIGHLIGHTING_KEY);

private final PsiFile myFile;
private final EditorEx myEditor;

private final Editor myEditor;

private final List<Couple<TextRange>> myPairsToHighlight = new ArrayList<>();

public XmlTagTreeHighlightingPass(PsiFile file, EditorEx editor) {
public XmlTagTreeHighlightingPass(PsiFile file, Editor editor) {
super(file.getProject(), editor.getDocument(), true);
myFile = file;
myEditor = editor;
Expand All @@ -84,15 +85,11 @@ public XmlTagTreeHighlightingPass(PsiFile file, EditorEx editor) {
@RequiredReadAction
@Override
public void doCollectInformation(ProgressIndicator progress) {
if (Application.get().isUnitTestMode()) {
return;
}

if (!XmlEditorOptions.getInstance().isTagTreeHighlightingEnabled()) {
return;
}

int offset = myEditor.getCaretModel().getOffset();
int offset = getImaginaryEditor().getCaretModel().getOffset();
PsiElement[] elements = null; // FIXME [VISTALL] for now idk when it used, due it based on breadcrumbs, which removed

if (elements == null || elements.length == 0 || !XmlTagTreeHighlightingUtil.containsTagsWithSameName(elements)) {
Expand Down Expand Up @@ -188,6 +185,7 @@ public void doApplyInformationToEditor() {
UpdateHighlightersUtil.setHighlightersToEditor(
myProject,
myDocument,
myFile,
0,
myFile.getTextLength(),
infos,
Expand Down Expand Up @@ -309,7 +307,7 @@ private static ColorValue[] toColorsForLineMarkers(ColorValue[] baseColors) {
}

private ColorValue[] toColorsForEditor(ColorValue[] baseColors) {
ColorValue tagBackground = myEditor.getBackgroundColor();
ColorValue tagBackground = ((EditorEx) myEditor).getBackgroundColor();

if (tagBackground == null) {
return baseColors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public void register(Registrar registrar) {
public TextEditorHighlightingPass createHighlightingPass(PsiFile file, Editor editor) {
return !editor.isOneLineMode()
&& XmlTagTreeHighlightingUtil.isTagTreeHighlightingActive(file)
&& editor instanceof EditorEx editorEx
? new XmlTagTreeHighlightingPass(file, editorEx)
? new XmlTagTreeHighlightingPass(file, editor)
: null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import consulo.annotation.access.RequiredReadAction;
import consulo.annotation.component.ExtensionImpl;
import consulo.application.Application;
import consulo.application.concurrent.coroutine.ReadLock;
import consulo.codeEditor.*;
import consulo.codeEditor.event.EditorFactoryEvent;
import consulo.codeEditor.event.EditorFactoryListener;
Expand Down Expand Up @@ -36,6 +37,10 @@
import consulo.undoRedo.event.CommandEvent;
import consulo.undoRedo.event.CommandListener;
import consulo.util.collection.ContainerUtil;
import consulo.util.concurrent.coroutine.Continuation;
import consulo.util.concurrent.coroutine.Coroutine;
import consulo.util.concurrent.coroutine.CoroutineScope;
import consulo.util.concurrent.coroutine.step.CodeExecution;
import consulo.util.dataholder.Key;
import consulo.util.lang.Couple;
import consulo.util.lang.StringUtil;
Expand All @@ -48,7 +53,6 @@
import consulo.xml.psi.xml.XmlTokenType;
import jakarta.inject.Inject;


import java.util.Objects;
import java.util.Set;

Expand All @@ -62,6 +66,8 @@ public final class XmlTagNameSynchronizer implements CommandListener, EditorFact
XHTMLLanguage.INSTANCE
);

private static final Key<Continuation<?>> CONTINUATION_KEY = Key.create("XmlTagNameSynchronizer#CONTINUATION_KEY");

private static final Key<TagNameSynchronizer> SYNCHRONIZER_KEY = Key.create("tag_name_synchronizer");

@Inject
Expand All @@ -80,9 +86,30 @@ public void editorCreated(EditorFactoryEvent event) {

Document document = editor.getDocument();
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
Language language = findXmlLikeLanguage(project, file);
if (language != null) {
new TagNameSynchronizer((RealEditor)editor, project, language).listenForDocumentChanges();

Continuation<?> continuation = CoroutineScope.launchAsync(project.coroutineContext(), () -> {
return Coroutine.first(ReadLock.apply(o -> findXmlLikeLanguage(project, file)))
.then(CodeExecution.consume((language, c) -> {
if (language != null) {
new TagNameSynchronizer((RealEditor) editor, project, language).listenForDocumentChanges();

editor.putUserData(CONTINUATION_KEY, null);
}
}));
});

editor.putUserData(CONTINUATION_KEY, continuation);
}

@Override
public void editorReleased(EditorFactoryEvent event) {
Editor editor = event.getEditor();

Continuation<?> continuation = editor.getUserData(CONTINUATION_KEY);
if (continuation != null) {
continuation.cancel();

editor.putUserData(CONTINUATION_KEY, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,9 @@ public String getResourceLocation() {

private void createUIComponents() {
myExplorerPanel = new JPanel(new BorderLayout());
DataManager.registerDataProvider(myExplorerPanel, dataId ->
{
if (CommonDataKeys.VIRTUAL_FILE_ARRAY == dataId) {
return myExplorer.getSelectedFiles();
}
else if (FileSystemTree.DATA_KEY == dataId) {
return myExplorer;
}
return null;
DataManager.registerUiDataProvider(myExplorerPanel, dataSink -> {
dataSink.set(CommonDataKeys.VIRTUAL_FILE_ARRAY, myExplorer.getSelectedFiles());
dataSink.set(FileSystemTree.DATA_KEY, myExplorer);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/
package consulo.xml.util.xml.ui;

import consulo.application.HelpManager;
import consulo.dataContext.DataSink;
import consulo.dataContext.TypeSafeDataProvider;
import consulo.dataContext.UiDataProvider;
import consulo.language.editor.PlatformDataKeys;
import consulo.platform.base.icon.PlatformIconGroup;
import consulo.project.Project;
Expand Down Expand Up @@ -52,7 +53,7 @@
/**
* @author peter
*/
public abstract class AbstractTableView<T> extends JPanel implements TypeSafeDataProvider {
public abstract class AbstractTableView<T> extends JPanel implements UiDataProvider {
private final MyTableView myTable = new MyTableView();
private final String myHelpID;
private final String myEmptyPaneText;
Expand Down Expand Up @@ -224,10 +225,9 @@ public final ListTableModel getTableModel() {
return myTableModel;
}

public void calcData(Key<?> key, DataSink sink) {
if (PlatformDataKeys.HELP_ID == key) {
sink.put(PlatformDataKeys.HELP_ID, getHelpId());
}
@Override
public void uiDataSnapshot(DataSink dataSink) {
dataSink.set(HelpManager.HELP_ID, getHelpId());
}

private String getHelpId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import consulo.application.Application;
import consulo.application.Result;
import consulo.dataContext.DataSink;
import consulo.dataContext.TypeSafeDataProvider;
import consulo.dataContext.UiDataProvider;
import consulo.language.editor.WriteCommandAction;
import consulo.language.psi.PsiFile;
import consulo.language.psi.PsiUtilCore;
Expand All @@ -40,6 +40,7 @@
import consulo.xml.util.xml.highlighting.DomElementProblemDescriptor;
import consulo.xml.util.xml.reflect.DomCollectionChildDescription;
import consulo.xml.util.xml.ui.actions.DefaultAddAction;
import jakarta.annotation.Nonnull;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
Expand All @@ -52,7 +53,7 @@
/**
* @author peter
*/
public class DomCollectionControl<T extends DomElement> extends DomUIControl implements Highlightable, TypeSafeDataProvider {
public class DomCollectionControl<T extends DomElement> extends DomUIControl implements Highlightable, UiDataProvider {
private static final Key<DomCollectionControl> DOM_COLLECTION_CONTROL = Key.create("DomCollectionControl");

private final EventDispatcher<CommitListener> myDispatcher = EventDispatcher.create(CommitListener.class);
Expand Down Expand Up @@ -145,10 +146,8 @@ public void navigate(DomElement element) {
}

@Override
public void calcData(Key<?> key, DataSink sink) {
if (DOM_COLLECTION_CONTROL.equals(key)) {
sink.put(DOM_COLLECTION_CONTROL, this);
}
public void uiDataSnapshot(DataSink dataSink) {
dataSink.set(DOM_COLLECTION_CONTROL, this);
}

@Nullable
Expand Down
Loading
Loading