|
From: David C. <dc...@us...> - 2005-10-09 22:13:10
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21652/src/org/rubypeople/rdt/internal/core/builder Modified Files: IndexUpdater_UT.java TC_RdtCompiler.java Log Message: Upgraded to JRuby head. More work on Updating the Symbol Index for class names. Index: TC_RdtCompiler.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RdtCompiler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TC_RdtCompiler.java 1 Oct 2005 23:10:58 -0000 1.2 --- TC_RdtCompiler.java 9 Oct 2005 22:13:01 -0000 1.3 *************** *** 1,4 **** --- 1,7 ---- package org.rubypeople.rdt.internal.core.builder; + import java.util.ArrayList; + import java.util.List; + import junit.framework.TestCase; *************** *** 24,31 **** file.setContents(FILE_CONTENTS); ! rootNode = new Node() { ! public void accept(NodeVisitor visitor) { } }; markerManager = new ShamMarkerManager(); --- 27,37 ---- file.setContents(FILE_CONTENTS); ! rootNode = new Node(null) { public void accept(NodeVisitor visitor) { } + + public List childNodes() { + return new ArrayList(); + } }; markerManager = new ShamMarkerManager(); Index: IndexUpdater_UT.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/IndexUpdater_UT.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IndexUpdater_UT.java 1 Oct 2005 23:00:54 -0000 1.1 --- IndexUpdater_UT.java 9 Oct 2005 22:13:01 -0000 1.2 *************** *** 1,9 **** --- 1,13 ---- package org.rubypeople.rdt.internal.core.builder; + import java.io.InputStreamReader; + import junit.framework.TestCase; import org.eclipse.core.resources.IFile; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.jruby.ast.ClassNode; + import org.jruby.ast.Colon2Node; import org.jruby.ast.Node; import org.jruby.ast.TrueNode; *************** *** 11,14 **** --- 15,19 ---- import org.rubypeople.eclipse.shams.resources.ShamFile; import org.rubypeople.rdt.internal.core.parser.RdtPosition; + import org.rubypeople.rdt.internal.core.parser.RubyParser; import org.rubypeople.rdt.internal.core.symbols.ClassSymbol; import org.rubypeople.rdt.internal.core.symbols.SymbolIndex; *************** *** 38,42 **** public void testSimple() { ! Node node = new ClassNode(POSITION_1, TEST_CLASS_NAME, null, null); updater.update(file, node); --- 43,48 ---- public void testSimple() { ! Colon2Node nameNode = new Colon2Node(POSITION_1, null, TEST_CLASS_NAME); ! Node node = new ClassNode(POSITION_1, nameNode, null, null); updater.update(file, node); *************** *** 44,47 **** --- 50,96 ---- symbolIndex.assertAdded(new ClassSymbol(TEST_CLASS_NAME), file, POSITION_1); } + + public void testWithTree() throws Exception { + Node node = parseCode("if x\nclass Foo\nend\n end\n"); + + updater.update(file,node); + + symbolIndex.assertFlushed(file.getFullPath()); + symbolIndex.assertAdded(new ClassSymbol("Foo"), file, new RdtPosition(1, 2, 10, 18)); + } + + public void testTreeWithScopedClass() throws Exception { + Node node = parseCode("if x\nclass Foo::Bar\nend\n end\n"); + + updater.update(file,node); + + symbolIndex.assertFlushed(file.getFullPath()); + symbolIndex.assertAdded(new ClassSymbol("Foo::Bar"), file, new RdtPosition(1, 2, 10, 23)); + } + + public void testTreeWithDeeplyScopedClass() throws Exception { + Node node = parseCode("if x\nclass X::Foo::Bar\nend\n end\n"); + + updater.update(file,node); + + symbolIndex.assertFlushed(file.getFullPath()); + symbolIndex.assertAdded(new ClassSymbol("X::Foo::Bar"), file, new RdtPosition(1, 2, 10, 26)); + } + + public void testTreeWithNesting() throws Exception { + Node node = parseCode("if x\nmodule Foo\nclass Bar\nend\n end\nend\n"); + + updater.update(file,node); + + symbolIndex.assertFlushed(file.getFullPath()); + symbolIndex.assertAdded(new ClassSymbol("Foo::Bar"), file, new RdtPosition(2, 3, 21, 29)); + } + + + private Node parseCode(String code) throws CoreException { + file.setContents(code); + InputStreamReader reader = new InputStreamReader(file.getContents()); + return new RubyParser().parse(file, reader); + } private static class MockSymbolIndex extends SymbolIndex { |