|
From: <caw...@us...> - 2007-02-07 16:13:37
|
Revision: 1932
http://svn.sourceforge.net/rubyeclipse/?rev=1932&view=rev
Author: cawilliams
Date: 2007-02-07 08:13:32 -0800 (Wed, 07 Feb 2007)
Log Message:
-----------
start removing options that aren't hooked up under the hood for errors/warnings. Also do the plumbing so that it actually follows users' settings for the options available (only empty statements so far)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyCorePreferenceInitializer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/OptionsConfigurationBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CompilerOptions.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-02-07 15:35:26 UTC (rev 1931)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-02-07 16:13:32 UTC (rev 1932)
@@ -232,7 +232,7 @@
/**
* Possible configurable option ID.
* @see #getDefaultOptions()
- * @since 0.90.
+ * @since 0.9.0
*/
public static final String COMPILER_PB_EMPTY_STATEMENT = PLUGIN_ID + ".compiler.problem.emptyStatement"; //$NON-NLS-1$
/**
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CompilerOptions.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CompilerOptions.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CompilerOptions.java 2007-02-07 16:13:32 UTC (rev 1932)
@@ -0,0 +1,52 @@
+package org.rubypeople.rdt.internal.compiler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CompilerOptions {
+
+ public static final String OPTION_ReportEmptyStatement = "org.rubypeople.rdt.core.compiler.problem.emptyStatement"; //$NON-NLS-1$
+
+ public static final long EmptyStatement = 0x80000;
+
+ public static final String ERROR = "error"; //$NON-NLS-1$
+ public static final String WARNING = "warning"; //$NON-NLS-1$
+ public static final String IGNORE = "ignore"; //$NON-NLS-1$
+
+// Default severity level for handlers
+ public long errorThreshold = 0;
+ public long warningThreshold = 0;
+
+ public Map getMap() {
+ Map optionsMap = new HashMap(30);
+ optionsMap.put(OPTION_ReportEmptyStatement, getSeverityString(EmptyStatement));
+ return optionsMap;
+ }
+
+ public String getSeverityString(long irritant) {
+ if((this.warningThreshold & irritant) != 0)
+ return WARNING;
+ if((this.errorThreshold & irritant) != 0)
+ return ERROR;
+ return IGNORE;
+ }
+
+ public void set(Map optionsMap) {
+ Object optionValue;
+ if ((optionValue = optionsMap.get(OPTION_ReportEmptyStatement)) != null) updateSeverity(EmptyStatement, optionValue);
+ }
+
+ void updateSeverity(long irritant, Object severityString) {
+ if (ERROR.equals(severityString)) {
+ this.errorThreshold |= irritant;
+ this.warningThreshold &= ~irritant;
+ } else if (WARNING.equals(severityString)) {
+ this.errorThreshold &= ~irritant;
+ this.warningThreshold |= irritant;
+ } else if (IGNORE.equals(severityString)) {
+ this.errorThreshold &= ~irritant;
+ this.warningThreshold &= ~irritant;
+ }
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyCorePreferenceInitializer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyCorePreferenceInitializer.java 2007-02-07 15:35:26 UTC (rev 1931)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyCorePreferenceInitializer.java 2007-02-07 16:13:32 UTC (rev 1932)
@@ -1,6 +1,5 @@
package org.rubypeople.rdt.internal.core;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@@ -10,15 +9,17 @@
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.formatter.DefaultCodeFormatterConstants;
+import org.rubypeople.rdt.internal.compiler.CompilerOptions;
public class RubyCorePreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
// Get options names set
HashSet optionNames = RubyModelManager.getRubyModelManager().optionNames;
-
+
+ // Compiler settings
+ Map defaultOptionsMap = new CompilerOptions().getMap(); // compiler defaults
- Map defaultOptionsMap = new HashMap();
// Override some compiler defaults
defaultOptionsMap.put(RubyCore.COMPILER_TASK_TAGS, RubyCore.DEFAULT_TASK_TAGS);
defaultOptionsMap.put(RubyCore.COMPILER_TASK_PRIORITIES, RubyCore.DEFAULT_TASK_PRIORITIES);
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java 2007-02-07 15:35:26 UTC (rev 1931)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java 2007-02-07 16:13:32 UTC (rev 1932)
@@ -56,9 +56,7 @@
String source = NodeUtil.getSource(contents, iVisited);
if (iVisited.getThenBody() == null && source.indexOf("unless") == -1) {
- IProblem problem = createProblem(
- RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Conditional Body");
-
+ IProblem problem = createProblem(RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Conditional Body");
if (problem != null)
problemRequestor.acceptProblem(problem);
}
@@ -81,7 +79,6 @@
public Instruction visitIterNode(IterNode iVisited) {
if (iVisited.getBodyNode() == null) {
IProblem problem = createProblem(RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Block");
-
if (problem != null)
problemRequestor.acceptProblem(problem);
}
@@ -102,7 +99,6 @@
public Instruction visitDefsNode(DefsNode iVisited) {
if (iVisited.getBodyNode() == null) {
IProblem problem = createProblem(RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Method Definition");
-
if (problem != null)
problemRequestor.acceptProblem(problem);
}
@@ -123,6 +119,8 @@
String value = RubyCore.getOption(compilerOption);
if (value != null && value.equals(RubyCore.ERROR))
return new Error(position, message);
+ if (value != null && value.equals(RubyCore.IGNORE))
+ return null;
return new Warning(position, message);
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/OptionsConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/OptionsConfigurationBlock.java 2007-02-07 15:35:26 UTC (rev 1931)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/OptionsConfigurationBlock.java 2007-02-07 16:13:32 UTC (rev 1932)
@@ -60,7 +60,7 @@
* Abstract options configuration block providing a general implementation for setting up
* an options configuration page.
*
- * @since 2.1
+ * @since 0.8.0
*/
public abstract class OptionsConfigurationBlock {
@@ -238,11 +238,11 @@
return new Key(plugin, key);
}
- protected final static Key getJDTCoreKey(String key) {
+ protected final static Key getRDTCoreKey(String key) {
return getKey(RubyCore.PLUGIN_ID, key);
}
- protected final static Key getJDTUIKey(String key) {
+ protected final static Key getRDTUIKey(String key) {
return getKey(RubyUI.ID_PLUGIN, key);
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java 2007-02-07 15:35:26 UTC (rev 1931)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java 2007-02-07 16:13:32 UTC (rev 1932)
@@ -33,15 +33,16 @@
private static final String SETTINGS_SECTION_NAME= null; //"ProblemSeveritiesConfigurationBlock";
// Preference store keys, see RubyCore.getOptions
- private static final Key PREF_PB_ENSURE_BLOCK_NOT_COMPLETING = getJDTCoreKey(RubyCore.COMPILER_PB_ENSURE_BLOCK_NOT_COMPLETING);
- private static final Key PREF_PB_EMPTY_STATEMENT = getJDTCoreKey(RubyCore.COMPILER_PB_EMPTY_STATEMENT);
- private static final Key PREF_PB_HIDDEN_RESCUE_BLOCK = getJDTCoreKey(RubyCore.COMPILER_PB_HIDDEN_RESCUE_BLOCK);
- private static final Key PREF_PB_FALLTHROUGH_CASE = getJDTCoreKey(RubyCore.COMPILER_PB_FALLTHROUGH_CASE);
- private static final Key PREF_PB_NULL_REFERENCE = getJDTCoreKey(RubyCore.COMPILER_PB_NULL_REFERENCE);
- private static final Key PREF_PB_UNUSED_LOCAL = getJDTCoreKey(RubyCore.COMPILER_PB_UNUSED_LOCAL);
- private static final Key PREF_PB_UNUSED_PARAMETER = getJDTCoreKey(RubyCore.COMPILER_PB_UNUSED_PARAMETER);
- private static final Key PREF_PB_UNUSED_PRIVATE = getJDTCoreKey(RubyCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER);
- private static final Key PREF_PB_UNNECESSARY_ELSE = getJDTCoreKey(RubyCore.COMPILER_PB_UNNECESSARY_ELSE);
+ // TODO Actually implement checking for these things in the builders!
+ private static final Key PREF_PB_ENSURE_BLOCK_NOT_COMPLETING = getRDTCoreKey(RubyCore.COMPILER_PB_ENSURE_BLOCK_NOT_COMPLETING);
+ private static final Key PREF_PB_EMPTY_STATEMENT = getRDTCoreKey(RubyCore.COMPILER_PB_EMPTY_STATEMENT);
+ private static final Key PREF_PB_HIDDEN_RESCUE_BLOCK = getRDTCoreKey(RubyCore.COMPILER_PB_HIDDEN_RESCUE_BLOCK);
+ private static final Key PREF_PB_FALLTHROUGH_CASE = getRDTCoreKey(RubyCore.COMPILER_PB_FALLTHROUGH_CASE);
+ private static final Key PREF_PB_NULL_REFERENCE = getRDTCoreKey(RubyCore.COMPILER_PB_NULL_REFERENCE);
+ private static final Key PREF_PB_UNUSED_LOCAL = getRDTCoreKey(RubyCore.COMPILER_PB_UNUSED_LOCAL);
+ private static final Key PREF_PB_UNUSED_PARAMETER = getRDTCoreKey(RubyCore.COMPILER_PB_UNUSED_PARAMETER);
+ private static final Key PREF_PB_UNUSED_PRIVATE = getRDTCoreKey(RubyCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER);
+ private static final Key PREF_PB_UNNECESSARY_ELSE = getRDTCoreKey(RubyCore.COMPILER_PB_UNNECESSARY_ELSE);
// values
private static final String ERROR= RubyCore.ERROR;
private static final String WARNING= RubyCore.WARNING;
@@ -60,9 +61,11 @@
private static Key[] getKeys() {
return new Key[] {
- PREF_PB_ENSURE_BLOCK_NOT_COMPLETING, PREF_PB_EMPTY_STATEMENT, PREF_PB_HIDDEN_RESCUE_BLOCK,
- PREF_PB_FALLTHROUGH_CASE, PREF_PB_NULL_REFERENCE, PREF_PB_UNUSED_LOCAL,
- PREF_PB_UNUSED_PARAMETER, PREF_PB_UNUSED_PRIVATE, PREF_PB_UNNECESSARY_ELSE
+// PREF_PB_ENSURE_BLOCK_NOT_COMPLETING,
+ PREF_PB_EMPTY_STATEMENT,
+// PREF_PB_HIDDEN_RESCUE_BLOCK,
+// PREF_PB_FALLTHROUGH_CASE, PREF_PB_NULL_REFERENCE, PREF_PB_UNUSED_LOCAL,
+// PREF_PB_UNUSED_PARAMETER, PREF_PB_UNUSED_PRIVATE, PREF_PB_UNNECESSARY_ELSE
};
}
@@ -134,42 +137,42 @@
inner.setLayout(new GridLayout(nColumns, false));
excomposite.setClient(inner);
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_ensure_block_not_completing_label;
- addComboBox(inner, label, PREF_PB_ENSURE_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_ensure_block_not_completing_label;
+// addComboBox(inner, label, PREF_PB_ENSURE_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_empty_statement_label;
addComboBox(inner, label, PREF_PB_EMPTY_STATEMENT, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_hidden_rescueblock_label;
- addComboBox(inner, label, PREF_PB_HIDDEN_RESCUE_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_hidden_rescueblock_label;
+// addComboBox(inner, label, PREF_PB_HIDDEN_RESCUE_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
+//
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_fall_through_case;
+// addComboBox(inner, label, PREF_PB_FALLTHROUGH_CASE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
+//
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_null_reference;
+// addComboBox(inner, label, PREF_PB_NULL_REFERENCE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_fall_through_case;
- addComboBox(inner, label, PREF_PB_FALLTHROUGH_CASE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_null_reference;
- addComboBox(inner, label, PREF_PB_NULL_REFERENCE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
// --- unnecessary_code
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_unnecessary_code;
- excomposite= createStyleSection(composite, label, nColumns);
-
- inner= new Composite(excomposite, SWT.NONE);
- inner.setFont(composite.getFont());
- inner.setLayout(new GridLayout(nColumns, false));
- excomposite.setClient(inner);
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_unnecessary_code;
+// excomposite= createStyleSection(composite, label, nColumns);
+//
+// inner= new Composite(excomposite, SWT.NONE);
+// inner.setFont(composite.getFont());
+// inner.setLayout(new GridLayout(nColumns, false));
+// excomposite.setClient(inner);
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_local_label;
- addComboBox(inner, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_parameter_label;
- addComboBox(inner, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_private_label;
- addComboBox(inner, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
-
- label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unnecessary_else_label;
- addComboBox(inner, label, PREF_PB_UNNECESSARY_ELSE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_local_label;
+// addComboBox(inner, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
+//
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_parameter_label;
+// addComboBox(inner, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
+//
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_private_label;
+// addComboBox(inner, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
+//
+// label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unnecessary_else_label;
+// addComboBox(inner, label, PREF_PB_UNNECESSARY_ELSE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
IDialogSettings section= RubyPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME);
restoreSectionExpansionStates(section);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/TodoTaskConfigurationBlock.java 2007-02-07 15:35:26 UTC (rev 1931)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/TodoTaskConfigurationBlock.java 2007-02-07 16:13:32 UTC (rev 1932)
@@ -45,10 +45,10 @@
*/
public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
- private static final Key PREF_COMPILER_TASK_TAGS= getJDTCoreKey(RubyCore.COMPILER_TASK_TAGS);
- private static final Key PREF_COMPILER_TASK_PRIORITIES= getJDTCoreKey(RubyCore.COMPILER_TASK_PRIORITIES);
+ private static final Key PREF_COMPILER_TASK_TAGS= getRDTCoreKey(RubyCore.COMPILER_TASK_TAGS);
+ private static final Key PREF_COMPILER_TASK_PRIORITIES= getRDTCoreKey(RubyCore.COMPILER_TASK_PRIORITIES);
- private static final Key PREF_COMPILER_TASK_CASE_SENSITIVE= getJDTCoreKey(RubyCore.COMPILER_TASK_CASE_SENSITIVE);
+ private static final Key PREF_COMPILER_TASK_CASE_SENSITIVE= getRDTCoreKey(RubyCore.COMPILER_TASK_CASE_SENSITIVE);
private static final String PRIORITY_HIGH= RubyCore.COMPILER_TASK_PRIORITY_HIGH;
private static final String PRIORITY_NORMAL= RubyCore.COMPILER_TASK_PRIORITY_NORMAL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|