Skip to content

Commit

Permalink
refact: remove usage of deprecated classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bjansen committed Mar 10, 2024
1 parent c5c51a5 commit c196365
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 31 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.event.EditorFactoryAdapter;
import com.intellij.openapi.editor.event.EditorFactoryEvent;
import com.intellij.openapi.editor.event.EditorMouseAdapter;
import com.intellij.openapi.editor.event.EditorFactoryListener;
import com.intellij.openapi.editor.event.EditorMouseEvent;
import com.intellij.openapi.editor.event.EditorMouseListener;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
Expand All @@ -26,12 +26,11 @@
import com.intellij.openapi.progress.util.BackgroundTaskUtil;
import com.intellij.openapi.progress.util.ProgressWindow;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileAdapter;
import com.intellij.openapi.vfs.VirtualFileEvent;
import com.intellij.openapi.vfs.VirtualFileListener;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
Expand All @@ -55,7 +54,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/** This object is the controller for the ANTLR plug-in. It receives
* events and can send them on to its contained components. For example,
Expand Down Expand Up @@ -226,7 +224,7 @@ public void installListeners() {

EditorFactory factory = EditorFactory.getInstance();
factory.addEditorFactoryListener(
new EditorFactoryAdapter() {
new EditorFactoryListener() {
@Override
public void editorCreated(@NotNull EditorFactoryEvent event) {
final Editor editor = event.getEditor();
Expand Down Expand Up @@ -610,7 +608,7 @@ public static VirtualFile getCurrentGrammarFile(Project project) {
return null;
}

private class GrammarEditorMouseAdapter extends EditorMouseAdapter {
private class GrammarEditorMouseAdapter implements EditorMouseListener {
@Override
public void mouseClicked(EditorMouseEvent e) {
Document doc = e.getEditor().getDocument();
Expand All @@ -621,7 +619,7 @@ public void mouseClicked(EditorMouseEvent e) {
}
}

private class MyVirtualFileAdapter extends VirtualFileAdapter {
private class MyVirtualFileAdapter implements VirtualFileListener {
@Override
public void contentsChanged(VirtualFileEvent event) {
final VirtualFile vfile = event.getFile();
Expand Down
34 changes: 27 additions & 7 deletions src/main/java/org/antlr/intellij/plugin/preview/InputPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@
import com.intellij.codeInsight.hint.HintUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.EditorSettings;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.editor.ScrollingModel;
import com.intellij.openapi.editor.event.CaretListener;
import com.intellij.openapi.editor.event.DocumentAdapter;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.event.DocumentListener;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.EditorMarkupModel;
import com.intellij.openapi.editor.markup.*;
import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.HighlighterLayer;
import com.intellij.openapi.editor.markup.HighlighterTargetArea;
import com.intellij.openapi.editor.markup.MarkupModel;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.fileEditor.FileDocumentManager;
Expand All @@ -32,8 +44,16 @@
import org.antlr.intellij.plugin.parsing.PreviewParser;
import org.antlr.intellij.plugin.profiler.ProfilerPanel;
import org.antlr.runtime.CommonToken;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.LexerNoViableAltException;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.atn.AmbiguityInfo;
import org.antlr.v4.runtime.atn.ContextSensitivityInfo;
import org.antlr.v4.runtime.atn.DecisionEventInfo;
import org.antlr.v4.runtime.atn.LookaheadEventInfo;
import org.antlr.v4.runtime.atn.PredicateEvalInfo;
import org.antlr.v4.runtime.misc.Interval;
import org.antlr.v4.runtime.misc.Pair;
import org.antlr.v4.runtime.misc.Utils;
Expand Down Expand Up @@ -158,7 +178,7 @@ public void createManualInputPreviewEditor(final PreviewState previewState) {
final EditorFactory factory = EditorFactory.getInstance();
Document doc = factory.createDocument("");
doc.addDocumentListener(
new DocumentAdapter() {
new DocumentListener() {
@Override
public void documentChanged(DocumentEvent e) {
previewState.manualInputText = e.getDocument().getCharsSequence();
Expand Down Expand Up @@ -217,7 +237,7 @@ public Editor createPreviewEditor(final VirtualFile grammarFile, Document doc, b
LOG.info("createEditor: create new editor for "+grammarFile.getPath()+" "+previewPanel.project.getName());
final EditorFactory factory = EditorFactory.getInstance();
doc.addDocumentListener(
new DocumentAdapter() {
new DocumentListener() {
@Override
public void documentChanged(DocumentEvent event) {
previewPanel.updateParseTreeFromDoc(grammarFile);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package org.antlr.intellij.plugin.preview;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.editor.event.CaretAdapter;
import com.intellij.openapi.editor.event.CaretEvent;
import com.intellij.openapi.editor.event.CaretListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.SystemInfo;
Expand Down Expand Up @@ -106,7 +111,7 @@ private void createGUI() {
// Had to set min size / preferred size in InputPanel.form to get slider to allow left shift of divider
Splitter splitPane = new Splitter();
inputPanel = getEditorPanel();
inputPanel.addCaretListener(new CaretAdapter() {
inputPanel.addCaretListener(new CaretListener() {
@Override
public void caretPositionChanged(@NotNull CaretEvent event) {
Caret caret = event.getCaret();
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ For really big files and slow grammars, there is an appreciable delay when displ
</actions>

<extensions defaultExtensionNs="com.intellij">
<fileTypeFactory implementation="org.antlr.intellij.plugin.ANTLRv4FileTypeFactory"/>
<fileType name="ANTLRv4 grammar" language="ANTLRv4" extensions="g4"
implementationClass="org.antlr.intellij.plugin.ANTLRv4FileType" fieldName="INSTANCE"/>
<lang.syntaxHighlighterFactory language="ANTLRv4" implementationClass="org.antlr.intellij.plugin.ANTLRv4SyntaxHighlighterFactory"/>
<lang.commenter language="ANTLRv4" implementationClass="org.antlr.intellij.plugin.ANTLRv4Commenter" />
<indexPatternBuilder implementation="org.antlr.intellij.plugin.psi.ANTLRv4IndexPatternBuilder"/>
Expand Down

0 comments on commit c196365

Please sign in to comment.