|
From: <caw...@us...> - 2007-08-21 18:24:15
|
Revision: 3030
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3030&view=rev
Author: cawilliams
Date: 2007-08-21 11:24:14 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java
Modified: trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java
===================================================================
--- trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 18:21:55 UTC (rev 3029)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 18:24:14 UTC (rev 3030)
@@ -14,6 +14,7 @@
import org.jruby.ast.visitor.rewriter.FormatHelper;
import org.jruby.ast.visitor.rewriter.ReWriteVisitor;
import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.formatter.Indents;
import org.rubypeople.rdt.core.util.Util;
import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
@@ -56,23 +57,19 @@
LocalCorrectionsSubProcessor.addReplacementProposal("initialize\n", "Rename to 'initialize'", problem, proposals);
break;
case IProblem.ConstantNamingConvention:
- IRubyScript script = context.getRubyScript();
- String src = script.getSource();
- String constName = src.substring(problem.getOffset(), problem.getOffset() + problem.getLength());
+ String constName = getSource(context, problem);
String fixed = Util.camelCaseToUnderscores(constName).toUpperCase();
LocalCorrectionsSubProcessor.addReplacementProposal(fixed, "Convert to UPPERCASE_WITH_UNDERSCORES convention", problem, proposals);
break;
case IProblem.LocalAndMethodNamingConvention:
- script = context.getRubyScript();
- src = script.getSource();
- constName = src.substring(problem.getOffset(), problem.getOffset() + problem.getLength());
- fixed = Util.camelCaseToUnderscores(constName).toLowerCase();
+ String name = getSource(context, problem);
+ fixed = Util.camelCaseToUnderscores(name).toLowerCase();
LocalCorrectionsSubProcessor.addReplacementProposal(fixed, "Convert to lowercase_with_undercores convention", problem, proposals);
break;
case IProblem.MethodMissingWithoutRespondTo:
// FIXME Only do this stuff when we apply the proposal! Don't do all this work just to create the proposal...
- script = context.getRubyScript();
- src = script.getSource();
+ IRubyScript script = context.getRubyScript();
+ String src = script.getSource();
int offset = 0;
Node rootNode = ASTProvider.getASTProvider().getAST(script, ASTProvider.WAIT_YES, null);
Node typeNode = ClosestSpanningNodeLocator.Instance().findClosestSpanner(rootNode, problem.getOffset(), new INodeAcceptor() {
@@ -105,6 +102,13 @@
default:
}
}
+
+ private String getSource(IInvocationContext context, IProblemLocation problem) throws RubyModelException {
+ IRubyScript script = context.getRubyScript();
+ String src = script.getSource();
+ String constName = src.substring(problem.getOffset(), problem.getOffset() + problem.getLength());
+ return constName;
+ }
protected FormatHelper getFormatHelper() {
return new DefaultFormatHelper();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|