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-serv12765/src/org/rubypeople/rdt/internal/core/builder Modified Files: ShamRubyParser.java TC_IndexUpdater.java TS_CoreBuilder.java TC_RdtCompiler.java Added Files: TC_MassIndexUpdater.java Log Message: Index all projects on plugin (eclipse) start. Index: TS_CoreBuilder.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TS_CoreBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TS_CoreBuilder.java 1 Oct 2005 23:00:54 -0000 1.1 --- TS_CoreBuilder.java 16 Oct 2005 17:29:16 -0000 1.2 *************** *** 1,2 **** --- 1,12 ---- + /* + * Author: David Corbin + * + * Copyright (c) 2005 RubyPeople. + * + * This file is part of the Ruby Development Tools (RDT) plugin for eclipse. + * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use + * RDT except in compliance with the License. For further information see + * org.rubypeople.rdt/rdt.license. + */ package org.rubypeople.rdt.internal.core.builder; *************** *** 11,14 **** --- 21,26 ---- suite.addTestSuite(TC_TaskCompiler.class); suite.addTestSuite(TC_RdtCompiler.class); + suite.addTestSuite(TC_MassIndexUpdater.class); + suite.addTestSuite(TC_IndexUpdater.class); return suite; Index: ShamRubyParser.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamRubyParser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ShamRubyParser.java 1 Oct 2005 23:00:54 -0000 1.1 --- ShamRubyParser.java 16 Oct 2005 17:29:16 -0000 1.2 *************** *** 1,5 **** --- 1,19 ---- + /* + * Author: David Corbin + * + * Copyright (c) 2005 RubyPeople. + * + * This file is part of the Ruby Development Tools (RDT) plugin for eclipse. + * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use + * RDT except in compliance with the License. For further information see + * org.rubypeople.rdt/rdt.license. + */ package org.rubypeople.rdt.internal.core.builder; import java.io.Reader; + import java.util.HashMap; + import java.util.HashSet; + import java.util.Map; + import java.util.Set; import junit.framework.Assert; *************** *** 12,31 **** public class ShamRubyParser extends RubyParser { ! private IFile fileArg; ! private String contentArg; private SyntaxException syntaxException; ! private Node parseResult; public Node parse(IFile file, Reader reader) { ! fileArg = file; ! contentArg = IoUtils.readAllQuietly(reader); if (syntaxException != null) throw syntaxException; ! return parseResult; } public void assertParsed(IFile expectedFile, String expectedContent) { ! Assert.assertEquals("File", expectedFile, fileArg); ! Assert.assertEquals("Content", expectedContent, contentArg); } --- 26,46 ---- public class ShamRubyParser extends RubyParser { ! private Map parsingsWithContent = new HashMap(); ! private Set parsingsWithoutContent = new HashSet(); private SyntaxException syntaxException; ! private Map parseResults = new HashMap(); public Node parse(IFile file, Reader reader) { ! parsingsWithContent.put(file, IoUtils.readAllQuietly(reader)); if (syntaxException != null) throw syntaxException; ! return (Node) parseResults.get(file); } public void assertParsed(IFile expectedFile, String expectedContent) { ! Assert.assertTrue("File " + expectedFile + " should have been parsed", ! parsingsWithContent.containsKey(expectedFile)); ! Assert.assertEquals("Content", expectedContent, ! parsingsWithContent.get(expectedFile)); } *************** *** 34,40 **** } ! public void setParseResult(Node parseResult) { ! this.parseResult = parseResult; ! } } --- 49,64 ---- } ! public Node parse(IFile file) { ! parsingsWithoutContent.add((file)); ! return (Node) parseResults.get(file); ! } ! ! public void assertParsed(IFile expectedFile) { ! Assert.assertTrue("expected to have parsed "+ expectedFile, ! parsingsWithoutContent.contains(expectedFile)); ! } ! ! public void addParseResult(IFile file, Node node) { ! parseResults.put(file,node); } } 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.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TC_RdtCompiler.java 13 Oct 2005 01:00:30 -0000 1.4 --- TC_RdtCompiler.java 16 Oct 2005 17:29:16 -0000 1.5 *************** *** 1,2 **** --- 1,12 ---- + /* + * Author: David Corbin + * + * Copyright (c) 2005 RubyPeople. + * + * This file is part of the Ruby Development Tools (RDT) plugin for eclipse. + * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use + * RDT except in compliance with the License. For further information see + * org.rubypeople.rdt/rdt.license. + */ package org.rubypeople.rdt.internal.core.builder; *************** *** 37,41 **** markerManager = new ShamMarkerManager(); parser = new ShamRubyParser(); ! parser.setParseResult(rootNode); indexUpdater = new MockIndexUpdater(); compiler = new RdtCompiler(markerManager, parser, indexUpdater); --- 47,51 ---- markerManager = new ShamMarkerManager(); parser = new ShamRubyParser(); ! parser.addParseResult(file, rootNode); indexUpdater = new MockIndexUpdater(); compiler = new RdtCompiler(markerManager, parser, indexUpdater); --- NEW FILE: TC_MassIndexUpdater.java --- /* * Author: David Corbin * * Copyright (c) 2005 RubyPeople. * * This file is part of the Ruby Development Tools (RDT) plugin for eclipse. * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use * RDT except in compliance with the License. For further information see * org.rubypeople.rdt/rdt.license. */ package org.rubypeople.rdt.internal.core.builder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import junit.framework.TestCase; import org.eclipse.core.resources.IFile; import org.jruby.ast.Node; import org.rubypeople.eclipse.shams.resources.ShamFile; import org.rubypeople.eclipse.shams.resources.ShamProject; import org.rubypeople.rdt.internal.core.parser.ShamNode; import org.rubypeople.rdt.internal.core.util.ListUtil; public class TC_MassIndexUpdater extends TestCase { public void testUpdateProjects() throws Exception { ShamRubyParser parser = new ShamRubyParser(); ShamIndexUpdater updater = new ShamIndexUpdater(); MassIndexUpdater massUpdater = new MassIndexUpdater(updater, parser); ShamProject project1 = new ShamProject("test1"); ShamProject project2 = new ShamProject("test2"); ShamFile file1 = new ShamFile("file1.rb"); ShamFile file2 = new ShamFile("file2.rb"); ShamFile file3 = new ShamFile("file3.rb"); ShamNode rootNode1 = new ShamNode(); ShamNode rootNode2 = new ShamNode(); ShamNode rootNode3 = new ShamNode(); parser.addParseResult(file1, rootNode1); parser.addParseResult(file2, rootNode2); parser.addParseResult(file3, rootNode3); project1.setResourcesToVisit(ListUtil.create(file1, file2)); project2.setResourcesToVisit(ListUtil.create(file3)); List projects = new ArrayList(); projects.add(project1); projects.add(project2); massUpdater.update(projects); RubySourceFileCollectingVisitor expectedVisitor = new RubySourceFileCollectingVisitor(new ArrayList()); project1.assertAcceptCalled(expectedVisitor, 0); project2.assertAcceptCalled(expectedVisitor, 0); parser.assertParsed(file1); parser.assertParsed(file2); parser.assertParsed(file3); updater.assertUpdated(file1, rootNode1); updater.assertUpdated(file2, rootNode2); updater.assertUpdated(file3, rootNode3); } private static class ShamIndexUpdater extends IndexUpdater { private Map updates = new HashMap(); public ShamIndexUpdater() { super(null); } public void assertUpdated(ShamFile expectedFile, ShamNode expectedNode) { assertTrue("Should have updated " + expectedFile, updates.containsKey(expectedFile)); assertEquals(expectedNode, updates.get(expectedFile)); } public void update(IFile file, Node rootNode) { updates.put(file, rootNode); } } } Index: TC_IndexUpdater.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IndexUpdater.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TC_IndexUpdater.java 13 Oct 2005 01:00:30 -0000 1.1 --- TC_IndexUpdater.java 16 Oct 2005 17:29:16 -0000 1.2 *************** *** 1,2 **** --- 1,12 ---- + /* + * Author: David Corbin + * + * Copyright (c) 2005 RubyPeople. + * + * This file is part of the Ruby Development Tools (RDT) plugin for eclipse. + * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use + * RDT except in compliance with the License. For further information see + * org.rubypeople.rdt/rdt.license. + */ package org.rubypeople.rdt.internal.core.builder; *************** *** 57,61 **** symbolIndex.assertFlushed(file.getFullPath()); ! symbolIndex.assertAdded(new ClassSymbol("Foo"), file, new RdtPosition(1, 2, 10, 18)); } --- 67,71 ---- symbolIndex.assertFlushed(file.getFullPath()); ! symbolIndex.assertAdded(new ClassSymbol("Foo"), file, new RdtPosition(1, 2, 14, 15)); } *************** *** 66,70 **** symbolIndex.assertFlushed(file.getFullPath()); ! symbolIndex.assertAdded(new ClassSymbol("Foo::Bar"), file, new RdtPosition(1, 2, 10, 23)); } --- 76,80 ---- symbolIndex.assertFlushed(file.getFullPath()); ! symbolIndex.assertAdded(new ClassSymbol("Foo::Bar"), file, new RdtPosition(1, 2, 16, 20)); } *************** *** 75,79 **** symbolIndex.assertFlushed(file.getFullPath()); ! symbolIndex.assertAdded(new ClassSymbol("X::Foo::Bar"), file, new RdtPosition(1, 2, 10, 26)); } --- 85,89 ---- symbolIndex.assertFlushed(file.getFullPath()); ! symbolIndex.assertAdded(new ClassSymbol("X::Foo::Bar"), file, new RdtPosition(1, 2, 19, 23)); } *************** *** 84,88 **** symbolIndex.assertFlushed(file.getFullPath()); ! symbolIndex.assertAdded(new ClassSymbol("Foo::Bar"), file, new RdtPosition(2, 3, 21, 29)); } --- 94,98 ---- symbolIndex.assertFlushed(file.getFullPath()); ! symbolIndex.assertAdded(new ClassSymbol("Foo::Bar"), file, new RdtPosition(2, 3, 25, 26)); } |