Search in sources :

Example 6 with ExpectedHighlightingData

use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-community by JetBrains.

the class LightDaemonAnalyzerTestCase method doTestFile.

protected HighlightTestInfo doTestFile(@NonNls @NotNull String filePath) {
    return new HighlightTestInfo(getTestRootDisposable(), filePath) {

        @Override
        public HighlightTestInfo doTest() {
            String path = assertOneElement(filePaths);
            configureByFile(path);
            ExpectedHighlightingData data = new JavaExpectedHighlightingData(myEditor.getDocument(), checkWarnings, checkWeakWarnings, checkInfos, myFile);
            if (checkSymbolNames)
                data.checkSymbolNames();
            checkHighlighting(data, composeLocalPath(path));
            return this;
        }
    };
}
Also used : HighlightTestInfo(com.intellij.testFramework.HighlightTestInfo) ExpectedHighlightingData(com.intellij.testFramework.ExpectedHighlightingData)

Example 7 with ExpectedHighlightingData

use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-community by JetBrains.

the class LightDaemonAnalyzerTestCase method doTestConfiguredFile.

protected void doTestConfiguredFile(boolean checkWarnings, boolean checkWeakWarnings, boolean checkInfos, @Nullable String filePath) {
    PsiManagerEx.getInstanceEx(getProject()).setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, getTestRootDisposable());
    ExpectedHighlightingData data = getExpectedHighlightingData(checkWarnings, checkWeakWarnings, checkInfos);
    checkHighlighting(data, composeLocalPath(filePath));
}
Also used : ExpectedHighlightingData(com.intellij.testFramework.ExpectedHighlightingData)

Example 8 with ExpectedHighlightingData

use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-community by JetBrains.

the class DumpCleanHighlightingTestdataAction method actionPerformed.

@Override
public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getProject();
    final PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE);
    if (psiFile != null) {
        final VirtualFile virtualFile = psiFile.getVirtualFile();
        if (virtualFile != null) {
            final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
            if (document != null) {
                final ExpectedHighlightingData data = new ExpectedHighlightingData(document, true, true);
                data.init();
            }
            return;
        }
    }
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle("Choose Directory");
    descriptor.setDescription("Directory containing highlighting test data");
    final VirtualFile dirToProcess = FileChooser.chooseFile(descriptor, project, null);
    if (dirToProcess != null) {
        LOG.assertTrue(project != null);
        final FileChooserDescriptor targetDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
        targetDescriptor.setTitle("Choose Directory");
        targetDescriptor.setDescription("Directory where highlighting-markup-free copies would be placed");
        final VirtualFile destinationFolder = FileChooser.chooseFile(targetDescriptor, project, null);
        if (dirToProcess.equals(destinationFolder)) {
            Messages.showErrorDialog(project, "Source and destination roots should differ", "Reject to Proceed");
            return;
        }
        if (destinationFolder != null) {
            final File destination = VfsUtilCore.virtualToIoFile(destinationFolder);
            final VirtualFile[] files = dirToProcess.getChildren();
            for (VirtualFile virtualFile : files) {
                final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
                if (document != null) {
                    final ExpectedHighlightingData data = new ExpectedHighlightingData(document, true, true);
                    data.init();
                    final File file = new File(destination, virtualFile.getName());
                    try {
                        FileUtil.writeToFile(file, document.getText());
                    } catch (IOException ex) {
                        LOG.error(ex);
                    }
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ExpectedHighlightingData(com.intellij.testFramework.ExpectedHighlightingData) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) PsiFile(com.intellij.psi.PsiFile) IOException(java.io.IOException) Document(com.intellij.openapi.editor.Document) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile)

Example 9 with ExpectedHighlightingData

use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-plugins by JetBrains.

the class FlexHighlightingTest method testSpellChecker.

@JSTestOptions(JSTestOption.WithFlexSdk)
public void testSpellChecker() throws Exception {
    enableInspectionTool(new SpellCheckingInspection());
    configureByFile(getBasePath() + "/" + getTestName(false) + ".mxml");
    ExpectedHighlightingData expectedHighlightingData = new ExpectedHighlightingData(myEditor.getDocument(), true, true, false, myFile);
    Collection<HighlightInfo> infoCollection = checkHighlighting(expectedHighlightingData);
    assertEquals(1, countNonInformationHighlights(infoCollection));
    findAndInvokeActionWithExpectedCheck("Typo: Rename to...", "mxml", infoCollection);
}
Also used : SpellCheckingInspection(com.intellij.spellchecker.inspections.SpellCheckingInspection) ExpectedHighlightingData(com.intellij.testFramework.ExpectedHighlightingData) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo)

Example 10 with ExpectedHighlightingData

use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-plugins by JetBrains.

the class ActionScriptHighlightingInTextFieldTest method doTestForEditorTextField.

private void doTestForEditorTextField(JSExpressionCodeFragment fragment) throws Exception {
    myFile = fragment;
    Document document = PsiDocumentManager.getInstance(myProject).getDocument(fragment);
    final JSEditorTextField editorTextField = new JSEditorTextField(myProject, document);
    // initialize editor
    editorTextField.addNotify();
    myEditor = editorTextField.getEditor();
    try {
        checkHighlighting(new ExpectedHighlightingData(editorTextField.getDocument(), true, true, true, myFile));
    } finally {
        editorTextField.removeNotify();
        UIUtil.dispatchAllInvocationEvents();
    }
}
Also used : ExpectedHighlightingData(com.intellij.testFramework.ExpectedHighlightingData) Document(com.intellij.openapi.editor.Document) JSEditorTextField(com.intellij.lang.javascript.refactoring.ui.JSEditorTextField)

Aggregations

ExpectedHighlightingData (com.intellij.testFramework.ExpectedHighlightingData)10 Document (com.intellij.openapi.editor.Document)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)2 Project (com.intellij.openapi.project.Project)2 PsiFile (com.intellij.psi.PsiFile)2 HighlightTestInfo (com.intellij.testFramework.HighlightTestInfo)2 File (java.io.File)2 IOException (java.io.IOException)2 LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)1 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)1 JSEditorTextField (com.intellij.lang.javascript.refactoring.ui.JSEditorTextField)1 DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)1 EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Module (com.intellij.openapi.module.Module)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)1 Ref (com.intellij.openapi.util.Ref)1