Package com.python.pydev.analysis.messages

Examples of com.python.pydev.analysis.messages.IMessage


            Map<Integer, List<IMessage>> messagesByType = getMessagesByType(l);
            for (int type : messagesByType.keySet()) {
                l = messagesByType.get(type);

                //the values are guaranteed to have size at least equal to 1
                IMessage message = l.get(0);

                //messages are grouped by type, and the severity is set by type, so, this is ok...
                if (message.getSeverity() == IMarker.SEVERITY_INFO) {
                    if (doIgnoreMessageIfJustInformational(message.getType())) {
                        //ok, let's ignore it for real (and don't add it) as those are not likely to be
                        //used anyways for other actions)
                        continue;

                    }
                }
                //we add even ignore messages because they might be used later in actions dependent on code analysis

                if (l.size() == 1) {
                    //don't add additional info: not being used
                    //                    addAdditionalInfoToUnusedWildImport(message);
                    addToResult(result, message);

                } else {
                    //the generator token has many associated messages - the messages may have different types,
                    //so, we need to get them by types
                    IToken generator = message.getGenerator();
                    CompositeMessage compositeMessage;
                    if (generator != null) {
                        compositeMessage = new CompositeMessage(message.getType(), generator, prefs);
                    } else {
                        compositeMessage = new CompositeMessage(message.getType(), message.getStartLine(document),
                                message.getEndLine(document), message.getStartCol(document),
                                message.getEndCol(document), prefs);

                    }
                    for (IMessage m : l) {
                        compositeMessage.addMessage(m);
                    }

                    //don't add additional info: not being used
                    //                    addAdditionalInfoToUnusedWildImport(compositeMessage);
                    addToResult(result, compositeMessage);
                }
            }
        }

        for (IMessage message : independentMessages) {
            if (message.getSeverity() == IMarker.SEVERITY_INFO) {
                if (doIgnoreMessageIfJustInformational(message.getType())) {
                    //ok, let's ignore it for real (and don't add it) as those are not likely to be
                    //used anyways for other actions)
                    continue;

                }
View Full Code Here


    protected IMessage assertContainsMsg(String msg, IMessage[] msgs2) {
        return assertContainsMsg(msg, msgs2, -1);
    }

    protected IMessage assertContainsMsg(String msg, IMessage[] msgs2, int line) {
        IMessage found = containsMsg(msg, msgs2, line);

        if (found != null) {
            return found;
        }
View Full Code Here

                "\n" +
                "");

        List<IMessage> messages = TabNanny.analyzeDoc(doc, this.prefs, "", new TestIndentPrefs(true, 4),
                new NullProgressMonitor());
        IMessage m = messages.get(0);
        assertEquals(1, messages.size());
        assertEquals("Mixed Indentation: Tab found", m.getMessage());
        assertEquals(3, m.getStartLine(null));
        assertEquals(3, m.getEndLine(null));
        assertEquals(1, m.getStartCol(null));
        assertEquals(2, m.getEndCol(null));

    }
View Full Code Here

    /**
     * Checks if a specific message is contained within the messages passed
     */
    protected IMessage containsMsg(String msg, IMessage[] msgs2, int line) {
        IMessage ret = null;
        for (IMessage message : msgs2) {
            if (message.getMessage().equals(msg)) {
                if (line != -1) {
                    ret = message;
                    if (line == message.getStartLine(doc)) {
View Full Code Here

                "");

        List<IMessage> messages = TabNanny.analyzeDoc(doc, this.prefs, "", new TestIndentPrefs(true, 4),
                new NullProgressMonitor());
        assertEquals(1, messages.size());
        IMessage m = messages.get(0);
        assertEquals("Bad Indentation (3 spaces)", m.getMessage());
        assertEquals(2, m.getStartLine(null));
        assertEquals(2, m.getEndLine(null));
        assertEquals(1, m.getStartCol(null));
        assertEquals(4, m.getEndCol(null));

    }
View Full Code Here

    public void testParameterAnalysis8() throws IOException {
        doc = new Document("from extendable.calltips.mod1.sub1 import method1\n" + //method1(a, b)
                "method1(10)");
        IMessage[] errors = checkError(1);
        IMessage msg = errors[0];
        assertEquals(msg.getMessage(), "method1: arguments don't match");
        assertEquals(msg.getStartCol(doc), 8);
        assertEquals(msg.getEndCol(doc), 12);
        assertEquals(msg.getStartLine(doc), 2);
        assertEquals(msg.getEndLine(doc), 2);
    }
View Full Code Here

    public void testParameterAnalysis8a() throws IOException {
        doc = new Document("from extendable.calltips.mod1.sub1 import method1\n" +
                "method1(\n" +
                "       10)");
        IMessage[] errors = checkError(1);
        IMessage msg = errors[0];
        assertEquals(msg.getMessage(), "method1: arguments don't match");
        assertEquals(msg.getStartCol(doc), 8);
        assertEquals(msg.getEndCol(doc), 11);
        assertEquals(msg.getStartLine(doc), 2);
        assertEquals(msg.getEndLine(doc), 3);
    }
View Full Code Here

        analyzer = new OccurrencesAnalyzer();
        msgs = analyzeDoc();

        printMessages(msgs, 1);

        IMessage message = assertContainsMsg("Unused import: os.path", msgs);
        assertEquals(8, message.getStartCol(doc));
        assertEquals(15, message.getEndCol(doc));

    }
View Full Code Here

                "");
        analyzer = new OccurrencesAnalyzer();
        msgs = analyzeDoc();

        printMessages(msgs, 2);
        IMessage message = assertContainsMsg("Unused import: otherthing", msgs);
        assertEquals(8, message.getStartCol(doc));
        assertEquals(29, message.getEndCol(doc));

        message = assertContainsMsg("Unused import: unittest", msgs);
        assertEquals(31, message.getStartCol(doc));
        assertEquals(39, message.getEndCol(doc));

    }
View Full Code Here

                "");
        analyzer = new OccurrencesAnalyzer();
        msgs = analyzeDoc();

        printMessages(msgs, 2);
        IMessage message = assertContainsMsg("Unused import: unittest", msgs);
        assertEquals(21, message.getStartCol(doc));
        assertEquals(29, message.getEndCol(doc));

        message = assertContainsMsg("Unused import: __init__", msgs);
        assertEquals(31, message.getStartCol(doc));
        assertEquals(39, message.getEndCol(doc));

    }
View Full Code Here

TOP

Related Classes of com.python.pydev.analysis.messages.IMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.