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