Search in sources :

Example 6 with HighlightInfo

use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.

the class XmlHighlightingTest method testduplicateAttribute2.

public void testduplicateAttribute2() throws Exception {
    configureByFiles(null, BASE_PATH + getTestName(false) + ".xml", BASE_PATH + getTestName(false) + ".xsd");
    final String url = "http://www.foo.org/schema";
    final String url2 = "http://www.bar.org/foo";
    ExternalResourceManagerExImpl.registerResourceTemporarily(url, getTestName(false) + ".xsd", getTestRootDisposable());
    ExternalResourceManagerExImpl.registerResourceTemporarily(url2, getTestName(false) + ".xsd", getTestRootDisposable());
    final Collection<HighlightInfo> infoCollection = doDoTest(true, false, true);
    final TextRange startTagNameRange = XmlTagUtil.getStartTagNameElement(((XmlFile) myFile).getDocument().getRootTag()).getTextRange();
    HighlightInfo infoAtTagName = null;
    for (HighlightInfo info : infoCollection) {
        if (info.startOffset == startTagNameRange.getStartOffset() && info.endOffset == startTagNameRange.getEndOffset()) {
            if (info.getDescription().equals("Attribute \"foo\" bound to namespace \"http://www.w3.org/2000/xmlns/\" was already specified for element \"root\".")) {
                infoAtTagName = info;
                break;
            }
        }
    }
    assertNotNull(infoAtTagName);
}
Also used : HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) TextRange(com.intellij.openapi.util.TextRange)

Example 7 with HighlightInfo

use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.

the class XmlHighlightingTest method testChangeRootElement.

public void testChangeRootElement() throws Exception {
    enableInspectionTool(new XmlWrongRootElementInspection());
    final String testName = getTestName(false);
    configureByFile(BASE_PATH + testName + ".xml");
    Collection<HighlightInfo> infos = doDoTest(true, false);
    findAndInvokeIntentionAction(infos, "Change root tag name to xxx", myEditor, myFile);
    checkResultByFile(BASE_PATH + testName + "_after.xml");
}
Also used : XmlWrongRootElementInspection(com.intellij.codeInspection.htmlInspections.XmlWrongRootElementInspection) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo)

Example 8 with HighlightInfo

use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.

the class XmlHighlightingTest method testResolvedDtdElementReferences.

public void testResolvedDtdElementReferences() throws Exception {
    configureByFile(BASE_PATH + getTestName(false) + ".dtd");
    doDoTest(true, false);
    final String text = myEditor.getDocument().getText();
    WriteCommandAction.runWriteCommandAction(null, () -> myEditor.getSelectionModel().setSelection(0, myEditor.getDocument().getTextLength()));
    AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_COMMENT_BLOCK);
    action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext()));
    assertNotSame(text, myEditor.getDocument().getText());
    PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
    Collection<HighlightInfo> infos = doHighlighting();
    assertEquals(0, infos.size());
    action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext()));
    assertEquals(text, myEditor.getDocument().getText().trim());
    PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
    infos = doHighlighting();
    assertEquals(0, infos.size());
}
Also used : HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 9 with HighlightInfo

use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.

the class HighlightingTestBase method doCustomHighlighting.

protected void doCustomHighlighting(boolean checkWeakWarnings, Boolean includeExternalToolPass) {
    final PsiFile file = myTestFixture.getFile();
    final Document doc = myTestFixture.getEditor().getDocument();
    ExpectedHighlightingData data = new ExpectedHighlightingData(doc, true, checkWeakWarnings, false, file);
    data.init();
    PsiDocumentManager.getInstance(myTestFixture.getProject()).commitAllDocuments();
    Collection<HighlightInfo> highlights1 = doHighlighting(includeExternalToolPass);
    data.checkResult(highlights1, doc.getText());
}
Also used : ExpectedHighlightingData(com.intellij.testFramework.ExpectedHighlightingData) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) PsiFile(com.intellij.psi.PsiFile) Document(com.intellij.openapi.editor.Document)

Example 10 with HighlightInfo

use of com.intellij.codeInsight.daemon.impl.HighlightInfo in project intellij-community by JetBrains.

the class SpellcheckerPerformanceTest method testManyWhitespaces.

public void testManyWhitespaces() {
    final int count = 100000;
    String text = StringUtil.repeat("//\n     \t      \t    \n   \n", count);
    long start = System.currentTimeMillis();
    VirtualFile file = myFixture.addFileToProject("foo.java", text).getVirtualFile();
    System.out.println("creation took " + (System.currentTimeMillis() - start) + " ms");
    start = System.currentTimeMillis();
    myFixture.configureFromExistingVirtualFile(file);
    System.out.println("configure took " + (System.currentTimeMillis() - start) + " ms");
    start = System.currentTimeMillis();
    List<HighlightInfo> infos = runLocalInspections();
    assertEmpty(infos);
    System.out.println("warm-up took " + (System.currentTimeMillis() - start) + " ms");
    PlatformTestUtil.startPerformanceTest("many whitespaces highlighting", 4000, () -> {
        DaemonCodeAnalyzer.getInstance(getProject()).restart();
        assertEmpty(runLocalInspections());
    }).cpuBound().assertTiming();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo)

Aggregations

HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)221 Nullable (org.jetbrains.annotations.Nullable)51 TextRange (com.intellij.openapi.util.TextRange)33 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)30 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 NotNull (org.jetbrains.annotations.NotNull)17 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)16 Document (com.intellij.openapi.editor.Document)12 ArrayList (java.util.ArrayList)11 PsiElement (com.intellij.psi.PsiElement)10 File (java.io.File)8 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)7 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)6 Pair (com.intellij.openapi.util.Pair)6 PsiFile (com.intellij.psi.PsiFile)6 Editor (com.intellij.openapi.editor.Editor)5 NonNls (org.jetbrains.annotations.NonNls)5 StringUtil (com.intellij.openapi.util.text.StringUtil)4 IElementType (com.intellij.psi.tree.IElementType)4 ContainerUtil (com.intellij.util.containers.ContainerUtil)4