Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkstyle should run on src/test #605

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static class TokenMakerCreator {
private String className;
private ClassLoader cl;

public TokenMakerCreator(String className, ClassLoader cl) {
TokenMakerCreator(String className, ClassLoader cl) {
this.className = className;
this.cl = cl!=null ? cl : getClass().getClassLoader();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private synchronized void sortTemplates() {
* to compare the template's ID to the segment's text.
*/
private static final class TemplateComparator implements Comparator<Object>,
Serializable{
Serializable {

@Override
public int compare(Object template, Object segment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public String getMacroID() {
/**
* Collapses all comment folds.
*/
public static class CollapseAllCommentFoldsAction extends FoldRelatedAction{
public static class CollapseAllCommentFoldsAction extends FoldRelatedAction {

private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class TokenMakerFactory {
/**
* The singleton default <code>TokenMakerFactory</code> instance.
*/
private static TokenMakerFactory DEFAULT_INSTANCE;
private static TokenMakerFactory defaultInstance;


/**
Expand All @@ -43,7 +43,7 @@ public abstract class TokenMakerFactory {
* @see #setDefaultInstance(TokenMakerFactory)
*/
public static synchronized TokenMakerFactory getDefaultInstance() {
if (DEFAULT_INSTANCE==null) {
if (defaultInstance ==null) {
String clazz;
try {
clazz= System.getProperty(PROPERTY_DEFAULT_TOKEN_MAKER_FACTORY);
Expand All @@ -54,7 +54,7 @@ public static synchronized TokenMakerFactory getDefaultInstance() {
clazz = "org.fife.ui.rsyntaxtextarea.DefaultTokenMakerFactory";
}
try {
DEFAULT_INSTANCE = (TokenMakerFactory)Class.forName(clazz).
defaultInstance = (TokenMakerFactory)Class.forName(clazz).
getDeclaredConstructor().newInstance();
} catch (RuntimeException re) { // FindBugs
throw re;
Expand All @@ -64,7 +64,7 @@ public static synchronized TokenMakerFactory getDefaultInstance() {
clazz);
}
}
return DEFAULT_INSTANCE;
return defaultInstance;
}


Expand Down Expand Up @@ -117,7 +117,7 @@ public static synchronized void setDefaultInstance(TokenMakerFactory tmf) {
if (tmf==null) {
throw new IllegalArgumentException("tmf cannot be null");
}
DEFAULT_INSTANCE = tmf;
defaultInstance = tmf;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/*
* 02/11/2008
*
* JSPTokenMaker.java - Generates tokens for JSP syntax highlighting.
*
* This library is distributed under a modified BSD license. See the included
* LICENSE file for details.
*/
Expand Down Expand Up @@ -837,7 +833,6 @@ CSS_Number = ({CSS_Digits}|{CSS_Hex})

<COMMENT> {
[^hwf\n\-]+ {}
{URL} { int temp=zzStartRead; addToken(start,zzStartRead-1, Token.MARKUP_COMMENT); addHyperlinkToken(temp,zzMarkedPos-1, Token.MARKUP_COMMENT); start = zzMarkedPos; }
{URL} {
int temp = zzStartRead;
if (start <= zzStartRead - 1) {
Expand Down Expand Up @@ -1660,6 +1655,8 @@ CSS_Number = ({CSS_Digits}|{CSS_Hex})
"FilenameFilter" |
"Flushable" |
"ObjectInput" |
"ObjectInputFilter" |
"ObjectInputFilter.FilterInfo" |
"ObjectInputValidation" |
"ObjectOutput" |
"ObjectStreamConstants" |
Expand Down Expand Up @@ -1691,6 +1688,7 @@ CSS_Number = ({CSS_Digits}|{CSS_Hex})
"InputStreamReader" |
"LineNumberInputStream" |
"LineNumberReader" |
"ObjectInputFilter.Config" |
"ObjectInputStream" |
"ObjectInputStream.GetField" |
"ObjectOutputStream" |
Expand Down Expand Up @@ -1737,6 +1735,8 @@ CSS_Number = ({CSS_Digits}|{CSS_Hex})

"IOError" |

"Serial" |

/* java.util classes */
"Collection" |
"Comparator" |
Expand Down
12,067 changes: 6,053 additions & 6,014 deletions RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/modes/JSPTokenMaker.java

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions RSyntaxTextArea/src/test/java/org/fife/TestUtil.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* This library is distributed under a modified BSD license. See the included
* LICENSE file for details.
*/
Expand All @@ -16,7 +16,7 @@
*/
public final class TestUtil {

private static String DEFAULT_TEMP_FILE_EXTENSION = ".tmp";
private static final String DEFAULT_TEMP_FILE_EXTENSION = ".tmp";


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class UnicodeReaderTest {

private static final String CONTENT = "Hello world";
private static boolean origWriteUtf8Bom = false;
private static boolean origWriteUtf8Bom;

private static File createTempFile(Charset charset) throws IOException {
return createTempFile(charset.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class UnicodeWriterTest {

private static final String CONTENT = "Hello world";
private static boolean origWriteUtf8Bom = false;
private static boolean origWriteUtf8Bom;

private static File createTempFile() throws IOException {
File file = File.createTempFile("unitTest", ".tmp");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* This library is distributed under a modified BSD license. See the included
* LICENSE file for details.
*/
package org.fife.ui;

import java.lang.reflect.Method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void testRemoveLastToken_multipleTokensFoundSoFar() {
/**
* A concrete implementation for test purposes.
*/
private static class ConcreteTestTokenMaker extends AbstractTokenMaker {
private static final class ConcreteTestTokenMaker extends AbstractTokenMaker {

@Override
public TokenMap getWordsToHighlight() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ void testSaveTemplates_deletesOldFiles() throws IOException {
File tempDir = Files.createTempDirectory("testDir").toFile();
manager.setTemplateDirectory(tempDir);

File oldFile = TestUtil.createFile(
".xml", "<test/>", tempDir);
// Directory starts out with a file in it
TestUtil.createFile(".xml", "<test/>", tempDir);

manager.saveTemplates();
Assertions.assertEquals(0, tempDir.listFiles().length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void testSetMarkerToolTipProvider_notNull() {
/**
* A dummy parser that returns a single parser notice for test purposes.
*/
private static class TestParser extends AbstractParser {
private static final class TestParser extends AbstractParser {

@Override
public ParseResult parse(RSyntaxDocument doc, String style) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public ParseResult parse(RSyntaxDocument doc, String style) {
RSyntaxTextArea textArea = createTextArea();
textArea.addNotify();
textArea.setAntiAliasingEnabled(false); // Needed to initialize font metrics cache
RTextScrollPane sp = new RTextScrollPane(textArea); // text area needs a parent
new RTextScrollPane(textArea); // text area needs a parent
ParserManager manager = new ParserManager(textArea);
manager.addParser(parser);

Expand All @@ -235,7 +235,7 @@ public ParseResult parse(RSyntaxDocument doc, String style) {
void testInsertUpdate() {

RSyntaxTextArea textArea = createTextArea();
ParserManager manager = new ParserManager(textArea);
new ParserManager(textArea);

textArea.insert("inserted text", 5);
}
Expand All @@ -245,7 +245,7 @@ void testInsertUpdate() {
void testPropertyChange_document() {

RSyntaxTextArea textArea = createTextArea();
ParserManager manager = new ParserManager(textArea);
new ParserManager(textArea);
RSyntaxDocument origDocument = (RSyntaxDocument)textArea.getDocument();

RSyntaxDocument newDocument = new RSyntaxDocument(SyntaxConstants.SYNTAX_STYLE_C);
Expand All @@ -261,7 +261,7 @@ void testPropertyChange_document() {
void testRemoveUpdate() {

RSyntaxTextArea textArea = createTextArea();
ParserManager manager = new ParserManager(textArea);
new ParserManager(textArea);

textArea.replaceRange("", 5, 9);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class RSyntaxDocumentTest {
*/
private static void insertHelloWorldC(RSyntaxDocument doc)
throws Exception {
String str = "#include <stdio.h>\n"
+ "/*\n"
+ " * Multi-line comment */\n"
+ "int main(int argc, char **argv)\n"
+ "{\n"
+ " printf(\"Hello world!\n\");\n"
+ "\n"
+ "}\n";
String str = "#include <stdio.h>\n" +
"/*\n" +
" * Multi-line comment */\n" +
"int main(int argc, char **argv)\n" +
"{\n" +
" printf(\"Hello world!\n\");\n" +
"\n" +
"}\n";
doc.insertString(0, str, null);
}

Expand Down Expand Up @@ -515,7 +515,7 @@ private static void assertDocumentEvent(DocumentEvent e,
/**
* A token maker factory with no mappings to languages.
*/
private static class EmptyTokenMakerFactory
private static final class EmptyTokenMakerFactory
extends AbstractTokenMakerFactory {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ void testActionPerformedImpl_collapseAllCommentFolds() {

textArea.setCaretPosition(textArea.getDocument().getLength());

RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction a = new RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction();
RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction a = new RSyntaxTextAreaEditorKit.
CollapseAllCommentFoldsAction();
ActionEvent e = createActionEvent(textArea, RSyntaxTextAreaEditorKit.rstaCollapseAllCommentFoldsAction);
a.actionPerformedImpl(e, textArea);

Expand All @@ -79,7 +80,8 @@ void testActionPerformedImpl_codeFoldingDisabled() {
textArea.setCodeFoldingEnabled(false);
textArea.setCaretPosition(textArea.getDocument().getLength());

RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction a = new RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction();
RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction a = new RSyntaxTextAreaEditorKit.
CollapseAllCommentFoldsAction();
ActionEvent e = createActionEvent(textArea, RSyntaxTextAreaEditorKit.rstaCollapseAllCommentFoldsAction);
a.actionPerformedImpl(e, textArea);

Expand All @@ -89,7 +91,8 @@ void testActionPerformedImpl_codeFoldingDisabled() {

@Test
void testGetMacroId() {
RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction a = new RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction();
RSyntaxTextAreaEditorKit.CollapseAllCommentFoldsAction a = new RSyntaxTextAreaEditorKit.
CollapseAllCommentFoldsAction();
Assertions.assertEquals(RSyntaxTextAreaEditorKit.rstaCollapseAllCommentFoldsAction, a.getMacroID());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ void testActionPerformedImpl_copyAsStyledText() throws Exception {
textArea.setCaretPosition(5);
textArea.moveCaretPosition(8);

RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(false);
RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.
CopyCutAsStyledTextAction(false);
ActionEvent e = createActionEvent(textArea, RSyntaxTextAreaEditorKit.rstaCopyAsStyledTextAction);
a.actionPerformedImpl(e, textArea);

Expand All @@ -100,7 +101,8 @@ void testActionPerformedImpl_copyAsStyledText_rTextArea() throws Exception {
textArea.setCaretPosition(5);
textArea.moveCaretPosition(8);

RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(false);
RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.
CopyCutAsStyledTextAction(false);
ActionEvent e = createActionEvent(textArea, RSyntaxTextAreaEditorKit.rstaCopyAsStyledTextAction);
a.actionPerformedImpl(e, textArea);

Expand All @@ -126,7 +128,8 @@ void testActionPerformedImpl_cutAsStyledText() throws Exception {
textArea.setCaretPosition(5);
textArea.moveCaretPosition(8);

RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(true);
RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.
CopyCutAsStyledTextAction(true);
ActionEvent e = createActionEvent(textArea, RSyntaxTextAreaEditorKit.rstaCutAsStyledTextAction);
a.actionPerformedImpl(e, textArea);

Expand Down Expand Up @@ -163,7 +166,8 @@ void testActionPerformedImpl_cutAsStyledText_rTextArea() throws Exception {
textArea.setCaretPosition(5);
textArea.moveCaretPosition(8);

RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(true);
RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.
CopyCutAsStyledTextAction(true);
ActionEvent e = createActionEvent(textArea, RSyntaxTextAreaEditorKit.rstaCutAsStyledTextAction);
a.actionPerformedImpl(e, textArea);

Expand Down Expand Up @@ -201,7 +205,8 @@ void testActionPerformedImpl_notEditable() throws Exception {
textArea.setCaretPosition(5);
textArea.moveCaretPosition(8);

RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(false);
RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.
CopyCutAsStyledTextAction(false);
ActionEvent e = createActionEvent(textArea, RSyntaxTextAreaEditorKit.rstaCopyAsStyledTextAction);
a.actionPerformedImpl(e, textArea);

Expand Down Expand Up @@ -240,7 +245,8 @@ void testActionPerformedImpl_notEnabled() throws Exception {
textArea.setCaretPosition(5);
textArea.moveCaretPosition(8);

RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(false);
RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.
CopyCutAsStyledTextAction(false);
ActionEvent e = createActionEvent(textArea, RSyntaxTextAreaEditorKit.rstaCopyAsStyledTextAction);
a.actionPerformedImpl(e, textArea);

Expand All @@ -263,7 +269,8 @@ void testActionPerformedImpl_notEnabled() throws Exception {

@Test
void testGetMacroId() {
RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(false);
RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction a = new RSyntaxTextAreaEditorKit.
CopyCutAsStyledTextAction(false);
Assertions.assertEquals(RSyntaxTextAreaEditorKit.rstaCopyAsStyledTextAction, a.getMacroID());

a = new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void testActionPerformed_manyLinesInBetween() {
action.actionPerformed(createActionEvent(textArea));
Assertions.assertEquals("aaron arthur aardvark\nfoo bar\n// bad code\namazing\n amazing", textArea.getText());
action.actionPerformed(createActionEvent(textArea));
Assertions.assertEquals("aaron arthur aardvark\nfoo bar\n// bad code\namazing\n aardvark", textArea.getText());
Assertions.assertEquals("aaron arthur aardvark\nfoo bar\n// bad code\namazing\n aardvark",
textArea.getText());
action.actionPerformed(createActionEvent(textArea));
Assertions.assertEquals("aaron arthur aardvark\nfoo bar\n// bad code\namazing\n arthur", textArea.getText());
action.actionPerformed(createActionEvent(textArea));
Expand Down Expand Up @@ -270,8 +271,10 @@ void testGetPreviousWord_manyLinesInBetween() throws Exception {
RSyntaxTextArea textArea = new RSyntaxTextArea(doc);

textArea.setText("aaron arthur aardvark\nfoo bar\n// bad code\namazing\n a");
Assertions.assertEquals(textArea.getDocument().getLength()-1, action.getPreviousWord(textArea, textArea.getDocument().getLength()));
Assertions.assertEquals("aaron arthur aardvark\nfoo bar\n// bad code\n".length(), action.getPreviousWord(textArea, textArea.getDocument().getLength()-2));
Assertions.assertEquals(textArea.getDocument().getLength()-1,
action.getPreviousWord(textArea, textArea.getDocument().getLength()));
Assertions.assertEquals("aaron arthur aardvark\nfoo bar\n// bad code\n".length(),
action.getPreviousWord(textArea, textArea.getDocument().getLength()-2));
Assertions.assertEquals("aaron arthur ".length(), action.getPreviousWord(textArea, 22));
Assertions.assertEquals("aaron ".length(), action.getPreviousWord(textArea, 8));

Expand Down
Loading