You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2007-08-22 21:05:33
|
Revision: 3047
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3047&view=rev
Author: cawilliams
Date: 2007-08-22 14:05:06 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
update to latest JRuby. Also fix ITypeHierarchy interface to refer to modules and not interfaces
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/PreviewGeneratorImpl.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java 2007-08-22 21:04:58 UTC (rev 3046)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/NodeProvider.java 2007-08-22 21:05:06 UTC (rev 3047)
@@ -64,10 +64,9 @@
import org.jruby.lexer.yacc.LexerSource;
import org.jruby.lexer.yacc.SyntaxException;
import org.jruby.parser.DefaultRubyParser;
-import org.jruby.parser.RubyParserConfiguration;
+import org.jruby.parser.ParserConfiguration;
import org.jruby.parser.RubyParserPool;
import org.jruby.parser.RubyParserResult;
-//import org.jruby.parser.postprocessor.DefaultCommentPlacer;
import org.rubypeople.rdt.refactoring.nodewrapper.AttrAccessorNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.FieldNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
@@ -104,8 +103,9 @@
DefaultRubyParser parser;
parser = RubyParserPool.getInstance().borrowParser();
parser.setWarnings(new NullWarnings());
- LexerSource lexerSource = new LexerSource(fileName, reader, 1, true);
- RubyParserConfiguration parserConfig = new RubyParserConfiguration(false);
+
+ ParserConfiguration parserConfig = new ParserConfiguration(1, true, false);
+ LexerSource lexerSource = LexerSource.getSource(fileName, reader, null, parserConfig);
// parserConfig.addPostProcessor(new DefaultCommentPlacer());
RubyParserResult result = parser.parse(parserConfig, lexerSource);
return (RootNode) result.getAST();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/PreviewGeneratorImpl.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/PreviewGeneratorImpl.java 2007-08-22 21:04:58 UTC (rev 3046)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/PreviewGeneratorImpl.java 2007-08-22 21:05:06 UTC (rev 3047)
@@ -39,9 +39,8 @@
import org.jruby.common.NullWarnings;
import org.jruby.lexer.yacc.LexerSource;
import org.jruby.parser.DefaultRubyParser;
-import org.jruby.parser.RubyParserConfiguration;
+import org.jruby.parser.ParserConfiguration;
import org.jruby.parser.RubyParserPool;
-//import org.jruby.parser.postprocessor.DefaultCommentPlacer;
public class PreviewGeneratorImpl implements PreviewGenerator {
@@ -58,9 +57,9 @@
DefaultRubyParser parser = RubyParserPool.getInstance().borrowParser();
parser.setWarnings(new NullWarnings());
- LexerSource lexerSource = new LexerSource("", new StringReader(source), 1, true); //$NON-NLS-1$
- ReWriteVisitor visitor = factory.createReWriteVisitor();
- RubyParserConfiguration parserConfig = new RubyParserConfiguration(false);
+ ParserConfiguration parserConfig = new ParserConfiguration(1, true, false);
+ LexerSource lexerSource = LexerSource.getSource("", new StringReader(source), null, parserConfig); //$NON-NLS-1$
+ ReWriteVisitor visitor = factory.createReWriteVisitor();
// parserConfig.addPostProcessor(new DefaultCommentPlacer());
parser.parse(parserConfig, lexerSource).getAST().accept(visitor);
visitor.flushStream();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 21:05:02
|
Revision: 3046
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3046&view=rev
Author: cawilliams
Date: 2007-08-22 14:04:58 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
update to latest JRuby. Also fix ITypeHierarchy interface to refer to modules and not interfaces
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/MethodOverrideTester.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/OverrideIndicatorLabelDecorator.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/MethodOverrideTester.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/MethodOverrideTester.java 2007-08-22 16:40:08 UTC (rev 3045)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/MethodOverrideTester.java 2007-08-22 21:04:58 UTC (rev 3046)
@@ -122,7 +122,7 @@
}
}
if (!overriding.isConstructor()) {
- IType[] interfaces= fHierarchy.getSuperInterfaces(type);
+ IType[] interfaces= fHierarchy.getSuperModules(type);
for (int i= 0; i < interfaces.length; i++) {
IMethod res= findOverriddenMethodInHierarchy(interfaces[i], overriding);
if (res != null) {
@@ -154,7 +154,7 @@
}
}
if (!overriding.isConstructor()) {
- IType[] superInterfaces= fHierarchy.getSuperInterfaces(type);
+ IType[] superInterfaces= fHierarchy.getSuperModules(type);
for (int i= 0; i < superInterfaces.length; i++) {
IMethod res= findOverriddenMethodInHierarchy(superInterfaces[i], overriding);
if (res != null) {
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2007-08-22 16:40:08 UTC (rev 3045)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2007-08-22 21:04:58 UTC (rev 3046)
@@ -188,7 +188,7 @@
return true;
}
if (Flags.isModule(hierarchy.getCachedFlags(possibleSuperType))) {
- IType[] superInterfaces= hierarchy.getSuperInterfaces(type);
+ IType[] superInterfaces= hierarchy.getSuperModules(type);
for (int i= 0; i < superInterfaces.length; i++) {
IType curr= superInterfaces[i];
if (possibleSuperType.equals(curr) || isSuperType(hierarchy, possibleSuperType, curr)) {
@@ -250,7 +250,7 @@
}
}
if (!isConstructor) {
- IType[] superInterfaces= hierarchy.getSuperInterfaces(type);
+ IType[] superInterfaces= hierarchy.getSuperModules(type);
for (int i= 0; i < superInterfaces.length; i++) {
IMethod res= findMethodInHierarchy(hierarchy, superInterfaces[i], name, paramTypes, false);
if (res != null) {
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2007-08-22 16:40:08 UTC (rev 3045)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2007-08-22 21:04:58 UTC (rev 3046)
@@ -20,8 +20,8 @@
import org.jruby.lexer.yacc.LexerSource;
import org.jruby.lexer.yacc.RubyYaccLexer;
import org.jruby.lexer.yacc.SyntaxException;
+import org.jruby.parser.ParserConfiguration;
import org.jruby.parser.ParserSupport;
-import org.jruby.parser.RubyParserConfiguration;
import org.jruby.parser.RubyParserResult;
import org.jruby.parser.Tokens;
import org.rubypeople.rdt.internal.core.util.ASTUtil;
@@ -90,7 +90,7 @@
public RubyPartitionScanner() {
lexer = new RubyYaccLexer();
parserSupport = new ParserSupport();
- parserSupport.setConfiguration(new RubyParserConfiguration(false));
+ parserSupport.setConfiguration(new ParserConfiguration(0, false));
result = new RubyParserResult();
parserSupport.setResult(result);
lexer.setParserSupport(parserSupport);
@@ -107,12 +107,13 @@
length += diff;
}
if (myOffset == -1) myOffset = 0;
+ ParserConfiguration config = new ParserConfiguration(0, true, false);
try {
- fContents = document.get(myOffset, length);
- lexerSource = new LexerSource("filename", new StringReader(fContents), 0, true);
+ fContents = document.get(myOffset, length);
+ lexerSource = LexerSource.getSource("filename", new StringReader(fContents), null, config);
lexer.setSource(lexerSource);
} catch (BadLocationException e) {
- lexerSource = new LexerSource("filename", new StringReader(""), 0, true);
+ lexerSource = LexerSource.getSource("filename", new StringReader(""), null, config);
lexer.setSource(lexerSource);
}
origOffset = myOffset;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-08-22 16:40:08 UTC (rev 3045)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-08-22 21:04:58 UTC (rev 3046)
@@ -14,8 +14,8 @@
import org.jruby.lexer.yacc.LexerSource;
import org.jruby.lexer.yacc.RubyYaccLexer;
import org.jruby.lexer.yacc.SyntaxException;
+import org.jruby.parser.ParserConfiguration;
import org.jruby.parser.ParserSupport;
-import org.jruby.parser.RubyParserConfiguration;
import org.jruby.parser.RubyParserResult;
import org.jruby.parser.Tokens;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
@@ -61,7 +61,7 @@
super(manager, store);
lexer = new RubyYaccLexer();
parserSupport = new ParserSupport();
- parserSupport.setConfiguration(new RubyParserConfiguration(false));
+ parserSupport.setConfiguration(new ParserConfiguration(0, true, false));
result = new RubyParserResult();
parserSupport.setResult(result);
lexer.setParserSupport(parserSupport);
@@ -252,12 +252,13 @@
lexer.setState(LexState.EXPR_BEG);
parserSupport.initTopLocalVariables();
isInSymbol = false;
+ ParserConfiguration config = new ParserConfiguration(0, true, false);
try {
- fContents = document.get(offset, length);
- lexerSource = new LexerSource("filename", new StringReader(fContents), 0, true);
+ fContents = document.get(offset, length);
+ lexerSource = LexerSource.getSource("filename", new StringReader(fContents), null, config);
lexer.setSource(lexerSource);
} catch (BadLocationException e) {
- lexerSource = new LexerSource("filename", new StringReader(""), 0, true);
+ lexerSource = LexerSource.getSource("filename", new StringReader(""), null, config);
lexer.setSource(lexerSource);
}
origOffset = offset;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java 2007-08-22 16:40:08 UTC (rev 3045)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java 2007-08-22 21:04:58 UTC (rev 3046)
@@ -106,7 +106,7 @@
for (int i= 0; i < classes.length; i++) {
res.add(classes[i]);
}
- IType[] interfaces= hierarchy.getRootInterfaces();
+ IType[] interfaces= hierarchy.getRootModules();
for (int i= 0; i < interfaces.length; i++) {
res.add(interfaces[i]);
}
@@ -114,7 +114,7 @@
if (Flags.isModule(hierarchy.getCachedFlags(input))) {
res.add(input);
} else if (isAnonymousFromInterface(input)) {
- res.add(hierarchy.getSuperInterfaces(input)[0]);
+ res.add(hierarchy.getSuperModules(input)[0]);
} else {
IType[] roots= hierarchy.getRootClasses();
for (int i= 0; i < roots.length; i++) {
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java 2007-08-22 16:40:08 UTC (rev 3045)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java 2007-08-22 21:04:58 UTC (rev 3046)
@@ -343,7 +343,7 @@
}
protected final boolean isAnonymousFromInterface(IType type) {
- return isAnonymous(type) && fTypeHierarchy.getHierarchy().getSuperInterfaces(type).length != 0;
+ return isAnonymous(type) && fTypeHierarchy.getHierarchy().getSuperModules(type).length != 0;
}
protected final boolean isObject(IType type) {
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/OverrideIndicatorLabelDecorator.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/OverrideIndicatorLabelDecorator.java 2007-08-22 16:40:08 UTC (rev 3045)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/OverrideIndicatorLabelDecorator.java 2007-08-22 21:04:58 UTC (rev 3046)
@@ -189,7 +189,7 @@
return RubyElementImageDescriptor.OVERRIDES;
}
}
- IType[] interfaces= hierarchy.getSuperInterfaces(type);
+ IType[] interfaces= hierarchy.getSuperModules(type);
for (int i= 0; i < interfaces.length; i++) {
IMethod res= RubyModelUtil.findMethodInHierarchy(hierarchy, interfaces[i], name, paramTypes, false);
if (res != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 16:40:11
|
Revision: 3045
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3045&view=rev
Author: cawilliams
Date: 2007-08-22 09:40:08 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
start work on an AST based code formatter...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/FormatTestData.xml
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_CodeFormatter.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter_Data.xml
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/FormatTestData.xml
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/FormatTestData.xml 2007-08-22 16:39:58 UTC (rev 3044)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/FormatTestData.xml 2007-08-22 16:40:08 UTC (rev 3045)
@@ -5,7 +5,7 @@
<part>
<assertionMessage>Keywords</assertionMessage>
<unformatted>
-class xx
+class Xx
def xx()
if bla() then
bla
@@ -16,7 +16,7 @@
end
</unformatted>
<formatted>
-class xx
+class Xx
def xx()
if bla() then
bla
Added: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter.java (rev 0)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter.java 2007-08-22 16:40:08 UTC (rev 3045)
@@ -0,0 +1,27 @@
+package org.rubypeople.rdt.internal.formatter;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.rubypeople.rdt.core.formatter.CodeFormatter;
+import org.xml.sax.SAXException;
+
+public class TC_ASTBasedCodeFormatter extends TC_CodeFormatter {
+
+ public TC_ASTBasedCodeFormatter(String name) throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError {
+ super(name);
+ }
+
+ @Override
+ protected CodeFormatter getCodeFormatter() {
+ return new ASTBasedCodeFormatter();
+ }
+
+ protected InputStream getInputDataStream() {
+ return this.getClass().getResourceAsStream("TC_ASTBasedCodeFormatter_Data.xml");
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter_Data.xml
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter_Data.xml (rev 0)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter_Data.xml 2007-08-22 16:40:08 UTC (rev 3045)
@@ -0,0 +1,722 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tests>
+ <test ID="Keywords">
+
+<part>
+<assertionMessage>Keywords</assertionMessage>
+<unformatted>
+class Xx
+ def xx()
+ if bla() then
+bla
+ else
+ arg
+ end
+end
+end
+</unformatted>
+<formatted>
+class Xx
+ def xx()
+ if bla() then
+ bla
+ else
+ arg
+ end
+ end
+end
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Keyword with following delimiter</assertionMessage>
+<unformatted>
+if(true)
+while(true)do
+if/test/=~"test" then
+puts "TEST MATCHES" ;
+elsif/test/=~"abc"
+puts "ABC MATCHES";
+end
+end
+end
+</unformatted>
+<formatted>
+if(true)
+ while(true)do
+ if/test/=~"test" then
+ puts "TEST MATCHES" ;
+ elsif/test/=~"abc"
+ puts "ABC MATCHES";
+ end
+ end
+end
+</formatted>
+</part>
+
+
+<part>
+<assertionMessage>Keyword in comment</assertionMessage>
+<unformatted>
+# class
+class abc
+end
+</unformatted>
+<formatted>
+# class
+class abc
+end
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Keyword as method name</assertionMessage>
+<unformatted>
+object.class
+puts o
+</unformatted>
+<formatted>
+object.class
+puts o
+</formatted>
+</part>
+
+ </test>
+
+ <test ID="takeIndentationOfFirstKeyword">
+<unformatted>
+ # comment
+ def firstMethod
+ if a
+ b
+ end
+ end
+</unformatted>
+<formatted>
+ # comment
+ def firstMethod
+ if a
+ b
+ end
+ end
+</formatted>
+ </test>
+
+<test ID="blockWithBrackets">
+<part>
+<assertionMessage>Block starts in middle of line</assertionMessage>
+<unformatted>
+a.each { | x |
+if a
+b
+end
+}
+</unformatted>
+<formatted>
+a.each { | x |
+ if a
+ b
+ end
+}
+</formatted>
+</part>
+<part>
+<assertionMessage>Block starts in new line</assertionMessage>
+<unformatted>
+a.each
+{ | x |
+test
+}
+</unformatted>
+<formatted>
+a.each
+{ | x |
+ test
+}
+</formatted>
+</part>
+</test>
+
+
+<test ID="Blocks">
+<part>
+<assertionMessage>Begin/rescue/end block</assertionMessage>
+<unformatted>
+begin
+ x
+rescue
+ y
+end
+</unformatted>
+<formatted>
+begin
+ x
+rescue
+ y
+end
+</formatted>
+</part>
+<part>
+<assertionMessage>Begin/rescue/end in one line</assertionMessage>
+<unformatted>
+begin a rescue x end
+</unformatted>
+<formatted>
+begin a rescue x end
+</formatted>
+</part>
+
+<part>
+<assertionMessage>No-Block Do</assertionMessage>
+<unformatted>
+while (a) do
+test
+end
+x = 5 ; until x do
+test
+end
+</unformatted>
+<formatted>
+while (a) do
+ test
+end
+x = 5 ; until x do
+ test
+end
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Block Do</assertionMessage>
+<unformatted>
+3.timeswhile do
+test
+end
+while (a) x end ; 2.times do
+test
+end
+</unformatted>
+<formatted>
+3.timeswhile do
+ test
+end
+while (a) x end ; 2.times do
+ test
+end
+</formatted>
+</part>
+
+<part>
+<assertionMessage>No Block Expressions</assertionMessage>
+<unformatted>
+a = 0 if a != 0
+test
+a() if trace?
+a +=1 while a != 10
+i += 1 until i == 5
+test
+</unformatted>
+<formatted>
+a = 0 if a != 0
+test
+a() if trace?
+a +=1 while a != 10
+i += 1 until i == 5
+test
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Block Expressions starting in the middle of a line</assertionMessage>
+<unformatted>
+a = 0 ; if a != 0
+test
+end
+a = if a != 0
+5
+end
+</unformatted>
+<formatted>
+a = 0 ; if a != 0
+ test
+end
+a = if a != 0
+ 5
+end
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Until with Begin/End</assertionMessage>
+<unformatted>
+begin
+i+=1
+end until i == 5
+test
+</unformatted>
+<formatted>
+begin
+ i+=1
+end until i == 5
+test
+</formatted>
+</part>
+
+<part>
+<assertionMessage>End with following semicolon</assertionMessage>
+<unformatted>
+class A
+end;
+</unformatted>
+<formatted>
+class A
+end;
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Two ends in a row</assertionMessage>
+<unformatted>
+class A
+def a
+end;end
+class B end;
+</unformatted>
+<formatted>
+class A
+ def a
+ end;end
+class B end;
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Semicolon before start</assertionMessage>
+<unformatted>
+def a;if 0 then puts "X"
+end;
+end;
+</unformatted>
+<formatted>
+def a;if 0 then puts "X"
+ end;
+end;
+</formatted>
+</part>
+</test>
+
+
+
+<test ID="Parameters">
+<part>
+<assertionMessage>Method Parameter in one line</assertionMessage>
+<unformatted>
+def x(a, b)
+y
+end
+</unformatted>
+<formatted>
+def x(a, b)
+ y
+end
+</formatted>
+</part>
+<part>
+<assertionMessage>Method Parameter in multiple lines</assertionMessage>
+<unformatted>
+
+def x(a
+b,
+ c)
+x
+end
+</unformatted>
+<formatted>
+
+def x(a
+ b,
+ c)
+ x
+end
+</formatted>
+</part>
+<part>
+<assertionMessage>Method call with multiple lines</assertionMessage>
+<unformatted>
+def x(a,b)
+object.method(arg1,
+ arg2)
+end
+</unformatted>
+<formatted>
+def x(a,b)
+ object.method(arg1,
+ arg2)
+end
+</formatted>
+</part>
+
+</test>
+
+<test ID="Literals">
+<part>
+<assertionMessage>Literal with double quotation</assertionMessage>
+<unformatted>
+ puts "def x(a, b)"
+ puts ""
+ if a
+b
+ end
+ puts "if{"
+ b
+ puts "end"
+</unformatted>
+<formatted>
+puts "def x(a, b)"
+puts ""
+if a
+ b
+end
+puts "if{"
+b
+puts "end"
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Literal with double quotation over multiple lines</assertionMessage>
+<unformatted>
+ puts "Bla
+class"
+ puts "def method"
+ puts "end"
+</unformatted>
+<formatted>
+ puts "Bla
+class"
+ puts "def method"
+ puts "end"
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Literal with backslashed quotation</assertionMessage>
+<unformatted>
+ puts "\"{"
+ puts "xx"
+ puts "class \\"
+if
+b
+</unformatted>
+<formatted>
+ puts "\"{"
+ puts "xx"
+ puts "class \\"
+ if
+ b
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Literal with single quotation</assertionMessage>
+<unformatted>
+ puts 'def x(a, b)'
+ puts 'if{'
+ puts 'end'
+</unformatted>
+<formatted>
+ puts 'def x(a, b)'
+ puts 'if{'
+ puts 'end'
+</formatted>
+</part>
+<part>
+
+<assertionMessage>Special char $'</assertionMessage>
+<unformatted>
+if $'
+o.m
+end
+</unformatted>
+<formatted>
+if $'
+ o.m
+end
+</formatted>
+</part>
+
+<part>
+<assertionMessage>Literal with single and double quotation</assertionMessage>
+<unformatted>
+ puts '"def" if x(a, b)'
+ puts 'if{'
+ puts 'end'
+</unformatted>
+<formatted>
+ puts '"def" if x(a, b)'
+ puts 'if{'
+ puts 'end'
+</formatted>
+</part>
+<part>
+<assertionMessage>=begin, =end</assertionMessage>
+<unformatted>
+=begin
+ if
+ b
+ end
+=end
+ if
+ b
+ end
+</unformatted>
+<formatted>
+=begin
+ if
+ b
+ end
+=end
+if
+ b
+end
+</formatted>
+</part>
+
+<part>
+<assertionMessage>String def with <<ID ID</assertionMessage>
+<unformatted>
+<<ID
+ do not touch this ID while processing
+ test
+ID
+<<-ID
+ do not touch this while processing
+ test
+ ID
+<<'ID'
+ do not touch this while processing
+ test
+ID
+<<ID
+ uups
+ no end ID
+</unformatted>
+<formatted>
+<<ID
+ do not touch this ID while processing
+ test
+ID
+<<-ID
+ do not touch this while processing
+ test
+ ID
+<<'ID'
+ do not touch this while processing
+ test
+ID
+<<ID
+ uups
+ no end ID
+</formatted>
+</part>
+
+
+<part>
+<assertionMessage>regular expressions</assertionMessage>
+<unformatted>
+v =~ / { \/ { \\/
+if
+o.m()
+end
+v =~ /{/
+o.m()
+</unformatted>
+<formatted>
+v =~ / { \/ { \\/
+if
+ o.m()
+end
+v =~ /{/
+o.m()
+</formatted>
+</part>
+
+<part>
+<assertionMessage>regular expressions with multiple lines</assertionMessage>
+<comment>
+while ruby allows regular expressions with multiple lines, the code formatter won't consider them.
+the reason is, that the simple code formatting parser cannot make a decision if a slash is for starting
+a regex or for a division
+</comment>
+<unformatted>
+if /abc
+/ =~ "\ndef" then
+puts 'matched def' ;
+end
+</unformatted>
+<formatted>
+if /abc
+ / =~ "\ndef" then
+ puts 'matched def' ;
+end
+</formatted>
+</part>
+
+
+<part>
+<assertionMessage>Two divisions</assertionMessage>
+<unformatted>
+def a
+if true
+1/2
+else
+1/4
+end
+end
+</unformatted>
+<formatted>
+def a
+ if true
+ 1/2
+ else
+ 1/4
+ end
+end
+</formatted>
+</part>
+
+
+
+</test>
+
+<test ID="LiteralsStartingWithPercentSign">
+<part>
+<assertionMessage>literals starting with %</assertionMessage>
+<unformatted>
+puts %-class-
+puts %Q(class (m) class)
+puts %Q{class {m} class}
+puts %Q{ def class #{class} { if } class}
+puts ""
+</unformatted>
+<formatted>
+puts %-class-
+puts %Q(class (m) class)
+puts %Q{class {m} class}
+puts %Q{ def class #{class} { if } class}
+puts ""
+</formatted>
+</part>
+</test>
+
+
+<test ID="NegativeIndentation">
+
+<part>
+<assertionMessage>Invalid ruby with too many end</assertionMessage>
+<unformatted>
+class Bob
+ def m
+ end
+ end
+</unformatted>
+<formatted>
+class Bob
+ def m
+ end
+end
+</formatted>
+</part>
+
+</test>
+<test ID="RescueModifier">
+<part>
+<assertionMessage>Rescue Modifier</assertionMessage>
+<unformatted>
+class A
+ var = do_something rescue nil
+foo
+end
+</unformatted>
+<formatted>
+class A
+ var = do_something rescue nil
+ foo
+end
+</formatted>
+</part>
+<part>
+<assertionMessage>Rescue Modifier With Previous Block</assertionMessage>
+<unformatted>
+class A
+ begin
+do_something
+ rescue
+yeah
+ end
+ var = do_something rescue nil
+foo
+end
+</unformatted>
+<formatted>
+class A
+ begin
+ do_something
+ rescue
+ yeah
+ end
+ var = do_something rescue nil
+ foo
+end
+</formatted>
+</part>
+</test>
+
+<test ID="LineStartingWithParen">
+<part>
+<assertionMessage>Align line starting with paren</assertionMessage>
+<unformatted>
+class A
+ foo
+ (1 - 2).inspect
+end
+</unformatted>
+<formatted>
+class A
+ foo
+ (1 - 2).inspect
+end
+</formatted>
+</part>
+</test>
+
+<test ID="CaseWithWhens">
+<part>
+<assertionMessage>Indent when</assertionMessage>
+<unformatted>
+module Foo
+ def bar
+ case baz
+ when 'sweet harmonious biscuits'
+when 'yuck'
+ when 'eww'
+ end
+ end
+end
+</unformatted>
+<formatted>
+module Foo
+ def bar
+ case baz
+ when 'sweet harmonious biscuits'
+ when 'yuck'
+ when 'eww'
+ end
+ end
+end
+</formatted>
+</part>
+</test>
+
+</tests>
+
Property changes on: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_ASTBasedCodeFormatter_Data.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_CodeFormatter.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_CodeFormatter.java 2007-08-22 16:39:58 UTC (rev 3044)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/formatter/TC_CodeFormatter.java 2007-08-22 16:40:08 UTC (rev 3045)
@@ -1,6 +1,7 @@
package org.rubypeople.rdt.internal.formatter;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Hashtable;
@@ -11,6 +12,11 @@
import junit.framework.Assert;
import junit.framework.TestCase;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.TextEdit;
+import org.rubypeople.rdt.core.formatter.CodeFormatter;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -44,7 +50,7 @@
}
public void parseXmlConfiguration() throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError {
- Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(this.getClass().getResourceAsStream("FormatTestData.xml"));
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(getInputDataStream());
NodeList tests = document.getElementsByTagName("test");
for (int i = 0; i < tests.getLength(); i++) {
Node test = tests.item(i);
@@ -62,6 +68,10 @@
}
}
+ protected InputStream getInputDataStream() {
+ return this.getClass().getResourceAsStream("FormatTestData.xml");
+ }
+
private void createTestData(ArrayList partList, NodeList partNodes) {
String formattedText = null;
String unformattedText = null;
@@ -84,8 +94,17 @@
public void doTest(String name) {
ArrayList partList = (ArrayList) testMap.get(name);
for (int i = 0; i < partList.size(); i++) {
- TestData data = (TestData) partList.get(i);
- String formatted = new OldCodeFormatter().formatString(data.unformattedText);
+ TestData data = (TestData) partList.get(i);
+ TextEdit edit = getCodeFormatter().format(-1, data.unformattedText, 0, data.unformattedText.length(), 0, "\n");
+ IDocument doc = new org.eclipse.jface.text.Document(data.unformattedText);
+ try {
+ edit.apply(doc);
+ } catch (MalformedTreeException e) {
+ fail(e.getMessage());
+ } catch (BadLocationException e) {
+ fail(e.getMessage());
+ }
+ String formatted = doc.get();
log("---------- " + data.assertionMessage + " --------") ;
log(data.unformattedText) ;
log("------------") ;
@@ -94,6 +113,10 @@
}
}
+ protected CodeFormatter getCodeFormatter() {
+ return new OldCodeFormatter();
+ }
+
private void log(String formatted) {
if (VERBOSE)
System.out.println(formatted);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 16:40:04
|
Revision: 3044
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3044&view=rev
Author: cawilliams
Date: 2007-08-22 09:39:58 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
start work on an AST based code formatter...
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/formatter/ASTBasedCodeFormatter.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/formatter/ASTBasedCodeFormatter.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/formatter/ASTBasedCodeFormatter.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/formatter/ASTBasedCodeFormatter.java 2007-08-22 16:39:58 UTC (rev 3044)
@@ -0,0 +1,37 @@
+package org.rubypeople.rdt.internal.formatter;
+
+import java.io.StringWriter;
+
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.jruby.ast.Node;
+import org.jruby.ast.visitor.rewriter.ReWriteVisitor;
+import org.jruby.ast.visitor.rewriter.ReWriterFactory;
+import org.jruby.ast.visitor.rewriter.utils.ReWriterContext;
+import org.rubypeople.rdt.core.formatter.CodeFormatter;
+import org.rubypeople.rdt.core.formatter.EditableFormatHelper;
+import org.rubypeople.rdt.internal.core.parser.RubyParser;
+
+public class ASTBasedCodeFormatter extends CodeFormatter {
+
+ @Override
+ public TextEdit format(int kind, String source, int offset, int length,
+ int indentationLevel, String lineSeparator) {
+ StringWriter writer = new StringWriter();
+ EditableFormatHelper helper = new EditableFormatHelper();
+ helper.setLineDelimeter(lineSeparator);
+ helper.setSpacesBeforeAndAfterAssignments(true);
+ helper.setAlwaysParanthesizeMethodDefs(true);
+ source = source.substring(offset, length);
+ ReWriterContext context = new ReWriterContext(writer, source, helper);
+ ReWriterFactory factory = new ReWriterFactory(context);
+ ReWriteVisitor visitor = factory.createReWriteVisitor();
+ RubyParser parser = new RubyParser();
+ Node root = parser.parse(source);
+ root.accept(visitor);
+ writer.append(lineSeparator);
+ String result = writer.getBuffer().toString();
+ return new ReplaceEdit(offset, length, result);
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/formatter/ASTBasedCodeFormatter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 16:39:37
|
Revision: 3043
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3043&view=rev
Author: cawilliams
Date: 2007-08-22 09:39:36 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
use editable FormatHelper, so we don't need to patch DefaultFormatHelper in JRuby
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-22 16:39:30 UTC (rev 3042)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-22 16:39:36 UTC (rev 3043)
@@ -10,11 +10,11 @@
import org.jruby.ast.DefnNode;
import org.jruby.ast.ModuleNode;
import org.jruby.ast.Node;
-import org.jruby.ast.visitor.rewriter.DefaultFormatHelper;
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.EditableFormatHelper;
import org.rubypeople.rdt.core.formatter.Indents;
import org.rubypeople.rdt.core.util.Util;
import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
@@ -176,6 +176,9 @@
}
protected FormatHelper getFormatHelper() {
- return new DefaultFormatHelper();
+ EditableFormatHelper helper = new EditableFormatHelper();
+ helper.setAlwaysParanthesizeMethodCalls(true);
+ helper.setAlwaysParanthesizeMethodDefs(true);
+ return helper;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 16:39:35
|
Revision: 3042
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3042&view=rev
Author: cawilliams
Date: 2007-08-22 09:39:30 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
use editable FormatHelper, so we don't need to patch DefaultFormatHelper in JRuby
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/formatter/EditableFormatHelper.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/formatter/EditableFormatHelper.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/formatter/EditableFormatHelper.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/formatter/EditableFormatHelper.java 2007-08-22 16:39:30 UTC (rev 3042)
@@ -0,0 +1,231 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.core.formatter;
+
+import org.jruby.ast.visitor.rewriter.FormatHelper;
+import org.jruby.ast.visitor.rewriter.utils.Indentor;
+
+public class EditableFormatHelper implements FormatHelper {
+
+ private String lineDelimeter = "\n";
+
+ private Indentor indentor = new Indentor(2, ' ');
+
+ public Indentor getIndentor() {
+ return indentor;
+ }
+
+ public void setTabInsteadOfSpaces(boolean tabInsteadOfSpaces) {
+ if (tabInsteadOfSpaces) {
+ indentor.setIndentationChar('\t');
+ } else {
+ indentor.setIndentationChar(' ');
+ }
+ }
+
+ public void setIndentationSteps(int indentationSteps) {
+ indentor.setIndentationSteps(indentationSteps);
+ }
+
+ public void setLineDelimeter(String lineDelimeter) {
+ this.lineDelimeter = lineDelimeter;
+ }
+
+ /*
+ * | | v v test = 5
+ */
+
+ private boolean spacesBeforeAndAfterAssignments;
+
+ public String beforeAssignment() {
+ return spacesBeforeAndAfterAssignments ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String afterAssignment() {
+ return spacesBeforeAndAfterAssignments ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String matchOperator() {
+ return spacesBeforeAndAfterAssignments ? " =~ " : "=~"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*
+ * | | v v puts("hello")
+ */
+
+ private boolean alwaysParanthesizeMethodCalls;
+
+ public String beforeCallArguments() {
+ return alwaysParanthesizeMethodCalls ? "(" : " "; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String afterCallArguments() {
+ return alwaysParanthesizeMethodCalls ? ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*
+ * | | v v { :a = 10 }
+ */
+
+ private boolean spacesBeforeAndAfterHashContent;
+
+ public String beforeHashContent() {
+ return spacesBeforeAndAfterHashContent ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String afterHashContent() {
+ return spacesBeforeAndAfterHashContent ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*
+ * | | v v [].each_with_index { | e, i | p e }
+ */
+
+ private boolean spaceBeforeIterVars;
+
+ private boolean spaceAfterIterVars;
+
+ public String beforeIterVars() {
+ return spaceBeforeIterVars ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String afterIterVars() {
+ return spaceAfterIterVars ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*
+ * | | v v def test(par1, par2)
+ */
+
+ private boolean alwaysParanthesizeMethodDefs;
+
+ public String beforeMethodArguments() {
+ return alwaysParanthesizeMethodDefs ? "(" : " "; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String afterMethodArguments() {
+ return alwaysParanthesizeMethodDefs ? ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*
+ * | | v v [].each_with_index { | e, i | p e }
+ */
+
+ private boolean spaceBeforeIterBrackets;
+
+ private boolean spaceBeforeClosingIterBrackets;
+
+ public String beforeIterBrackets() {
+ return spaceBeforeIterBrackets ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String beforeClosingIterBrackets() {
+ return spaceBeforeClosingIterBrackets ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*
+ * def ... end | v
+ *
+ * def ... end
+ */
+
+ private boolean newlineBetweenClassBodyElements;
+
+ public String classBodyElementsSeparator() {
+ return newlineBetweenClassBodyElements ? getLineDelimiter() : ""; //$NON-NLS-1$
+ }
+
+ /*
+ * | | | v v v [1, 2, 3, 4]
+ */
+
+ private boolean spaceAfterCommaInListings;
+
+ public String getListSeparator() {
+ return spaceAfterCommaInListings ? ", " : ","; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*
+ * | | v v { :a => 10 }
+ */
+
+ private boolean spacesAroundHashAssignment;
+
+ public String hashAssignment() {
+ return spacesAroundHashAssignment ? " => " : "=>"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void setAlwaysParanthesizeMethodCalls(boolean alwaysParanthesizeMethodCalls) {
+ this.alwaysParanthesizeMethodCalls = alwaysParanthesizeMethodCalls;
+ }
+
+ public void setAlwaysParanthesizeMethodDefs(boolean alwaysParanthesizeMethodDefs) {
+ this.alwaysParanthesizeMethodDefs = alwaysParanthesizeMethodDefs;
+ }
+
+ public void setNewlineBetweenClassBodyElements(boolean newlineBetweenClassBodyElements) {
+ this.newlineBetweenClassBodyElements = newlineBetweenClassBodyElements;
+ }
+
+ public void setSpaceAfterCommaInListings(boolean spaceAfterCommaInListings) {
+ this.spaceAfterCommaInListings = spaceAfterCommaInListings;
+ }
+
+ public void setSpaceAfterIterVars(boolean spaceAfterIterVars) {
+ this.spaceAfterIterVars = spaceAfterIterVars;
+ }
+
+ public void setSpaceBeforeClosingIterBrackets(boolean spaceBeforeClosingIterBrackets) {
+ this.spaceBeforeClosingIterBrackets = spaceBeforeClosingIterBrackets;
+ }
+
+ public void setSpaceBeforeIterBrackets(boolean spaceBeforeIterBrackets) {
+ this.spaceBeforeIterBrackets = spaceBeforeIterBrackets;
+ }
+
+ public void setSpaceBeforeIterVars(boolean spaceBeforeIterVars) {
+ this.spaceBeforeIterVars = spaceBeforeIterVars;
+ }
+
+ public void setSpacesAroundHashAssignment(boolean spacesAroundHashAssignment) {
+ this.spacesAroundHashAssignment = spacesAroundHashAssignment;
+ }
+
+ public void setSpacesBeforeAndAfterAssignments(boolean spacesBeforeAndAfterAssignments) {
+ this.spacesBeforeAndAfterAssignments = spacesBeforeAndAfterAssignments;
+ }
+
+ public void setSpacesBeforeAndAfterHashContent(boolean spacesBeforeAndAfterHashContent) {
+ this.spacesBeforeAndAfterHashContent = spacesBeforeAndAfterHashContent;
+ }
+
+ public String getLineDelimiter() {
+ return lineDelimeter;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/formatter/EditableFormatHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 13:56:44
|
Revision: 3041
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3041&view=rev
Author: cawilliams
Date: 2007-08-22 06:56:41 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
check if we're inside code or not before we try to create a hyperlink. If we're in a comment, string, regexp, or command just immediately return null.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyElementsHyperlinkProvider.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyElementsHyperlinkProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyElementsHyperlinkProvider.java 2007-08-22 13:42:53 UTC (rev 3040)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyElementsHyperlinkProvider.java 2007-08-22 13:56:41 UTC (rev 3041)
@@ -1,7 +1,11 @@
package org.rubypeople.rdt.internal.ui.text.hyperlinks;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PartInitException;
@@ -12,6 +16,7 @@
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.actions.OpenActionUtil;
import org.rubypeople.rdt.internal.ui.actions.SelectionConverter;
+import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
import org.rubypeople.rdt.internal.ui.text.RubyWordFinder;
import org.rubypeople.rdt.ui.IWorkingCopyManager;
import org.rubypeople.rdt.ui.text.hyperlinks.IHyperlinkProvider;
@@ -59,6 +64,7 @@
}
public IHyperlink getHyperlink(IEditorInput input, ITextViewer textViewer, Node node, IRegion region, boolean canShowMultipleHyperlinks) {
+ if (!inCode(textViewer, region)) return null;
IRegion newRegion = RubyWordFinder.findWord(textViewer.getDocument(), region.getOffset());
try {
IWorkingCopyManager manager = RubyPlugin.getDefault().getWorkingCopyManager();
@@ -73,4 +79,20 @@
}
return null;
}
+
+ private boolean inCode(ITextViewer textViewer, IRegion region) {
+ try {
+ ITypedRegion[] regions= TextUtilities.computePartitioning(textViewer.getDocument(), IRubyPartitions.RUBY_PARTITIONING, region.getOffset(), region.getLength(), false);
+ if (regions == null) return false;
+ for (int i = 0; i < regions.length; i++) {
+ String type = regions[i].getType();
+ if (type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
+ return true;
+ }
+ }
+ } catch (BadLocationException e1) {
+ // ignore
+ }
+ return false;
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 13:43:06
|
Revision: 3040
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3040&view=rev
Author: cawilliams
Date: 2007-08-22 06:42:53 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
streamline code a little. Hack removes our grabbing the IRubyScript and parsing out a RootNode, since our only existing hover provider doesn't use it...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyElementsHyperlinkProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyHyperLinkDetector.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyElementsHyperlinkProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyElementsHyperlinkProvider.java 2007-08-21 20:51:59 UTC (rev 3039)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyElementsHyperlinkProvider.java 2007-08-22 13:42:53 UTC (rev 3040)
@@ -62,7 +62,7 @@
IRegion newRegion = RubyWordFinder.findWord(textViewer.getDocument(), region.getOffset());
try {
IWorkingCopyManager manager = RubyPlugin.getDefault().getWorkingCopyManager();
- IRubyScript script = manager.getWorkingCopy(input);
+ IRubyScript script = manager.getWorkingCopy(input);
IRubyElement[] elements = SelectionConverter.codeResolve(script, newRegion.getOffset(), newRegion.getLength());
if (elements == null || elements.length == 0) {
return null;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyHyperLinkDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyHyperLinkDetector.java 2007-08-21 20:51:59 UTC (rev 3039)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/hyperlinks/RubyHyperLinkDetector.java 2007-08-22 13:42:53 UTC (rev 3040)
@@ -1,10 +1,8 @@
package org.rubypeople.rdt.internal.ui.text.hyperlinks;
-import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -15,13 +13,7 @@
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.ui.IEditorInput;
-import org.jruby.ast.Node;
-import org.jruby.lexer.yacc.SyntaxException;
-import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
-import org.rubypeople.rdt.ui.IWorkingCopyManager;
import org.rubypeople.rdt.ui.text.hyperlinks.IHyperlinkProvider;
public class RubyHyperLinkDetector implements IHyperlinkDetector {
@@ -79,29 +71,16 @@
}
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
- IRegion newRegion = region;
List extensions = initExtensions();
- // first ask the extensions
- if (extensions.size() > 0) {
- IWorkingCopyManager manager = RubyPlugin.getDefault().getWorkingCopyManager();
- IRubyScript script = manager.getWorkingCopy(fEditorInput);
- if (script == null) return null;
- RubyParser parser = new RubyParser();
- try {
- Node root = parser.parse((IFile) script.getResource(), new StringReader(script.getSource()));
- for (int i = 0; i < extensions.size(); i++) {
- IHyperlinkProvider currentProvider = (IHyperlinkProvider) extensions.get(i);
- IHyperlink link = currentProvider.getHyperlink(fEditorInput, textViewer, root, newRegion, true);
- // TODO: either do that or query all HyperlinkProviders and
- // return a list of hyperlinks?
- if (link != null) {
- return new IHyperlink[] { link };
- }
- }
- } catch (SyntaxException se) {
- // ignore
- } catch (RubyModelException e) {
- //ignore
+ if (extensions.isEmpty()) return null;
+ // FIXME We cheat and pass a null Node down to providers, because so far we only have one, and it doesn't use it. So this allows us to speed things up by not parsing the file...
+ for (int i = 0; i < extensions.size(); i++) {
+ IHyperlinkProvider currentProvider = (IHyperlinkProvider) extensions.get(i);
+ IHyperlink link = currentProvider.getHyperlink(fEditorInput, textViewer, null, region, canShowMultipleHyperlinks);
+ // TODO: either do that or query all HyperlinkProviders and
+ // return a list of hyperlinks?
+ if (link != null) {
+ return new IHyperlink[] { link };
}
}
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 20:52:00
|
Revision: 3039
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3039&view=rev
Author: cawilliams
Date: 2007-08-21 13:51:59 -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 20:50:39 UTC (rev 3038)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 20:51:59 UTC (rev 3039)
@@ -76,6 +76,7 @@
case IProblem.ConstantNamingConvention:
String constName = getProblemSource(context, problem);
String fixed = Util.camelCaseToUnderscores(constName).toUpperCase();
+ // FIXME Use the rename refactoring!
LocalCorrectionsSubProcessor.addReplacementProposal(fixed, "Convert to UPPERCASE_WITH_UNDERSCORES convention", problem, proposals);
break;
case IProblem.LocalVariablePossibleAttributeAccess:
@@ -87,6 +88,7 @@
case IProblem.LocalAndMethodNamingConvention:
String name = getProblemSource(context, problem);
fixed = Util.camelCaseToUnderscores(name).toLowerCase();
+ // FIXME Use the rename refactoring!
LocalCorrectionsSubProcessor.addReplacementProposal(fixed, "Convert to lowercase_with_undercores convention", problem, proposals);
break;
case IProblem.MethodMissingWithoutRespondTo:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 20:50:41
|
Revision: 3038
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3038&view=rev
Author: cawilliams
Date: 2007-08-21 13:50:39 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix #5632 - Add quick fix for local var as possible attribute access
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/LocalVariablePossibleAttributeAccess.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java 2007-08-21 20:50:34 UTC (rev 3037)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java 2007-08-21 20:50:39 UTC (rev 3038)
@@ -7,4 +7,5 @@
public static final int LocalAndMethodNamingConvention = 131;
public static final int ComparableInclusionMissingCompareMethod = 132;
public static final int EnumerableInclusionMissingEachMethod = 133;
+ public static final int LocalVariablePossibleAttributeAccess = 134;
}
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/LocalVariablePossibleAttributeAccess.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/LocalVariablePossibleAttributeAccess.java 2007-08-21 20:50:34 UTC (rev 3037)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/LocalVariablePossibleAttributeAccess.java 2007-08-21 20:50:39 UTC (rev 3038)
@@ -11,6 +11,7 @@
import org.rubypeople.rdt.internal.core.util.ASTUtil;
import com.aptana.rdt.AptanaRDTPlugin;
+import com.aptana.rdt.IProblem;
public class LocalVariablePossibleAttributeAccess extends RubyLintVisitor {
@@ -69,5 +70,10 @@
}
super.exitClassNode(iVisited);
}
+
+ @Override
+ protected int getProblemID() {
+ return IProblem.LocalVariablePossibleAttributeAccess;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 20:50:38
|
Revision: 3037
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3037&view=rev
Author: cawilliams
Date: 2007-08-21 13:50:34 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix #5632 - Add quick fix for local var as possible attribute access
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 20:27:55 UTC (rev 3036)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 20:50:34 UTC (rev 3037)
@@ -78,6 +78,12 @@
String fixed = Util.camelCaseToUnderscores(constName).toUpperCase();
LocalCorrectionsSubProcessor.addReplacementProposal(fixed, "Convert to UPPERCASE_WITH_UNDERSCORES convention", problem, proposals);
break;
+ case IProblem.LocalVariablePossibleAttributeAccess:
+ String local = getProblemSource(context, problem);
+ fixed = "self." + local;
+ LocalCorrectionsSubProcessor.addReplacementProposal(fixed, "change assignment to " + fixed + " to use attribute", problem, proposals);
+ // TODO Add a proposal to invoke rename local refactoring
+ break;
case IProblem.LocalAndMethodNamingConvention:
String name = getProblemSource(context, problem);
fixed = Util.camelCaseToUnderscores(name).toLowerCase();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 20:27:57
|
Revision: 3036
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3036&view=rev
Author: cawilliams
Date: 2007-08-21 13:27:55 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
add missing strings
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-08-21 19:23:44 UTC (rev 3035)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-08-21 20:27:55 UTC (rev 3036)
@@ -244,4 +244,31 @@
commandParameter.showElementInPackageView.elementRef.name= Ruby element reference
command.showElementInTypeHierarchyView.name= Show Ruby Element Type Hierarchy
command.showElementInTypeHierarchyView.desc= Show a Ruby element in the Type Hierarchy view
-commandParameter.showElementInTypeHierarchyView.elementRef.name= Ruby element reference
\ No newline at end of file
+commandParameter.showElementInTypeHierarchyView.elementRef.name= Ruby element reference
+
+##########################################################################
+# Ruby Search
+##########################################################################
+RubySearchPage.label= Ruby Search
+openRubySearchPageAction.label= &Ruby...
+
+# Action sets
+RubySearchActionSet.label= Ruby Search
+RubySearchActionSet.description= Action set containing search related Ruby actions
+
+# Menus
+searchMenu.label= Se&arch
+OccurrencesInFile.label= Occurrences in File
+declarationsSubMenu.label= Dec&larations
+referencesSubMenu.label= R&eferences
+occurrencesSubMenu.label= Occurre&nces in File
+readAccessSubMenu.label= &Read Access
+writeAccessSubMenu.label= &Write Access
+
+ReferencesInWorkspace.label= &Workspace
+DeclarationsInWorkspace.label= &Workspace
+
+InWorkspace.label= &Workspace
+InProject.label= &Project
+InHierarchy.label= &Hierarchy
+InWorkingSet.label= Working &Set...
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 19:23:46
|
Revision: 3035
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3035&view=rev
Author: cawilliams
Date: 2007-08-21 12:23:44 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix #5630 - Add quick fix for Enumerable inclusion missing "each" method definition
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/EnumerableInclusionVisitor.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java 2007-08-21 19:23:38 UTC (rev 3034)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java 2007-08-21 19:23:44 UTC (rev 3035)
@@ -6,4 +6,5 @@
public static final int MethodMissingWithoutRespondTo = 130;
public static final int LocalAndMethodNamingConvention = 131;
public static final int ComparableInclusionMissingCompareMethod = 132;
+ public static final int EnumerableInclusionMissingEachMethod = 133;
}
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/EnumerableInclusionVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/EnumerableInclusionVisitor.java 2007-08-21 19:23:38 UTC (rev 3034)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/EnumerableInclusionVisitor.java 2007-08-21 19:23:44 UTC (rev 3035)
@@ -11,6 +11,7 @@
import org.rubypeople.rdt.core.parser.warnings.RubyLintVisitor;
import com.aptana.rdt.AptanaRDTPlugin;
+import com.aptana.rdt.IProblem;
public class EnumerableInclusionVisitor extends RubyLintVisitor {
@@ -72,5 +73,10 @@
pos = null;
definedEnumerableMethod = false;
}
+
+ @Override
+ protected int getProblemID() {
+ return IProblem.EnumerableInclusionMissingEachMethod;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 19:23:39
|
Revision: 3034
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3034&view=rev
Author: cawilliams
Date: 2007-08-21 12:23:38 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix #5630 - Add quick fix for Enumerable inclusion missing "each" method definition
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 19:22:31 UTC (rev 3033)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 19:23:38 UTC (rev 3034)
@@ -6,17 +6,13 @@
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
-import org.jruby.ast.BlockNode;
import org.jruby.ast.ClassNode;
-import org.jruby.ast.CommentNode;
import org.jruby.ast.DefnNode;
-import org.jruby.ast.InstAsgnNode;
import org.jruby.ast.ModuleNode;
import org.jruby.ast.Node;
import org.jruby.ast.visitor.rewriter.DefaultFormatHelper;
import org.jruby.ast.visitor.rewriter.FormatHelper;
import org.jruby.ast.visitor.rewriter.ReWriteVisitor;
-import org.jruby.lexer.yacc.IDESourcePosition;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.formatter.Indents;
@@ -35,6 +31,8 @@
public class QuickFixProcessor implements IQuickFixProcessor {
+ private static final String NEWLINE = "\n";
+
public IRubyCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException {
if (locations == null || locations.length == 0) {
return null;
@@ -51,6 +49,20 @@
}
return (IRubyCompletionProposal[]) resultingCollections.toArray(new IRubyCompletionProposal[resultingCollections.size()]);
}
+
+ public boolean hasCorrections(IRubyScript unit, int problemId) {
+ switch (problemId) {
+ case IProblem.MisspelledConstructor:
+ case IProblem.ConstantNamingConvention:
+ case IProblem.MethodMissingWithoutRespondTo:
+ case IProblem.LocalAndMethodNamingConvention:
+ case IProblem.ComparableInclusionMissingCompareMethod:
+ case IProblem.EnumerableInclusionMissingEachMethod:
+ return true;
+ default:
+ return false;
+ }
+ }
private void process(IInvocationContext context, IProblemLocation problem, Collection<IRubyCompletionProposal> proposals) throws CoreException {
int id = problem.getProblemId();
@@ -82,6 +94,11 @@
text = insertedMethodText(context, offset, "<=>", new String[] {"other"});
LocalCorrectionsSubProcessor.addReplacementProposal(offset, 0, text, "Add <=> method stub", proposals);
break;
+ case IProblem.EnumerableInclusionMissingEachMethod:
+ offset = getOffsetOfFirstLineInsideType(context, problem);
+ text = insertedMethodText(context, offset, "each", new String[] {});
+ LocalCorrectionsSubProcessor.addReplacementProposal(offset, 0, text, "Add each method stub", proposals);
+ break;
default:
}
}
@@ -100,23 +117,23 @@
String text = ReWriteVisitor.createCodeFromNode(insert, src, getFormatHelper());
StringBuffer buffer = new StringBuffer(text);
- int index = text.indexOf("\n", 1);
+ int index = text.indexOf(NEWLINE, 1);
buffer.insert(index + 1, " # TODO Auto-generated method stub\n");
// Figure out indent at offset and apply that to each line of text and at end of text
String indent = findIndent(offset, script, src);
buffer.insert(0, indent);
- buffer.append("\n");
+ buffer.append(NEWLINE);
text = buffer.toString();
- text = text.replaceAll("\\n", "\n" + indent);
+ text = text.replaceAll("\\n", NEWLINE + indent);
return text;
}
private String findIndent(int offset, IRubyScript script, String src) {
if (src == null || src.length() == 0) return "";
- int index = src.indexOf("\n", offset);
+ int index = src.indexOf(NEWLINE, offset);
if (index < 1 || index > src.length()) return "";
String line = src.substring(0, index);
- index = line.lastIndexOf("\n");
+ index = line.lastIndexOf(NEWLINE);
Map options = script.getRubyProject().getOptions(true);
if (index == -1 || ((index + 1) >= line.length()) ) return Indents.extractIndentString(line, options);
line = line.substring(index + 1);
@@ -153,17 +170,4 @@
protected FormatHelper getFormatHelper() {
return new DefaultFormatHelper();
}
-
- public boolean hasCorrections(IRubyScript unit, int problemId) {
- switch (problemId) {
- case IProblem.MisspelledConstructor:
- case IProblem.ConstantNamingConvention:
- case IProblem.MethodMissingWithoutRespondTo:
- case IProblem.LocalAndMethodNamingConvention:
- case IProblem.ComparableInclusionMissingCompareMethod:
- return true;
- default:
- return false;
- }
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 19:22:32
|
Revision: 3033
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3033&view=rev
Author: cawilliams
Date: 2007-08-21 12:22:31 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
avoid NPE
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java 2007-08-21 19:15:48 UTC (rev 3032)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java 2007-08-21 19:22:31 UTC (rev 3033)
@@ -30,7 +30,7 @@
public TypeReferencePattern(char[] qualification, char[] simpleName, int matchRule) {
this(matchRule);
- if (qualification.length == 0) {
+ if (qualification != null && qualification.length == 0) {
this.qualification = null;
} else {
this.qualification = isCaseSensitive() ? qualification : CharOperation.toLowerCase(qualification);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 19:15:49
|
Revision: 3032
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3032&view=rev
Author: cawilliams
Date: 2007-08-21 12:15:48 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix for #5628 - Add quick fix for Comparable inclusion missing <=>
Also add a task marker to method stubs
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/ComparableInclusionVisitor.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java 2007-08-21 19:15:40 UTC (rev 3031)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/IProblem.java 2007-08-21 19:15:48 UTC (rev 3032)
@@ -5,4 +5,5 @@
public static final int ConstantNamingConvention = 129;
public static final int MethodMissingWithoutRespondTo = 130;
public static final int LocalAndMethodNamingConvention = 131;
+ public static final int ComparableInclusionMissingCompareMethod = 132;
}
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/ComparableInclusionVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/ComparableInclusionVisitor.java 2007-08-21 19:15:40 UTC (rev 3031)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/ComparableInclusionVisitor.java 2007-08-21 19:15:48 UTC (rev 3032)
@@ -11,6 +11,7 @@
import org.rubypeople.rdt.core.parser.warnings.RubyLintVisitor;
import com.aptana.rdt.AptanaRDTPlugin;
+import com.aptana.rdt.IProblem;
public class ComparableInclusionVisitor extends RubyLintVisitor {
@@ -72,5 +73,10 @@
pos = null;
definedComparableMethod = false;
}
+
+ @Override
+ protected int getProblemID() {
+ return IProblem.ComparableInclusionMissingCompareMethod;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 19:15:41
|
Revision: 3031
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3031&view=rev
Author: cawilliams
Date: 2007-08-21 12:15:40 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix for #5628 - Add quick fix for Comparable inclusion missing <=>
Also add a task marker to method stubs
Modified Paths:
--------------
trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java
trunk/com.aptana.rdt.ui/src/com/aptana/rdt/ui/AptanaRDTUIPlugin.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:24:14 UTC (rev 3030)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 19:15:40 UTC (rev 3031)
@@ -6,13 +6,17 @@
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
+import org.jruby.ast.BlockNode;
import org.jruby.ast.ClassNode;
+import org.jruby.ast.CommentNode;
import org.jruby.ast.DefnNode;
+import org.jruby.ast.InstAsgnNode;
import org.jruby.ast.ModuleNode;
import org.jruby.ast.Node;
import org.jruby.ast.visitor.rewriter.DefaultFormatHelper;
import org.jruby.ast.visitor.rewriter.FormatHelper;
import org.jruby.ast.visitor.rewriter.ReWriteVisitor;
+import org.jruby.lexer.yacc.IDESourcePosition;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.formatter.Indents;
@@ -27,6 +31,7 @@
import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
import com.aptana.rdt.IProblem;
+import com.aptana.rdt.ui.AptanaRDTUIPlugin;
public class QuickFixProcessor implements IQuickFixProcessor {
@@ -57,57 +62,92 @@
LocalCorrectionsSubProcessor.addReplacementProposal("initialize\n", "Rename to 'initialize'", problem, proposals);
break;
case IProblem.ConstantNamingConvention:
- String constName = getSource(context, problem);
+ String constName = getProblemSource(context, problem);
String fixed = Util.camelCaseToUnderscores(constName).toUpperCase();
LocalCorrectionsSubProcessor.addReplacementProposal(fixed, "Convert to UPPERCASE_WITH_UNDERSCORES convention", problem, proposals);
break;
case IProblem.LocalAndMethodNamingConvention:
- String name = getSource(context, problem);
+ String name = getProblemSource(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...
- 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() {
-
- public boolean doesAccept(Node node) {
- return node instanceof ClassNode || node instanceof ModuleNode;
- }
-
- });
- if (typeNode instanceof ClassNode) {
- ClassNode classNode = (ClassNode) typeNode;
- offset = classNode.getBodyNode().getPosition().getStartOffset();
- } else if (typeNode instanceof ModuleNode) {
- ModuleNode classNode = (ModuleNode) typeNode;
- offset = classNode.getBodyNode().getPosition().getStartOffset();
- }
- DefnNode methodNode = NodeFactory.createMethodNode("respond_to?", new String[] {"symbol", "include_private = false"}, null);
- Node insert = NodeFactory.createBlockNode(true, NodeFactory.createNewLineNode(methodNode));
- String text = ReWriteVisitor.createCodeFromNode(insert, src, getFormatHelper());
- // Figure out indent at offset and apply that to each line of text and at end of text
- String line = src.substring(0, src.indexOf("\n", offset));
- line = line.substring(line.lastIndexOf("\n") + 1);
- Map options = script.getRubyProject().getOptions(true);
- String indent = Indents.extractIndentString(line, options);
- text = indent + text;
- text = text + "\n";
- text = text.replaceAll("\\n", "\n" + indent);
+ int offset = getOffsetOfFirstLineInsideType(context, problem);
+ String text = insertedMethodText(context, offset, "respond_to?", new String[] {"symbol", "include_private = false"});
LocalCorrectionsSubProcessor.addReplacementProposal(offset, 0, text, "Add respond_to? method stub", proposals);
break;
+ case IProblem.ComparableInclusionMissingCompareMethod:
+ offset = getOffsetOfFirstLineInsideType(context, problem);
+ text = insertedMethodText(context, offset, "<=>", new String[] {"other"});
+ LocalCorrectionsSubProcessor.addReplacementProposal(offset, 0, text, "Add <=> method stub", proposals);
+ break;
default:
}
}
+
+ private String insertedMethodText(IInvocationContext context, int offset, String methodName, String[] args) {
+ IRubyScript script = context.getRubyScript();
+ String src = "";
+ try {
+ src = script.getSource();
+ } catch (RubyModelException e) {
+ AptanaRDTUIPlugin.log(e);
+ }
+
+ DefnNode methodNode = NodeFactory.createMethodNode(methodName, args, null);
+ Node insert = NodeFactory.createBlockNode(true, NodeFactory.createNewLineNode(methodNode));
+ String text = ReWriteVisitor.createCodeFromNode(insert, src, getFormatHelper());
+
+ StringBuffer buffer = new StringBuffer(text);
+ int index = text.indexOf("\n", 1);
+ buffer.insert(index + 1, " # TODO Auto-generated method stub\n");
+ // Figure out indent at offset and apply that to each line of text and at end of text
+ String indent = findIndent(offset, script, src);
+ buffer.insert(0, indent);
+ buffer.append("\n");
+ text = buffer.toString();
+ text = text.replaceAll("\\n", "\n" + indent);
+ return text;
+ }
- private String getSource(IInvocationContext context, IProblemLocation problem) throws RubyModelException {
+ private String findIndent(int offset, IRubyScript script, String src) {
+ if (src == null || src.length() == 0) return "";
+ int index = src.indexOf("\n", offset);
+ if (index < 1 || index > src.length()) return "";
+ String line = src.substring(0, index);
+ index = line.lastIndexOf("\n");
+ Map options = script.getRubyProject().getOptions(true);
+ if (index == -1 || ((index + 1) >= line.length()) ) return Indents.extractIndentString(line, options);
+ line = line.substring(index + 1);
+ return Indents.extractIndentString(line, options);
+ }
+
+ private int getOffsetOfFirstLineInsideType(IInvocationContext context, IProblemLocation problem) {
IRubyScript script = context.getRubyScript();
+ int offset = -1;
+ Node rootNode = ASTProvider.getASTProvider().getAST(script, ASTProvider.WAIT_YES, null);
+ Node typeNode = ClosestSpanningNodeLocator.Instance().findClosestSpanner(rootNode, problem.getOffset(), new INodeAcceptor() {
+
+ public boolean doesAccept(Node node) {
+ return node instanceof ClassNode || node instanceof ModuleNode;
+ }
+
+ });
+ if (typeNode instanceof ClassNode) {
+ ClassNode classNode = (ClassNode) typeNode;
+ offset = classNode.getBodyNode().getPosition().getStartOffset();
+ } else if (typeNode instanceof ModuleNode) {
+ ModuleNode classNode = (ModuleNode) typeNode;
+ offset = classNode.getBodyNode().getPosition().getStartOffset();
+ }
+ return offset;
+ }
+
+ private String getProblemSource(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;
+ return src.substring(problem.getOffset(), problem.getOffset() + problem.getLength());
}
protected FormatHelper getFormatHelper() {
@@ -120,6 +160,7 @@
case IProblem.ConstantNamingConvention:
case IProblem.MethodMissingWithoutRespondTo:
case IProblem.LocalAndMethodNamingConvention:
+ case IProblem.ComparableInclusionMissingCompareMethod:
return true;
default:
return false;
Modified: trunk/com.aptana.rdt.ui/src/com/aptana/rdt/ui/AptanaRDTUIPlugin.java
===================================================================
--- trunk/com.aptana.rdt.ui/src/com/aptana/rdt/ui/AptanaRDTUIPlugin.java 2007-08-21 18:24:14 UTC (rev 3030)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/ui/AptanaRDTUIPlugin.java 2007-08-21 19:15:40 UTC (rev 3031)
@@ -2,6 +2,7 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.rubypeople.rdt.core.RubyModelException;
/**
* The activator class controls the plug-in life cycle
@@ -47,4 +48,8 @@
return plugin;
}
+ public static void log(RubyModelException e) {
+ getDefault().getLog().log(e.getStatus());
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <caw...@us...> - 2007-08-21 18:22:00
|
Revision: 3029
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3029&view=rev
Author: cawilliams
Date: 2007-08-21 11:21:55 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix #5626 - Add quick fix for method/local naming convention (and move common code to convert camelCase to under_scores into Util class).
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:51 UTC (rev 3028)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 18:21:55 UTC (rev 3029)
@@ -15,6 +15,7 @@
import org.jruby.ast.visitor.rewriter.ReWriteVisitor;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.formatter.Indents;
+import org.rubypeople.rdt.core.util.Util;
import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
import org.rubypeople.rdt.internal.ui.rubyeditor.ASTProvider;
@@ -58,13 +59,14 @@
IRubyScript script = context.getRubyScript();
String src = script.getSource();
String constName = src.substring(problem.getOffset(), problem.getOffset() + problem.getLength());
- LocalCorrectionsSubProcessor.addReplacementProposal(constName.toUpperCase(), "Convert to all uppercase", problem, proposals);
+ 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());
- String fixed = constName.toLowerCase(); // FIXME We need to convert in a smarter way!
+ fixed = Util.camelCaseToUnderscores(constName).toLowerCase();
LocalCorrectionsSubProcessor.addReplacementProposal(fixed, "Convert to lowercase_with_undercores convention", problem, proposals);
break;
case IProblem.MethodMissingWithoutRespondTo:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 18:21:54
|
Revision: 3028
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3028&view=rev
Author: cawilliams
Date: 2007-08-21 11:21:51 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix #5626 - Add quick fix for method/local naming convention (and move common code to convert camelCase to under_scores into Util class).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/Util.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/Util.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/Util.java 2007-08-21 18:21:47 UTC (rev 3027)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/Util.java 2007-08-21 18:21:51 UTC (rev 3028)
@@ -206,4 +206,23 @@
return contents;
}
+
+ public static String camelCaseToUnderscores(String name) {
+ if (name == null) return null;
+ if (name.length() == 0) return "";
+ StringBuffer newName = new StringBuffer();
+ boolean lastWasUpper = false;
+ for (int i = 0; i < name.length(); i++) {
+ char c = name.charAt(i);
+ newName.append(Character.toLowerCase(c));
+ if (lastWasUpper && Character.isLowerCase(c)) {
+ if (newName.length() > 2) newName.insert(newName.length() - 2, "_");
+ lastWasUpper = false;
+ }
+ if (Character.isUpperCase(c)) {
+ lastWasUpper = true;
+ }
+ }
+ return newName.toString();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 18:21:54
|
Revision: 3027
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3027&view=rev
Author: cawilliams
Date: 2007-08-21 11:21:47 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
fix #5626 - Add quick fix for method/local naming convention (and move common code to convert camelCase to under_scores into Util class).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-08-21 18:12:31 UTC (rev 3026)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-08-21 18:21:47 UTC (rev 3027)
@@ -32,6 +32,7 @@
import org.rubypeople.rdt.core.search.IRubySearchConstants;
import org.rubypeople.rdt.core.search.IRubySearchScope;
import org.rubypeople.rdt.core.search.SearchEngine;
+import org.rubypeople.rdt.core.util.Util;
import org.rubypeople.rdt.internal.corext.codemanipulation.StubUtility;
import org.rubypeople.rdt.internal.corext.util.CodeFormatterUtil;
import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
@@ -118,8 +119,6 @@
protected IStatus fSuperModulesStatus;
private int fTypeKind;
-
- private boolean fCanModifySourceFolder;
/**
* Constant to signal that the created type is a class.
@@ -409,38 +408,9 @@
* @since 0.9.0
*/
protected String getRubyScriptName(String typeName) {
- return convertCamelCaseToUnderscore(typeName) + RubyModelUtil.DEFAULT_SCRIPT_SUFFIX;
+ return Util.camelCaseToUnderscores(typeName) + RubyModelUtil.DEFAULT_SCRIPT_SUFFIX;
}
- private String convertCamelCaseToUnderscore(String name) {
- StringBuffer newName = new StringBuffer();
- boolean lastWasUpper = false;
- for (int i = 0; i < name.length(); i++) {
- char c = name.charAt(i);
- newName.append(Character.toLowerCase(c));
- if (lastWasUpper && Character.isLowerCase(c)) {
- if (newName.length() > 2) newName.insert(newName.length() - 2, "_");
- lastWasUpper = false;
- }
- if (Character.isUpperCase(c)) {
- lastWasUpper = true;
- }
- }
- return newName.toString();
- }
-
- /*
- * Updates the enable state of buttons related to the enclosing type selection checkbox.
- */
- private void updateEnableState() {
-
- }
-
- private boolean isEnclosingTypeSelected() {
- // TODO Auto-generated method stub
- return false;
- }
-
/**
* Creates the new type using the entered field values.
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 18:12:36
|
Revision: 3026
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3026&view=rev
Author: cawilliams
Date: 2007-08-21 11:12:31 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
remove unused code, use common CorrectionProposal class
Modified Paths:
--------------
trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
Removed Paths:
-------------
trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/CorrectionProposal.java
Deleted: trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/CorrectionProposal.java
===================================================================
--- trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/CorrectionProposal.java 2007-08-21 18:11:08 UTC (rev 3025)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/CorrectionProposal.java 2007-08-21 18:12:31 UTC (rev 3026)
@@ -1,25 +0,0 @@
-package com.aptana.rdt.internal.ui.text.correction;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.graphics.Image;
-import org.rubypeople.rdt.internal.ui.text.ruby.RubyCompletionProposal;
-
-public class CorrectionProposal extends RubyCompletionProposal {
-
- public CorrectionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance) {
- super(replacementString, replacementOffset, replacementLength, image, displayString, relevance);
- }
-
- @Override
- protected boolean isValidPrefix(String prefix) {
- return true;
- }
-
- @Override
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDocument document= viewer.getDocument();
- apply(document, trigger, getReplacementOffset());
- }
-
-}
Modified: trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
===================================================================
--- trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java 2007-08-21 18:11:08 UTC (rev 3025)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java 2007-08-21 18:12:31 UTC (rev 3026)
@@ -3,21 +3,13 @@
import java.util.Collection;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.ui.RubyUI;
-import org.rubypeople.rdt.ui.text.ruby.IInvocationContext;
+import org.rubypeople.rdt.ui.text.correction.CorrectionProposal;
import org.rubypeople.rdt.ui.text.ruby.IProblemLocation;
import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
public class LocalCorrectionsSubProcessor {
- public static void addUnusedMemberProposal(IInvocationContext context, IProblemLocation problem, Collection<IRubyCompletionProposal> proposals) {
- Image image= RubyPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
- CorrectionProposal proposal = new CorrectionProposal("", problem.getOffset(), problem.getLength(), image, "clean up unused code", 100);
- proposals.add(proposal);
- }
-
public static void addReplacementProposal(String replacement, String display, IProblemLocation problem, Collection<IRubyCompletionProposal> proposals) {
addReplacementProposal(problem.getOffset(), problem.getLength(), replacement, display, proposals);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 18:11:14
|
Revision: 3025
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3025&view=rev
Author: cawilliams
Date: 2007-08-21 11:11:08 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
move common class out to externally visible package
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/QuickFixProcessor.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/correction/CorrectionProposal.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionProposal.java
Modified: trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-08-21 18:09:28 UTC (rev 3024)
+++ trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-08-21 18:11:08 UTC (rev 3025)
@@ -34,6 +34,7 @@
org.rubypeople.rdt.ui.extensions,
org.rubypeople.rdt.ui.rubyeditor,
org.rubypeople.rdt.ui.text,
+ org.rubypeople.rdt.ui.text.correction,
org.rubypeople.rdt.ui.text.folding,
org.rubypeople.rdt.ui.text.hyperlinks,
org.rubypeople.rdt.ui.text.ruby,
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionProposal.java 2007-08-21 18:09:28 UTC (rev 3024)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionProposal.java 2007-08-21 18:11:08 UTC (rev 3025)
@@ -1,25 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.correction;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.graphics.Image;
-import org.rubypeople.rdt.internal.ui.text.ruby.RubyCompletionProposal;
-
-public class CorrectionProposal extends RubyCompletionProposal {
-
- public CorrectionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance) {
- super(replacementString, replacementOffset, replacementLength, image, displayString, relevance);
- }
-
- @Override
- protected boolean isValidPrefix(String prefix) {
- return true;
- }
-
- @Override
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDocument document= viewer.getDocument();
- apply(document, trigger, getReplacementOffset());
- }
-
-}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/QuickFixProcessor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 18:09:28 UTC (rev 3024)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 18:11:08 UTC (rev 3025)
@@ -12,6 +12,7 @@
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.ui.text.correction.CorrectionProposal;
import org.rubypeople.rdt.ui.text.ruby.IInvocationContext;
import org.rubypeople.rdt.ui.text.ruby.IProblemLocation;
import org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor;
Copied: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/correction/CorrectionProposal.java (from rev 3022, trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionProposal.java)
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/correction/CorrectionProposal.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/correction/CorrectionProposal.java 2007-08-21 18:11:08 UTC (rev 3025)
@@ -0,0 +1,25 @@
+package org.rubypeople.rdt.ui.text.correction;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.graphics.Image;
+import org.rubypeople.rdt.internal.ui.text.ruby.RubyCompletionProposal;
+
+public class CorrectionProposal extends RubyCompletionProposal {
+
+ public CorrectionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance) {
+ super(replacementString, replacementOffset, replacementLength, image, displayString, relevance);
+ }
+
+ @Override
+ protected boolean isValidPrefix(String prefix) {
+ return true;
+ }
+
+ @Override
+ public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+ IDocument document= viewer.getDocument();
+ apply(document, trigger, getReplacementOffset());
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 18:09:32
|
Revision: 3024
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3024&view=rev
Author: cawilliams
Date: 2007-08-21 11:09:28 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/correction/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-21 18:08:40
|
Revision: 3023
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3023&view=rev
Author: cawilliams
Date: 2007-08-21 11:08:38 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
move quick fixes for problems defined in RDT core into RDT UI. Keep com.aptana.rdt.ui to only do quick fixes for com.aptana.rdt
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:08:33 UTC (rev 3022)
+++ trunk/com.aptana.rdt.ui/src/com/aptana/rdt/internal/ui/text/correction/QuickFixProcessor.java 2007-08-21 18:08:38 UTC (rev 3023)
@@ -14,7 +14,6 @@
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.compiler.IProblem;
import org.rubypeople.rdt.core.formatter.Indents;
import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
@@ -25,9 +24,7 @@
import org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor;
import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
-import com.aptana.rdt.internal.parser.warnings.ConstantNamingConvention;
-import com.aptana.rdt.internal.parser.warnings.MethodMissingWithoutRespondTo;
-import com.aptana.rdt.internal.parser.warnings.MisspelledConstructorVisitor;
+import com.aptana.rdt.IProblem;
public class QuickFixProcessor implements IQuickFixProcessor {
@@ -54,22 +51,23 @@
return;
}
switch (id) {
- case IProblem.UnusedPrivateMethod:
- case IProblem.UnusedPrivateField:
- case IProblem.LocalVariableIsNeverUsed:
- case IProblem.ArgumentIsNeverUsed:
- LocalCorrectionsSubProcessor.addUnusedMemberProposal(context, problem, proposals);
- break;
- case MisspelledConstructorVisitor.PROBLEM_ID:
+ case IProblem.MisspelledConstructor:
LocalCorrectionsSubProcessor.addReplacementProposal("initialize\n", "Rename to 'initialize'", problem, proposals);
break;
- case ConstantNamingConvention.PROBLEM_ID:
+ case IProblem.ConstantNamingConvention:
IRubyScript script = context.getRubyScript();
String src = script.getSource();
String constName = src.substring(problem.getOffset(), problem.getOffset() + problem.getLength());
LocalCorrectionsSubProcessor.addReplacementProposal(constName.toUpperCase(), "Convert to all uppercase", problem, proposals);
break;
- case MethodMissingWithoutRespondTo.PROBLEM_ID:
+ case IProblem.LocalAndMethodNamingConvention:
+ script = context.getRubyScript();
+ src = script.getSource();
+ constName = src.substring(problem.getOffset(), problem.getOffset() + problem.getLength());
+ String fixed = constName.toLowerCase(); // FIXME We need to convert in a smarter way!
+ 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();
@@ -112,13 +110,10 @@
public boolean hasCorrections(IRubyScript unit, int problemId) {
switch (problemId) {
- case IProblem.UnusedPrivateMethod:
- case IProblem.UnusedPrivateField:
- case IProblem.LocalVariableIsNeverUsed:
- case IProblem.ArgumentIsNeverUsed:
- case MisspelledConstructorVisitor.PROBLEM_ID:
- case ConstantNamingConvention.PROBLEM_ID:
- case MethodMissingWithoutRespondTo.PROBLEM_ID:
+ case IProblem.MisspelledConstructor:
+ case IProblem.ConstantNamingConvention:
+ case IProblem.MethodMissingWithoutRespondTo:
+ case IProblem.LocalAndMethodNamingConvention:
return true;
default:
return false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|