SyntaxTextArea.java

1
package com.jsql.view.swing.text;
2
3
import com.jsql.util.LogLevelUtil;
4
import com.jsql.view.swing.popupmenu.JPopupMenuComponent;
5
import com.jsql.view.swing.util.UiUtil;
6
import org.apache.commons.lang3.StringUtils;
7
import org.apache.logging.log4j.LogManager;
8
import org.apache.logging.log4j.Logger;
9
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
10
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
11
import org.fife.ui.rsyntaxtextarea.Token;
12
13
import java.awt.*;
14
import java.awt.event.FocusAdapter;
15
import java.awt.event.FocusEvent;
16
17
public class SyntaxTextArea extends RSyntaxTextArea implements JPlaceholder {
18
19
    private static final Logger LOGGER = LogManager.getRootLogger();
20
21
    private String placeholderText;
22
23
    public SyntaxTextArea() {
24
        this(StringUtils.EMPTY);
25
    }
26
27
    public SyntaxTextArea(String text) {
28
        this.placeholderText = text;
29
30 1 1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::setPopupMenu → NO_COVERAGE
        this.setPopupMenu(new JPopupMenuComponent(this));
31 1 1. <init> : removed call to javax/swing/text/Caret::setBlinkRate → NO_COVERAGE
        this.getCaret().setBlinkRate(0);
32 1 1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::addFocusListener → NO_COVERAGE
        this.addFocusListener(new FocusAdapter() {
33
            @Override
34
            public void focusGained(FocusEvent focusEvent) {
35 1 1. focusGained : removed call to javax/swing/text/Caret::setVisible → NO_COVERAGE
                SyntaxTextArea.this.getCaret().setVisible(true);
36 1 1. focusGained : removed call to javax/swing/text/Caret::setSelectionVisible → NO_COVERAGE
                SyntaxTextArea.this.getCaret().setSelectionVisible(true);
37
            }
38
        });
39 1 1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::setCursor → NO_COVERAGE
        this.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
40 1 1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::setSyntaxEditingStyle → NO_COVERAGE
        this.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
41 1 1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::setMarkOccurrences → NO_COVERAGE
        this.setMarkOccurrences(true);
42 1 1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::setMarkOccurrencesDelay → NO_COVERAGE
        this.setMarkOccurrencesDelay(200);
43
    }
44
45
    @Override
46
    public void paint(Graphics g) {
47
        // Fix #6350: ArrayIndexOutOfBoundsException on paint()
48
        // Fix #90822: IllegalArgumentException on paint()
49
        // Fix #90761: StateInvariantError on paint()
50
        // StateInvariantError possible on jdk 8 when WrappedPlainView.drawLine in paint()
51
        try {
52 1 1. paint : removed call to org/fife/ui/rsyntaxtextarea/RSyntaxTextArea::paint → NO_COVERAGE
            super.paint(g);
53 2 1. paint : negated conditional → NO_COVERAGE
2. paint : negated conditional → NO_COVERAGE
            if (StringUtils.isEmpty(this.getText()) && StringUtils.isNotEmpty(this.placeholderText)) {
54 1 1. paint : removed call to com/jsql/view/swing/util/UiUtil::drawPlaceholder → NO_COVERAGE
                UiUtil.drawPlaceholder(this, g, this.placeholderText);
55
            }
56
        } catch (IllegalArgumentException | NullPointerException | ArrayIndexOutOfBoundsException e) {
57
            LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
58
        }
59
    }
60
61
    @Override
62
    public Font getFont() {
63 1 1. getFont : replaced return value with null for com/jsql/view/swing/text/SyntaxTextArea::getFont → NO_COVERAGE
        return UiUtil.FONT_MONO_NON_ASIAN;
64
    }
65
    @Override
66
    public Font getFontForToken(Token token) {
67 1 1. getFontForToken : replaced return value with null for com/jsql/view/swing/text/SyntaxTextArea::getFontForToken → NO_COVERAGE
        return UiUtil.FONT_MONO_NON_ASIAN;
68
    }
69
    @Override
70
    public Font getFontForTokenType(int type) {
71 1 1. getFontForTokenType : replaced return value with null for com/jsql/view/swing/text/SyntaxTextArea::getFontForTokenType → NO_COVERAGE
        return UiUtil.FONT_MONO_NON_ASIAN;
72
    }
73
    @Override
74
    public void setPlaceholderText(String placeholderText) {
75
        this.placeholderText = placeholderText;
76
    }
77
}

Mutations

30

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/text/SyntaxTextArea::setPopupMenu → NO_COVERAGE

31

1.1
Location : <init>
Killed by : none
removed call to javax/swing/text/Caret::setBlinkRate → NO_COVERAGE

32

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/text/SyntaxTextArea::addFocusListener → NO_COVERAGE

35

1.1
Location : focusGained
Killed by : none
removed call to javax/swing/text/Caret::setVisible → NO_COVERAGE

36

1.1
Location : focusGained
Killed by : none
removed call to javax/swing/text/Caret::setSelectionVisible → NO_COVERAGE

39

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/text/SyntaxTextArea::setCursor → NO_COVERAGE

40

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/text/SyntaxTextArea::setSyntaxEditingStyle → NO_COVERAGE

41

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/text/SyntaxTextArea::setMarkOccurrences → NO_COVERAGE

42

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/text/SyntaxTextArea::setMarkOccurrencesDelay → NO_COVERAGE

52

1.1
Location : paint
Killed by : none
removed call to org/fife/ui/rsyntaxtextarea/RSyntaxTextArea::paint → NO_COVERAGE

53

1.1
Location : paint
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : paint
Killed by : none
negated conditional → NO_COVERAGE

54

1.1
Location : paint
Killed by : none
removed call to com/jsql/view/swing/util/UiUtil::drawPlaceholder → NO_COVERAGE

63

1.1
Location : getFont
Killed by : none
replaced return value with null for com/jsql/view/swing/text/SyntaxTextArea::getFont → NO_COVERAGE

67

1.1
Location : getFontForToken
Killed by : none
replaced return value with null for com/jsql/view/swing/text/SyntaxTextArea::getFontForToken → NO_COVERAGE

71

1.1
Location : getFontForTokenType
Killed by : none
replaced return value with null for com/jsql/view/swing/text/SyntaxTextArea::getFontForTokenType → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1