mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
move a couple tests with right dependencies to community
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class InsideBlock {
|
||||
void f() {
|
||||
int i = 0<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package x;
|
||||
public class X {
|
||||
int xxxxxxx() {ddd}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package y;
|
||||
public class Y {
|
||||
int yyyyy() {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i<caret>
|
||||
* @param argument
|
||||
*/
|
||||
void test(int i, int argument) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i description
|
||||
* @param argument<caret>
|
||||
* @return very important value
|
||||
*/
|
||||
int test(int i, int argument) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i description
|
||||
* @param argument <caret>
|
||||
* @return very important value
|
||||
*/
|
||||
int test(int i, int argument) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class A{
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class A{
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
void foo (){
|
||||
/*
|
||||
<caret>
|
||||
text text text
|
||||
text text text
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
void foo (){
|
||||
/*
|
||||
<caret>
|
||||
text text text
|
||||
text text text
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class A {
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class A {
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i<caret>
|
||||
* @param argument
|
||||
*/
|
||||
void test(int i, int argument) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i this is my
|
||||
* multiline description<caret>
|
||||
* @param argument
|
||||
*/
|
||||
void test(int i, int argument) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i this is my
|
||||
* multiline description<caret>
|
||||
* @param argument
|
||||
*/
|
||||
void test(int i, int argument) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i this is my description<caret>
|
||||
* @param argument
|
||||
*/
|
||||
void test(int i, int argument) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i this is my description<caret>
|
||||
* @param argument
|
||||
*/
|
||||
void test(int i, int argument) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
c<caret>lass A{
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
class A{<caret>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class A{
|
||||
<caret> void foo();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class A{
|
||||
void foo();<caret>
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i<caret>
|
||||
* @param argument
|
||||
*/
|
||||
void test(int i, int argument) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i <caret>
|
||||
* @param argument
|
||||
*/
|
||||
void test(int i, int argument) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class Bundles {
|
||||
|
||||
String woman="wo<caret>man";
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
woman=woman
|
||||
@@ -0,0 +1 @@
|
||||
woman=femme
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.editor.VisualPosition;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
|
||||
public class EndActionTest extends LightPlatformCodeInsightTestCase {
|
||||
|
||||
private static final String PATH = "/codeInsight/endAction/";
|
||||
|
||||
public void testNormal1() { doTest(); }
|
||||
public void testNormal2() { doTest(); }
|
||||
|
||||
public void testEmptyLine1() {
|
||||
init();
|
||||
assertEquals(new VisualPosition(1, 4), myEditor.getCaretModel().getVisualPosition());
|
||||
}
|
||||
public void testInComment() { doTest(); }
|
||||
|
||||
public void testLongWhiteSpace() { doTest(); }
|
||||
|
||||
public void testAlignedJavadocParameterDescription() {
|
||||
init();
|
||||
assertEquals(new VisualPosition(4, 23), myEditor.getCaretModel().getVisualPosition());
|
||||
}
|
||||
|
||||
public void testNonAlignedJavadocParameterDescription() {
|
||||
String name = getTestName(false);
|
||||
configureByFile(PATH + name + ".java");
|
||||
JavaCodeStyleSettings.getInstance(getProject()).JD_ALIGN_PARAM_COMMENTS = false;
|
||||
performAction();
|
||||
assertEquals(new VisualPosition(4, 16), myEditor.getCaretModel().getVisualPosition());
|
||||
}
|
||||
|
||||
public void testNonEmptyParameterDescription() { doTest(); }
|
||||
|
||||
public void testNonEmptyMultiLineParameterDescription() { doTest(); }
|
||||
|
||||
public void testWhiteSpaceInsertionOnJavadocDescriptionPositionNavigation() {
|
||||
String name = getTestName(false);
|
||||
configureByFile(PATH + name + ".java");
|
||||
getEditor().getSettings().setVirtualSpace(false);
|
||||
performAction();
|
||||
checkResultByFile(null, PATH + getTestName(false) + ".java.after", false);
|
||||
}
|
||||
|
||||
public void testAlignedReturnWithDescription() {
|
||||
String name = getTestName(false);
|
||||
configureByFile(PATH + name + ".java");
|
||||
getEditor().getSettings().setVirtualSpace(false);
|
||||
performAction();
|
||||
checkResultByFile(null, PATH + getTestName(false) + ".java.after", false);
|
||||
}
|
||||
|
||||
public void testWithSomeWhitespaceExisting() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
String name = getTestName(false);
|
||||
configureByFile(PATH + name + ".java");
|
||||
performAction();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
init();
|
||||
checkResultByFile(null, PATH + getTestName(false) + ".java.after", false);
|
||||
}
|
||||
|
||||
private static void performAction() {
|
||||
EditorActionManager actionManager = EditorActionManager.getInstance();
|
||||
EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_MOVE_LINE_END);
|
||||
actionHandler.execute(getEditor(), null, DataManager.getInstance().getDataContext(getEditor().getComponent()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.lang.properties.IProperty;
|
||||
import com.intellij.lang.properties.psi.Property;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Dmitry AJvdeev
|
||||
*/
|
||||
public class ShowImplementationsTest extends JavaCodeInsightFixtureTestCase {
|
||||
|
||||
public void testMessages() {
|
||||
myFixture.configureByFiles("Bundles.java", "bundle.properties", "bundle_fr.properties");
|
||||
PsiElement[] elements = ShowImplementationsTestUtil.getImplementations();
|
||||
assertNotNull(elements);
|
||||
assertEquals(2, elements.length);
|
||||
assertTrue(elements[0] instanceof IProperty && elements[1] instanceof IProperty);
|
||||
}
|
||||
|
||||
public void testMessagesCompletion() {
|
||||
myFixture.configureByFiles("Bundles.java", "bundle.properties", "bundle_fr.properties");
|
||||
LookupElement[] elements = myFixture.completeBasic();
|
||||
assertNotNull(elements);
|
||||
assertTrue(ContainerUtil.find(elements, element -> element.getObject() instanceof Property) != null);
|
||||
PsiElement[] implementations = ShowImplementationsTestUtil.getImplementations();
|
||||
assertNotNull(implementations);
|
||||
assertEquals(Arrays.asList(implementations).toString(), 1, implementations.length);
|
||||
assertTrue(implementations[0] instanceof IProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/showImplementations/";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight.problems;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.compiler.options.ExcludeEntryDescription;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.problems.ProblemListener;
|
||||
import com.intellij.problems.WolfTheProblemSolver;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.scope.ProblemsScope;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
public class WolfTheProblemSolverTest extends DaemonAnalyzerTestCase {
|
||||
@NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/projectWide";
|
||||
private MockWolfTheProblemSolver myWolfTheProblemSolver;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myWolfTheProblemSolver = prepareWolf(myProject);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myWolfTheProblemSolver = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testHighlighting() throws Exception {
|
||||
VirtualFile root = configureRoot();
|
||||
VirtualFile x = root.findFileByRelativePath("x/X.java");
|
||||
VirtualFile y = root.findFileByRelativePath("y/Y.java");
|
||||
highlightFile(x);
|
||||
highlightFile(y);
|
||||
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(x));
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(y));
|
||||
PsiJavaFile psiX = (PsiJavaFile)myPsiManager.findFile(x);
|
||||
PsiJavaFile psiY = (PsiJavaFile)myPsiManager.findFile(y);
|
||||
DependencyValidationManager validationManager = DependencyValidationManager.getInstance(myProject);
|
||||
ProblemsScope problemsScope = ProblemsScope.INSTANCE;
|
||||
assertTrue(problemsScope.getValue().contains(psiX, validationManager));
|
||||
assertTrue(problemsScope.getValue().contains(psiY, validationManager));
|
||||
|
||||
deleteMethodWithProblem(x);
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(x));
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(y));
|
||||
highlightFile(x);
|
||||
assertFalse(myWolfTheProblemSolver.isProblemFile(x));
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(y));
|
||||
assertFalse(problemsScope.getValue().contains(psiX, validationManager));
|
||||
assertTrue(problemsScope.getValue().contains(psiY, validationManager));
|
||||
|
||||
deleteMethodWithProblem(y);
|
||||
assertFalse(myWolfTheProblemSolver.isProblemFile(x));
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(y));
|
||||
highlightFile(y);
|
||||
assertFalse(myWolfTheProblemSolver.isProblemFile(x));
|
||||
assertFalse(myWolfTheProblemSolver.isProblemFile(y));
|
||||
assertFalse(problemsScope.getValue().contains(psiX, validationManager));
|
||||
assertFalse(problemsScope.getValue().contains(psiY, validationManager));
|
||||
}
|
||||
|
||||
private void deleteMethodWithProblem(VirtualFile virtualFile) {
|
||||
PsiJavaFile psiX = (PsiJavaFile)myPsiManager.findFile(virtualFile);
|
||||
final PsiClass xClass = psiX.getClasses()[0];
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), () -> WriteCommandAction.runWriteCommandAction(null, () -> {
|
||||
try {
|
||||
xClass.getMethods()[0].delete();
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}), null, null);
|
||||
}
|
||||
|
||||
public void testRemoveFile() throws Exception {
|
||||
VirtualFile root = configureRoot();
|
||||
VirtualFile x = root.findFileByRelativePath("x/X.java");
|
||||
VirtualFile y = root.findFileByRelativePath("y/Y.java");
|
||||
highlightFile(x);
|
||||
highlightFile(y);
|
||||
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(x));
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(y));
|
||||
final PsiJavaFile psiX = (PsiJavaFile)myPsiManager.findFile(x);
|
||||
PsiJavaFile psiY = (PsiJavaFile)myPsiManager.findFile(y);
|
||||
assertNotNull(psiY);
|
||||
|
||||
WriteCommandAction.runWriteCommandAction(null, psiX::delete);
|
||||
assertFalse(myWolfTheProblemSolver.isProblemFile(x));
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(y));
|
||||
}
|
||||
|
||||
public void testExcludedFile() throws Exception {
|
||||
VirtualFile root = configureRoot();
|
||||
VirtualFile x = root.findFileByRelativePath("x/X.java");
|
||||
highlightFile(x);
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(x));
|
||||
|
||||
ExcludeEntryDescription description = new ExcludeEntryDescription(x, false, true, myProject);
|
||||
CompilerConfiguration.getInstance(myProject).getExcludedEntriesConfiguration().addExcludeEntryDescription(description);
|
||||
FileStatusManager.getInstance(myProject).fileStatusesChanged();
|
||||
|
||||
assertFalse(myWolfTheProblemSolver.isProblemFile(x));
|
||||
highlightFile(x);
|
||||
assertFalse(myWolfTheProblemSolver.isProblemFile(x));
|
||||
}
|
||||
|
||||
public static MockWolfTheProblemSolver prepareWolf(final Project project) {
|
||||
MockWolfTheProblemSolver wolfTheProblemSolver = (MockWolfTheProblemSolver)WolfTheProblemSolver.getInstance(project);
|
||||
|
||||
WolfTheProblemSolverImpl theRealSolver = new WolfTheProblemSolverImpl(project, PsiManager.getInstance(project), project.getMessageBus());
|
||||
wolfTheProblemSolver.setDelegate(theRealSolver);
|
||||
return wolfTheProblemSolver;
|
||||
}
|
||||
|
||||
private VirtualFile configureRoot() throws Exception {
|
||||
configureByFile(BASE_PATH + "/x/X.java", BASE_PATH);
|
||||
return ModuleRootManager.getInstance(myModule).getContentRoots()[0];
|
||||
}
|
||||
|
||||
public void testEvents() throws Exception {
|
||||
VirtualFile root = configureRoot();
|
||||
MyProblemListener handler = new MyProblemListener();
|
||||
myProject.getMessageBus().connect(getTestRootDisposable()).subscribe(ProblemListener.TOPIC, handler);
|
||||
|
||||
VirtualFile x = root.findFileByRelativePath("x/X.java");
|
||||
VirtualFile y = root.findFileByRelativePath("y/Y.java");
|
||||
highlightFile(x);
|
||||
handler.verifyEvents(Collections.singleton(x), emptySet(), emptySet());
|
||||
assertTrue(myWolfTheProblemSolver.hasSyntaxErrors(x));
|
||||
|
||||
highlightFile(y);
|
||||
handler.verifyEvents(Collections.singleton(y), emptySet(), emptySet());
|
||||
assertFalse(myWolfTheProblemSolver.hasSyntaxErrors(y));
|
||||
|
||||
final PsiJavaFile psiX = (PsiJavaFile)myPsiManager.findFile(x);
|
||||
WriteCommandAction.runWriteCommandAction(null, () -> {
|
||||
psiX.getClasses()[0].replace(psiX.getClasses()[0]);
|
||||
|
||||
});
|
||||
highlightFile(x);
|
||||
handler.verifyEvents(emptySet(), Collections.singleton(x), emptySet());
|
||||
assertFalse(myWolfTheProblemSolver.hasSyntaxErrors(y));
|
||||
|
||||
PsiJavaFile psiY = (PsiJavaFile)myPsiManager.findFile(y);
|
||||
assertNotNull(psiY);
|
||||
final PsiClass newX = myJavaFacade.getElementFactory().createClassFromText("",null);
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
try {
|
||||
psiX.getClasses()[0].replace(newX);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
}), null, null);
|
||||
highlightFile(x);
|
||||
handler.verifyEvents(emptySet(), emptySet(), Collections.singleton(x));
|
||||
assertFalse(myWolfTheProblemSolver.hasSyntaxErrors(x));
|
||||
}
|
||||
|
||||
public void testExternalSources() throws Exception {
|
||||
VirtualFile root = configureRoot();
|
||||
MyProblemListener handler = new MyProblemListener();
|
||||
myProject.getMessageBus().connect(getTestRootDisposable()).subscribe(ProblemListener.TOPIC, handler);
|
||||
|
||||
VirtualFile t = root.findFileByRelativePath("foo.java");
|
||||
Object source1 = new Object();
|
||||
Object source2 = new Object();
|
||||
myWolfTheProblemSolver.reportProblemsFromExternalSource(t, source1);
|
||||
handler.verifyEvents(Collections.singleton(t), emptySet(), emptySet());
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(t));
|
||||
assertTrue(myWolfTheProblemSolver.hasProblemFilesBeneath(myModule));
|
||||
|
||||
myWolfTheProblemSolver.reportProblemsFromExternalSource(t, source2);
|
||||
handler.verifyEvents(emptySet(), Collections.singleton(t), emptySet());
|
||||
|
||||
myWolfTheProblemSolver.clearProblemsFromExternalSource(t, source2);
|
||||
handler.verifyEvents(emptySet(), Collections.singleton(t), emptySet());
|
||||
|
||||
myWolfTheProblemSolver.clearProblemsFromExternalSource(t, source1);
|
||||
handler.verifyEvents(emptySet(), emptySet(), Collections.singleton(t));
|
||||
}
|
||||
|
||||
public void testRegularAndExternalProblems() throws Exception {
|
||||
VirtualFile root = configureRoot();
|
||||
MyProblemListener handler = new MyProblemListener();
|
||||
myProject.getMessageBus().connect(getTestRootDisposable()).subscribe(ProblemListener.TOPIC, handler);
|
||||
|
||||
Object source1 = new Object();
|
||||
VirtualFile x = root.findFileByRelativePath("x/X.java");
|
||||
myWolfTheProblemSolver.reportProblemsFromExternalSource(x, source1);
|
||||
handler.verifyEvents(Collections.singleton(x), emptySet(), emptySet());
|
||||
|
||||
highlightFile(x);
|
||||
handler.verifyEvents(emptySet(), Collections.singleton(x), emptySet());
|
||||
|
||||
deleteMethodWithProblem(x);
|
||||
highlightFile(x);
|
||||
handler.verifyEvents(emptySet(), Collections.singleton(x), emptySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invokeTestRunnable(@NotNull final Runnable runnable) {
|
||||
ApplicationManager.getApplication().runReadAction(runnable);
|
||||
}
|
||||
|
||||
private void highlightFile(@NotNull VirtualFile virtualFile) {
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
|
||||
documentManager.commitAllDocuments();
|
||||
FileEditor fileEditor = FileEditorManagerEx.getInstanceEx(getProject()).openFile(virtualFile, false)[0];
|
||||
Editor editor = ((TextEditor)fileEditor).getEditor();
|
||||
PsiFile file = documentManager.getPsiFile(editor.getDocument());
|
||||
|
||||
CodeInsightTestFixtureImpl.instantiateAndRun(file, editor, new int[0], false);
|
||||
}
|
||||
|
||||
public void testChangeInsideBlock() {
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), () -> {
|
||||
try {
|
||||
configureByFile(BASE_PATH + "/pack/InsideBlock.java");
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, null, null);
|
||||
final VirtualFile virtualFile = myFile.getVirtualFile();
|
||||
List<HighlightInfo> errors = highlightErrors();
|
||||
assertTrue(myWolfTheProblemSolver.isProblemFile(virtualFile));
|
||||
assertEquals(1, errors.size());
|
||||
type(';');
|
||||
errors = highlightErrors();
|
||||
assertEmpty(errors);
|
||||
assertFalse(myWolfTheProblemSolver.isProblemFile(virtualFile));
|
||||
}
|
||||
|
||||
private static class MyProblemListener implements ProblemListener {
|
||||
private final Set<VirtualFile> myEventAdded;
|
||||
private final Set<VirtualFile> myEventChanged;
|
||||
private final Set<VirtualFile> myEventRemoved;
|
||||
|
||||
private MyProblemListener() {
|
||||
myEventAdded = new HashSet<>();
|
||||
myEventChanged = new HashSet<>();
|
||||
myEventRemoved = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void problemsAppeared(@NotNull VirtualFile file) {
|
||||
myEventAdded.add(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void problemsChanged(@NotNull VirtualFile file) {
|
||||
myEventChanged.add(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void problemsDisappeared(@NotNull VirtualFile file) {
|
||||
myEventRemoved.add(file);
|
||||
}
|
||||
|
||||
public void verifyEvents(Collection<VirtualFile> added, Collection<VirtualFile> changed, Collection<VirtualFile> removed) {
|
||||
assertEquals(added, myEventAdded);
|
||||
assertEquals(changed, myEventChanged);
|
||||
assertEquals(removed, myEventRemoved);
|
||||
myEventAdded.clear();
|
||||
myEventChanged.clear();
|
||||
myEventRemoved.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user