Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2015-10-01 04:52:03 -0400
committerAlexander Kurtakov2015-10-01 04:52:03 -0400
commit49edfc466b047991897356dc712bce58885ed0a8 (patch)
tree3f4fdd76a644d0ed2b6b1c7ef39a8eb9d55760bd
parentf38b4d4005843e80b10085178b04190daf8cbe04 (diff)
downloadorg.eclipse.dltk.sh-49edfc466b047991897356dc712bce58885ed0a8.tar.gz
org.eclipse.dltk.sh-49edfc466b047991897356dc712bce58885ed0a8.tar.xz
org.eclipse.dltk.sh-49edfc466b047991897356dc712bce58885ed0a8.zip
No bug: Fix sonar warnings.
* No need for null check before instanceof. * Missing curly braces around control structures. * Static variable names. * Use indexOf(char) for performance. * Use static inner class where it fits. * Make class with private constructor only final. * Reduce members to local variables. Change-Id: I1e6fcd6817f3cec4fd751b65a8310bdceee596dc Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/ShelledContentDescriber.java4
-rw-r--r--plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/parser/ShellScriptSourceParser.java8
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/Activator.java5
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/IShellColorConstants.java22
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/commands/ShowManHandler.java2
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/editor/ShellSourceViewerConfiguration.java27
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/preferences/SimpleShellSourceViewerConfiguration.java4
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/AssignmentRule.java9
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarBraceCountingRule.java21
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarRule.java12
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IShellPartitions.java22
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IndentType.java2
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ScriptAutoIndentStrategy.java20
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ShellCodeScanner.java15
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/wizards/ShellScriptProjectWizard.java6
15 files changed, 104 insertions, 75 deletions
diff --git a/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/ShelledContentDescriber.java b/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/ShelledContentDescriber.java
index c89e380..129abee 100644
--- a/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/ShelledContentDescriber.java
+++ b/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/ShelledContentDescriber.java
@@ -16,10 +16,10 @@ import org.eclipse.dltk.core.ScriptContentDescriber;
public class ShelledContentDescriber extends ScriptContentDescriber {
- protected static Pattern[] header_patterns = { Pattern.compile("^#!.*sh.*", Pattern.MULTILINE) };
+ protected static final Pattern[] HEADER_PATTERNS = { Pattern.compile("^#!.*sh.*", Pattern.MULTILINE) };
@Override
protected Pattern[] getHeaderPatterns() {
- return header_patterns;
+ return HEADER_PATTERNS;
}
}
diff --git a/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/parser/ShellScriptSourceParser.java b/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/parser/ShellScriptSourceParser.java
index 425674d..e1d09fc 100644
--- a/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/parser/ShellScriptSourceParser.java
+++ b/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/core/parser/ShellScriptSourceParser.java
@@ -65,10 +65,12 @@ public class ShellScriptSourceParser extends AbstractSourceParser {
} else if (line.contains("function ")) {
int fPlusEight = line.indexOf("function") + 8;
int lBracket = line.indexOf('{') == -1 ? line.length() : line.indexOf('{') - 1;
- if (fPlusEight >= line.length())
+ if (fPlusEight >= line.length()) {
continue;
- if (fPlusEight > lBracket)
+ }
+ if (fPlusEight > lBracket) {
continue;
+ }
mDeclaration = new MethodDeclaration(line.substring(fPlusEight, lBracket).trim(), lineStart,
lineStart + line.length() - 1, lBracket + lineStart, lBracket + lineStart);
functionNames.add(line.substring(fPlusEight, lBracket).trim());
@@ -160,7 +162,7 @@ public class ShellScriptSourceParser extends AbstractSourceParser {
if (line.charAt(line.length() - 1) == '\\' && !isPrevLnContinued) {
isPrevLnContinued = true;
mDeclaration = new MethodDeclaration(line.substring(0, line.length()).trim(),
- lineStart + line.indexOf("\\"), lineStart + line.length() - 1, lineStart,
+ lineStart + line.indexOf('\\'), lineStart + line.length() - 1, lineStart,
lineStart + line.length());
tmp.push(mDeclaration);
model.addStatement(mDeclaration);
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/Activator.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/Activator.java
index ae3060f..8121952 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/Activator.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/Activator.java
@@ -27,7 +27,7 @@ public class Activator extends AbstractUIPlugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
@@ -37,8 +37,9 @@ public class Activator extends AbstractUIPlugin {
private ShellTextTools fShellTextTools;
public synchronized ShellTextTools getTextTools() {
- if (fShellTextTools == null)
+ if (fShellTextTools == null) {
fShellTextTools = new ShellTextTools(true);
+ }
return fShellTextTools;
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/IShellColorConstants.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/IShellColorConstants.java
index 13bbd84..ad4da18 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/IShellColorConstants.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/IShellColorConstants.java
@@ -13,15 +13,15 @@ package org.eclipse.dltk.sh.ui;
import org.eclipse.dltk.ui.text.DLTKColorConstants;
public interface IShellColorConstants {
- public static final String SHELL_COMMENT = DLTKColorConstants.DLTK_SINGLE_LINE_COMMENT;
- public static final String SHELL_DEFAULT = DLTKColorConstants.DLTK_DEFAULT;
- public static final String SHELL_DOUBLE_QUOTE = "SHELLED_interpolated_string";
- public static final String SHELL_EVAL = DLTKColorConstants.DLTK_OPERATOR;
- public static final String SHELL_FUNCTION = DLTKColorConstants.DLTK_FUNCTION_DEFINITION;
- public static final String SHELL_HASHBANG = DLTKColorConstants.DLTK_MULTI_LINE_COMMENT;
- public static final String SHELL_KEYWORD = DLTKColorConstants.DLTK_KEYWORD;
- public static final String SHELL_SINGLE_QUOTE = DLTKColorConstants.DLTK_STRING;
- public static final String SHELL_VARIABLE = DLTKColorConstants.DLTK_ARGUMENT;
- public static final String SHELL_COMMAND = DLTKColorConstants.DLTK_BASE_CLASS;
- public static final String SHELL_TODO_TAG = DLTKColorConstants.TASK_TAG;
+ String SHELL_COMMENT = DLTKColorConstants.DLTK_SINGLE_LINE_COMMENT;
+ String SHELL_DEFAULT = DLTKColorConstants.DLTK_DEFAULT;
+ String SHELL_DOUBLE_QUOTE = "SHELLED_interpolated_string";
+ String SHELL_EVAL = DLTKColorConstants.DLTK_OPERATOR;
+ String SHELL_FUNCTION = DLTKColorConstants.DLTK_FUNCTION_DEFINITION;
+ String SHELL_HASHBANG = DLTKColorConstants.DLTK_MULTI_LINE_COMMENT;
+ String SHELL_KEYWORD = DLTKColorConstants.DLTK_KEYWORD;
+ String SHELL_SINGLE_QUOTE = DLTKColorConstants.DLTK_STRING;
+ String SHELL_VARIABLE = DLTKColorConstants.DLTK_ARGUMENT;
+ String SHELL_COMMAND = DLTKColorConstants.DLTK_BASE_CLASS;
+ String SHELL_TODO_TAG = DLTKColorConstants.TASK_TAG;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/commands/ShowManHandler.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/commands/ShowManHandler.java
index 09c84ad..1b65dba 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/commands/ShowManHandler.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/commands/ShowManHandler.java
@@ -30,7 +30,7 @@ public class ShowManHandler extends AbstractHandler {
ISelection selection = HandlerUtil.getActiveEditor(event).getEditorSite().getSelectionProvider()
.getSelection();
String manPage = "";
- if ((selection != null) & (selection instanceof TextSelection)) {
+ if (selection instanceof TextSelection) {
TextSelection textSelection = (TextSelection) selection;
manPage = textSelection.getText();
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/editor/ShellSourceViewerConfiguration.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/editor/ShellSourceViewerConfiguration.java
index bae23eb..3019e09 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/editor/ShellSourceViewerConfiguration.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/editor/ShellSourceViewerConfiguration.java
@@ -68,8 +68,9 @@ public class ShellSourceViewerConfiguration extends ScriptSourceViewerConfigurat
}
}, defaultToken);
- for (String word : words)
+ for (String word : words) {
wordL.addWord(word, keywordToken);
+ }
return wordL;
}
@@ -203,22 +204,30 @@ public class ShellSourceViewerConfiguration extends ScriptSourceViewerConfigurat
@Override
public void handlePropertyChangeEvent(PropertyChangeEvent event) {
- if (fCodeScanner.affectsBehavior(event))
+ if (fCodeScanner.affectsBehavior(event)) {
fCodeScanner.adaptToPreferenceChange(event);
- if (fCommentScanner.affectsBehavior(event))
+ }
+ if (fCommentScanner.affectsBehavior(event)) {
fCommentScanner.adaptToPreferenceChange(event);
- if (fDoubleQuoteScanner.affectsBehavior(event))
+ }
+ if (fDoubleQuoteScanner.affectsBehavior(event)) {
fDoubleQuoteScanner.adaptToPreferenceChange(event);
- if (fSingleQuoteScanner.affectsBehavior(event))
+ }
+ if (fSingleQuoteScanner.affectsBehavior(event)) {
fSingleQuoteScanner.adaptToPreferenceChange(event);
- if (fFunctionScanner.affectsBehavior(event))
+ }
+ if (fFunctionScanner.affectsBehavior(event)) {
fFunctionScanner.adaptToPreferenceChange(event);
- if (fParamScanner.affectsBehavior(event))
+ }
+ if (fParamScanner.affectsBehavior(event)) {
fParamScanner.adaptToPreferenceChange(event);
- if (fEvalScanner.affectsBehavior(event))
+ }
+ if (fEvalScanner.affectsBehavior(event)) {
fEvalScanner.adaptToPreferenceChange(event);
- if (fHashbangScanner.affectsBehavior(event))
+ }
+ if (fHashbangScanner.affectsBehavior(event)) {
fHashbangScanner.adaptToPreferenceChange(event);
+ }
}
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/preferences/SimpleShellSourceViewerConfiguration.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/preferences/SimpleShellSourceViewerConfiguration.java
index fdb3046..2a7ed23 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/preferences/SimpleShellSourceViewerConfiguration.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/preferences/SimpleShellSourceViewerConfiguration.java
@@ -67,8 +67,8 @@ public class SimpleShellSourceViewerConfiguration extends ShellSourceViewerConfi
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
if (changeFormatter) {
return super.getContentFormatter(sourceViewer);
- } else
- return null;
+ }
+ return null;
}
@Override
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/AssignmentRule.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/AssignmentRule.java
index fb5f885..8b68866 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/AssignmentRule.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/AssignmentRule.java
@@ -38,10 +38,12 @@ public class AssignmentRule implements IRule {
c = (char) scanner.read();
} while ((c != ICharacterScanner.EOF) && detector.isWordPart(c));
scanner.unread();
- if (c == '=')
+ if (c == '=') {
return successToken;
- if (defaultToken.isUndefined())
+ }
+ if (defaultToken.isUndefined()) {
unreadBuffer(scanner);
+ }
return defaultToken;
}
scanner.unread();
@@ -55,7 +57,8 @@ public class AssignmentRule implements IRule {
* the scanner to be used
*/
protected void unreadBuffer(ICharacterScanner scanner) {
- for (int i = buffer.length() - 1; i >= 0; i--)
+ for (int i = buffer.length() - 1; i >= 0; i--) {
scanner.unread();
+ }
}
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarBraceCountingRule.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarBraceCountingRule.java
index a23af99..b7bf20c 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarBraceCountingRule.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarBraceCountingRule.java
@@ -25,7 +25,6 @@ public class DollarBraceCountingRule extends PatternRule {
private final char fOpening;
private final char fClosing;
- private int fBraceCount;
/**
* Creates a rule for the given opening and closing braces. When these
@@ -65,8 +64,9 @@ public class DollarBraceCountingRule extends PatternRule {
if ((fLineDelimiters == null) || (originalDelimiters.length != count)) {
fSortedLineDelimiters = new char[count][];
} else {
- while ((count > 0) && (fLineDelimiters[count - 1] == originalDelimiters[count - 1]))
+ while ((count > 0) && (fLineDelimiters[count - 1] == originalDelimiters[count - 1])) {
count--;
+ }
}
if (count != 0) {
fLineDelimiters = originalDelimiters;
@@ -75,15 +75,16 @@ public class DollarBraceCountingRule extends PatternRule {
int readCount = 1;
int c;
- fBraceCount = 1;
+ int fBraceCount = 1;
while ((c = scanner.read()) != ICharacterScanner.EOF) {
if (c == fEscapeCharacter) {
// Skip escaped character(s)
if (fEscapeContinuesLine) {
c = scanner.read();
for (char[] fSortedLineDelimiter : fSortedLineDelimiters) {
- if ((c == fSortedLineDelimiter[0]) && sequenceDetected(scanner, fSortedLineDelimiter, true))
+ if ((c == fSortedLineDelimiter[0]) && sequenceDetected(scanner, fSortedLineDelimiter, true)) {
break;
+ }
}
} else
scanner.read();
@@ -95,24 +96,28 @@ public class DollarBraceCountingRule extends PatternRule {
// Count closing braces
fBraceCount--;
// End successfully when the open brace count returns to zero
- if (fBraceCount == 0)
+ if (fBraceCount == 0) {
return true;
+ }
} else if (fBreaksOnEOL) {
// Check for end of line since it can be used to terminate the
// pattern.
for (char[] fSortedLineDelimiter : fSortedLineDelimiters) {
- if ((c == fSortedLineDelimiter[0]) && sequenceDetected(scanner, fSortedLineDelimiter, true))
+ if ((c == fSortedLineDelimiter[0]) && sequenceDetected(scanner, fSortedLineDelimiter, true)) {
return true;
+ }
}
}
readCount++;
}
- if (fBreaksOnEOF)
+ if (fBreaksOnEOF) {
return true;
+ }
- for (; readCount > 0; readCount--)
+ for (; readCount > 0; readCount--) {
scanner.unread();
+ }
return false;
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarRule.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarRule.java
index 0ee86e1..5dada48 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarRule.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/DollarRule.java
@@ -67,14 +67,17 @@ public class DollarRule implements IRule {
do {
buffer.append((char) c);
c = scanner.read();
- if ((buffer.length() == 1) && isSpecial((char) c))
+ if ((buffer.length() == 1) && isSpecial((char) c)) {
return successToken;
+ }
} while ((c != ICharacterScanner.EOF) && detector.isWordPart((char) c));
scanner.unread();
- if (buffer.length() > 1)
+ if (buffer.length() > 1) {
return successToken;
- if (defaultToken.isUndefined())
+ }
+ if (defaultToken.isUndefined()) {
unreadBuffer(scanner);
+ }
return defaultToken;
}
scanner.unread();
@@ -88,7 +91,8 @@ public class DollarRule implements IRule {
* the scanner to be used
*/
protected void unreadBuffer(ICharacterScanner scanner) {
- for (int i = buffer.length() - 1; i >= 0; i--)
+ for (int i = buffer.length() - 1; i >= 0; i--) {
scanner.unread();
+ }
}
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IShellPartitions.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IShellPartitions.java
index 5a3e05b..a27fe50 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IShellPartitions.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IShellPartitions.java
@@ -13,18 +13,18 @@ package org.eclipse.dltk.sh.ui.text;
import org.eclipse.jface.text.IDocument;
public interface IShellPartitions {
- public final static String SHELL_PARTITIONING = "__shell_partitioning";
+ String SHELL_PARTITIONING = "__shell_partitioning";
// Content types supplied by the shell script partitioner
- public static final String COMMENT_CONTENT_TYPE = "__comment";
- public static final String DOUBLE_QUOTE_CONTENT_TYPE = "__double_quote";
- public static final String PARAM_CONTENT_TYPE = "__parameter";
- public static final String EVAL_CONTENT_TYPE = "__eval";
- public static final String HASHBANG_CONTENT_TYPE = "__hashbang";
- public static final String FUNCTION_CONTENT_TYPE = "__function";
- public static final String SINGLE_QUOTE_CONTENT_TYPE = "__single_quote";
+ String COMMENT_CONTENT_TYPE = "__comment";
+ String DOUBLE_QUOTE_CONTENT_TYPE = "__double_quote";
+ String PARAM_CONTENT_TYPE = "__parameter";
+ String EVAL_CONTENT_TYPE = "__eval";
+ String HASHBANG_CONTENT_TYPE = "__hashbang";
+ String FUNCTION_CONTENT_TYPE = "__function";
+ String SINGLE_QUOTE_CONTENT_TYPE = "__single_quote";
- public static final String[] CONTENT_TYPES = new String[] { IDocument.DEFAULT_CONTENT_TYPE, HASHBANG_CONTENT_TYPE,
- COMMENT_CONTENT_TYPE, SINGLE_QUOTE_CONTENT_TYPE, DOUBLE_QUOTE_CONTENT_TYPE, PARAM_CONTENT_TYPE,
- EVAL_CONTENT_TYPE, FUNCTION_CONTENT_TYPE };
+ String[] CONTENT_TYPES = new String[] { IDocument.DEFAULT_CONTENT_TYPE, HASHBANG_CONTENT_TYPE, COMMENT_CONTENT_TYPE,
+ SINGLE_QUOTE_CONTENT_TYPE, DOUBLE_QUOTE_CONTENT_TYPE, PARAM_CONTENT_TYPE, EVAL_CONTENT_TYPE,
+ FUNCTION_CONTENT_TYPE };
} \ No newline at end of file
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IndentType.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IndentType.java
index ef8154b..cd9a117 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IndentType.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/IndentType.java
@@ -13,7 +13,7 @@ package org.eclipse.dltk.sh.ui.text;
/**
* A type of indent.
*/
-public class IndentType {
+public final class IndentType {
/** A single indent decrement */
public static final IndentType DECREMENT = new IndentType();
/** A single indent increment */
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ScriptAutoIndentStrategy.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ScriptAutoIndentStrategy.java
index a7a4151..da30b87 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ScriptAutoIndentStrategy.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ScriptAutoIndentStrategy.java
@@ -73,8 +73,9 @@ public class ScriptAutoIndentStrategy implements IAutoEditStrategy {
* the command being performed
*/
protected void smartIndentAfterNewLine(IDocument document, DocumentCommand c) {
- if ((c.offset == -1) || (document.getLength() == 0))
+ if ((c.offset == -1) || (document.getLength() == 0)) {
return;
+ }
try {
StringBuffer buf = new StringBuffer(c.text);
int p = c.offset == document.getLength() ? c.offset - 1 : c.offset;
@@ -98,8 +99,9 @@ public class ScriptAutoIndentStrategy implements IAutoEditStrategy {
* the command being performed
*/
protected void smartIndentAfterKeypress(IDocument document, DocumentCommand c) {
- if ((c.offset == -1) || (document.getLength() == 0))
+ if ((c.offset == -1) || (document.getLength() == 0)) {
return;
+ }
try {
StringBuffer buf = new StringBuffer();
int p = c.offset == document.getLength() ? c.offset - 1 : c.offset;
@@ -189,15 +191,17 @@ public class ScriptAutoIndentStrategy implements IAutoEditStrategy {
private int getBracketCount(IDocument document, DocumentCommand command, int start, int end,
boolean ignoreInflexions) {
int bracketcount = 0;
- if (command != null)
+ if (command != null) {
scanner.setRange(document, command, start, end - start);
- else
+ } else {
scanner.setRange(document, start, end - start);
+ }
while (true) {
IToken token = scanner.nextToken();
- if (token.isEOF())
+ if (token.isEOF()) {
break;
+ }
if (token.isOther()) {
IndentType type = (IndentType) token.getData();
@@ -270,10 +274,12 @@ public class ScriptAutoIndentStrategy implements IAutoEditStrategy {
tabs = 0;
spaces = 0;
}
- for (int i = 0; i < tabs; i++)
+ for (int i = 0; i < tabs; i++) {
indent += "\t";
- for (int i = 0; i < spaces; i++)
+ }
+ for (int i = 0; i < spaces; i++) {
indent += " ";
+ }
return indent;
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ShellCodeScanner.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ShellCodeScanner.java
index a7cea10..77cc5cf 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ShellCodeScanner.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/text/ShellCodeScanner.java
@@ -30,7 +30,7 @@ import org.eclipse.jface.text.rules.WhitespaceRule;
import org.eclipse.jface.text.rules.WordRule;
public class ShellCodeScanner extends AbstractScriptScanner {
- public class ShellWordDetector implements IWordDetector {
+ public static class ShellWordDetector implements IWordDetector {
@Override
public boolean isWordPart(char character) {
return (Character.isJavaIdentifierPart(character) && (character != '$')) || (character == '-')
@@ -43,14 +43,14 @@ public class ShellCodeScanner extends AbstractScriptScanner {
}
}
- public static String[] KEYWORDS = { "do", "done", "if", "fi", "then", "else", "elif", "case", "esac", "while",
- "for", "in", "select", "time", "until", "function", "[", "[[", "]", "]]", "set", "unset", "declare" };
+ public static final String[] KEYWORDS = { "do", "done", "if", "fi", "then", "else", "elif", "case", "esac", "while",
+ "for", "in", "select", "time", "until", "function", "[", "[[", "]", "]]", "set", "unset", "declare" };
private static List<String> fgCommands = getCommands();
private static String fgTokenProperties[] = new String[] { IShellColorConstants.SHELL_DEFAULT,
- IShellColorConstants.SHELL_KEYWORD, IShellColorConstants.SHELL_VARIABLE,
- IShellColorConstants.SHELL_COMMAND };
+ IShellColorConstants.SHELL_KEYWORD, IShellColorConstants.SHELL_VARIABLE,
+ IShellColorConstants.SHELL_COMMAND };
public ShellCodeScanner(IColorManager manager, IPreferenceStore store) {
super(manager, store);
@@ -78,10 +78,11 @@ public class ShellCodeScanner extends AbstractScriptScanner {
for (File file : files) {
if (file.canExecute()) {
- if (file.getName().endsWith(".exe"))
+ if (file.getName().endsWith(".exe")) {
commands.add(file.getName().substring(0, file.getName().length() - 4));
- else
+ } else {
commands.add(file.getName());
+ }
}
}
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/wizards/ShellScriptProjectWizard.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/wizards/ShellScriptProjectWizard.java
index 5bc8109..f91d120 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/wizards/ShellScriptProjectWizard.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/ui/wizards/ShellScriptProjectWizard.java
@@ -7,8 +7,6 @@ import org.eclipse.dltk.ui.wizards.ProjectWizardFirstPage;
import org.eclipse.dltk.ui.wizards.ProjectWizardSecondPage;
public class ShellScriptProjectWizard extends ProjectWizard {
- private ProjectWizardFirstPage firstPage;
- private ProjectWizardSecondPage secondPage;
public ShellScriptProjectWizard() {
setWindowTitle("New Shell Script Project");
@@ -23,7 +21,7 @@ public class ShellScriptProjectWizard extends ProjectWizard {
@Override
public void addPages() {
super.addPages();
- firstPage = new ProjectWizardFirstPage() {
+ ProjectWizardFirstPage firstPage = new ProjectWizardFirstPage() {
@Override
protected boolean interpeterRequired() {
@@ -37,7 +35,7 @@ public class ShellScriptProjectWizard extends ProjectWizard {
addPage(firstPage);
// Second page
- secondPage = new ProjectWizardSecondPage(firstPage);
+ ProjectWizardSecondPage secondPage = new ProjectWizardSecondPage(firstPage);
addPage(secondPage);
}
}

Back to the top