Search in sources :

Example 6 with JsErrorMessage

use of com.google.jstestdriver.idea.common.JsErrorMessage in project intellij-plugins by JetBrains.

the class JsErrorMessageTest method testStrangeErrorName.

public void testStrangeErrorName() throws Exception {
    String text = "error loading file: /test/assertFramework/jstd/structure/emptyTestCase.js:1: Uncaught #<Object>";
    JsErrorMessage errorMessage = JsErrorMessage.parseFromText(text, myBasePath);
    assertNotNull(errorMessage);
    assertEquals(new File(myBasePath, "assertFramework/jstd/structure/emptyTestCase.js"), errorMessage.getFileWithError());
    assertEquals(1, errorMessage.getLineNumber());
    assertEquals(null, errorMessage.getColumnNumber());
    assertEquals("Uncaught Error", errorMessage.getErrorName());
}
Also used : JsErrorMessage(com.google.jstestdriver.idea.common.JsErrorMessage) File(java.io.File)

Example 7 with JsErrorMessage

use of com.google.jstestdriver.idea.common.JsErrorMessage in project intellij-plugins by JetBrains.

the class JsErrorMessageTest method testName.

public void testName() throws Exception {
    String text = "error loading file: /test/assertFramework/jstd/structure/emptyTestCase.js:1: ReferenceError: s is not defined";
    JsErrorMessage errorMessage = JsErrorMessage.parseFromText(text, myBasePath);
    assertNotNull(errorMessage);
    assertEquals(new File(myBasePath, "assertFramework/jstd/structure/emptyTestCase.js"), errorMessage.getFileWithError());
    assertEquals(1, errorMessage.getLineNumber());
    assertEquals(null, errorMessage.getColumnNumber());
    assertEquals("ReferenceError", errorMessage.getErrorName());
}
Also used : JsErrorMessage(com.google.jstestdriver.idea.common.JsErrorMessage) File(java.io.File)

Example 8 with JsErrorMessage

use of com.google.jstestdriver.idea.common.JsErrorMessage in project intellij-plugins by JetBrains.

the class JsErrorFilter method applyFilter.

@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
    JsErrorMessage message;
    try {
        message = JsErrorMessage.parseFromText(line, myBasePath);
    } catch (Exception e) {
        LOG.error("Can't parse error message from '" + line + "'", e);
        return null;
    }
    if (message == null) {
        return null;
    }
    VirtualFile virtualFile = VfsUtil.findFileByIoFile(message.getFileWithError(), false);
    if (virtualFile == null || !virtualFile.isValid()) {
        return null;
    }
    int column = ObjectUtils.notNull(message.getColumnNumber(), 0);
    HyperlinkInfo hyperlinkInfo = new OpenFileHyperlinkInfo(myProject, virtualFile, message.getLineNumber() - 1, column);
    return new Filter.Result(message.getHyperlinkStartInclusiveInd(), message.getHyperlinkEndExclusiveInd(), hyperlinkInfo);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) JsErrorMessage(com.google.jstestdriver.idea.common.JsErrorMessage) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

JsErrorMessage (com.google.jstestdriver.idea.common.JsErrorMessage)8 File (java.io.File)7 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 OpenFileHyperlinkInfo (com.intellij.execution.filters.OpenFileHyperlinkInfo)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1