@Override public void setUp() throws Exception { super.setUp(); ((CodeInsightTestFixtureImpl)myFixture).canChangeDocumentDuringHighlighting(true); myFixture.enableInspections(GoUnusedImportInspection.class); }
private void doInspectionTest(@NotNull InspectionProfileEntry tool, long expected) { VirtualFile sourceDir = installTestData("docker"); if (sourceDir == null) return; //noinspection ConstantConditions AnalysisScope scope = new AnalysisScope(getPsiManager().findDirectory(sourceDir)); scope.invalidate(); InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject()); InspectionToolWrapper wrapper = InspectionToolRegistrar.wrapTool(tool); GlobalInspectionContextForTests globalContext = CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, wrapper); PlatformTestUtil.startPerformanceTest(getTestName(true), (int)expected, () -> InspectionTestUtil.runTool(wrapper, scope, globalContext)).cpuBound().usesAllCPUCores().assertTiming(); InspectionTestUtil.compareToolResults(globalContext, wrapper, false, new File(getTestDataPath(), wrapper.getShortName()).getPath()); }
protected void testFoldingRegions(@NotNull String verificationFileName, boolean doCheckCollapseStatus, LanguageFileType fileType) { String expectedContent; try { expectedContent = FileUtil.loadFile(new File(getTestDataPath() + "/" + verificationFileName + ".code")); } catch (IOException e) { throw new RuntimeException(e); } Assert.assertNotNull(expectedContent); expectedContent = StringUtil.replace(expectedContent, "\r", ""); final String cleanContent = expectedContent.replaceAll(START_FOLD, "").replaceAll(END_FOLD, ""); myFixture.configureByText(fileType, cleanContent); final String actual = ((CodeInsightTestFixtureImpl)myFixture).getFoldingDescription(doCheckCollapseStatus); Assert.assertEquals(expectedContent, actual); }
public void checkSerializedReferencesWithFile(@NotNull String appendix) { CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); addVirtualFileFilter(); StringBuilder sb = new StringBuilder(); List<PsiReference> references = collectFileReferences(); for (PsiReference psiReference : references) { psiReference.resolve(); } removeVirtualFileFilter(); for (PsiReference psiReference : references) { sb.append(serializeReference(psiReference)).append("\n"); } UsefulTestCase.assertSameLinesWithFile(getTestResultsFilePath(appendix), sb.toString()); }
throw new RuntimeException(e); final String actual = ((CodeInsightTestFixtureImpl)myFixture).getFoldingDescription(doCheckCollapseStatus); if (!expectedContent.equals(actual)) { throw new FileComparisonFailure(verificationFile.getName(), expectedContent, actual, verificationFile.getPath());
protected void doTestCompletionCheck(@NotNull String answerSuffix) { CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); addVirtualFileFilter(); myFixture.complete(CompletionType.BASIC, 1);
/** * Adds a library from testData/testLibSets as external dependency * * @param testLibraryName library name */ protected void addTestLibrary(@NotNull String testLibraryName) { Application application = ApplicationManager.getApplication(); application.invokeAndWait(() -> application.runWriteAction( () -> { VirtualFile libdir = LocalFileSystem.getInstance().refreshAndFindFileByPath( FileUtil.join("testData", "testLibSets", testLibraryName) ); assert libdir != null; PerlProjectManager perlProjectManager = PerlProjectManager.getInstance(getProject()); perlProjectManager.addExternalLibrary(libdir); CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); })); }
@Override protected void setUp() throws Exception { super.setUp(); myFixture.enableInspections(GoUnresolvedReferenceInspection.class); ((CodeInsightTestFixtureImpl)myFixture).canChangeDocumentDuringHighlighting(true); CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance(); defaultJavaOnTheFly = codeInsightSettings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY; defaultJavaMemberOnTheFly = codeInsightSettings.ADD_MEMBER_IMPORTS_ON_THE_FLY; defaultGoOnTheFly = GoCodeInsightSettings.getInstance().isAddUnambiguousImportsOnTheFly(); codeInsightSettings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true; codeInsightSettings.ADD_MEMBER_IMPORTS_ON_THE_FLY = true; }
final Editor editor = getEditor(); final Project project = getProject(); CodeInsightTestFixtureImpl.ensureIndexesUpToDate(project); final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project); final TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
protected void setUpLibrary() { Application application = ApplicationManager.getApplication(); application.invokeAndWait(() -> application.runWriteAction( () -> { VirtualFile libdir = LocalFileSystem.getInstance().refreshAndFindFileByPath("../testData/testlib"); assert libdir != null; PerlProjectManager perlProjectManager = PerlProjectManager.getInstance(getProject()); ProjectJdkImpl testSdk = PerlSdkTable.getInstance().createSdk("test"); testSdk.setSdkAdditionalData(new PerlSdkAdditionalData( PerlHostHandler.getDefaultHandler().createData(), PerlVersionManagerData.getDefault(), PerlImplementationHandler.getDefaultHandler().createData())); PerlSdkTable.getInstance().addJdk(testSdk, getTestRootDisposable()); perlProjectManager.setProjectSdk(testSdk); perlProjectManager.addExternalLibrary(libdir); CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); })); }