Browse Source

REPORT-20328 sonar

persist/11.0
jinbokai 5 years ago
parent
commit
2ebff9157d
  1. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextArea.java
  2. 9
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Style.java
  3. 9
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java
  4. 2
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java
  5. 24
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaBase.java
  6. 3
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/SearchEngine.java
  7. 5
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/VolatileImageBackgroundPainterStrategy.java

8
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextArea.java

@ -3016,11 +3016,6 @@ private boolean fractionalFontMetricsEnabled;
return he;
}
private final boolean equal(LinkGeneratorResult e1,
LinkGeneratorResult e2) {
return e1.getSourceOffset()==e2.getSourceOffset();
}
@Override
public void mouseClicked(MouseEvent e) {
if (getHyperlinksEnabled() && isScanningForLinks &&
@ -3080,8 +3075,7 @@ private boolean fractionalFontMetricsEnabled;
isLinkAtOffset(RSyntaxTextArea.this, offs);
if (newResult!=null) {
// Repaint if we're at a new link now.
if (linkGeneratorResult==null ||
!equal(newResult, linkGeneratorResult)) {
if (linkGeneratorResult==null || newResult.getSourceOffset() != linkGeneratorResult.getSourceOffset()) {
repaint();
}
linkGeneratorResult = newResult;

9
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Style.java

@ -9,6 +9,7 @@
*/
package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import com.fr.log.FineLoggerFactory;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
@ -123,15 +124,15 @@ public class Style implements Cloneable {
Style clone = null;
try {
clone = (Style)super.clone();
} catch (CloneNotSupportedException cnse) { // Never happens
cnse.printStackTrace();
return null;
}
clone.foreground = foreground;
clone.background = background;
clone.font = font;
clone.underline = underline;
clone.fontMetrics = fontMetrics;
} catch (CloneNotSupportedException cnse) { // Never happens
FineLoggerFactory.getLogger().error(cnse.getMessage(), cnse);
clone = null;
}
return clone;
}

9
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java

@ -9,6 +9,7 @@
*/
package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import com.fr.log.FineLoggerFactory;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
@ -122,10 +123,6 @@ public class SyntaxScheme implements Cloneable, TokenTypes {
SyntaxScheme shcs = null;
try {
shcs = (SyntaxScheme) super.clone();
} catch (CloneNotSupportedException cnse) { // Never happens
cnse.printStackTrace();
return null;
}
shcs.styles = new Style[styles.length];
for (int i = 0; i < styles.length; i++) {
Style s = styles[i];
@ -133,6 +130,10 @@ public class SyntaxScheme implements Cloneable, TokenTypes {
shcs.styles[i] = (Style) s.clone();
}
}
} catch (CloneNotSupportedException cnse) { // Never happens
FineLoggerFactory.getLogger().error(cnse.getMessage(), cnse);
shcs = null;
}
return shcs;
}

2
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java

@ -149,7 +149,7 @@ public class HtmlFoldParser implements FoldParser {
}
// ?> or %>
else if (t.startsWith(LANG_END[language])) {
else if (currentFold != null && t.startsWith(LANG_END[language])) {
int phpEnd = t.getEndOffset() - 1;
currentFold.setEndOffset(phpEnd);
Fold parentFold = currentFold.getParent();

24
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaBase.java

@ -723,7 +723,6 @@ int currentCaretY; // Used to know when to rehighlight current line.
// If we're wrapping lines we need to check the actual y-coordinate
// of the caret, not just the line number, since a single logical
// line can span multiple physical lines.
if (getLineWrap()) {
try {
Rectangle temp = modelToView(dot);
if (temp != null) {
@ -732,29 +731,6 @@ int currentCaretY; // Used to know when to rehighlight current line.
} catch (BadLocationException ble) {
ble.printStackTrace(); // Should never happen.
}
}
// No line wrap - we can simply check the line number (quicker).
else {
// Document doc = getDocument();
// if (doc!=null) {
// Element map = doc.getDefaultRootElement();
// int caretLine = map.getElementIndex(dot);
// Rectangle alloc = ((RTextAreaUI)getUI()).
// getVisibleEditorRect();
// if (alloc!=null)
// currentCaretY = alloc.y + caretLine*lineHeight;
// }
// Modified for code folding requirements
try {
Rectangle temp = modelToView(dot);
if (temp!=null) {
currentCaretY = temp.y;
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Should never happen.
}
}
// Repaint current line (to fill in entire highlight), and old line
// (to erase entire old highlight) if necessary. Always repaint

3
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/SearchEngine.java

@ -25,6 +25,7 @@ import javax.swing.text.Caret;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.DocumentRange;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import org.jetbrains.annotations.NotNull;
/**
@ -174,6 +175,7 @@ public class SearchEngine {
* @param forward Whether we're searching forward or backward.
* @return The character sequence.
*/
@NotNull
private static CharSequence getFindInCharSequence(RTextArea textArea,
int start, boolean forward) {
RDocument doc = (RDocument)textArea.getDocument();
@ -752,7 +754,6 @@ public class SearchEngine {
int start = makeMarkAndDotEqual(textArea, forward);
CharSequence findIn = getFindInCharSequence(textArea, start, forward);
if (findIn==null) return new SearchResult();
int markAllCount = 0;
if (context.getMarkAll()) {

5
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/VolatileImageBackgroundPainterStrategy.java

@ -103,6 +103,9 @@ public class VolatileImageBackgroundPainterStrategy
} finally {
tracker.removeImage(i, 1);
}
if(bgImage == null) {
continue;
}
bgImage.getGraphics().drawImage(i, 0,0, null);
tracker.addImage(bgImage, 0);
try {
@ -114,7 +117,7 @@ public class VolatileImageBackgroundPainterStrategy
} finally {
tracker.removeImage(bgImage, 0);
}
} while (bgImage.contentsLost());
} while (bgImage != null && bgImage.contentsLost());
} // End of if (master!=null).
else {
bgImage = null;

Loading…
Cancel
Save