From f48ab9ba6d5b6810494b8db3c2f4b38560475d02 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Tue, 27 Aug 2019 09:33:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=EF=BC=8Csonar?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java | 5 +++++ .../ui/rsyntaxtextarea/parser/TaskTagParser.java | 5 +++++ .../design/gui/syntax/ui/rtextarea/LineNumberList.java | 10 +++++++++- .../fr/design/gui/syntax/ui/rtextarea/RTextArea.java | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java index 5f2f83337..b08b0caf7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java @@ -1351,6 +1351,11 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l // Start at alloc.x since this chunk starts // at the beginning of a physical line. + if (tlist == null) { + p0 = (p == p0) ? p1 : p; + alloc.y += alloc.height; + continue; + } int n = tlist.getListOffset(textArea, WrappedSyntaxView.this, alloc.x, x); diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java index 126193e82..7366c1d63 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java @@ -18,6 +18,7 @@ import com.fr.design.gui.syntax.ui.rsyntaxtextarea.ErrorStrip; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxDocument; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token; +import com.fr.stable.StringUtils; /** @@ -60,6 +61,7 @@ public class TaskTagParser extends AbstractParser { } + @SuppressWarnings("squid:S2259") public ParseResult parse(RSyntaxDocument doc, String style) { Element root = doc.getDefaultRootElement(); @@ -101,6 +103,9 @@ public class TaskTagParser extends AbstractParser { } if (start>-1) { + if (StringUtils.isEmpty(text)) { + continue; + } text = text.substring(start); // TODO: Strip off end of MLC's if they're there. int len = text.length(); diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java index b6cf8edd5..3fd4c7504 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java @@ -2,7 +2,7 @@ * 02/11/2009 * * LineNumberList.java - Renders line numbers in an RTextScrollPane. - * + * * This library is distributed under a modified BSD license. See the included * RSyntaxTextArea.License.txt file for details. */ @@ -349,6 +349,10 @@ public class LineNumberList extends AbstractGutterComponent int width = metrics.stringWidth(number); g.drawString(number, rhs-width,y); y += cellHeight; + if (fm == null) { + line++; + continue; + } Fold fold = fm.getFoldForLine(line-1); // Skip to next line to paint, taking extra care for lines with // block ends and begins together, e.g. "} else {" @@ -371,6 +375,10 @@ public class LineNumberList extends AbstractGutterComponent String number = Integer.toString(line + getLineNumberingStartIndex() - 1); g.drawString(number, RHS_BORDER_WIDTH, y); y += cellHeight; + if (fm == null) { + line++; + continue; + } Fold fold = fm.getFoldForLine(line-1); // Skip to next line to paint, taking extra care for lines with // block ends and begins together, e.g. "} else {" diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java index 9ea11b64d..d2e3284d7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java @@ -635,6 +635,9 @@ public class RTextArea extends RTextAreaBase implements Printable { parent = parent.getParent(); } KeyStroke backspace = KeyStroke.getKeyStroke("BACK_SPACE"); + if (inputMap == null) { + return; + } inputMap.put(backspace, DefaultEditorKit.deletePrevCharAction); }