mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[java] API cleanup: remove unused deprecated API (IJPL-503)
GitOrigin-RevId: 36db2165d4a4bb133b7d63db944f6c8fe3490fa8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cb9a49220f
commit
70676eed64
@@ -11,7 +11,6 @@ import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.impl.DocumentImpl;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
@@ -85,11 +84,6 @@ public abstract class JavaCodeInsightTestCase extends JavaPsiTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull PsiTestData createData() {
|
||||
return new CodeInsightTestData();
|
||||
}
|
||||
|
||||
protected void configureByFile(String filePath) throws Exception {
|
||||
configureByFile(filePath, null);
|
||||
}
|
||||
@@ -189,14 +183,6 @@ public abstract class JavaCodeInsightTestCase extends JavaPsiTestCase {
|
||||
IndexingTestUtil.waitUntilIndexesAreReady(getProject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #configureByFiles(File, VirtualFile...)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public VirtualFile doConfigureByFiles(@Nullable File rawProjectRoot, VirtualFile @NotNull ... vFiles) throws IOException {
|
||||
return configureByFiles(rawProjectRoot, vFiles);
|
||||
}
|
||||
|
||||
protected VirtualFile configureByFiles(@Nullable File rawProjectRoot, VirtualFile @NotNull ... vFiles) throws IOException {
|
||||
myFile = null;
|
||||
myEditor = null;
|
||||
@@ -329,16 +315,6 @@ public abstract class JavaCodeInsightTestCase extends JavaPsiTestCase {
|
||||
myFile = getPsiFile(editor.getDocument());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated usages must be inlined
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
protected @NotNull List<Editor> openEditorsAndActivateLast(@NotNull Map<VirtualFile, EditorInfo> editorInfos) {
|
||||
final List<Editor> list = openEditors(editorInfos);
|
||||
setActiveEditor(list.get(list.size() - 1));
|
||||
return list;
|
||||
}
|
||||
|
||||
protected final @NotNull List<Editor> openEditors(@NotNull Map<VirtualFile, EditorInfo> editorInfos) {
|
||||
return ContainerUtil.map(editorInfos.keySet(), newVFile -> {
|
||||
PsiFile file = myPsiManager.findFile(newVFile);
|
||||
@@ -385,43 +361,6 @@ public abstract class JavaCodeInsightTestCase extends JavaPsiTestCase {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated cursor and selection is automatically configured in {@code configureByFile*} methods
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
protected void setupCursorAndSelection(final @NotNull Editor editor) {
|
||||
Document document = editor.getDocument();
|
||||
EditorTestUtil.CaretAndSelectionState caretState = EditorTestUtil.extractCaretAndSelectionMarkers(document);
|
||||
EditorTestUtil.setCaretsAndSelection(editor, caretState);
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated caret and selection are now configured directly in files, see {@link EditorTestUtil#extractCaretAndSelectionMarkers}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Override
|
||||
protected void configure(@NotNull String path, String dataName) throws Exception {
|
||||
super.configure(path, dataName);
|
||||
|
||||
myEditor = createEditor(myFile.getVirtualFile());
|
||||
|
||||
CodeInsightTestData data = (CodeInsightTestData) myTestDataBefore;
|
||||
|
||||
LogicalPosition pos = new LogicalPosition(data.getLineNumber() - 1, data.getColumnNumber() - 1);
|
||||
myEditor.getCaretModel().moveToLogicalPosition(pos);
|
||||
|
||||
int selectionEnd;
|
||||
int selectionStart = selectionEnd = myEditor.getCaretModel().getOffset();
|
||||
|
||||
if (data.getSelectionStartColumnNumber() >= 0) {
|
||||
selectionStart = myEditor.logicalPositionToOffset(new LogicalPosition(data.getSelectionStartLineNumber() - 1, data.getSelectionStartColumnNumber() - 1));
|
||||
selectionEnd = myEditor.logicalPositionToOffset(new LogicalPosition(data.getSelectionEndLineNumber() - 1, data.getSelectionEndColumnNumber() - 1));
|
||||
}
|
||||
|
||||
myEditor.getSelectionModel().setSelection(selectionStart, selectionEnd);
|
||||
}
|
||||
|
||||
protected void checkResultByFile(@NotNull String filePath) throws Exception {
|
||||
checkResultByFile(filePath, false);
|
||||
}
|
||||
@@ -472,43 +411,6 @@ public abstract class JavaCodeInsightTestCase extends JavaPsiTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated caret and selection are now configured directly in files, see {@link EditorTestUtil#extractCaretAndSelectionMarkers}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated(forRemoval = true)
|
||||
protected void checkResult(String dataName) throws Exception {
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
super.checkResult(dataName);
|
||||
|
||||
CodeInsightTestData data = (CodeInsightTestData) myTestDataAfter;
|
||||
|
||||
if (data.getColumnNumber() >= 0) {
|
||||
assertEquals(dataName + ":caretColumn", data.getColumnNumber(), myEditor.getCaretModel().getLogicalPosition().column + 1);
|
||||
}
|
||||
if (data.getLineNumber() >= 0) {
|
||||
assertEquals(dataName + ":caretLine", data.getLineNumber(), myEditor.getCaretModel().getLogicalPosition().line + 1);
|
||||
}
|
||||
|
||||
int selectionStart = myEditor.getSelectionModel().getSelectionStart();
|
||||
int selectionEnd = myEditor.getSelectionModel().getSelectionEnd();
|
||||
LogicalPosition startPosition = myEditor.offsetToLogicalPosition(selectionStart);
|
||||
LogicalPosition endPosition = myEditor.offsetToLogicalPosition(selectionEnd);
|
||||
|
||||
if (data.getSelectionStartColumnNumber() >= 0) {
|
||||
assertEquals(dataName + ":selectionStartColumn", data.getSelectionStartColumnNumber(), startPosition.column + 1);
|
||||
}
|
||||
if (data.getSelectionStartLineNumber() >= 0) {
|
||||
assertEquals(dataName + ":selectionStartLine", data.getSelectionStartLineNumber(), startPosition.line + 1);
|
||||
}
|
||||
if (data.getSelectionEndColumnNumber() >= 0) {
|
||||
assertEquals(dataName + ":selectionEndColumn", data.getSelectionEndColumnNumber(), endPosition.column + 1);
|
||||
}
|
||||
if (data.getSelectionEndLineNumber() >= 0) {
|
||||
assertEquals(dataName + ":selectionEndLine", data.getSelectionEndLineNumber(), endPosition.line + 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected @NotNull VirtualFile findVirtualFile(@NotNull String filePath) {
|
||||
String absolutePath = getTestDataPath() + filePath;
|
||||
VfsRootAccess.allowRootAccess(getTestRootDisposable(), absolutePath);
|
||||
|
||||
@@ -9,10 +9,6 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
@@ -21,20 +17,16 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public abstract class JavaPsiTestCase extends JavaModuleTestCase {
|
||||
protected PsiManagerImpl myPsiManager;
|
||||
protected PsiFile myFile;
|
||||
private String myDataRoot;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -47,8 +39,6 @@ public abstract class JavaPsiTestCase extends JavaModuleTestCase {
|
||||
try {
|
||||
myPsiManager = null;
|
||||
myFile = null;
|
||||
myTestDataBefore = null;
|
||||
myTestDataAfter = null;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
addSuppressedException(e);
|
||||
@@ -109,22 +99,6 @@ public abstract class JavaPsiTestCase extends JavaModuleTestCase {
|
||||
return myFile.findElementAt(offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use other methods to configure the files, data.xml files aren't supported anymore
|
||||
*/
|
||||
@Deprecated
|
||||
protected void configure(@NotNull String path, String dataName) throws Exception {
|
||||
myDataRoot = getTestDataPath() + path;
|
||||
|
||||
myTestDataBefore = loadData(dataName);
|
||||
|
||||
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
|
||||
VirtualFile vDir = createTestProjectStructure(myModule, myDataRoot, true, getTempDir());
|
||||
|
||||
VirtualFile vFile = vDir.findChild(myTestDataBefore.getTextFile());
|
||||
myFile = myPsiManager.findFile(Objects.requireNonNull(vFile));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getTestDataPath() {
|
||||
return PathManagerEx.getTestDataPath();
|
||||
@@ -136,104 +110,6 @@ public abstract class JavaPsiTestCase extends JavaModuleTestCase {
|
||||
return StringUtil.convertLineSeparators(result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PsiTestData loadData(String dataName) throws Exception {
|
||||
PsiTestData data = createData();
|
||||
Element documentElement = JDOMUtil.load(Paths.get(myDataRoot, "data.xml"));
|
||||
for (Element node : documentElement.getChildren("data")) {
|
||||
String value = node.getAttributeValue("name");
|
||||
if (value.equals(dataName)) {
|
||||
DefaultJDOMExternalizer.readExternal(data, node);
|
||||
data.loadText(myDataRoot);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Cannot find data chunk '" + dataName + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use other methods to configure the files, data.xml files aren't supported anymore
|
||||
*/
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@Deprecated(forRemoval = true)
|
||||
@NotNull
|
||||
protected PsiTestData createData() {
|
||||
return new PsiTestData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use other methods to configure the files, data.xml files aren't supported anymore
|
||||
*/
|
||||
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||
@Deprecated
|
||||
protected void checkResult(String dataName) throws Exception {
|
||||
myTestDataAfter = loadData(dataName);
|
||||
|
||||
final String textExpected = myTestDataAfter.getText();
|
||||
final String actualText = myFile.getText();
|
||||
|
||||
if (!textExpected.equals(actualText)) {
|
||||
System.out.println("Text mismatch: " + getName() + "(" + getClass().getName() + ")");
|
||||
System.out.println("Text expected:");
|
||||
printText(textExpected);
|
||||
System.out.println("Text found:");
|
||||
printText(actualText);
|
||||
|
||||
fail("text");
|
||||
}
|
||||
|
||||
// assertEquals(myTestDataAfter.getText(), myFile.getText());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated printing text to {@code System.out} is discouraged, use other methods instead
|
||||
*/
|
||||
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||
@Deprecated(forRemoval = true)
|
||||
protected static void printText(@NotNull String text) {
|
||||
final String q = "\"";
|
||||
System.out.print(q);
|
||||
|
||||
text = StringUtil.convertLineSeparators(text);
|
||||
|
||||
StringTokenizer tokenizer = new StringTokenizer(text, "\n", true);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
final String token = tokenizer.nextToken();
|
||||
|
||||
if (token.equals("\n")) {
|
||||
System.out.print(q);
|
||||
System.out.println();
|
||||
System.out.print(q);
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.print(token);
|
||||
}
|
||||
|
||||
System.out.print(q);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ModuleRootModificationUtil#addModuleLibrary} directly instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
protected void addLibraryToRoots(@NotNull VirtualFile jarFile, @NotNull OrderRootType rootType) {
|
||||
addLibraryToRoots(myModule, jarFile, rootType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ModuleRootModificationUtil#addModuleLibrary} directly instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
protected static void addLibraryToRoots(@NotNull Module module, @NotNull VirtualFile root, @NotNull OrderRootType rootType) {
|
||||
assertEquals(OrderRootType.CLASSES, rootType);
|
||||
ModuleRootModificationUtil.addModuleLibrary(module, root.getUrl());
|
||||
}
|
||||
|
||||
|
||||
public PsiFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
@@ -249,18 +125,4 @@ public abstract class JavaPsiTestCase extends JavaModuleTestCase {
|
||||
public void commitDocument(@NotNull Document document) {
|
||||
PsiDocumentManager.getInstance(getProject()).commitDocument(document);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use other methods to configure the files, data.xml files aren't supported anymore
|
||||
*/
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@Deprecated(forRemoval = true)
|
||||
protected PsiTestData myTestDataBefore;
|
||||
|
||||
/**
|
||||
* @deprecated use other methods to configure the files, data.xml files aren't supported anymore
|
||||
*/
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@Deprecated(forRemoval = true)
|
||||
protected PsiTestData myTestDataAfter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user