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-05-23 03:01:51
|
Revision: 2522
http://svn.sourceforge.net/rubyeclipse/?rev=2522&view=rev
Author: cawilliams
Date: 2007-05-22 20:01:47 -0700 (Tue, 22 May 2007)
Log Message:
-----------
create a new helper util class which tries to grab any documentation for a given IRubyElement.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/RDocUtil.java
Modified: trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-05-23 03:01:17 UTC (rev 2521)
+++ trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-05-23 03:01:47 UTC (rev 2522)
@@ -12,6 +12,7 @@
org.rubypeople.rdt.core.compiler,
org.rubypeople.rdt.core.formatter,
org.rubypeople.rdt.core.search,
+ org.rubypeople.rdt.core.util,
org.rubypeople.rdt.internal.compiler,
org.rubypeople.rdt.internal.core,
org.rubypeople.rdt.internal.core.buffer,
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/RDocUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/RDocUtil.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/RDocUtil.java 2007-05-23 03:01:47 UTC (rev 2522)
@@ -0,0 +1,93 @@
+package org.rubypeople.rdt.core.util;
+
+import java.util.Collection;
+
+import org.jruby.ast.CommentNode;
+import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.parser.RubyParser;
+
+public class RDocUtil {
+ private RDocUtil() {}
+
+ public static String getDocumentation(IRubyElement element) {
+ if (element instanceof IMember) {
+ return getContents((IMember)element);
+ }
+ return "";
+ }
+
+ private static String getContents(IMember member) {
+ String src = "";
+ int elementOffset = -1;
+ try {
+ src = member.getRubyScript().getSource();
+ elementOffset = member.getSourceRange().getOffset();
+ } catch (RubyModelException e) {
+ return null;
+ }
+ RubyParser parser = new RubyParser();
+ parser.parse(src); // parse so we can grab the comment nodes
+ Collection<CommentNode> comments = parser.getComments();
+ if (member.isType(IRubyElement.TYPE) || member.isType(IRubyElement.METHOD) || member.isType(IRubyElement.CONSTANT)) {
+ return getPrecedingComment(comments, elementOffset, src);
+ }
+ return getFollowingComment(comments, elementOffset, src);
+ }
+
+ /**
+ * Grabs and merges together all comment nodes which immediately preced the elementStart offset.
+ * @param comments
+ * @param elementStart
+ * @param src
+ * @return a combined string of all immediately preceding comments
+ */
+ private static String getPrecedingComment(Collection<CommentNode> comments, int elementStart, String src) {
+ for (CommentNode comment : comments) {
+ ISourcePosition pos = comment.getPosition();
+ if (pos.getEndOffset() > elementStart) continue;
+ String between = src.substring(pos.getEndOffset(), elementStart);
+ if (between.trim().length() > 0)
+ continue; // if there's anything but whitespace between (\n\r\t ), move to next comment
+ String preceding = getPrecedingComment(comments, pos.getStartOffset(), src);
+ if (preceding == null) {
+ preceding = removePrecedingHashes(comment.getContent());
+ } else {
+ preceding += "\n" + removePrecedingHashes(comment.getContent());
+ }
+ return preceding;
+ }
+ return null;
+ }
+
+ /**
+ * Grabs the comment from any comment node that follows this element (has to be on the same line)
+ * @param comments
+ * @param elementStart
+ * @param src
+ * @return
+ */
+ private static String getFollowingComment(Collection<CommentNode> comments, int elementStart, String src) {
+ for (CommentNode comment : comments) {
+ ISourcePosition pos = comment.getPosition();
+ if (pos.getStartOffset() < elementStart) continue;
+ String between = src.substring(elementStart, pos.getStartOffset());
+ if (between.contains("\n")) continue; // if there's a newline between the positions - it's not on same line
+ String com = comment.getContent();
+ if (com != null && com.length() > 0)
+ return removePrecedingHashes(com);
+ }
+ return null;
+ }
+
+ /**
+ * Trims the string and drops the beginning hash mark (#)
+ * @param comment
+ * @return
+ */
+ private static String removePrecedingHashes(String comment) {
+ return comment.trim().substring(1);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-23 03:01:20
|
Revision: 2521
http://svn.sourceforge.net/rubyeclipse/?rev=2521&view=rev
Author: cawilliams
Date: 2007-05-22 20:01:17 -0700 (Tue, 22 May 2007)
Log Message:
-----------
hide rdocexport package
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
Modified: trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-05-22 18:48:12 UTC (rev 2520)
+++ trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-05-23 03:01:17 UTC (rev 2521)
@@ -17,7 +17,6 @@
org.rubypeople.rdt.internal.ui.infoviews,
org.rubypeople.rdt.internal.ui.preferences,
org.rubypeople.rdt.internal.ui.preferences.formatter,
- org.rubypeople.rdt.internal.ui.rdocexport,
org.rubypeople.rdt.internal.ui.resourcesview,
org.rubypeople.rdt.internal.ui.rubyeditor,
org.rubypeople.rdt.internal.ui.search,
@@ -25,6 +24,7 @@
org.rubypeople.rdt.internal.ui.text.folding,
org.rubypeople.rdt.internal.ui.text.ruby,
org.rubypeople.rdt.internal.ui.text.ruby.hover,
+ org.rubypeople.rdt.internal.ui.text.template.contentassist,
org.rubypeople.rdt.internal.ui.util,
org.rubypeople.rdt.internal.ui.viewsupport,
org.rubypeople.rdt.internal.ui.wizards,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-22 18:48:15
|
Revision: 2520
http://svn.sourceforge.net/rubyeclipse/?rev=2520&view=rev
Author: cawilliams
Date: 2007-05-22 11:48:12 -0700 (Tue, 22 May 2007)
Log Message:
-----------
try to do a little cleanup with grabbing remote gem index. Pare byte array of content read to just waht was read. Also only allocate 10 times that space for buffer into which we deflate. (Ideally we should probably just pipe the bytes on through in small byte buffers rather than grabbing and allocating whole thing at a time).
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-22 18:23:05 UTC (rev 2519)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-22 18:48:12 UTC (rev 2520)
@@ -11,6 +11,7 @@
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -260,8 +261,12 @@
private List<String> getContents() throws MalformedURLException,
IOException, DataFormatException {
- // XXX Make sure this algorithm is returning same number of gems!!!!!
- List<String> lines = new ArrayList<String>();
+ String outputString = decompress(getZippedGemIndex());
+ String[] lineArray = outputString.split("\n");
+ return Arrays.asList(lineArray);
+ }
+
+ private byte[] getZippedGemIndex() throws MalformedURLException, IOException {
URL url = new URL(GEM_INDEX_URL);
URLConnection con = url.openConnection();
InputStream content = (InputStream) con.getContent();
@@ -283,23 +288,24 @@
System.arraycopy(tmp, 0, input, index, length);
index += length;
}
+ // Strip byte array down to just length of the content we actually read in.
+ byte[] newInput = new byte[index];
+ System.arraycopy(input, 0, newInput, 0, index);
+ return newInput;
+ }
+ private String decompress(byte[] input) throws DataFormatException {
// Decompress the bytes
Inflater decompresser = new Inflater();
decompresser.setInput(input);
- byte[] result = new byte[input.length * 20]; // XXX This is a hack. I
+ byte[] result = new byte[input.length * 10]; // XXX This is a hack. I
// have no idea what the
// length should be here
int resultLength = decompresser.inflate(result);
decompresser.end();
// Decode the bytes into a String
- String outputString = new String(result, 0, resultLength);
- String[] lineArray = outputString.split("\n");
- for (int i = 0; i < lineArray.length; i++) {
- lines.add(lineArray[i]);
- }
- return lines;
+ return new String(result, 0, resultLength);
}
private Set<Gem> loadLocalGems() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-22 18:23:06
|
Revision: 2519
http://svn.sourceforge.net/rubyeclipse/?rev=2519&view=rev
Author: cawilliams
Date: 2007-05-22 11:23:05 -0700 (Tue, 22 May 2007)
Log Message:
-----------
add translated string for errors/warnings page on project property page
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-05-22 17:26:12 UTC (rev 2518)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-05-22 18:23:05 UTC (rev 2519)
@@ -34,6 +34,7 @@
appearancePrefName=Appearance
problemSeveritiesPrefName=Errors/Warnings
+problemSeveritiesPageName=Errors/Warnings
preferenceKeywords.general=Ruby resources call type hierarchy refactoring search
preferenceKeywords.appearance=Ruby appearance resources browsing
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-22 17:26:25
|
Revision: 2518
http://svn.sourceforge.net/rubyeclipse/?rev=2518&view=rev
Author: cawilliams
Date: 2007-05-22 10:26:12 -0700 (Tue, 22 May 2007)
Log Message:
-----------
rename SourceParser to SourceElementParser
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddFolderToIndex.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java
trunk/org.rubypeople.rdt.core.tests/src/RubyParserCmd.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -182,7 +182,7 @@
*/
public int overridenEventType = -1;
- private SourceParser sourceElementParserCache;
+ private SourceElementParser sourceElementParserCache;
public DeltaProcessor(DeltaProcessingState state, RubyModelManager manager) {
this.state = state;
@@ -1881,7 +1881,7 @@
}
}
- private SourceParser getSourceElementParser(Openable element) {
+ private SourceElementParser getSourceElementParser(Openable element) {
if (this.sourceElementParserCache == null)
this.sourceElementParserCache = this.manager.getIndexManager().getSourceElementParser(element.getRubyProject(), null/*requestor will be set by indexer*/);
return this.sourceElementParserCache;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -39,7 +39,7 @@
RubyParser parser = new RubyParser();
Node node = parser.parse(null, new CharArrayReader(contents));
RubyScriptStructureBuilder visitor = new RubyScriptStructureBuilder(this, unitInfo, newElements);
- SourceParser sp = new SourceParser(visitor);
+ SourceElementParser sp = new SourceElementParser(visitor);
if (node != null) node.accept(sp);
unitInfo.setIsStructureKnown(true);
} catch (SyntaxException e) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -137,7 +137,7 @@
ast = parser.parse((IFile) getResource(), new CharArrayReader(contents));
lastGoodAST = ast;
ISourceElementRequestor requestor = new RubyScriptStructureBuilder(this, unitInfo, newElements);
- SourceParser sp = new SourceParser(requestor);
+ SourceElementParser sp = new SourceElementParser(requestor);
if (ast != null) ast.accept(sp);
unitInfo.setIsStructureKnown(true);
} catch (SyntaxException e) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddFolderToIndex.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddFolderToIndex.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddFolderToIndex.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -19,7 +19,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.core.SourceParser;
+import org.rubypeople.rdt.internal.core.SourceElementParser;
import org.rubypeople.rdt.internal.core.index.Index;
import org.rubypeople.rdt.internal.core.search.processing.JobManager;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -55,7 +55,7 @@
final IPath container = this.containerPath;
final IndexManager indexManager = this.manager;
- final SourceParser parser = indexManager.getSourceElementParser(RubyCore.create(this.project), null/*requestor will be set by indexer*/);
+ final SourceElementParser parser = indexManager.getSourceElementParser(RubyCore.create(this.project), null/*requestor will be set by indexer*/);
if (this.exclusionPatterns == null && this.inclusionPatterns == null) {
folder.accept(
new IResourceProxyVisitor() {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllProject.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllProject.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -28,7 +28,7 @@
import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
import org.rubypeople.rdt.internal.core.LoadpathEntry;
import org.rubypeople.rdt.internal.core.RubyProject;
-import org.rubypeople.rdt.internal.core.SourceParser;
+import org.rubypeople.rdt.internal.core.SourceElementParser;
import org.rubypeople.rdt.internal.core.index.Index;
import org.rubypeople.rdt.internal.core.search.processing.JobManager;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -181,7 +181,7 @@
}
}
- SourceParser parser = this.manager.getSourceElementParser(javaProject, null/*requestor will be set by indexer*/);
+ SourceElementParser parser = this.manager.getSourceElementParser(javaProject, null/*requestor will be set by indexer*/);
Object[] names = indexedFileNames.keyTable;
Object[] values = indexedFileNames.valueTable;
for (int i = 0, namesLength = names.length; i < namesLength; i++) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -27,7 +27,7 @@
import org.rubypeople.rdt.internal.core.RubyModel;
import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.RubyProject;
-import org.rubypeople.rdt.internal.core.SourceParser;
+import org.rubypeople.rdt.internal.core.SourceElementParser;
import org.rubypeople.rdt.internal.core.index.DiskIndex;
import org.rubypeople.rdt.internal.core.index.Index;
import org.rubypeople.rdt.internal.core.search.BasicSearchEngine;
@@ -404,7 +404,7 @@
* Trigger addition of a resource to an index
* Note: the actual operation is performed in background
*/
- public void addSource(IFile resource, IPath containerPath, SourceParser parser) {
+ public void addSource(IFile resource, IPath containerPath, SourceElementParser parser) {
if (RubyCore.getPlugin() == null) return;
SearchParticipant participant = BasicSearchEngine.getDefaultSearchParticipant();
SearchDocument document = participant.getDocument(resource.getFullPath().toString());
@@ -492,9 +492,9 @@
writeSavedIndexNamesFile();
}
- public SourceParser getSourceElementParser(IRubyProject project, ISourceElementRequestor requestor) {
+ public SourceElementParser getSourceElementParser(IRubyProject project, ISourceElementRequestor requestor) {
// TODO take into account the project?
- return new SourceParser(requestor);
+ return new SourceElementParser(requestor);
}
public void indexLibrary(IPath path, IProject project) {
// requestingProject is no longer used to cancel jobs but leave it here just in case
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.rubypeople.rdt.internal.core.search.indexing;
-import org.rubypeople.rdt.internal.core.SourceParser;
+import org.rubypeople.rdt.internal.core.SourceElementParser;
import org.rubypeople.rdt.internal.core.index.Index;
/**
@@ -19,7 +19,7 @@
public class InternalSearchDocument {
protected Index index;
private String containerRelativePath;
- public SourceParser parser;
+ public SourceElementParser parser;
/*
* Hidden by API SearchDocument subclass
*/
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -7,7 +7,7 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.search.SearchDocument;
import org.rubypeople.rdt.internal.core.RubyModelManager;
-import org.rubypeople.rdt.internal.core.SourceParser;
+import org.rubypeople.rdt.internal.core.SourceElementParser;
import org.rubypeople.rdt.internal.core.search.matching.ConstructorPattern;
import org.rubypeople.rdt.internal.core.search.matching.FieldPattern;
import org.rubypeople.rdt.internal.core.search.matching.MethodPattern;
@@ -27,7 +27,7 @@
// Create a new Parser
SourceIndexerRequestor requestor = new SourceIndexerRequestor(this);
String documentPath = this.document.getPath();
- SourceParser parser = ((InternalSearchDocument) this.document).parser;
+ SourceElementParser parser = ((InternalSearchDocument) this.document).parser;
if (parser == null) {
IPath path = new Path(documentPath);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
Modified: trunk/org.rubypeople.rdt.core.tests/src/RubyParserCmd.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/RubyParserCmd.java 2007-05-22 17:25:42 UTC (rev 2517)
+++ trunk/org.rubypeople.rdt.core.tests/src/RubyParserCmd.java 2007-05-22 17:26:12 UTC (rev 2518)
@@ -18,7 +18,7 @@
import org.rubypeople.rdt.internal.core.RubyScript;
import org.rubypeople.rdt.internal.core.RubyScriptElementInfo;
import org.rubypeople.rdt.internal.core.RubyScriptStructureBuilder;
-import org.rubypeople.rdt.internal.core.SourceParser;
+import org.rubypeople.rdt.internal.core.SourceElementParser;
import org.rubypeople.rdt.internal.core.parser.RdtWarnings;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
@@ -107,7 +107,7 @@
RubyScriptElementInfo unitInfo = new RubyScriptElementInfo() ;
RubyScript script = new RubyScript(null, file, DefaultWorkingCopyOwner.PRIMARY ) ;
ISourceElementRequestor visitor = new RubyScriptStructureBuilder(script, unitInfo, elements);
- SourceParser sp = new SourceParser(visitor);
+ SourceElementParser sp = new SourceElementParser(visitor);
if (node != null) {
node.accept(sp);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-22 17:25:45
|
Revision: 2517
http://svn.sourceforge.net/rubyeclipse/?rev=2517&view=rev
Author: cawilliams
Date: 2007-05-22 10:25:42 -0700 (Tue, 22 May 2007)
Log Message:
-----------
rename to SourceElementParser
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java (from rev 2474, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java 2007-05-22 17:25:42 UTC (rev 2517)
@@ -0,0 +1,525 @@
+/*
+ * Author: C.Williams
+ *
+ * Copyright (c) 2004 RubyPeople.
+ *
+ * This file is part of the Ruby Development Tools (RDT) plugin for eclipse. You
+ * can get copy of the GPL along with further information about RubyPeople and
+ * third party software bundled with RDT in the file
+ * org.rubypeople.rdt.core_x.x.x/RDT.license or otherwise at
+ * http://www.rubypeople.org/RDT.license.
+ *
+ * RDT is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * RDT is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * RDT; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+package org.rubypeople.rdt.internal.core;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jruby.ast.AliasNode;
+import org.jruby.ast.ArrayNode;
+import org.jruby.ast.AssignableNode;
+import org.jruby.ast.CallNode;
+import org.jruby.ast.ClassNode;
+import org.jruby.ast.ClassVarAsgnNode;
+import org.jruby.ast.Colon2Node;
+import org.jruby.ast.ConstDeclNode;
+import org.jruby.ast.ConstNode;
+import org.jruby.ast.DAsgnNode;
+import org.jruby.ast.DStrNode;
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.ast.FCallNode;
+import org.jruby.ast.GlobalAsgnNode;
+import org.jruby.ast.IArgumentNode;
+import org.jruby.ast.InstAsgnNode;
+import org.jruby.ast.IterNode;
+import org.jruby.ast.LocalAsgnNode;
+import org.jruby.ast.ModuleNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.RootNode;
+import org.jruby.ast.SClassNode;
+import org.jruby.ast.SelfNode;
+import org.jruby.ast.SplatNode;
+import org.jruby.ast.StrNode;
+import org.jruby.ast.VCallNode;
+import org.jruby.evaluator.Instruction;
+import org.jruby.runtime.Visibility;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor;
+import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor.FieldInfo;
+import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor.MethodInfo;
+import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor.TypeInfo;
+import org.rubypeople.rdt.internal.core.parser.InOrderVisitor;
+import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.util.ASTUtil;
+
+/**
+ * @author Chris
+ *
+ */
+public class SourceElementParser extends InOrderVisitor { // TODO Rename to SourceElementParser
+
+ private static final String MODULE_FUNCTION = "module_function";
+ private static final String EMPTY_STRING = "";
+ private static final String PROTECTED = "protected";
+ private static final String PRIVATE = "private";
+ private static final String PUBLIC = "public";
+ private static final String INCLUDE = "include";
+ private static final String LOAD = "load";
+ private static final String REQUIRE = "require";
+ private static final String ALIAS = "alias :";
+ private static final String MODULE = "Module";
+ private static final String CONSTRUCTOR_NAME = "initialize";
+ private static final String NAMESPACE_DELIMETER = "::";
+ private static final String OBJECT = "Object";
+ private Visibility currentVisibility = Visibility.PUBLIC;
+ private boolean inSingletonClass;
+ public ISourceElementRequestor requestor;
+ private boolean inModuleFunction;
+
+ /**
+ *
+ * @param requestor The {@link ISourceElementRequestor} that wants to be notified of the source structure
+ */
+ public SourceElementParser(ISourceElementRequestor requestor) {
+ super();
+ this.requestor = requestor;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jruby.ast.visitor.NodeVisitor#visitClassNode(org.jruby.ast.ClassNode)
+ */
+ public Instruction visitClassNode(ClassNode iVisited) {
+ // This resets the visibility when opening or declaring a class to
+ // public
+ currentVisibility = Visibility.PUBLIC;
+
+ TypeInfo typeInfo = new TypeInfo();
+ typeInfo.name = getFullyQualifiedName(iVisited.getCPath());
+ typeInfo.declarationStart = iVisited.getPosition().getStartOffset();
+ typeInfo.nameSourceStart = iVisited.getCPath().getPosition().getStartOffset();
+ typeInfo.nameSourceEnd = iVisited.getCPath().getPosition().getEndOffset() - 1;
+ if (!typeInfo.name.equals(OBJECT)) {
+ String superClass = getSuperClassName(iVisited.getSuperNode());
+ typeInfo.superclass = superClass;
+ }
+ typeInfo.isModule = false;
+ typeInfo.modules = new String[0]; // FIXME Set up the modules as we go, or proactively dive into AST to grab these?
+ typeInfo.secondary = false; // TODO Set secondary to true if we're enclosed by another type?
+ requestor.enterType(typeInfo);
+
+ Instruction ins = super.visitClassNode(iVisited);
+
+ requestor.exitType(iVisited.getPosition().getEndOffset() - 1);
+ return ins;
+ }
+
+ @Override
+ public Instruction visitConstNode(ConstNode iVisited) {
+ // FIXME ConstNode could be a reference to a type, or a constant(field)!
+ requestor.acceptTypeReference(iVisited.getName(), iVisited.getPosition().getStartOffset(), iVisited.getPosition().getEndOffset());
+ return super.visitConstNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitModuleNode(ModuleNode iVisited) {
+ TypeInfo typeInfo = new TypeInfo();
+ typeInfo.name = getFullyQualifiedName(iVisited.getCPath());
+ typeInfo.declarationStart = iVisited.getPosition().getStartOffset();
+ typeInfo.nameSourceStart = iVisited.getCPath().getPosition().getStartOffset();
+ typeInfo.nameSourceEnd = iVisited.getCPath().getPosition().getEndOffset() - 1;
+ typeInfo.superclass = MODULE; // FIXME Is this really true? Should it be null?
+ typeInfo.isModule = true;
+ typeInfo.modules = new String[0];
+ typeInfo.secondary = false; // TODO Set secondary to true if we're enclosed by another type?
+ requestor.enterType(typeInfo);
+
+ Instruction ins = super.visitModuleNode(iVisited);
+
+ requestor.exitType(iVisited.getPosition().getEndOffset() - 1);
+ inModuleFunction = false;
+ return ins;
+ }
+
+ @Override
+ public Instruction visitDefnNode(DefnNode iVisited) {
+ Visibility visibility = currentVisibility;
+ MethodInfo methodInfo = new MethodInfo();
+ methodInfo.declarationStart = iVisited.getPosition().getStartOffset();
+ methodInfo.name = iVisited.getName();
+ methodInfo.nameSourceStart = iVisited.getNameNode().getPosition().getStartOffset();
+ methodInfo.nameSourceEnd = iVisited.getNameNode().getPosition().getEndOffset() - 1;
+ if (methodInfo.name.equals(CONSTRUCTOR_NAME)) {
+ visibility = Visibility.PROTECTED;
+ methodInfo.isConstructor = true;
+ } else {
+ methodInfo.isConstructor = false;
+ }
+ methodInfo.isClassLevel = inSingletonClass || inModuleFunction;
+ methodInfo.visibility = convertVisibility(visibility);
+ methodInfo.parameterNames = ASTUtil.getArgs(iVisited.getArgsNode(), iVisited.getScope());
+
+ if (methodInfo.isConstructor) {
+ requestor.enterConstructor(methodInfo);
+ } else {
+ requestor.enterMethod(methodInfo);
+ }
+
+ Instruction ins = super.visitDefnNode(iVisited); // now traverse it's body
+
+ if (methodInfo.isConstructor) {
+ requestor.exitConstructor(iVisited.getPosition().getEndOffset());
+ } else {
+ requestor.exitMethod(iVisited.getPosition().getEndOffset());
+ }
+ return ins;
+ }
+
+ @Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ MethodInfo methodInfo = new MethodInfo();
+ methodInfo.declarationStart = iVisited.getPosition().getStartOffset();
+ methodInfo.name = iVisited.getName();
+ methodInfo.nameSourceStart = iVisited.getNameNode().getPosition().getStartOffset();
+ methodInfo.nameSourceEnd = iVisited.getNameNode().getPosition().getEndOffset() - 1;
+ methodInfo.isConstructor = false;
+ methodInfo.isClassLevel = true;
+ methodInfo.visibility = convertVisibility(currentVisibility);
+ methodInfo.parameterNames = ASTUtil.getArgs(iVisited.getArgsNode(), iVisited.getScope());
+ requestor.enterMethod(methodInfo);
+
+ Instruction ins = super.visitDefsNode(iVisited); // now traverse it's body
+
+ requestor.exitMethod(iVisited.getPosition().getEndOffset());
+ return ins;
+ }
+
+ /**
+ * @param visibility
+ * @return
+ */
+ private int convertVisibility(Visibility visibility) {
+ // FIXME What about the module function and public-protected
+ // visibilities?
+ if (visibility == Visibility.PUBLIC)
+ return IMethod.PUBLIC;
+ if (visibility == Visibility.PROTECTED)
+ return IMethod.PROTECTED;
+ return IMethod.PRIVATE;
+ }
+
+ @Override
+ public Instruction visitRootNode(RootNode iVisited) {
+ requestor.enterScript();
+ Instruction ins = super.visitRootNode(iVisited);
+ requestor.exitScript(-1); // FIXME Actually grab the correct end offset somehow!
+ return ins;
+ }
+
+ private String getFullyQualifiedName(Node node) {
+ if (node == null)
+ return EMPTY_STRING;
+ if (node instanceof ConstNode) {
+ ConstNode constNode = (ConstNode) node;
+ return constNode.getName();
+ }
+ if (node instanceof Colon2Node) {
+ Colon2Node colonNode = (Colon2Node) node;
+ String prefix = getFullyQualifiedName(colonNode.getLeftNode());
+ if (prefix.length() > 0)
+ prefix = prefix + NAMESPACE_DELIMETER;
+ return prefix + colonNode.getName();
+ }
+ return EMPTY_STRING;
+ }
+
+ /**
+ * Build up the fully qualified name of the super class for a class
+ * declaration
+ *
+ * @param superNode
+ * @return
+ */
+ private String getSuperClassName(Node superNode) {
+ if (superNode == null)
+ return OBJECT;
+ return getFullyQualifiedName(superNode);
+ }
+
+ @Override
+ public Instruction visitConstDeclNode(ConstDeclNode iVisited) {
+ FieldInfo field = createFieldInfo(iVisited);
+ field.name = iVisited.getName();
+ requestor.enterField(field);
+ exitField(iVisited);
+ return super.visitConstDeclNode(iVisited);
+ }
+
+ public Instruction visitClassVarAsgnNode(ClassVarAsgnNode iVisited) {
+ FieldInfo field = createFieldInfo(iVisited);
+ field.name = iVisited.getName();
+ requestor.enterField(field);
+ exitField(iVisited);
+ return super.visitClassVarAsgnNode(iVisited);
+ }
+
+ public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) {
+ FieldInfo field = createFieldInfo(iVisited);
+ field.name = iVisited.getName();
+ requestor.enterField(field);
+ exitField(iVisited);
+ return super.visitLocalAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitInstAsgnNode(InstAsgnNode iVisited) {
+ FieldInfo field = createFieldInfo(iVisited);
+ field.name = iVisited.getName();
+ requestor.enterField(field);
+ exitField(iVisited);
+ return super.visitInstAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitGlobalAsgnNode(GlobalAsgnNode iVisited) {
+ FieldInfo field = createFieldInfo(iVisited);
+ field.name = iVisited.getName();
+ requestor.enterField(field);
+ exitField(iVisited);
+ return super.visitGlobalAsgnNode(iVisited);
+ }
+
+ private void exitField(AssignableNode iVisited) {
+ requestor.exitField(iVisited.getPosition().getEndOffset() - 1);
+ }
+
+ private FieldInfo createFieldInfo(AssignableNode iVisited) {
+ FieldInfo field = new FieldInfo();
+ field.declarationStart = iVisited.getPosition().getStartOffset();
+ field.nameSourceStart = iVisited.getPosition().getStartOffset();
+ String name = ASTUtil.getNameReflectively(iVisited);
+ field.nameSourceEnd = iVisited.getPosition().getStartOffset() + name.length() - 1;
+ return field;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jruby.ast.visitor.NodeVisitor#visitIterNode(org.jruby.ast.IterNode)
+ */
+ public Instruction visitIterNode(IterNode iVisited) {
+// RubyBlock block = new RubyBlock(modelStack.peek()); FIXME Add method to notify of blocks?
+ return super.visitIterNode(iVisited);
+ }
+
+
+ @Override
+ public Instruction visitDAsgnNode(DAsgnNode iVisited) {
+// RubyDynamicVar var = new RubyDynamicVar(modelStack.peek(), iVisited.getName()); FIXME Notify like a normal local var?
+ return super.visitDAsgnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitSClassNode(SClassNode iVisited) {
+ Node receiver = iVisited.getReceiverNode();
+ if (receiver instanceof SelfNode) {
+ inSingletonClass = true;
+ Instruction ins = super.visitSClassNode(iVisited);
+ inSingletonClass = false;
+ return ins;
+ }
+ return super.visitSClassNode(iVisited);
+ }
+
+ public Instruction visitFCallNode(FCallNode iVisited) {
+ String name = iVisited.getName();
+ if (name.equals(REQUIRE) || name.equals(LOAD)) {
+ addImport(iVisited);
+ } else if (name.equals(INCLUDE)) { // Collect included mixins
+ includeModule(iVisited);
+ } if (name.equals(PUBLIC)) {
+ List<String> arguments = getArgumentsFromFunctionCall(iVisited);
+ for (String methodName : arguments) {
+ requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PUBLIC));
+ }
+ } else if (name.equals(PRIVATE)) {
+ List<String> arguments = getArgumentsFromFunctionCall(iVisited);
+ for (String methodName : arguments) {
+ requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PRIVATE));
+ }
+ } else if (name.equals(PROTECTED)) {
+ List<String> arguments = getArgumentsFromFunctionCall(iVisited);
+ for (String methodName : arguments) {
+ requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PROTECTED));
+ }
+ } else if (name.equals(MODULE_FUNCTION)) {
+ List<String> arguments = getArgumentsFromFunctionCall(iVisited);
+ for (String methodName : arguments) {
+ requestor.acceptModuleFunction(methodName);
+ }
+ }
+ return super.visitFCallNode(iVisited);
+ }
+
+ private void addImport(FCallNode iVisited) {
+ ArrayNode node = (ArrayNode) iVisited.getArgsNode();
+ String arg = getString(node);
+ if (arg != null) {
+ requestor.acceptImport(arg, iVisited.getPosition().getStartOffset(), iVisited.getPosition().getEndOffset());
+ }
+ }
+
+ /**
+ * @param node
+ * @return
+ */
+ private String getString(ArrayNode node) {
+ Object tmp = node.childNodes().iterator().next();
+ if (tmp instanceof DStrNode) {
+ DStrNode dstrNode = (DStrNode) tmp;
+ tmp = dstrNode.childNodes().iterator().next();
+ }
+ if (tmp instanceof StrNode) {
+ StrNode strNode = (StrNode) tmp;
+ return strNode.getValue().toString();
+ }
+ return null;
+ }
+
+ private void includeModule(FCallNode iVisited) {
+ List<String> mixins = new LinkedList<String>();
+ Node argsNode = iVisited.getArgsNode();
+ Iterator iter = null;
+ if (argsNode instanceof SplatNode) {
+ SplatNode splat = (SplatNode) argsNode;
+ iter = splat.childNodes().iterator();
+ } else if (argsNode instanceof ArrayNode) {
+ ArrayNode arrayNode = (ArrayNode) iVisited.getArgsNode();
+ iter = arrayNode.childNodes().iterator();
+ }
+ for (; iter.hasNext();) {
+ Node mixinNameNode = (Node) iter.next();
+ if (mixinNameNode instanceof StrNode) {
+ mixins.add(((StrNode) mixinNameNode).getValue().toString());
+ }
+ if (mixinNameNode instanceof DStrNode) {
+ Node next = (Node) ((DStrNode) mixinNameNode).childNodes().iterator().next();
+ if (next instanceof StrNode) {
+ mixins.add(((StrNode) next).getValue().toString());
+ }
+ }
+ if (mixinNameNode instanceof ConstNode) {
+ mixins.add(((ConstNode) mixinNameNode).getName());
+ }
+ }
+ for (String string : mixins) {
+ requestor.acceptMixin(string);
+ }
+ }
+
+ public Instruction visitVCallNode(VCallNode iVisited) {
+ // XXX If the call has arguments, we need to find the method matching the
+ // symbols and mark their visibility differently
+ String functionName = iVisited.getName();
+ if (functionName.equals(PUBLIC)) {
+ currentVisibility = Visibility.PUBLIC;
+ } else if (functionName.equals(PRIVATE)) {
+ currentVisibility = Visibility.PRIVATE;
+ } else if (functionName.equals(PROTECTED)) {
+ currentVisibility = Visibility.PROTECTED;
+ } else if (functionName.equals(MODULE_FUNCTION)) {
+ inModuleFunction = true;
+ }
+ return super.visitVCallNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitCallNode(CallNode iVisited) {
+ String name = iVisited.getName();
+ if (name.equals(PUBLIC)) {
+ List<String> arguments = getArgumentsFromFunctionCall(iVisited);
+ for (String methodName : arguments) {
+ requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PUBLIC));
+ }
+ } else if (name.equals(PRIVATE)) {
+ List<String> arguments = getArgumentsFromFunctionCall(iVisited);
+ for (String methodName : arguments) {
+ requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PRIVATE));
+ }
+ } else if (name.equals(PROTECTED)) {
+ List<String> arguments = getArgumentsFromFunctionCall(iVisited);
+ for (String methodName : arguments) {
+ requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PROTECTED));
+ }
+ } else if (name.equals(MODULE_FUNCTION)) {
+ List<String> arguments = getArgumentsFromFunctionCall(iVisited);
+ for (String methodName : arguments) {
+ requestor.acceptModuleFunction(methodName);
+ }
+ }
+ return super.visitCallNode(iVisited);
+ }
+
+ private List<String> getArgumentsFromFunctionCall(IArgumentNode iVisited) {
+ List<String> arguments = new ArrayList<String>();
+ Node argsNode = iVisited.getArgsNode();
+ Iterator iter = null;
+ if (argsNode instanceof SplatNode) {
+ SplatNode splat = (SplatNode) argsNode;
+ iter = splat.childNodes().iterator();
+ } else if (argsNode instanceof ArrayNode) {
+ ArrayNode arrayNode = (ArrayNode) iVisited.getArgsNode();
+ iter = arrayNode.childNodes().iterator();
+ }
+ for (; iter.hasNext();) {
+ Node mixinNameNode = (Node) iter.next();
+ arguments.add(ASTUtil.getNameReflectively(mixinNameNode));
+ }
+ return arguments;
+ }
+
+ public Instruction visitAliasNode(AliasNode iVisited) {
+ String name = iVisited.getNewName();
+ MethodInfo method = new MethodInfo();
+ // TODO Use the visibility for the original method that this is aliasing?
+ Visibility visibility = currentVisibility;
+ if (name.equals(CONSTRUCTOR_NAME)) {
+ visibility = Visibility.PROTECTED;
+ method.isConstructor = true;
+ } else {
+ method.isConstructor = false;
+ }
+ method.declarationStart = iVisited.getPosition().getStartOffset();
+ method.isClassLevel = inSingletonClass;
+ method.name = name;
+ method.visibility = convertVisibility(visibility);
+ method.nameSourceStart = iVisited.getPosition().getStartOffset() + ALIAS.length();
+ method.nameSourceEnd = iVisited.getPosition().getStartOffset() + ALIAS.length() + iVisited.getNewName().length() - 1;
+ method.parameterNames = new String[0]; // TODO Find the existing method and steal it's parameter names
+ requestor.enterMethod(method);
+ requestor.exitMethod(iVisited.getPosition().getEndOffset());
+ return super.visitAliasNode(iVisited);
+ }
+
+ public void parse(char[] source, char[] name) {
+ RubyParser p = new RubyParser();
+ Node ast = p.parse(new String(source));
+ acceptNode(ast);
+ }
+}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java 2007-05-22 15:24:48 UTC (rev 2516)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceParser.java 2007-05-22 17:25:42 UTC (rev 2517)
@@ -1,525 +0,0 @@
-/*
- * Author: C.Williams
- *
- * Copyright (c) 2004 RubyPeople.
- *
- * This file is part of the Ruby Development Tools (RDT) plugin for eclipse. You
- * can get copy of the GPL along with further information about RubyPeople and
- * third party software bundled with RDT in the file
- * org.rubypeople.rdt.core_x.x.x/RDT.license or otherwise at
- * http://www.rubypeople.org/RDT.license.
- *
- * RDT is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * RDT is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * RDT; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-package org.rubypeople.rdt.internal.core;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jruby.ast.AliasNode;
-import org.jruby.ast.ArrayNode;
-import org.jruby.ast.AssignableNode;
-import org.jruby.ast.CallNode;
-import org.jruby.ast.ClassNode;
-import org.jruby.ast.ClassVarAsgnNode;
-import org.jruby.ast.Colon2Node;
-import org.jruby.ast.ConstDeclNode;
-import org.jruby.ast.ConstNode;
-import org.jruby.ast.DAsgnNode;
-import org.jruby.ast.DStrNode;
-import org.jruby.ast.DefnNode;
-import org.jruby.ast.DefsNode;
-import org.jruby.ast.FCallNode;
-import org.jruby.ast.GlobalAsgnNode;
-import org.jruby.ast.IArgumentNode;
-import org.jruby.ast.InstAsgnNode;
-import org.jruby.ast.IterNode;
-import org.jruby.ast.LocalAsgnNode;
-import org.jruby.ast.ModuleNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.RootNode;
-import org.jruby.ast.SClassNode;
-import org.jruby.ast.SelfNode;
-import org.jruby.ast.SplatNode;
-import org.jruby.ast.StrNode;
-import org.jruby.ast.VCallNode;
-import org.jruby.evaluator.Instruction;
-import org.jruby.runtime.Visibility;
-import org.rubypeople.rdt.core.IMethod;
-import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor;
-import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor.FieldInfo;
-import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor.MethodInfo;
-import org.rubypeople.rdt.internal.compiler.ISourceElementRequestor.TypeInfo;
-import org.rubypeople.rdt.internal.core.parser.InOrderVisitor;
-import org.rubypeople.rdt.internal.core.parser.RubyParser;
-import org.rubypeople.rdt.internal.core.util.ASTUtil;
-
-/**
- * @author Chris
- *
- */
-public class SourceParser extends InOrderVisitor { // TODO Rename to SourceElementParser
-
- private static final String MODULE_FUNCTION = "module_function";
- private static final String EMPTY_STRING = "";
- private static final String PROTECTED = "protected";
- private static final String PRIVATE = "private";
- private static final String PUBLIC = "public";
- private static final String INCLUDE = "include";
- private static final String LOAD = "load";
- private static final String REQUIRE = "require";
- private static final String ALIAS = "alias :";
- private static final String MODULE = "Module";
- private static final String CONSTRUCTOR_NAME = "initialize";
- private static final String NAMESPACE_DELIMETER = "::";
- private static final String OBJECT = "Object";
- private Visibility currentVisibility = Visibility.PUBLIC;
- private boolean inSingletonClass;
- public ISourceElementRequestor requestor;
- private boolean inModuleFunction;
-
- /**
- *
- * @param requestor The {@link ISourceElementRequestor} that wants to be notified of the source structure
- */
- public SourceParser(ISourceElementRequestor requestor) {
- super();
- this.requestor = requestor;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.jruby.ast.visitor.NodeVisitor#visitClassNode(org.jruby.ast.ClassNode)
- */
- public Instruction visitClassNode(ClassNode iVisited) {
- // This resets the visibility when opening or declaring a class to
- // public
- currentVisibility = Visibility.PUBLIC;
-
- TypeInfo typeInfo = new TypeInfo();
- typeInfo.name = getFullyQualifiedName(iVisited.getCPath());
- typeInfo.declarationStart = iVisited.getPosition().getStartOffset();
- typeInfo.nameSourceStart = iVisited.getCPath().getPosition().getStartOffset();
- typeInfo.nameSourceEnd = iVisited.getCPath().getPosition().getEndOffset() - 1;
- if (!typeInfo.name.equals(OBJECT)) {
- String superClass = getSuperClassName(iVisited.getSuperNode());
- typeInfo.superclass = superClass;
- }
- typeInfo.isModule = false;
- typeInfo.modules = new String[0]; // FIXME Set up the modules as we go, or proactively dive into AST to grab these?
- typeInfo.secondary = false; // TODO Set secondary to true if we're enclosed by another type?
- requestor.enterType(typeInfo);
-
- Instruction ins = super.visitClassNode(iVisited);
-
- requestor.exitType(iVisited.getPosition().getEndOffset() - 1);
- return ins;
- }
-
- @Override
- public Instruction visitConstNode(ConstNode iVisited) {
- // FIXME ConstNode could be a reference to a type, or a constant(field)!
- requestor.acceptTypeReference(iVisited.getName(), iVisited.getPosition().getStartOffset(), iVisited.getPosition().getEndOffset());
- return super.visitConstNode(iVisited);
- }
-
- @Override
- public Instruction visitModuleNode(ModuleNode iVisited) {
- TypeInfo typeInfo = new TypeInfo();
- typeInfo.name = getFullyQualifiedName(iVisited.getCPath());
- typeInfo.declarationStart = iVisited.getPosition().getStartOffset();
- typeInfo.nameSourceStart = iVisited.getCPath().getPosition().getStartOffset();
- typeInfo.nameSourceEnd = iVisited.getCPath().getPosition().getEndOffset() - 1;
- typeInfo.superclass = MODULE; // FIXME Is this really true? Should it be null?
- typeInfo.isModule = true;
- typeInfo.modules = new String[0];
- typeInfo.secondary = false; // TODO Set secondary to true if we're enclosed by another type?
- requestor.enterType(typeInfo);
-
- Instruction ins = super.visitModuleNode(iVisited);
-
- requestor.exitType(iVisited.getPosition().getEndOffset() - 1);
- inModuleFunction = false;
- return ins;
- }
-
- @Override
- public Instruction visitDefnNode(DefnNode iVisited) {
- Visibility visibility = currentVisibility;
- MethodInfo methodInfo = new MethodInfo();
- methodInfo.declarationStart = iVisited.getPosition().getStartOffset();
- methodInfo.name = iVisited.getName();
- methodInfo.nameSourceStart = iVisited.getNameNode().getPosition().getStartOffset();
- methodInfo.nameSourceEnd = iVisited.getNameNode().getPosition().getEndOffset() - 1;
- if (methodInfo.name.equals(CONSTRUCTOR_NAME)) {
- visibility = Visibility.PROTECTED;
- methodInfo.isConstructor = true;
- } else {
- methodInfo.isConstructor = false;
- }
- methodInfo.isClassLevel = inSingletonClass || inModuleFunction;
- methodInfo.visibility = convertVisibility(visibility);
- methodInfo.parameterNames = ASTUtil.getArgs(iVisited.getArgsNode(), iVisited.getScope());
-
- if (methodInfo.isConstructor) {
- requestor.enterConstructor(methodInfo);
- } else {
- requestor.enterMethod(methodInfo);
- }
-
- Instruction ins = super.visitDefnNode(iVisited); // now traverse it's body
-
- if (methodInfo.isConstructor) {
- requestor.exitConstructor(iVisited.getPosition().getEndOffset());
- } else {
- requestor.exitMethod(iVisited.getPosition().getEndOffset());
- }
- return ins;
- }
-
- @Override
- public Instruction visitDefsNode(DefsNode iVisited) {
- MethodInfo methodInfo = new MethodInfo();
- methodInfo.declarationStart = iVisited.getPosition().getStartOffset();
- methodInfo.name = iVisited.getName();
- methodInfo.nameSourceStart = iVisited.getNameNode().getPosition().getStartOffset();
- methodInfo.nameSourceEnd = iVisited.getNameNode().getPosition().getEndOffset() - 1;
- methodInfo.isConstructor = false;
- methodInfo.isClassLevel = true;
- methodInfo.visibility = convertVisibility(currentVisibility);
- methodInfo.parameterNames = ASTUtil.getArgs(iVisited.getArgsNode(), iVisited.getScope());
- requestor.enterMethod(methodInfo);
-
- Instruction ins = super.visitDefsNode(iVisited); // now traverse it's body
-
- requestor.exitMethod(iVisited.getPosition().getEndOffset());
- return ins;
- }
-
- /**
- * @param visibility
- * @return
- */
- private int convertVisibility(Visibility visibility) {
- // FIXME What about the module function and public-protected
- // visibilities?
- if (visibility == Visibility.PUBLIC)
- return IMethod.PUBLIC;
- if (visibility == Visibility.PROTECTED)
- return IMethod.PROTECTED;
- return IMethod.PRIVATE;
- }
-
- @Override
- public Instruction visitRootNode(RootNode iVisited) {
- requestor.enterScript();
- Instruction ins = super.visitRootNode(iVisited);
- requestor.exitScript(-1); // FIXME Actually grab the correct end offset somehow!
- return ins;
- }
-
- private String getFullyQualifiedName(Node node) {
- if (node == null)
- return EMPTY_STRING;
- if (node instanceof ConstNode) {
- ConstNode constNode = (ConstNode) node;
- return constNode.getName();
- }
- if (node instanceof Colon2Node) {
- Colon2Node colonNode = (Colon2Node) node;
- String prefix = getFullyQualifiedName(colonNode.getLeftNode());
- if (prefix.length() > 0)
- prefix = prefix + NAMESPACE_DELIMETER;
- return prefix + colonNode.getName();
- }
- return EMPTY_STRING;
- }
-
- /**
- * Build up the fully qualified name of the super class for a class
- * declaration
- *
- * @param superNode
- * @return
- */
- private String getSuperClassName(Node superNode) {
- if (superNode == null)
- return OBJECT;
- return getFullyQualifiedName(superNode);
- }
-
- @Override
- public Instruction visitConstDeclNode(ConstDeclNode iVisited) {
- FieldInfo field = createFieldInfo(iVisited);
- field.name = iVisited.getName();
- requestor.enterField(field);
- exitField(iVisited);
- return super.visitConstDeclNode(iVisited);
- }
-
- public Instruction visitClassVarAsgnNode(ClassVarAsgnNode iVisited) {
- FieldInfo field = createFieldInfo(iVisited);
- field.name = iVisited.getName();
- requestor.enterField(field);
- exitField(iVisited);
- return super.visitClassVarAsgnNode(iVisited);
- }
-
- public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) {
- FieldInfo field = createFieldInfo(iVisited);
- field.name = iVisited.getName();
- requestor.enterField(field);
- exitField(iVisited);
- return super.visitLocalAsgnNode(iVisited);
- }
-
- @Override
- public Instruction visitInstAsgnNode(InstAsgnNode iVisited) {
- FieldInfo field = createFieldInfo(iVisited);
- field.name = iVisited.getName();
- requestor.enterField(field);
- exitField(iVisited);
- return super.visitInstAsgnNode(iVisited);
- }
-
- @Override
- public Instruction visitGlobalAsgnNode(GlobalAsgnNode iVisited) {
- FieldInfo field = createFieldInfo(iVisited);
- field.name = iVisited.getName();
- requestor.enterField(field);
- exitField(iVisited);
- return super.visitGlobalAsgnNode(iVisited);
- }
-
- private void exitField(AssignableNode iVisited) {
- requestor.exitField(iVisited.getPosition().getEndOffset() - 1);
- }
-
- private FieldInfo createFieldInfo(AssignableNode iVisited) {
- FieldInfo field = new FieldInfo();
- field.declarationStart = iVisited.getPosition().getStartOffset();
- field.nameSourceStart = iVisited.getPosition().getStartOffset();
- String name = ASTUtil.getNameReflectively(iVisited);
- field.nameSourceEnd = iVisited.getPosition().getStartOffset() + name.length() - 1;
- return field;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.jruby.ast.visitor.NodeVisitor#visitIterNode(org.jruby.ast.IterNode)
- */
- public Instruction visitIterNode(IterNode iVisited) {
-// RubyBlock block = new RubyBlock(modelStack.peek()); FIXME Add method to notify of blocks?
- return super.visitIterNode(iVisited);
- }
-
-
- @Override
- public Instruction visitDAsgnNode(DAsgnNode iVisited) {
-// RubyDynamicVar var = new RubyDynamicVar(modelStack.peek(), iVisited.getName()); FIXME Notify like a normal local var?
- return super.visitDAsgnNode(iVisited);
- }
-
- @Override
- public Instruction visitSClassNode(SClassNode iVisited) {
- Node receiver = iVisited.getReceiverNode();
- if (receiver instanceof SelfNode) {
- inSingletonClass = true;
- Instruction ins = super.visitSClassNode(iVisited);
- inSingletonClass = false;
- return ins;
- }
- return super.visitSClassNode(iVisited);
- }
-
- public Instruction visitFCallNode(FCallNode iVisited) {
- String name = iVisited.getName();
- if (name.equals(REQUIRE) || name.equals(LOAD)) {
- addImport(iVisited);
- } else if (name.equals(INCLUDE)) { // Collect included mixins
- includeModule(iVisited);
- } if (name.equals(PUBLIC)) {
- List<String> arguments = getArgumentsFromFunctionCall(iVisited);
- for (String methodName : arguments) {
- requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PUBLIC));
- }
- } else if (name.equals(PRIVATE)) {
- List<String> arguments = getArgumentsFromFunctionCall(iVisited);
- for (String methodName : arguments) {
- requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PRIVATE));
- }
- } else if (name.equals(PROTECTED)) {
- List<String> arguments = getArgumentsFromFunctionCall(iVisited);
- for (String methodName : arguments) {
- requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PROTECTED));
- }
- } else if (name.equals(MODULE_FUNCTION)) {
- List<String> arguments = getArgumentsFromFunctionCall(iVisited);
- for (String methodName : arguments) {
- requestor.acceptModuleFunction(methodName);
- }
- }
- return super.visitFCallNode(iVisited);
- }
-
- private void addImport(FCallNode iVisited) {
- ArrayNode node = (ArrayNode) iVisited.getArgsNode();
- String arg = getString(node);
- if (arg != null) {
- requestor.acceptImport(arg, iVisited.getPosition().getStartOffset(), iVisited.getPosition().getEndOffset());
- }
- }
-
- /**
- * @param node
- * @return
- */
- private String getString(ArrayNode node) {
- Object tmp = node.childNodes().iterator().next();
- if (tmp instanceof DStrNode) {
- DStrNode dstrNode = (DStrNode) tmp;
- tmp = dstrNode.childNodes().iterator().next();
- }
- if (tmp instanceof StrNode) {
- StrNode strNode = (StrNode) tmp;
- return strNode.getValue().toString();
- }
- return null;
- }
-
- private void includeModule(FCallNode iVisited) {
- List<String> mixins = new LinkedList<String>();
- Node argsNode = iVisited.getArgsNode();
- Iterator iter = null;
- if (argsNode instanceof SplatNode) {
- SplatNode splat = (SplatNode) argsNode;
- iter = splat.childNodes().iterator();
- } else if (argsNode instanceof ArrayNode) {
- ArrayNode arrayNode = (ArrayNode) iVisited.getArgsNode();
- iter = arrayNode.childNodes().iterator();
- }
- for (; iter.hasNext();) {
- Node mixinNameNode = (Node) iter.next();
- if (mixinNameNode instanceof StrNode) {
- mixins.add(((StrNode) mixinNameNode).getValue().toString());
- }
- if (mixinNameNode instanceof DStrNode) {
- Node next = (Node) ((DStrNode) mixinNameNode).childNodes().iterator().next();
- if (next instanceof StrNode) {
- mixins.add(((StrNode) next).getValue().toString());
- }
- }
- if (mixinNameNode instanceof ConstNode) {
- mixins.add(((ConstNode) mixinNameNode).getName());
- }
- }
- for (String string : mixins) {
- requestor.acceptMixin(string);
- }
- }
-
- public Instruction visitVCallNode(VCallNode iVisited) {
- // XXX If the call has arguments, we need to find the method matching the
- // symbols and mark their visibility differently
- String functionName = iVisited.getName();
- if (functionName.equals(PUBLIC)) {
- currentVisibility = Visibility.PUBLIC;
- } else if (functionName.equals(PRIVATE)) {
- currentVisibility = Visibility.PRIVATE;
- } else if (functionName.equals(PROTECTED)) {
- currentVisibility = Visibility.PROTECTED;
- } else if (functionName.equals(MODULE_FUNCTION)) {
- inModuleFunction = true;
- }
- return super.visitVCallNode(iVisited);
- }
-
- @Override
- public Instruction visitCallNode(CallNode iVisited) {
- String name = iVisited.getName();
- if (name.equals(PUBLIC)) {
- List<String> arguments = getArgumentsFromFunctionCall(iVisited);
- for (String methodName : arguments) {
- requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PUBLIC));
- }
- } else if (name.equals(PRIVATE)) {
- List<String> arguments = getArgumentsFromFunctionCall(iVisited);
- for (String methodName : arguments) {
- requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PRIVATE));
- }
- } else if (name.equals(PROTECTED)) {
- List<String> arguments = getArgumentsFromFunctionCall(iVisited);
- for (String methodName : arguments) {
- requestor.acceptMethodVisibilityChange(methodName, convertVisibility(Visibility.PROTECTED));
- }
- } else if (name.equals(MODULE_FUNCTION)) {
- List<String> arguments = getArgumentsFromFunctionCall(iVisited);
- for (String methodName : arguments) {
- requestor.acceptModuleFunction(methodName);
- }
- }
- return super.visitCallNode(iVisited);
- }
-
- private List<String> getArgumentsFromFunctionCall(IArgumentNode iVisited) {
- List<String> arguments = new ArrayList<String>();
- Node argsNode = iVisited.getArgsNode();
- Iterator iter = null;
- if (argsNode instanceof SplatNode) {
- SplatNode splat = (SplatNode) argsNode;
- iter = splat.childNodes().iterator();
- } else if (argsNode instanceof ArrayNode) {
- ArrayNode arrayNode = (ArrayNode) iVisited.getArgsNode();
- iter = arrayNode.childNodes().iterator();
- }
- for (; iter.hasNext();) {
- Node mixinNameNode = (Node) iter.next();
- arguments.add(ASTUtil.getNameReflectively(mixinNameNode));
- }
- return arguments;
- }
-
- public Instruction visitAliasNode(AliasNode iVisited) {
- String name = iVisited.getNewName();
- MethodInfo method = new MethodInfo();
- // TODO Use the visibility for the original method that this is aliasing?
- Visibility visibility = currentVisibility;
- if (name.equals(CONSTRUCTOR_NAME)) {
- visibility = Visibility.PROTECTED;
- method.isConstructor = true;
- } else {
- method.isConstructor = false;
- }
- method.declarationStart = iVisited.getPosition().getStartOffset();
- method.isClassLevel = inSingletonClass;
- method.name = name;
- method.visibility = convertVisibility(visibility);
- method.nameSourceStart = iVisited.getPosition().getStartOffset() + ALIAS.length();
- method.nameSourceEnd = iVisited.getPosition().getStartOffset() + ALIAS.length() + iVisited.getNewName().length() - 1;
- method.parameterNames = new String[0]; // TODO Find the existing method and steal it's parameter names
- requestor.enterMethod(method);
- requestor.exitMethod(iVisited.getPosition().getEndOffset());
- return super.visitAliasNode(iVisited);
- }
-
- public void parse(char[] source, char[] name) {
- RubyParser p = new RubyParser();
- Node ast = p.parse(new String(source));
- acceptNode(ast);
- }
-}
\ 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-05-22 15:24:51
|
Revision: 2516
http://svn.sourceforge.net/rubyeclipse/?rev=2516&view=rev
Author: cawilliams
Date: 2007-05-22 08:24:48 -0700 (Tue, 22 May 2007)
Log Message:
-----------
fix old templates so they validate, add Dr. Nics Textmate templates
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/templates/rdt.xml
Modified: trunk/org.rubypeople.rdt.ui/templates/rdt.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/templates/rdt.xml 2007-05-21 22:00:34 UTC (rev 2515)
+++ trunk/org.rubypeople.rdt.ui/templates/rdt.xml 2007-05-22 15:24:48 UTC (rev 2516)
@@ -83,7 +83,7 @@
context="ruby"
description="%ifTemplate2.description"
id="org.rubypeople.rdt.ui.templates.if2"
- name="if">if __FILE__ == $0
+ name="if">if __FILE__ == $$0
${cursor}
end</template>
@@ -130,7 +130,7 @@
id="org.rubypeople.rdt.ui.templates.begin1"
name="begin">begin
${body}
-end until {$condition}</template>
+end until ${condition}</template>
<template
context="ruby"
@@ -138,7 +138,7 @@
id="org.rubypeople.rdt.ui.templates.begin2"
name="begin">begin
${body}
-end while {$condition}</template>
+end while ${condition}</template>
<template
context="ruby"
@@ -192,4 +192,1424 @@
${rescue_body}
end</template>
+<!-- Dr. Nic's templates -->
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.all"
+ description="tm - all? { |e| .. }"
+ enabled="true"
+ name="all">all? { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ id="org.rubypeople.rdt.ui.templates.tm.alias_method"
+ context="ruby"
+ deleted="false"
+ description="tm - alias_method .."
+ enabled="true"
+ name="am">alias_method :${new_name}, :${old_name}</template>
+
+<template
+ autoinsert="true"
+ id="org.rubypeople.rdt.ui.templates.tm.any"
+ context="ruby"
+ deleted="false"
+ description="tm - any? { |e| .. }"
+ enabled="true"
+ name="any">any? { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ id="org.rubypeople.rdt.ui.templates.tm.application_code"
+ context="ruby"
+ deleted="false"
+ description="tm - application_code { .. }"
+ enabled="true"
+ name="app">if __FILE__ == $$PROGRAM_NAME
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ id="org.rubypeople.rdt.ui.templates.tm.array"
+ context="ruby"
+ deleted="false"
+ description="tm - Array.new(10) { |i| .. }"
+ enabled="true"
+ name="Array">Array.new(${10}) { |${i}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ id="org.rubypeople.rdt.ui.templates.tm.assert"
+ deleted="false"
+ description="tm - assert(..)"
+ enabled="true"
+ name="as">assert(${test}, "${message}")</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_equal"
+ description="tm - assert_equal(..)"
+ enabled="true"
+ name="ase">assert_equal(${expected}, ${actual})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_in_delta"
+ description="tm - assert_in_delta(..)"
+ enabled="true"
+ name="asid">assert_in_delta(${expected_float}, ${actual_float}, ${20})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_instance_of"
+ description="tm - assert_instance_of(..)"
+ enabled="true"
+ name="asio">assert_instance_of(${ExpectedClass}, ${actual_instance})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_kind_of"
+ description="tm - assert_kind_of(..)"
+ enabled="true"
+ name="asko">assert_kind_of(${ExpectedKind}, ${actual_instance})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_match"
+ description="tm - assert_match(..)"
+ enabled="true"
+ name="asm">assert_match(/${expected_pattern}/, ${actual_string})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_nil"
+ description="tm - assert_nil(..)"
+ enabled="true"
+ name="asn">assert_nil(${instance})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_not_equal"
+ description="tm - assert_not_equal(..)"
+ enabled="true"
+ name="asne">assert_not_equal(${unexpected}, ${actual})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_no_match"
+ description="tm - assert_no_match(..)"
+ enabled="true"
+ name="asnm">assert_no_match(/${unexpected_pattern}/, ${actual_string})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_not_nil"
+ description="tm - assert_not_nil(..)"
+ enabled="true"
+ name="asnn">assert_not_nil(${instance})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_not_nil_assigns"
+ description="assert_not_nil(var = assigns(:var))"
+ enabled="true"
+ name="asnnv">assert_not_nil(${var} = assigns(:${var}))</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_nothing_raised"
+ description="tm - assert_nothing_raised(..) { .. }"
+ enabled="true"
+ name="asnr">assert_nothing_raised(${Exception}) { ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_not_same"
+ description="tm - assert_not_same(..)"
+ enabled="true"
+ name="asns">assert_not_same(${unexpected}, ${actual})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_nothing_thrown"
+ description="tm - assert_nothing_thrown { .. }"
+ enabled="true"
+ name="asnt">assert_nothing_thrown { ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_operator"
+ description="tm - assert_operator(..)"
+ enabled="true"
+ name="aso">assert_operator(${left}, :${operator}, ${right})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_raise"
+ description="tm - assert_raise(..) { .. }"
+ enabled="true"
+ name="asr">assert_raise(${Exception}) { ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_respond_to"
+ description="tm - assert_respond_to(..)"
+ enabled="true"
+ name="asrt">assert_respond_to(${object}, :${method})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_same"
+ description="tm - assert_same(..)"
+ enabled="true"
+ name="ass">assert_same(${expected}, ${actual})</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_send"
+ description="tm - assert_send(..)"
+ enabled="true"
+ name="ass">assert_send([${object}, :${message}, ${args}])</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.assert_throws"
+ description="tm - assert_throws(..) { .. }"
+ enabled="true"
+ name="ast">assert_throws(:${expected}) { ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.rdoc"
+ description="tm - New Block"
+ enabled="true"
+ name="b">=begin rdoc
+ ${cursor}
+=end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.begin_resuce_end"
+ description="tm - begin … rescue … end"
+ enabled="true"
+ name="begin">begin
+ ${paste}
+rescue ${Exception} => ${e}
+ ${cursor}
+end
+</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.case_end"
+ description="tm - case … end"
+ enabled="true"
+ name="case">case ${object}
+when ${condition}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.classify"
+ description="tm - classify { |e| .. }"
+ enabled="true"
+ name="cl">classify { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.delegate_class"
+ description="tm - class .. < DelegateClass .. initialize .. end"
+ enabled="true"
+ name="cla">class ${ClassName} < DelegateClass(${ParentClass})
+ def initialize${1}
+ super(${del_obj})
+
+ ${cursor}
+ end
+
+
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.subclass_stub"
+ description="tm - class .. < ParentClass .. initialize .. end"
+ enabled="true"
+ name="cla">class ${ClassName} < ${ParentClass}
+ def initialize${1}
+ ${cursor}
+ end
+
+
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.struct_class"
+ description="tm - class .. < Struct .. initialize .. end"
+ enabled="true"
+ name="cla">class ${ClassName} < Struct.new(:${attr_names})
+ def initialize(*args)
+ super
+
+ ${cursor}
+ end
+
+
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.class_stub"
+ description="tm - class .. end"
+ enabled="true"
+ name="cla">class ${ClassName}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.class_with_constructor"
+ description="tm - class .. initialize .. end"
+ enabled="true"
+ name="cla">class ${ClassName}
+ def initialize${1}
+ ${cursor}
+ end
+
+
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.singleton_class"
+ description="tm - class << self .. end"
+ enabled="true"
+ name="cla">class << ${self}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.blank_slate"
+ description="tm - class BlankSlate .. initialize .. end"
+ enabled="true"
+ name="cla">class ${BlankSlate}
+ instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
+
+ def initialize${var}
+ @${delegate} = ${delegate_object}
+
+ ${cursor}
+ end
+
+ def method_missing(meth, *args, &block)
+ @${delegate}.send(meth, *args, &block)
+ end
+
+
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.class_from_name"
+ description="tm - class_from_name()"
+ enabled="true"
+ name="clafn">split("::").inject(Object) { |par, const| par.const_get(const) }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.class_end"
+ description="tm - class … end"
+ enabled="true"
+ name="class">class ${ClassName}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.collect"
+ description="tm - collect { |e| .. }"
+ enabled="true"
+ name="col">collect { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.collect_element"
+ description="tm - collect element"
+ enabled="true"
+ name="collect">collect { |${element}| ${element}.${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.include_comparable"
+ description="tm - include Comparable .."
+ enabled="true"
+ name="Comp">include Comparable
+
+def <=>(other)
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.deep_copy"
+ description="tm - deep_copy(..)"
+ enabled="true"
+ name="dee">Marshal.load(Marshal.dump(${obj_to_copy}))</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.def_end"
+ description="tm - def … end"
+ enabled="true"
+ name="def">def ${method_name}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.def_delegator"
+ description="tm - def_delegator .."
+ enabled="true"
+ name="defd">def_delegator :${del_obj}, :${del_meth}, :${new_name}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.def_delegators"
+ description="tm - def_delegators .."
+ enabled="true"
+ name="defds">def_delegators :${del_obj}, :${del_methods}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.deff"
+ description="tm - def … end"
+ enabled="true"
+ name="deff">def ${method_name}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.defs"
+ description="tm - def self .. end"
+ enabled="true"
+ name="defs">def self.${class_method_name}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.def_test"
+ description="tm - def test_ .. end"
+ enabled="true"
+ name="deft">def test_${case_name}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.delete_if"
+ description="tm - delete_if { |e| .. }"
+ enabled="true"
+ name="deli">delete_if { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.detect"
+ description="tm - detect { |e| .. }"
+ enabled="true"
+ name="det">detect { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.dir_glob"
+ description="tm - Dir.glob("..") { |file| .. }"
+ enabled="true"
+ name="Dir">Dir.glob(${glob}) { |${file}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.do_end"
+ description="tm - do … end"
+ enabled="true"
+ name="do">do
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.do_pipe_end"
+ description="tm - Insert do |object| … end"
+ enabled="true"
+ name="doo">do |${object}|
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.downto_0"
+ description="tm - downto(0) { |n| .. }"
+ enabled="true"
+ name="dow">downto(${0}) { |${n}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_block"
+ description="tm - each { |e| .. }"
+ enabled="true"
+ name="ea">each { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_byte"
+ description="tm - each_byte { |byte| .. }"
+ enabled="true"
+ name="eab">each_byte { |${byte}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_char"
+ description="tm - each_char { |chr| .. }"
+ enabled="true"
+ name="eac">each_char { |${chr}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_cons"
+ description="tm - each_cons(..) { |group| .. }"
+ enabled="true"
+ name="eac">each_cons(${2}) { |${group}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_element"
+ description="tm - each element"
+ enabled="true"
+ name="each">each { |${element}| ${element}.${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_with_index"
+ description="tm - each_with_index"
+ enabled="true"
+ name="each_with_index">each_with_index { |${element}, ${idx}| ${element}.${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_index"
+ description="tm - each_index { |i| .. }"
+ enabled="true"
+ name="eai">each_index { |${i}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_key"
+ description="tm - each_key { |key| .. }"
+ enabled="true"
+ name="eak">each_key { |${key}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_line"
+ description="tm - each_line { |line| .. }"
+ enabled="true"
+ name="eal">each_line${1} { |${line}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_pair"
+ description="tm - each_pair { |name, val| .. }"
+ enabled="true"
+ name="eap">each_pair { |${name}, ${val}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_slice"
+ description="tm - each_slice(..) { |group| .. }"
+ enabled="true"
+ name="eas">each_slice(${2}) { |${group}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_value"
+ description="tm - each_value { |val| .. }"
+ enabled="true"
+ name="eav">each_value { |${val}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.each_with_index2"
+ description="tm - each_with_index { |e, i| .. }"
+ enabled="true"
+ name="eawi">each_with_index { |${e}, ${i}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.elsif"
+ description="tm - elsif ..."
+ enabled="true"
+ name="elsif">elsif ${condition}
+ ${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.include_Enumerable"
+ description="tm - include Enumerable .."
+ enabled="true"
+ name="Enum">include Enumerable
+
+def each(&block)
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.fetch"
+ description="tm - fetch(name) { |key| .. }"
+ enabled="true"
+ name="fet">fetch(${name}) { |${key}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.fill"
+ description="tm - fill(range) { |i| .. }"
+ enabled="true"
+ name="fil">fill(${range}) { |${i}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.file_foreach"
+ description="tm - File.foreach ("..") { |line| .. }"
+ enabled="true"
+ name="File">File.foreach(${file}) { |${line}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.find"
+ description="tm - find { |e| .. }"
+ enabled="true"
+ name="fin">find { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.find_all"
+ description="tm - find_all { |e| .. }"
+ enabled="true"
+ name="fina">find_all { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.flunk"
+ description="tm - flunk(..)"
+ enabled="true"
+ name="fl">flunk("${message}")</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.flatten_once"
+ description="tm - flatten_once()"
+ enabled="true"
+ name="flao">inject(Array.new) { |${arr}, ${a}| ${arr}.push(*${a}) }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.for_in_end"
+ description="tm - for … in … end"
+ enabled="true"
+ name="forin">for ${element} in ${collection}
+ ${element}.${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.extend_forwardable"
+ description="tm - extend Forwardable"
+ enabled="true"
+ name="Forw">extend Forwardable</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.grep"
+ description="tm - grep(/pattern/) { |match| .. }"
+ enabled="true"
+ name="gre">grep(${pattern}) { |${match}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.gsub"
+ description="tm - gsub(/../) { |match| .. }"
+ enabled="true"
+ name="gsu">gsub(/${pattern}/) { |${match}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.hash_new"
+ description="tm - Hash.new { |hash, key| hash[key] = .. }"
+ enabled="true"
+ name="Hash">Hash.new { |${hash}, ${key}| ${hash}[${key}] = ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.hash_pair"
+ description="tm - Hash Pair — :key => "value""
+ enabled="true"
+ name="hp">:${key} => ${value}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.if_end"
+ description="tm - if … end"
+ enabled="true"
+ name="if">if ${condition}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.if_else_end"
+ description="tm - if … else … end"
+ enabled="true"
+ name="ife">if ${condition}
+ ${2}
+else
+ ${3}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.inject"
+ description="tm - inject(init) { |mem, var| .. }"
+ enabled="true"
+ name="inj">inject(${init}) { |${mem}, ${var}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.inject_object"
+ description="tm - inject object"
+ enabled="true"
+ name="inject">inject(${object}) { |${injection}, ${element}| ${4} }${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.lambda"
+ description="tm - lambda { |args| .. }"
+ enabled="true"
+ name="lam">lambda { |${args}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.logger_debug"
+ description="tm - logger.debug"
+ enabled="true"
+ name="log">logger.debug "${message}"${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.logger_error"
+ description="tm - logger.error"
+ enabled="true"
+ name="loge">logger.error "${message}"${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.logger_fatal"
+ description="tm - logger.fatal"
+ enabled="true"
+ name="logf">logger.fatal "${message}"${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.logger_info"
+ description="tm - logger.info"
+ enabled="true"
+ name="logi">logger.info "${message}"${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.logger_warn"
+ description="tm - logger.warn"
+ enabled="true"
+ name="logw">logger.warn "${message}"${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.map"
+ description="tm - map { |e| .. }"
+ enabled="true"
+ name="map">map { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.map_with_index"
+ description="tm - map_with_index { |e, i| .. }"
+ enabled="true"
+ name="mapwi">enum_with_index.map { |${e}, ${i}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.max"
+ description="tm - max { |a, b| .. }"
+ enabled="true"
+ name="max">max { |a, b| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.marshal_dump"
+ description="tm - Marshal.dump(.., file)"
+ enabled="true"
+ name="Md">File.open(${dump}, "w") { |${file}| Marshal.dump(${obj}, ${file}) }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.min"
+ description="tm - min { |a, b| .. }"
+ enabled="true"
+ name="min">min { |a, b| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.marshal_load"
+ description="tm - Marshal.load(obj)"
+ enabled="true"
+ name="Ml">File.open(${dump}) { |${file}| Marshal.load(${file}) }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.method_missing"
+ description="tm - def method_missing .. end"
+ enabled="true"
+ name="mm">def method_missing(meth, *args, &block)
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.module_class_methods"
+ description="tm - module .. ClassMethods .. end"
+ enabled="true"
+ name="mod">module ${ModuleName}
+ module ClassMethods
+ ${cursor}
+ end
+
+ extend ClassMethods
+
+ def self.included(receiver)
+ receiver.extend(ClassMethods)
+ end
+
+
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.module_end"
+ description="tm - module .. end"
+ enabled="true"
+ name="mod">module ${ModuleName}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.module_module_function_end"
+ description="tm - module .. module_function .. end"
+ enabled="true"
+ name="mod">module ${ModuleName}
+ module_function
+
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.open"
+ description="tm - open("path/or/url", "w") { |io| .. }"
+ enabled="true"
+ name="ope">open(${pipe}) { |${io}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ id="org.rubypeople.rdt.ui.templates.tm.option"
+ deleted="false" description="tm - option(..)"
+ enabled="true"
+ name="opt">opts.on( "-${o}", "--${option}"${1},
+ "${description}" ) do |${opt}|
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.option_parse"
+ description="tm - option_parse { .. }"
+ enabled="true"
+ name="optp">require "optparse"
+require "ostruct"
+
+options = OpenStruct.new(${default})
+
+ARGV.options do |opts|
+ opts.banner = "Usage: #{File.basename($$PROGRAM_NAME)} [OPTIONS]${1}"
+
+ opts.separator ""
+ opts.separator "Specific Options:"
+
+ ${cursor}
+
+ opts.separator "Common Options:"
+
+ opts.on( "-h", "--help",
+ "Show this message." ) do
+ puts opts
+ exit
+ end
+
+ begin
+ opts.parse!
+ rescue
+ puts opts
+ exit
+ end
+end
+</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.partition"
+ description="tm - partition { |e| .. }"
+ enabled="true"
+ name="par">partition { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.randomize"
+ description="tm - randomize()"
+ enabled="true"
+ name="ran">sort_by { rand }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.shebang"
+ description="tm - #!/usr/local/bin/ruby -w"
+ enabled="true"
+ name="rb">#!/usr/bin/env ruby -w
+
+</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.reject"
+ description="tm - reject { |e| .. }"
+ enabled="true"
+ name="rej">reject { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.reject_element"
+ description="tm - reject element"
+ enabled="true"
+ name="reject">reject { |${element}| ${element}.${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.results_report"
+ description="tm - results.report(..) { .. }"
+ enabled="true"
+ name="rep">results.report("${name}:") { TESTS.times { ${cursor} } }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.require"
+ description="tm - require "..""
+ enabled="true"
+ name="req">require "${cursor}"</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.reverse_each"
+ description="tm - reverse_each { |e| .. }"
+ enabled="true"
+ name="reve">reverse_each { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.attr_reader"
+ description="tm - attr_reader .."
+ enabled="true"
+ name="ro">attr_reader :${attr_names}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.attr_accessor"
+ description="tm - attr_accessor .."
+ enabled="true"
+ name="rw">attr_accessor :${attr_names}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.scan"
+ description="tm - scan(/../) { |match| .. }"
+ enabled="true"
+ name="sca">scan(/${pattern}/) { |${match}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.select"
+ description="tm - select { |e| .. }"
+ enabled="true"
+ name="sel">select { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.select_element"
+ description="tm - select element"
+ enabled="true"
+ name="select">select { |${element}| ${element}.${2} }${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.singleton_class"
+ description="tm - singleton_class()"
+ enabled="true"
+ name="sin">class << self; self end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.sort"
+ description="tm - sort { |a, b| .. }"
+ enabled="true"
+ name="sor">sort { |a, b| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.sort_by"
+ description="tm - sort_by { |e| .. }"
+ enabled="true"
+ name="sorb">sort_by { |${e}| ${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.step"
+ description="tm - step(2) { |e| .. }"
+ enabled="true"
+ name="ste">step(${2}) { |${n}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.sub"
+ description="tm - sub(/../) { |match| .. }"
+ enabled="true"
+ name="sub">sub(/${pattern}/) { |${match}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.testcase"
+ description="tm - class .. < Test::Unit::TestCase .. end"
+ enabled="true"
+ name="tc">require "test/unit"
+
+require "${library_file_name}"
+
+class Test${amp} < Test::Unit::TestCase
+ def test_${case_name}
+ ${cursor}
+ end
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.times"
+ description="tm - times { |n| .. }"
+ enabled="true"
+ name="tim">times { |${n}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.testsuite"
+ description="tm - require "tc_.." .."
+ enabled="true"
+ name="ts">require "test/unit"
+
+require "tc_${test_case_file}"
+require "tc_${test_case_file}"
+</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.argf_each_line"
+ description="tm - unix_filter { .. }"
+ enabled="true"
+ name="uni">ARGF.each_line${1} do |${line}|
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.unless_end"
+ description="tm - unless … end"
+ enabled="true"
+ name="unless">unless ${condition}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.until_end"
+ description="tm - until ... end"
+ enabled="true"
+ name="until">until ${condition}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.upto"
+ description="tm - upto(1.0/0.0) { |n| .. }"
+ enabled="true"
+ name="upt">upto(${0}) { |${n}|${cursor} }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.usage_if"
+ description="tm - usage_if()"
+ enabled="true"
+ name="usai">if ARGV.${1}
+ puts "Usage: #{$$PROGRAM_NAME} ${ARGS_GO_HERE}"
+ exit
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.usage_unless"
+ description="tm - usage_unless()"
+ enabled="true"
+ name="usau">unless ARGV.${1}
+ puts "Usage: #{$$PROGRAM_NAME} ${ARGS_GO_HERE}"
+ exit
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.when"
+ description="tm - when …"
+ enabled="true"
+ name="when">when ${condition}
+ ${cursor}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.while_end"
+ description="tm - while ... end"
+ enabled="true"
+ name="while">while ${condition}
+ ${cursor}
+end</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.attr_writer"
+ description="tm - attr_writer .."
+ enabled="true"
+ name="wo">attr_writer :${attr_names}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.yaml_dump"
+ description="tm - YAML.dump(.., file)"
+ enabled="true"
+ name="Yd">File.open(${yaml}, "w") { |${file}| YAML.dump(${obj}, ${file}) }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.rdoc_yields"
+ description="tm - :yields: for Rdoc"
+ enabled="true"
+ name="yields"> :yields: ${arguments}</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.yaml_load"
+ description="tm - YAML.load(file)"
+ enabled="true"
+ name="Yl">File.open(${yaml}) { |${file}| YAML.load(${file}) }</template>
+
+<template
+ autoinsert="true"
+ context="ruby"
+ deleted="false"
+ id="org.rubypeople.rdt.ui.templates.tm.zip"
+ description="tm - zip(enums) { |row| .. }"
+ enabled="true"
+ name="zip">zip(${enums}) { |${row}| ${cursor} }</template>
</templates>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 22:00:36
|
Revision: 2515
http://svn.sourceforge.net/rubyeclipse/?rev=2515&view=rev
Author: cawilliams
Date: 2007-05-21 15:00:34 -0700 (Mon, 21 May 2007)
Log Message:
-----------
fix Trac ticket #4374 - add a symbol into code shown in preview
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ColorSettingPreviewCode.txt
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ColorSettingPreviewCode.txt
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ColorSettingPreviewCode.txt 2007-05-21 21:50:11 UTC (rev 2514)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ColorSettingPreviewCode.txt 2007-05-21 22:00:34 UTC (rev 2515)
@@ -19,6 +19,7 @@
string.gsub!(/ah/, 'eet')
local = 42 * hash_code()
static_method()
+ hash = {:name => 'foo'}
return bar(local) + parameter
end
end
\ 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-05-21 21:50:14
|
Revision: 2514
http://svn.sourceforge.net/rubyeclipse/?rev=2514&view=rev
Author: cawilliams
Date: 2007-05-21 14:50:11 -0700 (Mon, 21 May 2007)
Log Message:
-----------
Removed Paths:
-------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 21:50:01
|
Revision: 2513
http://svn.sourceforge.net/rubyeclipse/?rev=2513&view=rev
Author: cawilliams
Date: 2007-05-21 14:49:59 -0700 (Mon, 21 May 2007)
Log Message:
-----------
fix how we index external libraries (actually traverse the directory structure!)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-05-21 21:34:00 UTC (rev 2512)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-05-21 21:49:59 UTC (rev 2513)
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -127,21 +128,7 @@
return false;
}
- File[] children = file.listFiles();
- for (int i = 0; i < children.length; i++) {
- if (this.isCancelled) {
- if (JobManager.VERBOSE)
- org.rubypeople.rdt.internal.core.util.Util.verbose("-> indexing of " + file.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
- return false;
- }
- String name = children[i].getName();
- if (Util.isRubyLikeFileName(name)) {
- InputStream stream = new FileInputStream(children[i]);
- char[] contents = Util.getInputStreamAsCharArray(stream, -1, null);
- RubySearchDocument entryDocument = new RubySearchDocument(children[i].getAbsolutePath(), contents, participant);
- this.manager.indexDocument(entryDocument, participant, index, this.containerPath);
- }
- }
+ if (!indexFiles(index, file, participant)) return false;
this.manager.saveIndex(index);
if (JobManager.VERBOSE)
org.rubypeople.rdt.internal.core.util.Util.verbose("-> done indexing of " //$NON-NLS-1$
@@ -161,6 +148,27 @@
return true;
}
+ private boolean indexFiles(Index index, File file, SearchParticipant participant) throws FileNotFoundException, IOException {
+ File[] children = file.listFiles();
+ if (children == null) return true;
+ for (int i = 0; i < children.length; i++) {
+ if (this.isCancelled) {
+ if (JobManager.VERBOSE)
+ org.rubypeople.rdt.internal.core.util.Util.verbose("-> indexing of " + file.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ }
+ String name = children[i].getName();
+ if (children[i].isFile() && Util.isRubyLikeFileName(name)) {
+ InputStream stream = new FileInputStream(children[i]);
+ char[] contents = Util.getInputStreamAsCharArray(stream, -1, null);
+ RubySearchDocument entryDocument = new RubySearchDocument(children[i].getAbsolutePath(), contents, participant);
+ this.manager.indexDocument(entryDocument, participant, index, this.containerPath);
+ }
+ if (!indexFiles(index, children[i], participant)) return false;
+ }
+ return true;
+ }
+
private void addDirectorysChildren(File file, String EXISTS, SimpleLookupTable indexedFileNames) {
File[] children = file.listFiles();
if (children == null) return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 21:34:03
|
Revision: 2512
http://svn.sourceforge.net/rubyeclipse/?rev=2512&view=rev
Author: cawilliams
Date: 2007-05-21 14:34:00 -0700 (Mon, 21 May 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java 2007-05-21 21:05:24 UTC (rev 2511)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java 2007-05-21 21:34:00 UTC (rev 2512)
@@ -26,4 +26,8 @@
public abstract IPath getGemInstallPath();
+ public abstract IPath getGemPath(String gemName);
+
+ public abstract IPath getGemPath(String gemName, String version);
+
}
\ No newline at end of file
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-21 21:05:24 UTC (rev 2511)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-21 21:34:00 UTC (rev 2512)
@@ -602,4 +602,20 @@
}
return lines;
}
+
+ public IPath getGemPath(String gemName) {
+ IPath path = getGemInstallPath();
+ path = path.append("gems");
+ File gemFolder = path.toFile();
+ File[] gems = gemFolder.listFiles();
+ for (int i = 0; i < gems.length; i++) {
+ if (gems[i].getName().startsWith(gemName))
+ return new Path(gems[i].getAbsolutePath()).append("lib");
+ }
+ return null;
+ }
+
+ public IPath getGemPath(String gemName, String version) {
+ return getGemPath(gemName + "-" + version);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 21:05:27
|
Revision: 2511
http://svn.sourceforge.net/rubyeclipse/?rev=2511&view=rev
Author: cawilliams
Date: 2007-05-21 14:05:24 -0700 (Mon, 21 May 2007)
Log Message:
-----------
fix to index folders when loadpath is changed.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SetLoadpathOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddFolderToIndex.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/RemoveFolderFromindex.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SetLoadpathOperation.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SetLoadpathOperation.java 2007-05-21 21:03:54 UTC (rev 2510)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SetLoadpathOperation.java 2007-05-21 21:05:24 UTC (rev 2511)
@@ -34,6 +34,7 @@
import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.compiler.util.ObjectVector;
+import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
import org.rubypeople.rdt.internal.core.util.Messages;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -298,7 +299,7 @@
int oldLength = oldResolvedPath.length;
int newLength = newResolvedPath.length;
-// final IndexManager indexManager = manager.getIndexManager();
+ final IndexManager indexManager = manager.getIndexManager();
Map oldRoots = null;
ISourceFolderRoot[] roots = null;
if (project.isOpen()) {
@@ -364,41 +365,41 @@
// Remove the .java files from the index for a source folder
// For a lib folder or a .jar file, remove the corresponding index if not shared.
-// if (indexManager != null) {
-// ILoadpathEntry oldEntry = oldResolvedPath[i];
-// final IPath path = oldEntry.getPath();
-// switch (changeKind) {
-// case ILoadpathEntry.CPE_SOURCE:
-// final char[][] inclusionPatterns = ((LoadpathEntry)oldEntry).fullInclusionPatternChars();
-// final char[][] exclusionPatterns = ((LoadpathEntry)oldEntry).fullExclusionPatternChars();
-// postAction(new IPostAction() {
-// public String getID() {
-// return path.toString();
-// }
-// public void run() /* throws RubyModelException */ {
-// indexManager.removeSourceFolderFromIndex(project, path, inclusionPatterns, exclusionPatterns);
-// }
-// },
-// REMOVEALL_APPEND);
-// break;
-// case ILoadpathEntry.CPE_LIBRARY:
-// final DeltaProcessingState deltaState = manager.deltaState;
-// postAction(new IPostAction() {
-// public String getID() {
-// return path.toString();
-// }
-// public void run() /* throws RubyModelException */ {
-// if (deltaState.otherRoots.get(path) == null) { // if root was not shared
-// indexManager.discardJobs(path.toString());
-// indexManager.removeIndex(path);
-// // TODO (kent) we could just remove the in-memory index and have the indexing check for timestamps
-// }
-// }
-// },
-// REMOVEALL_APPEND);
-// break;
-// }
-// }
+ if (indexManager != null) {
+ ILoadpathEntry oldEntry = oldResolvedPath[i];
+ final IPath path = oldEntry.getPath();
+ switch (changeKind) {
+ case ILoadpathEntry.CPE_SOURCE:
+ final char[][] inclusionPatterns = ((LoadpathEntry)oldEntry).fullInclusionPatternChars();
+ final char[][] exclusionPatterns = ((LoadpathEntry)oldEntry).fullExclusionPatternChars();
+ postAction(new IPostAction() {
+ public String getID() {
+ return path.toString();
+ }
+ public void run() /* throws RubyModelException */ {
+ indexManager.removeSourceFolderFromIndex(project, path, inclusionPatterns, exclusionPatterns);
+ }
+ },
+ REMOVEALL_APPEND);
+ break;
+ case ILoadpathEntry.CPE_LIBRARY:
+ final DeltaProcessingState deltaState = manager.deltaState;
+ postAction(new IPostAction() {
+ public String getID() {
+ return path.toString();
+ }
+ public void run() /* throws RubyModelException */ {
+ if (deltaState.otherRoots.get(path) == null) { // if root was not shared
+ indexManager.discardJobs(path.toString());
+ indexManager.removeIndex(path);
+ // TODO (kent) we could just remove the in-memory index and have the indexing check for timestamps
+ }
+ }
+ },
+ REMOVEALL_APPEND);
+ break;
+ }
+ }
hasDelta = true;
} else {
@@ -441,47 +442,47 @@
int changeKind = newResolvedPath[i].getEntryKind();
// Request indexing
-// if (indexManager != null) {
-// switch (changeKind) {
-// case ILoadpathEntry.CPE_LIBRARY:
-// boolean pathHasChanged = true;
-// final IPath newPath = newResolvedPath[i].getPath();
-// for (int j = 0; j < oldLength; j++) {
-// ILoadpathEntry oldEntry = oldResolvedPath[j];
-// if (oldEntry.getPath().equals(newPath)) {
-// pathHasChanged = false;
-// break;
-// }
-// }
-// if (pathHasChanged) {
-// postAction(new IPostAction() {
-// public String getID() {
-// return newPath.toString();
-// }
-// public void run() /* throws RubyModelException */ {
-// indexManager.indexLibrary(newPath, project.getProject());
-// }
-// },
-// REMOVEALL_APPEND);
-// }
-// break;
-// case ILoadpathEntry.CPE_SOURCE:
-// ILoadpathEntry entry = newResolvedPath[i];
-// final IPath path = entry.getPath();
-// final char[][] inclusionPatterns = ((LoadpathEntry)entry).fullInclusionPatternChars();
-// final char[][] exclusionPatterns = ((LoadpathEntry)entry).fullExclusionPatternChars();
-// postAction(new IPostAction() {
-// public String getID() {
-// return path.toString();
-// }
-// public void run() /* throws RubyModelException */ {
-// indexManager.indexSourceFolder(project, path, inclusionPatterns, exclusionPatterns);
-// }
-// },
-// APPEND); // append so that a removeSourceFolder action is not removed
-// break;
-// }
-// }
+ if (indexManager != null) {
+ switch (changeKind) {
+ case ILoadpathEntry.CPE_LIBRARY:
+ boolean pathHasChanged = true;
+ final IPath newPath = newResolvedPath[i].getPath();
+ for (int j = 0; j < oldLength; j++) {
+ ILoadpathEntry oldEntry = oldResolvedPath[j];
+ if (oldEntry.getPath().equals(newPath)) {
+ pathHasChanged = false;
+ break;
+ }
+ }
+ if (pathHasChanged) {
+ postAction(new IPostAction() {
+ public String getID() {
+ return newPath.toString();
+ }
+ public void run() /* throws RubyModelException */ {
+ indexManager.indexLibrary(newPath, project.getProject());
+ }
+ },
+ REMOVEALL_APPEND);
+ }
+ break;
+ case ILoadpathEntry.CPE_SOURCE:
+ ILoadpathEntry entry = newResolvedPath[i];
+ final IPath path = entry.getPath();
+ final char[][] inclusionPatterns = ((LoadpathEntry)entry).fullInclusionPatternChars();
+ final char[][] exclusionPatterns = ((LoadpathEntry)entry).fullExclusionPatternChars();
+ postAction(new IPostAction() {
+ public String getID() {
+ return path.toString();
+ }
+ public void run() /* throws RubyModelException */ {
+ indexManager.indexSourceFolder(project, path, inclusionPatterns, exclusionPatterns);
+ }
+ },
+ APPEND); // append so that a removeSourceFolder action is not removed
+ break;
+ }
+ }
needToUpdateDependents |= (changeKind == ILoadpathEntry.CPE_SOURCE) || newResolvedPath[i].isExported();
hasDelta = true;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-05-21 21:03:54 UTC (rev 2510)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-05-21 21:05:24 UTC (rev 2511)
@@ -267,7 +267,7 @@
}
public static Collection<? extends IType> findType(String simpleTypeName) {
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*" + simpleTypeName + "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
SearchParticipant[] participants = new SearchParticipant[] {getDefaultSearchParticipant()};
IRubySearchScope scope = createWorkspaceScope();
TypeRequestor requestor = new TypeRequestor();
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-05-21 21:03:54 UTC (rev 2510)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddExternalFolderToIndex.java 2007-05-21 21:05:24 UTC (rev 2511)
@@ -7,7 +7,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.rubypeople.rdt.core.search.SearchParticipant;
import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
import org.rubypeople.rdt.internal.core.RubyModelManager;
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddFolderToIndex.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddFolderToIndex.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddFolderToIndex.java 2007-05-21 21:05:24 UTC (rev 2511)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.search.indexing;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.core.SourceParser;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.processing.JobManager;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+class AddFolderToIndex extends IndexRequest {
+ IPath folderPath;
+ IProject project;
+ char[][] inclusionPatterns;
+ char[][] exclusionPatterns;
+
+ public AddFolderToIndex(IPath folderPath, IProject project, char[][] inclusionPatterns, char[][] exclusionPatterns, IndexManager manager) {
+ super(project.getFullPath(), manager);
+ this.folderPath = folderPath;
+ this.project = project;
+ this.inclusionPatterns = inclusionPatterns;
+ this.exclusionPatterns = exclusionPatterns;
+ }
+ public boolean execute(IProgressMonitor progressMonitor) {
+
+ if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;
+ if (!project.isAccessible()) return true; // nothing to do
+ IResource folder = this.project.getParent().findMember(this.folderPath);
+ if (folder == null || folder.getType() == IResource.FILE) return true; // nothing to do, source folder was removed
+
+ /* ensure no concurrent write access to index */
+ Index index = this.manager.getIndex(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = index.monitor;
+ if (monitor == null) return true; // index got deleted since acquired
+
+ try {
+ monitor.enterRead(); // ask permission to read
+
+ final IPath container = this.containerPath;
+ final IndexManager indexManager = this.manager;
+ final SourceParser parser = indexManager.getSourceElementParser(RubyCore.create(this.project), null/*requestor will be set by indexer*/);
+ if (this.exclusionPatterns == null && this.inclusionPatterns == null) {
+ folder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) /* throws CoreException */{
+ if (proxy.getType() == IResource.FILE) {
+ if (org.rubypeople.rdt.internal.core.util.Util.isRubyLikeFileName(proxy.getName()))
+ indexManager.addSource((IFile) proxy.requestResource(), container, parser);
+ return false;
+ }
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+ } else {
+ folder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) /* throws CoreException */{
+ switch(proxy.getType()) {
+ case IResource.FILE :
+ if (org.rubypeople.rdt.internal.core.util.Util.isRubyLikeFileName(proxy.getName())) {
+ IResource resource = proxy.requestResource();
+ if (!Util.isExcluded(resource, inclusionPatterns, exclusionPatterns))
+ indexManager.addSource((IFile)resource, container, parser);
+ }
+ return false;
+ case IResource.FOLDER :
+ if (exclusionPatterns != null && inclusionPatterns == null) {
+ // if there are inclusion patterns then we must walk the children
+ if (Util.isExcluded(proxy.requestFullPath(), inclusionPatterns, exclusionPatterns, true))
+ return false;
+ }
+ }
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+ }
+ } catch (CoreException e) {
+ if (JobManager.VERBOSE) {
+ Util.verbose("-> failed to add " + this.folderPath + " to index because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$
+ e.printStackTrace();
+ }
+ return false;
+ } finally {
+ monitor.exitRead(); // free read lock
+ }
+ return true;
+ }
+ public String toString() {
+ return "adding " + this.folderPath + " to index " + this.containerPath; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-05-21 21:03:54 UTC (rev 2510)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java 2007-05-21 21:05:24 UTC (rev 2511)
@@ -597,4 +597,31 @@
return null;
}
}
-}
+
+ /**
+ * Remove the content of the given source folder from the index.
+ */
+ public void removeSourceFolderFromIndex(RubyProject javaProject, IPath sourceFolder, char[][] inclusionPatterns, char[][] exclusionPatterns) {
+ IProject project = javaProject.getProject();
+ if (this.jobEnd > this.jobStart) {
+ // skip it if a job to index the project is already in the queue
+ IndexRequest request = new IndexAllProject(project, this);
+ if (isJobWaiting(request)) return;
+ }
+
+ this.request(new RemoveFolderFromIndex(sourceFolder, inclusionPatterns, exclusionPatterns, project, this));
+ }
+
+ /**
+ * Index the content of the given source folder.
+ */
+ public void indexSourceFolder(RubyProject javaProject, IPath sourceFolder, char[][] inclusionPatterns, char[][] exclusionPatterns) {
+ IProject project = javaProject.getProject();
+ if (this.jobEnd > this.jobStart) {
+ // skip it if a job to index the project is already in the queue
+ IndexRequest request = new IndexAllProject(project, this);
+ if (isJobWaiting(request)) return;
+ }
+ this.request(new AddFolderToIndex(sourceFolder, project, inclusionPatterns, exclusionPatterns, this));
+ }
+}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/RemoveFolderFromindex.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/RemoveFolderFromindex.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/RemoveFolderFromindex.java 2007-05-21 21:05:24 UTC (rev 2511)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.search.indexing;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.processing.JobManager;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+class RemoveFolderFromIndex extends IndexRequest {
+ IPath folderPath;
+ char[][] inclusionPatterns;
+ char[][] exclusionPatterns;
+ IProject project;
+
+ public RemoveFolderFromIndex(IPath folderPath, char[][] inclusionPatterns, char[][] exclusionPatterns, IProject project, IndexManager manager) {
+ super(project.getFullPath(), manager);
+ this.folderPath = folderPath;
+ this.inclusionPatterns = inclusionPatterns;
+ this.exclusionPatterns = exclusionPatterns;
+ this.project = project;
+ }
+ public boolean execute(IProgressMonitor progressMonitor) {
+
+ if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;
+
+ /* ensure no concurrent write access to index */
+ Index index = this.manager.getIndex(this.containerPath, true, /*reuse index file*/ false /*create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = index.monitor;
+ if (monitor == null) return true; // index got deleted since acquired
+
+ try {
+ monitor.enterRead(); // ask permission to read
+ String containerRelativePath = Util.relativePath(this.folderPath, this.containerPath.segmentCount());
+ String[] paths = index.queryDocumentNames(containerRelativePath);
+ // all file names belonging to the folder or its subfolders and that are not excluded (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32607)
+ if (paths != null) {
+ if (this.exclusionPatterns == null && this.inclusionPatterns == null) {
+ for (int i = 0, max = paths.length; i < max; i++) {
+ manager.remove(paths[i], this.containerPath); // write lock will be acquired by the remove operation
+ }
+ } else {
+ for (int i = 0, max = paths.length; i < max; i++) {
+ String documentPath = this.containerPath.toString() + '/' + paths[i];
+ if (!Util.isExcluded(new Path(documentPath), this.inclusionPatterns, this.exclusionPatterns, false))
+ manager.remove(paths[i], this.containerPath); // write lock will be acquired by the remove operation
+ }
+ }
+ }
+ } catch (IOException e) {
+ if (JobManager.VERBOSE) {
+ Util.verbose("-> failed to remove " + this.folderPath + " from index because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$
+ e.printStackTrace();
+ }
+ return false;
+ } finally {
+ monitor.exitRead(); // free read lock
+ }
+ return true;
+ }
+ public String toString() {
+ return "removing " + this.folderPath + " from index " + this.containerPath; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 21:03:56
|
Revision: 2510
http://svn.sourceforge.net/rubyeclipse/?rev=2510&view=rev
Author: cawilliams
Date: 2007-05-21 14:03:54 -0700 (Mon, 21 May 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-21 17:26:14 UTC (rev 2509)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-21 21:03:54 UTC (rev 2510)
@@ -578,8 +578,7 @@
while (!p.isTerminated()) {
Thread.yield();
}
- file = new File(launch
- .getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE));
+ file = new File(config.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String) null));
reader = new BufferedReader(new FileReader(file));
String line = null;
while ((line = reader.readLine()) != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 17:26:15
|
Revision: 2509
http://svn.sourceforge.net/rubyeclipse/?rev=2509&view=rev
Author: cawilliams
Date: 2007-05-21 10:26:14 -0700 (Mon, 21 May 2007)
Log Message:
-----------
use IPath for gem install path, not a string
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java 2007-05-21 16:30:18 UTC (rev 2508)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java 2007-05-21 17:26:14 UTC (rev 2509)
@@ -2,6 +2,8 @@
import java.util.Set;
+import org.eclipse.core.runtime.IPath;
+
public interface IGemManager {
public abstract boolean update(Gem gem);
@@ -22,6 +24,6 @@
public abstract void removeGemListener(GemListener listener);
- public abstract String getGemInstallPath();
+ public abstract IPath getGemInstallPath();
}
\ No newline at end of file
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-21 16:30:18 UTC (rev 2508)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-21 17:26:14 UTC (rev 2509)
@@ -32,6 +32,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
@@ -77,7 +78,7 @@
private Set<Gem> gems;
private Set<Gem> remoteGems;
private Set<GemListener> listeners;
- private String fGemInstallPath;
+ private IPath fGemInstallPath;
private GemManager() {
gems = new HashSet<Gem>();
@@ -554,14 +555,14 @@
listeners.remove(listener);
}
- public String getGemInstallPath() {
+ public IPath getGemInstallPath() {
if (fGemInstallPath == null) {
ILaunchConfiguration config = createGemLaunchConfiguration("environment", false);
List<String> lines = readOutput(config);
if (lines == null || lines.size() < 3) return null;
String path = lines.get(2);
path = path.substring(path.indexOf("INSTALLATION DIRECTORY:") + 23);
- fGemInstallPath = path.trim();
+ fGemInstallPath = new Path(path.trim());
}
return fGemInstallPath;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 16:30:21
|
Revision: 2508
http://svn.sourceforge.net/rubyeclipse/?rev=2508&view=rev
Author: cawilliams
Date: 2007-05-21 09:30:18 -0700 (Mon, 21 May 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManagerContentHandler.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/LogicalGem.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-21 16:17:38 UTC (rev 2507)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-05-21 16:30:18 UTC (rev 2508)
@@ -1,15 +1,12 @@
-package com.aptana.rdt.internal.gems;
+package com.aptana.rdt.internal.core.gems;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -23,15 +20,18 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.zip.DataFormatException;
+import java.util.zip.Inflater;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
+import org.eclipse.core.internal.resources.XMLWriter;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
@@ -40,12 +40,8 @@
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.osgi.service.environment.Constants;
import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
import org.rubypeople.rdt.launching.IVMInstall;
import org.rubypeople.rdt.launching.RubyRuntime;
@@ -54,24 +50,34 @@
import org.xml.sax.XMLReader;
import com.aptana.rdt.AptanaRDTPlugin;
+import com.aptana.rdt.core.gems.Gem;
+import com.aptana.rdt.core.gems.GemListener;
+import com.aptana.rdt.core.gems.IGemManager;
+import com.aptana.rdt.ui.gems.GemsMessages;
-public class GemManager {
+public class GemManager implements IGemManager {
- private static final int TIMEOUT = 30000;
+ private static final String LOCAL_SWITCH = "-l";
+ private static final String LIST_COMMAND = "list";
+ private static final String INSTALL_COMMAND = "install";
+ private static final String VERSION_SWITCH = "-v";
+ private static final String UNINSTALL_COMMAND = "uninstall";
+ private static final String UPDATE_COMMAND = "update";
+ private static final String EXECUTABLE = "ruby";
- private static final String TIMEOUT_MSG = "Installing gem took more than 30 seconds, intentionally broke out to avoid infinite loop";
+ private static final String VM_ARGS = "-e STDOUT.sync=true -e STDERR.sync=true -e load(ARGV.shift)";
- private static final String LOCAL_CACHE_FILE = "remote_gems.xml";
+ private static final String REMOTE_GEMS_CACHE_FILE = "remote_gems.xml";
+ private static final String LOCAL_GEMS_CACHE_FILE = "local_gems.xml";
- private static final String GEM_INDEX_URL = "http://gems.rubyforge.org/yaml";
+ private static final String GEM_INDEX_URL = "http://gems.rubyforge.org/yaml.Z";
- private static GemManager fgInstance;
+ private static IGemManager fgInstance;
private Set<Gem> gems;
-
private Set<Gem> remoteGems;
-
private Set<GemListener> listeners;
+ private String fGemInstallPath;
private GemManager() {
gems = new HashSet<Gem>();
@@ -79,26 +85,35 @@
// FIXME Do an incremental check for new remote gems somehow?
remoteGems = new HashSet<Gem>();
listeners = new HashSet<GemListener>();
- Job job = new Job("Loading remote gem information") {
+ Job job = new Job(GemsMessages.GemManager_loading_remote_gems) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- remoteGems = loadLocalCache();
+ remoteGems = loadLocalCache(getConfigFile(REMOTE_GEMS_CACHE_FILE));
if (remoteGems.isEmpty()) {
remoteGems = loadRemoteGems();
- storeGemCache();
+ storeGemCache(remoteGems,
+ getConfigFile(REMOTE_GEMS_CACHE_FILE));
}
return Status.OK_STATUS;
}
};
job.schedule();
- Job job2 = new Job("Loading local gem information") {
+ Job job2 = new Job(GemsMessages.GemManager_loading_local_gems) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- gems = loadLocalGems();
- informListeners();
+ gems = loadLocalCache(getConfigFile(LOCAL_GEMS_CACHE_FILE));
+ if (gems.isEmpty()) {
+ gems = loadLocalGems();
+ storeGemCache(gems, getConfigFile(LOCAL_GEMS_CACHE_FILE));
+ }
+ synchronized (listeners) {
+ for (GemListener listener : listeners) {
+ listener.gemsRefreshed();
+ }
+ }
return Status.OK_STATUS;
}
@@ -106,10 +121,10 @@
job2.schedule();
}
- protected Set<Gem> loadLocalCache() {
+ protected Set<Gem> loadLocalCache(File file) {
FileReader fileReader = null;
try {
- fileReader = new FileReader(getConfigFile());
+ fileReader = new FileReader(file);
XMLReader reader = SAXParserFactory.newInstance().newSAXParser()
.getXMLReader();
GemManagerContentHandler handler = new GemManagerContentHandler();
@@ -138,11 +153,11 @@
return new HashSet<Gem>();
}
- protected void storeGemCache() {
- PrintWriter out = null;
+ protected void storeGemCache(Set<Gem> gems, File file) {
+ XMLWriter out = null;
try {
- out = new PrintWriter(new FileWriter(getConfigFile()));
- writeXML(out);
+ out = new XMLWriter(new FileOutputStream(file));
+ writeXML(gems, out);
} catch (FileNotFoundException e) {
AptanaRDTPlugin.log(e);
} catch (IOException e) {
@@ -153,97 +168,142 @@
}
}
- /**
- * Returns the configuration file to use for the servers. The file is
- * located in the plugin state directory and called
- * <code>remote_gems.xml</code>.
- *
- * @return the config file
- */
- private File getConfigFile() {
- return AptanaRDTPlugin.getDefault().getStateLocation().append(
- LOCAL_CACHE_FILE).toFile();
+ private File getConfigFile(String fileName) {
+ return AptanaRDTPlugin.getDefault().getStateLocation().append(fileName)
+ .toFile();
}
/**
* Writes each server configuration to file in XML format.
*
+ * @param gems
+ *
* @param out
* the writer to use
*/
- private void writeXML(PrintWriter out) {
- out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- out.println("<gems>");
- for (Gem gem : remoteGems) {
- out.println("<gem>");
- out.println("<name>" + gem.getName() + "</name>");
- out.println("<version>" + gem.getVersion() + "</version>");
- out.println("<description>" + gem.getDescription()
- + "</description>");
- out.println("</gem>");
+ private void writeXML(Set<Gem> gems, XMLWriter out) {
+ out.startTag("gems", null);
+ for (Gem gem : gems) {
+ out.startTag("gem", null);
+ out.printSimpleTag("name", gem.getName());
+ out.printSimpleTag("version", gem.getVersion());
+ out.printSimpleTag("description", gem.getDescription());
+ out.printSimpleTag("platform", gem.getPlatform());
+ out.endTag("gem");
}
- out.println("</gems>");
+ out.endTag("gems");
out.flush();
}
private Set<Gem> loadRemoteGems() {
- Set<Gem> gems = new HashSet<Gem>();
+
try {
- URL url = new URL(GEM_INDEX_URL);
- URLConnection con = url.openConnection();
- InputStream content = (InputStream) con.getContent();
- BufferedReader reader = new BufferedReader(new InputStreamReader(
- content));
- String line = null;
- String name = null;
- String version = null;
- String description = null;
- String platform = null;
- boolean nextIsRealVersion = false;
- while ((line = reader.readLine()) != null) {
- if (nextIsRealVersion && line.trim().startsWith("version: ")) {
- version = line.trim().substring(9);
- if (version.charAt(0) == '"')
- version = version.substring(1);
- if (version.charAt(version.length() - 1) == '"')
- version = version.substring(0, version.length() - 1);
- nextIsRealVersion = false;
- } else if (line.trim().equals(
- "version: !ruby/object:Gem::Version")) {
- nextIsRealVersion = true;
- }
- // if (line.trim().endsWith(":
- // !ruby/object:Gem::Specification")) {
- // // new gem
- // }
- if (line.trim().startsWith("name:")) {
- name = line.trim().substring(6);
- }
- if (line.trim().startsWith("platform:")) {
- platform = line.trim().substring(10);
- }
- if (line.trim().startsWith("summary:")) {
- description = line.trim().substring(9);
- }
- if (description != null && name != null && version != null
- && platform != null) {
- gems.add(new Gem(name, version, description, platform));
- description = null;
- version = null;
- name = null;
- platform = null;
- }
+ List<String> lines = new ArrayList<String>();
+ try {
+ lines = getContents();
+ } catch (DataFormatException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
+ return convertToGems(lines);
} catch (MalformedURLException e) {
AptanaRDTPlugin.log(e);
} catch (IOException e) {
AptanaRDTPlugin.log(e);
}
+ return new HashSet<Gem>();
+ }
+
+ private Set<Gem> convertToGems(List<String> lines) {
+ Set<Gem> gems = new HashSet<Gem>();
+ String name = null;
+ String version = null;
+ String description = null;
+ String platform = null;
+ boolean nextIsRealVersion = false;
+ for (String line : lines) {
+ if (nextIsRealVersion && line.trim().startsWith("version: ")) {
+ version = line.trim().substring(9);
+ if (version.charAt(0) == '"')
+ version = version.substring(1);
+ if (version.charAt(version.length() - 1) == '"')
+ version = version.substring(0, version.length() - 1);
+ nextIsRealVersion = false;
+ } else if (line.trim().equals("version: !ruby/object:Gem::Version")) {
+ nextIsRealVersion = true;
+ }
+ if (line.trim().startsWith("name:")) {
+ name = line.trim().substring(6);
+ }
+ if (line.trim().startsWith("platform:")) {
+ if (line.trim().length() == 9) {
+ platform = Gem.RUBY_PLATFORM;
+ } else {
+ platform = line.trim().substring(10);
+ }
+ }
+ if (line.trim().startsWith("summary:")) {
+ description = line.trim().substring(9);
+ }
+ if (description != null && name != null && version != null
+ && platform != null) {
+ gems.add(new Gem(name, version, description, platform));
+ description = null;
+ version = null;
+ name = null;
+ platform = null;
+ }
+ }
return gems;
}
+ private List<String> getContents() throws MalformedURLException,
+ IOException, DataFormatException {
+ // XXX Make sure this algorithm is returning same number of gems!!!!!
+ List<String> lines = new ArrayList<String>();
+ URL url = new URL(GEM_INDEX_URL);
+ URLConnection con = url.openConnection();
+ InputStream content = (InputStream) con.getContent();
+ byte[] input = new byte[1024];
+ int index = 0;
+ while (true) {
+ int bytesToRead = content.available();
+ byte[] tmp = new byte[bytesToRead];
+ int length = content.read(tmp);
+ if (length == -1)
+ break;
+ while ((index + length) > input.length) { // if we'll overflow the
+ // array, we need to
+ // expand it
+ byte[] newInput = new byte[input.length * 2];
+ System.arraycopy(input, 0, newInput, 0, input.length);
+ input = newInput;
+ }
+ System.arraycopy(tmp, 0, input, index, length);
+ index += length;
+ }
+
+ // Decompress the bytes
+ Inflater decompresser = new Inflater();
+ decompresser.setInput(input);
+ byte[] result = new byte[input.length * 20]; // XXX This is a hack. I
+ // have no idea what the
+ // length should be here
+ int resultLength = decompresser.inflate(result);
+ decompresser.end();
+
+ // Decode the bytes into a String
+ String outputString = new String(result, 0, resultLength);
+ String[] lineArray = outputString.split("\n");
+ for (int i = 0; i < lineArray.length; i++) {
+ lines.add(lineArray[i]);
+ }
+ return lines;
+ }
+
private Set<Gem> loadLocalGems() {
- List<String> lines = launchAndRead("list -l");
+ ILaunchConfiguration config = createGemLaunchConfiguration(LIST_COMMAND + " " + LOCAL_SWITCH, false);
+ List<String> lines = readOutput(config);
if (lines.size() > 2) {
lines.remove(0); // Remove first 3 lines from local list
lines.remove(0);
@@ -252,56 +312,6 @@
return parseOutGems(lines);
}
- private List<String> launchAndRead(String command) {
- try {
- ILaunchConfiguration config = createGemLaunchConfiguration(command);
- ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
- IProcess[] processes = launch.getProcesses();
- IProcess p = processes[0];
- IStreamsProxy proxy = p.getStreamsProxy();
- final StringBuffer output = new StringBuffer();
- IStreamMonitor monitor = proxy.getOutputStreamMonitor();
- monitor.addListener(new IStreamListener() {
- public void streamAppended(String text, IStreamMonitor monitor) {
- output.append(text);
- }
-
- });
- long start = System.currentTimeMillis();
- String lastOut = null;
- while (!p.isTerminated() || output.length() == 0) {
- Thread.yield();
- if (lastOut != null && !lastOut.equals(output.toString())) {
- start = System.currentTimeMillis(); // restart timeout if we
- // have changes in
- // output
- }
- lastOut = output.toString();
- if (System.currentTimeMillis() > start + TIMEOUT) {
- AptanaRDTPlugin.log(new Exception(TIMEOUT_MSG));
- break;
- }
- }
-
- BufferedReader reader = new BufferedReader(new StringReader(output
- .toString()));
- String line = null;
- try {
- List<String> lines = new ArrayList<String>();
- while ((line = reader.readLine()) != null) {
- lines.add(line);
- }
- return lines;
- } catch (IOException e) {
- AptanaRDTPlugin.log(e);
- }
-
- } catch (CoreException e) {
- AptanaRDTPlugin.log(e);
- }
- return new ArrayList<String>();
- }
-
private Set<Gem> parseOutGems(List<String> lines) {
Set<Gem> gems = new HashSet<Gem>();
for (int i = 0; i < lines.size();) {
@@ -310,7 +320,7 @@
int j = 2;
if ((i + 2) < lines.size()) {
String nextLine = lines.get(i + 2);
- while (!nextLine.trim().isEmpty()) {
+ while (nextLine.trim().length() != 0) {
j++;
description += " " + nextLine.trim();
nextLine = lines.get(i + j);
@@ -327,10 +337,15 @@
return gems;
}
- public boolean upgrade(String gemName) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#update(com.aptana.rdt.internal.gems.Gem)
+ */
+ public boolean update(Gem gem) {
try {
- String command = "upgrade " + gemName;
- ILaunchConfiguration config = createGemLaunchConfiguration(command);
+ String command = UPDATE_COMMAND + " " + gem.getName();
+ ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
config.launch(ILaunchManager.RUN_MODE, null);
} catch (CoreException e) {
AptanaRDTPlugin.log(e);
@@ -339,10 +354,6 @@
return true;
}
- public boolean installGem(String name) {
- return installGem(name, null);
- }
-
private ILaunchConfigurationType getRubyApplicationConfigType() {
return getLaunchManager().getLaunchConfigurationType(
IRubyLaunchConfigurationConstants.ID_RUBY_APPLICATION);
@@ -352,8 +363,8 @@
return DebugPlugin.getDefault().getLaunchManager();
}
- private ILaunchConfiguration createGemLaunchConfiguration(String arguments) {
- String gemPath = getServerScript();
+ private ILaunchConfiguration createGemLaunchConfiguration(String arguments, boolean interactive) {
+ String gemPath = getGemScriptPath();
ILaunchConfiguration config = null;
try {
ILaunchConfigurationType configType = getRubyApplicationConfigType();
@@ -372,19 +383,29 @@
wc.setAttribute(
IRubyLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
arguments);
- wc
- .setAttribute(
- IRubyLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- "-e STDOUT.sync=true -e STDERR.sync=true -e load(ARGV.shift)");
+ wc.setAttribute(
+ IRubyLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
+ VM_ARGS);
Map<String, String> map = new HashMap<String, String>();
- map
- .put(IRubyLaunchConfigurationConstants.ATTR_RUBY_COMMAND,
- "ruby");
+ map.put(IRubyLaunchConfigurationConstants.ATTR_RUBY_COMMAND,
+ EXECUTABLE);
wc
.setAttribute(
IRubyLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE_SPECIFIC_ATTRS_MAP,
map);
- wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
+ wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
+ if (!interactive) {
+ wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND,
+ true);
+ wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE,
+ false);
+ IPath outFilePath = AptanaRDTPlugin.getDefault()
+ .getStateLocation();
+ outFilePath = outFilePath.append(System.currentTimeMillis()
+ + ".txt");
+ wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE,
+ outFilePath.toPortableString());
+ }
config = wc.doSave();
} catch (CoreException ce) {
// ignore for now
@@ -392,151 +413,108 @@
return config;
}
- private String getServerScript() {
+ private static String getGemScriptPath() {
IVMInstall vm = RubyRuntime.getDefaultVMInstall();
File installLocation = vm.getInstallLocation();
String path = installLocation.getAbsolutePath();
return path + File.separator + "bin" + File.separator + "gem";
}
- public boolean installGem(String name, String version) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#installGem(com.aptana.rdt.internal.gems.Gem)
+ */
+ public boolean installGem(Gem gem) {
try {
- String command = "install " + name;
- if (version != null && version.trim().length() > 0) {
- command += " -v " + version;
+ String command = INSTALL_COMMAND + " " + gem.getName();
+ if (gem.getVersion() != null
+ && gem.getVersion().trim().length() > 0) {
+ command += " " + VERSION_SWITCH + " " + gem.getVersion();
}
- ILaunchConfiguration config = createGemLaunchConfiguration(command);
- ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
- IProcess[] processes = launch.getProcesses();
- IProcess p = processes[0];
- IStreamMonitor monitor = p.getStreamsProxy()
- .getOutputStreamMonitor();
- final StringBuffer buffer = new StringBuffer();
- monitor.addListener(new IStreamListener() {
-
- public void streamAppended(String text, IStreamMonitor monitor) {
- buffer.append(text);
- }
-
- });
- String contents = null;
- boolean wroteSelection = false;
- long start = System.currentTimeMillis();
- String lastOut = null;
- while (!p.isTerminated()) {
- contents = buffer.toString();
- if (contents != null && contents.trim().length() > 0
- && !wroteSelection) {
- // System.out.println(contents);
- if (contents.contains("Select which gem")) {
- // Parse out options
- Map<String, String> options = new HashMap<String, String>();
-
- String[] lines = contents.split("\n");
- for (int i = 0; i < lines.length; i++) {
- String line = lines[i].trim();
- if (Character.isDigit(line.charAt(0))) {
- String number = line.substring(0, line
- .indexOf('.'));
- int parenIndex = line.indexOf('(');
- if (parenIndex == -1)
- continue; // Skip or cancel option
- String platform = line.substring(
- parenIndex + 1, line.lastIndexOf(')'));
- options.put(platform, number);
- }
- }
- // Automatically select the option which matches this
- // platform.
- String myPlatform = "ruby";
- if (Platform.getOS().equals(Constants.OS_WIN32)) {
- myPlatform = "mswin32";
- }
- try {
- p.getStreamsProxy().write(
- options.get(myPlatform) + "\r\n");
- wroteSelection = true;
- } catch (IOException e) {
- AptanaRDTPlugin.log(e);
- }
- }
- } else {
- Thread.yield();
- if (lastOut != null && !lastOut.equals(buffer.toString())) {
- start = System.currentTimeMillis(); // restart timeout
- // if we have
- // changes in output
- }
- if (System.currentTimeMillis() > start + TIMEOUT) {
- AptanaRDTPlugin.log(new Exception(TIMEOUT_MSG));
- break;
- }
- }
-
- }
+ ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
+ config.launch(ILaunchManager.RUN_MODE, null);
} catch (CoreException e) {
AptanaRDTPlugin.log(e);
return false;
}
- refresh();
+ for (GemListener listener : listeners) {
+ listener.gemAdded(gem);
+ }
return true;
}
- public boolean removeGem(String name, String version) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#removeGem(com.aptana.rdt.internal.gems.Gem)
+ */
+ public boolean removeGem(Gem gem) {
try {
- String command = "uninstall " + name;
- if (version != null && version.trim().length() > 0) {
- command += " -v " + version;
+ String command = UNINSTALL_COMMAND + " " + gem.getName();
+ if (gem.getVersion() != null
+ && gem.getVersion().trim().length() > 0) {
+ command += " " + VERSION_SWITCH + " " + gem.getVersion();
}
- ILaunchConfiguration config = createGemLaunchConfiguration(command);
+ ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
config.launch(ILaunchManager.RUN_MODE, null);
} catch (CoreException e) {
AptanaRDTPlugin.log(e);
return false;
}
- refresh(); // FIXME Need to wait until uninstall is finished!
+ for (GemListener listener : listeners) {
+ listener.gemRemoved(gem);
+ } // FIXME Need to wait until uninstall is finished!
return true;
}
- public boolean removeGem(String name) {
- return removeGem(name, null);
- }
-
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#getGems()
+ */
public Set<Gem> getGems() {
return Collections.unmodifiableSortedSet(new TreeSet<Gem>(gems));
}
- public static GemManager getInstance() {
+ public static IGemManager getInstance() {
if (fgInstance == null)
fgInstance = new GemManager();
return fgInstance;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#refresh()
+ */
public boolean refresh() {
Set<Gem> newGems = loadLocalGems();
if (!newGems.isEmpty()) {
gems.clear();
gems = newGems;
- informListeners();
+ for (GemListener listener : listeners) {
+ listener.gemsRefreshed();
+ }
return true;
}
return false;
}
- private void informListeners() {
- for (GemListener listener : listeners) {
- listener.gemsRefreshed();
- }
- }
-
- public void addGemObserver(GemListener listener) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#addGemListener(com.aptana.rdt.internal.gems.GemManager.GemListener)
+ */
+ public synchronized void addGemListener(GemListener listener) {
listeners.add(listener);
}
- public interface GemListener {
- public void gemsRefreshed();
- }
-
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#getRemoteGems()
+ */
public Set<Gem> getRemoteGems() {
SortedSet<Gem> sorted = new TreeSet<Gem>(remoteGems);
SortedSet<Gem> logical = new TreeSet<Gem>();
@@ -552,4 +530,76 @@
}
return Collections.unmodifiableSortedSet(logical);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#gemInstalled(java.lang.String)
+ */
+ public boolean gemInstalled(String gemName) {
+ Set<Gem> gems = getGems();
+ for (Gem gem : gems) {
+ if (gem.getName().equalsIgnoreCase(gemName))
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.aptana.rdt.internal.gems.IGemManager#removeGemListener(com.aptana.rdt.internal.gems.GemManager.GemListener)
+ */
+ public synchronized void removeGemListener(GemListener listener) {
+ listeners.remove(listener);
+ }
+
+ public String getGemInstallPath() {
+ if (fGemInstallPath == null) {
+ ILaunchConfiguration config = createGemLaunchConfiguration("environment", false);
+ List<String> lines = readOutput(config);
+ if (lines == null || lines.size() < 3) return null;
+ String path = lines.get(2);
+ path = path.substring(path.indexOf("INSTALLATION DIRECTORY:") + 23);
+ fGemInstallPath = path.trim();
+ }
+ return fGemInstallPath;
+ }
+
+ private List<String> readOutput(ILaunchConfiguration config) {
+ List<String> lines = new ArrayList<String>();
+ File file = null;
+ BufferedReader reader = null;
+ try {
+ ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
+ IProcess[] processes = launch.getProcesses();
+ IProcess p = processes[0];
+ while (!p.isTerminated()) {
+ Thread.yield();
+ }
+ file = new File(launch
+ .getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE));
+ reader = new BufferedReader(new FileReader(file));
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ lines.add(line);
+ }
+ } catch(CoreException e) {
+ AptanaRDTPlugin.log(e);
+ } catch (FileNotFoundException e) {
+ AptanaRDTPlugin.log(e);
+ } catch (IOException e) {
+ AptanaRDTPlugin.log(e);
+ } finally {
+ try {
+ if (reader != null) reader.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ if (file != null) {
+ file.delete();
+ }
+ }
+ return lines;
+ }
}
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManagerContentHandler.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManagerContentHandler.java 2007-05-21 16:17:38 UTC (rev 2507)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManagerContentHandler.java 2007-05-21 16:30:18 UTC (rev 2508)
@@ -1,4 +1,4 @@
-package com.aptana.rdt.internal.gems;
+package com.aptana.rdt.internal.core.gems;
import java.util.Collections;
import java.util.HashSet;
@@ -9,6 +9,8 @@
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import com.aptana.rdt.core.gems.Gem;
+
public class GemManagerContentHandler implements ContentHandler {
private HashSet<Gem> gems;
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/LogicalGem.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/LogicalGem.java 2007-05-21 16:17:38 UTC (rev 2507)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/LogicalGem.java 2007-05-21 16:30:18 UTC (rev 2508)
@@ -1,10 +1,12 @@
-package com.aptana.rdt.internal.gems;
+package com.aptana.rdt.internal.core.gems;
import java.util.Collection;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeSet;
+import com.aptana.rdt.core.gems.Gem;
+
public class LogicalGem extends Gem {
private LogicalGem(String name, String version, String description) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 16:17:39
|
Revision: 2507
http://svn.sourceforge.net/rubyeclipse/?rev=2507&view=rev
Author: cawilliams
Date: 2007-05-21 09:17:38 -0700 (Mon, 21 May 2007)
Log Message:
-----------
move internal gems package to internal.core.gems
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/AptanaRDTPlugin.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/InstallGemActionDelegate.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RefreshGemsActionDelegate.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RemoveGemActionDelegate.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/UpdateGemActionDelegate.java
trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemsView.java
trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/InstallGemDialog.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/AptanaRDTPlugin.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/AptanaRDTPlugin.java 2007-05-21 16:16:52 UTC (rev 2506)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/AptanaRDTPlugin.java 2007-05-21 16:17:38 UTC (rev 2507)
@@ -20,7 +20,7 @@
import com.aptana.rdt.core.gems.Gem;
import com.aptana.rdt.core.gems.GemListener;
import com.aptana.rdt.core.gems.IGemManager;
-import com.aptana.rdt.internal.gems.GemManager;
+import com.aptana.rdt.internal.core.gems.GemManager;
import com.aptana.rdt.internal.ui.RubyRedMessages;
/**
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/InstallGemActionDelegate.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/InstallGemActionDelegate.java 2007-05-21 16:16:52 UTC (rev 2506)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/InstallGemActionDelegate.java 2007-05-21 16:17:38 UTC (rev 2507)
@@ -18,7 +18,7 @@
import org.eclipse.ui.IWorkbenchPart;
import com.aptana.rdt.core.gems.Gem;
-import com.aptana.rdt.internal.gems.GemManager;
+import com.aptana.rdt.internal.core.gems.GemManager;
import com.aptana.rdt.ui.gems.InstallGemDialog;
/**
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RefreshGemsActionDelegate.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RefreshGemsActionDelegate.java 2007-05-21 16:16:52 UTC (rev 2506)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RefreshGemsActionDelegate.java 2007-05-21 16:17:38 UTC (rev 2507)
@@ -17,7 +17,7 @@
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
-import com.aptana.rdt.internal.gems.GemManager;
+import com.aptana.rdt.internal.core.gems.GemManager;
/**
* Install a gem
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RemoveGemActionDelegate.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RemoveGemActionDelegate.java 2007-05-21 16:16:52 UTC (rev 2506)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RemoveGemActionDelegate.java 2007-05-21 16:17:38 UTC (rev 2507)
@@ -19,7 +19,7 @@
import org.eclipse.ui.IWorkbenchPart;
import com.aptana.rdt.core.gems.Gem;
-import com.aptana.rdt.internal.gems.GemManager;
+import com.aptana.rdt.internal.core.gems.GemManager;
import com.aptana.rdt.ui.gems.GemsMessages;
import com.aptana.rdt.ui.gems.GemsView;
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/UpdateGemActionDelegate.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/UpdateGemActionDelegate.java 2007-05-21 16:16:52 UTC (rev 2506)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/UpdateGemActionDelegate.java 2007-05-21 16:17:38 UTC (rev 2507)
@@ -18,7 +18,7 @@
import org.eclipse.ui.IWorkbenchPart;
import com.aptana.rdt.core.gems.Gem;
-import com.aptana.rdt.internal.gems.GemManager;
+import com.aptana.rdt.internal.core.gems.GemManager;
import com.aptana.rdt.ui.gems.GemsView;
/**
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemsView.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemsView.java 2007-05-21 16:16:52 UTC (rev 2506)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemsView.java 2007-05-21 16:17:38 UTC (rev 2507)
@@ -21,7 +21,7 @@
import com.aptana.rdt.core.gems.Gem;
import com.aptana.rdt.core.gems.GemListener;
-import com.aptana.rdt.internal.gems.GemManager;
+import com.aptana.rdt.internal.core.gems.GemManager;
public class GemsView extends ViewPart implements GemListener {
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/InstallGemDialog.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/InstallGemDialog.java 2007-05-21 16:16:52 UTC (rev 2506)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/InstallGemDialog.java 2007-05-21 16:17:38 UTC (rev 2507)
@@ -27,8 +27,8 @@
import org.rubypeople.rdt.ui.TableViewerSorter;
import com.aptana.rdt.core.gems.Gem;
-import com.aptana.rdt.internal.gems.GemManager;
-import com.aptana.rdt.internal.gems.LogicalGem;
+import com.aptana.rdt.internal.core.gems.GemManager;
+import com.aptana.rdt.internal.core.gems.LogicalGem;
public class InstallGemDialog extends Dialog {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 16:16:55
|
Revision: 2506
http://svn.sourceforge.net/rubyeclipse/?rev=2506&view=rev
Author: cawilliams
Date: 2007-05-21 09:16:52 -0700 (Mon, 21 May 2007)
Log Message:
-----------
move internal gems package to internal.core.gems
Removed Paths:
-------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManagerContentHandler.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/LogicalGem.java
Deleted: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java 2007-05-21 16:15:42 UTC (rev 2505)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java 2007-05-21 16:16:52 UTC (rev 2506)
@@ -1,619 +0,0 @@
-package com.aptana.rdt.internal.gems;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.zip.DataFormatException;
-import java.util.zip.Inflater;
-
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.internal.resources.XMLWriter;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
-import org.rubypeople.rdt.launching.IVMInstall;
-import org.rubypeople.rdt.launching.RubyRuntime;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-
-import com.aptana.rdt.AptanaRDTPlugin;
-import com.aptana.rdt.core.gems.Gem;
-import com.aptana.rdt.core.gems.GemListener;
-import com.aptana.rdt.core.gems.IGemManager;
-import com.aptana.rdt.ui.gems.GemsMessages;
-
-public class GemManager implements IGemManager {
-
- private static final String LOCAL_SWITCH = "-l";
-
- private static final String LIST_COMMAND = "list";
-
- private static final String INSTALL_COMMAND = "install";
-
- private static final String VERSION_SWITCH = "-v";
-
- private static final String UNINSTALL_COMMAND = "uninstall";
-
- private static final String UPDATE_COMMAND = "update";
-
- private static final String EXECUTABLE = "ruby";
-
- private static final String VM_ARGS = "-e STDOUT.sync=true -e STDERR.sync=true -e load(ARGV.shift)";
-
- private static final int TIMEOUT = 30000;
-
- private static final String TIMEOUT_MSG = "Installing gem took more than 30 seconds, intentionally broke out to avoid infinite loop";
-
- private static final String REMOTE_GEMS_CACHE_FILE = "remote_gems.xml";
-
- private static final String LOCAL_GEMS_CACHE_FILE = "local_gems.xml";
-
- private static final String GEM_INDEX_URL = "http://gems.rubyforge.org/yaml.Z";
-
- private static IGemManager fgInstance;
-
- private Set<Gem> gems;
-
- private Set<Gem> remoteGems;
-
- private Set<GemListener> listeners;
-
- private String fGemInstallPath;
-
- private GemManager() {
- gems = new HashSet<Gem>();
- // FIXME Somehow allow user to refresh remote gem list
- // FIXME Do an incremental check for new remote gems somehow?
- remoteGems = new HashSet<Gem>();
- listeners = new HashSet<GemListener>();
- Job job = new Job(GemsMessages.GemManager_loading_remote_gems) {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- remoteGems = loadLocalCache(getConfigFile(REMOTE_GEMS_CACHE_FILE));
- if (remoteGems.isEmpty()) {
- remoteGems = loadRemoteGems();
- storeGemCache(remoteGems,
- getConfigFile(REMOTE_GEMS_CACHE_FILE));
- }
- return Status.OK_STATUS;
- }
-
- };
- job.schedule();
- Job job2 = new Job(GemsMessages.GemManager_loading_local_gems) {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- gems = loadLocalCache(getConfigFile(LOCAL_GEMS_CACHE_FILE));
- if (gems.isEmpty()) {
- gems = loadLocalGems();
- storeGemCache(gems, getConfigFile(LOCAL_GEMS_CACHE_FILE));
- }
- synchronized (listeners) {
- for (GemListener listener : listeners) {
- listener.gemsRefreshed();
- }
- }
- return Status.OK_STATUS;
- }
-
- };
- job2.schedule();
- }
-
- protected Set<Gem> loadLocalCache(File file) {
- FileReader fileReader = null;
- try {
- fileReader = new FileReader(file);
- XMLReader reader = SAXParserFactory.newInstance().newSAXParser()
- .getXMLReader();
- GemManagerContentHandler handler = new GemManagerContentHandler();
- reader.setContentHandler(handler);
- reader.parse(new InputSource(fileReader));
-
- return handler.getGems();
- } catch (FileNotFoundException e) {
- // This is okay, will get thrown if no config exists yet
- } catch (SAXException e) {
- AptanaRDTPlugin.log(e);
- } catch (ParserConfigurationException e) {
- AptanaRDTPlugin.log(e);
- } catch (FactoryConfigurationError e) {
- AptanaRDTPlugin.log(e);
- } catch (IOException e) {
- AptanaRDTPlugin.log(e);
- } finally {
- try {
- if (fileReader != null)
- fileReader.close();
- } catch (IOException e) {
- // ignore
- }
- }
- return new HashSet<Gem>();
- }
-
- protected void storeGemCache(Set<Gem> gems, File file) {
- XMLWriter out = null;
- try {
- out = new XMLWriter(new FileOutputStream(file));
- writeXML(gems, out);
- } catch (FileNotFoundException e) {
- AptanaRDTPlugin.log(e);
- } catch (IOException e) {
- AptanaRDTPlugin.log(e);
- } finally {
- if (out != null)
- out.close();
- }
- }
-
- private File getConfigFile(String fileName) {
- return AptanaRDTPlugin.getDefault().getStateLocation().append(fileName)
- .toFile();
- }
-
- /**
- * Writes each server configuration to file in XML format.
- *
- * @param gems
- *
- * @param out
- * the writer to use
- */
- private void writeXML(Set<Gem> gems, XMLWriter out) {
- out.startTag("gems", null);
- for (Gem gem : gems) {
- out.startTag("gem", null);
- out.printSimpleTag("name", gem.getName());
- out.printSimpleTag("version", gem.getVersion());
- out.printSimpleTag("description", gem.getDescription());
- out.printSimpleTag("platform", gem.getPlatform());
- out.endTag("gem");
- }
- out.endTag("gems");
- out.flush();
- }
-
- private Set<Gem> loadRemoteGems() {
-
- try {
- List<String> lines = new ArrayList<String>();
- try {
- lines = getContents();
- } catch (DataFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return convertToGems(lines);
- } catch (MalformedURLException e) {
- AptanaRDTPlugin.log(e);
- } catch (IOException e) {
- AptanaRDTPlugin.log(e);
- }
- return new HashSet<Gem>();
- }
-
- private Set<Gem> convertToGems(List<String> lines) {
- Set<Gem> gems = new HashSet<Gem>();
- String name = null;
- String version = null;
- String description = null;
- String platform = null;
- boolean nextIsRealVersion = false;
- for (String line : lines) {
- if (nextIsRealVersion && line.trim().startsWith("version: ")) {
- version = line.trim().substring(9);
- if (version.charAt(0) == '"')
- version = version.substring(1);
- if (version.charAt(version.length() - 1) == '"')
- version = version.substring(0, version.length() - 1);
- nextIsRealVersion = false;
- } else if (line.trim().equals("version: !ruby/object:Gem::Version")) {
- nextIsRealVersion = true;
- }
- if (line.trim().startsWith("name:")) {
- name = line.trim().substring(6);
- }
- if (line.trim().startsWith("platform:")) {
- if (line.trim().length() == 9) {
- platform = Gem.RUBY_PLATFORM;
- } else {
- platform = line.trim().substring(10);
- }
- }
- if (line.trim().startsWith("summary:")) {
- description = line.trim().substring(9);
- }
- if (description != null && name != null && version != null
- && platform != null) {
- gems.add(new Gem(name, version, description, platform));
- description = null;
- version = null;
- name = null;
- platform = null;
- }
- }
- return gems;
- }
-
- private List<String> getContents() throws MalformedURLException,
- IOException, DataFormatException {
- // XXX Make sure this algorithm is returning same number of gems!!!!!
- List<String> lines = new ArrayList<String>();
- URL url = new URL(GEM_INDEX_URL);
- URLConnection con = url.openConnection();
- InputStream content = (InputStream) con.getContent();
- byte[] input = new byte[1024];
- int index = 0;
- while (true) {
- int bytesToRead = content.available();
- byte[] tmp = new byte[bytesToRead];
- int length = content.read(tmp);
- if (length == -1)
- break;
- while ((index + length) > input.length) { // if we'll overflow the
- // array, we need to
- // expand it
- byte[] newInput = new byte[input.length * 2];
- System.arraycopy(input, 0, newInput, 0, input.length);
- input = newInput;
- }
- System.arraycopy(tmp, 0, input, index, length);
- index += length;
- }
-
- // Decompress the bytes
- Inflater decompresser = new Inflater();
- decompresser.setInput(input);
- byte[] result = new byte[input.length * 20]; // XXX This is a hack. I
- // have no idea what the
- // length should be here
- int resultLength = decompresser.inflate(result);
- decompresser.end();
-
- // Decode the bytes into a String
- String outputString = new String(result, 0, resultLength);
- String[] lineArray = outputString.split("\n");
- for (int i = 0; i < lineArray.length; i++) {
- lines.add(lineArray[i]);
- }
- return lines;
- }
-
- private Set<Gem> loadLocalGems() {
- ILaunchConfiguration config = createGemLaunchConfiguration(LIST_COMMAND + " " + LOCAL_SWITCH, false);
- List<String> lines = readOutput(config);
- if (lines.size() > 2) {
- lines.remove(0); // Remove first 3 lines from local list
- lines.remove(0);
- lines.remove(0);
- }
- return parseOutGems(lines);
- }
-
- private Set<Gem> parseOutGems(List<String> lines) {
- Set<Gem> gems = new HashSet<Gem>();
- for (int i = 0; i < lines.size();) {
- String nameAndVersion = lines.get(i);
- String description = lines.get(i + 1);
- int j = 2;
- if ((i + 2) < lines.size()) {
- String nextLine = lines.get(i + 2);
- while (nextLine.trim().length() != 0) {
- j++;
- description += " " + nextLine.trim();
- nextLine = lines.get(i + j);
- }
- }
- int openParen = nameAndVersion.indexOf('(');
- int closeParen = nameAndVersion.indexOf(')');
- String name = nameAndVersion.substring(0, openParen);
- String version = nameAndVersion
- .substring(openParen + 1, closeParen);
- gems.add(new Gem(name.trim(), version, description.trim()));
- i += (j + 1);
- }
- return gems;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#update(com.aptana.rdt.internal.gems.Gem)
- */
- public boolean update(Gem gem) {
- try {
- String command = UPDATE_COMMAND + " " + gem.getName();
- ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
- config.launch(ILaunchManager.RUN_MODE, null);
- } catch (CoreException e) {
- AptanaRDTPlugin.log(e);
- return false;
- }
- return true;
- }
-
- private ILaunchConfigurationType getRubyApplicationConfigType() {
- return getLaunchManager().getLaunchConfigurationType(
- IRubyLaunchConfigurationConstants.ID_RUBY_APPLICATION);
- }
-
- private ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- private ILaunchConfiguration createGemLaunchConfiguration(String arguments, boolean interactive) {
- String gemPath = getGemScriptPath();
- ILaunchConfiguration config = null;
- try {
- ILaunchConfigurationType configType = getRubyApplicationConfigType();
- ILaunchConfigurationWorkingCopy wc = configType
- .newInstance(null, getLaunchManager()
- .generateUniqueLaunchConfigurationNameFrom(gemPath));
- wc.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME,
- gemPath);
- wc.setAttribute(
- IRubyLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME,
- RubyRuntime.getDefaultVMInstall().getName());
- wc.setAttribute(
- IRubyLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE,
- RubyRuntime.getDefaultVMInstall().getVMInstallType()
- .getId());
- wc.setAttribute(
- IRubyLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
- arguments);
- wc.setAttribute(
- IRubyLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- VM_ARGS);
- Map<String, String> map = new HashMap<String, String>();
- map.put(IRubyLaunchConfigurationConstants.ATTR_RUBY_COMMAND,
- EXECUTABLE);
- wc
- .setAttribute(
- IRubyLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE_SPECIFIC_ATTRS_MAP,
- map);
- wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
- if (!interactive) {
- wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND,
- true);
- wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE,
- false);
- IPath outFilePath = AptanaRDTPlugin.getDefault()
- .getStateLocation();
- outFilePath = outFilePath.append(System.currentTimeMillis()
- + ".txt");
- wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE,
- outFilePath.toPortableString());
- }
- config = wc.doSave();
- } catch (CoreException ce) {
- // ignore for now
- }
- return config;
- }
-
- private static String getGemScriptPath() {
- IVMInstall vm = RubyRuntime.getDefaultVMInstall();
- File installLocation = vm.getInstallLocation();
- String path = installLocation.getAbsolutePath();
- return path + File.separator + "bin" + File.separator + "gem";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#installGem(com.aptana.rdt.internal.gems.Gem)
- */
- public boolean installGem(Gem gem) {
- try {
- String command = INSTALL_COMMAND + " " + gem.getName();
- if (gem.getVersion() != null
- && gem.getVersion().trim().length() > 0) {
- command += " " + VERSION_SWITCH + " " + gem.getVersion();
- }
- ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
- config.launch(ILaunchManager.RUN_MODE, null);
- } catch (CoreException e) {
- AptanaRDTPlugin.log(e);
- return false;
- }
- for (GemListener listener : listeners) {
- listener.gemAdded(gem);
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#removeGem(com.aptana.rdt.internal.gems.Gem)
- */
- public boolean removeGem(Gem gem) {
- try {
- String command = UNINSTALL_COMMAND + " " + gem.getName();
- if (gem.getVersion() != null
- && gem.getVersion().trim().length() > 0) {
- command += " " + VERSION_SWITCH + " " + gem.getVersion();
- }
- ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
- config.launch(ILaunchManager.RUN_MODE, null);
- } catch (CoreException e) {
- AptanaRDTPlugin.log(e);
- return false;
- }
- for (GemListener listener : listeners) {
- listener.gemRemoved(gem);
- } // FIXME Need to wait until uninstall is finished!
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#getGems()
- */
- public Set<Gem> getGems() {
- return Collections.unmodifiableSortedSet(new TreeSet<Gem>(gems));
- }
-
- public static IGemManager getInstance() {
- if (fgInstance == null)
- fgInstance = new GemManager();
- return fgInstance;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#refresh()
- */
- public boolean refresh() {
- Set<Gem> newGems = loadLocalGems();
- if (!newGems.isEmpty()) {
- gems.clear();
- gems = newGems;
- for (GemListener listener : listeners) {
- listener.gemsRefreshed();
- }
- return true;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#addGemListener(com.aptana.rdt.internal.gems.GemManager.GemListener)
- */
- public synchronized void addGemListener(GemListener listener) {
- listeners.add(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#getRemoteGems()
- */
- public Set<Gem> getRemoteGems() {
- SortedSet<Gem> sorted = new TreeSet<Gem>(remoteGems);
- SortedSet<Gem> logical = new TreeSet<Gem>();
- String name = null;
- Collection<Gem> temp = new HashSet<Gem>();
- for (Gem gem : sorted) {
- if (name != null && !gem.getName().equals(name)) {
- logical.add(LogicalGem.create(temp));
- temp.clear();
- }
- name = gem.getName();
- temp.add(gem);
- }
- return Collections.unmodifiableSortedSet(logical);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#gemInstalled(java.lang.String)
- */
- public boolean gemInstalled(String gemName) {
- Set<Gem> gems = getGems();
- for (Gem gem : gems) {
- if (gem.getName().equalsIgnoreCase(gemName))
- return true;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.aptana.rdt.internal.gems.IGemManager#removeGemListener(com.aptana.rdt.internal.gems.GemManager.GemListener)
- */
- public synchronized void removeGemListener(GemListener listener) {
- listeners.remove(listener);
- }
-
- public String getGemInstallPath() {
- if (fGemInstallPath == null) {
- ILaunchConfiguration config = createGemLaunchConfiguration("environment", false);
- List<String> lines = readOutput(config);
- if (lines == null || lines.size() < 3) return null;
- String path = lines.get(2);
- path = path.substring(path.indexOf("INSTALLATION DIRECTORY:") + 23);
- fGemInstallPath = path.trim();
- }
- return fGemInstallPath;
- }
-
- private List<String> readOutput(ILaunchConfiguration config) {
- List<String> lines = new ArrayList<String>();
- File file = null;
- BufferedReader reader = null;
- try {
- ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
- IProcess[] processes = launch.getProcesses();
- IProcess p = processes[0];
- while (!p.isTerminated()) {
- Thread.yield();
- }
- file = new File(launch
- .getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE));
- reader = new BufferedReader(new FileReader(file));
- String line = null;
- while ((line = reader.readLine()) != null) {
- lines.add(line);
- }
- } catch(CoreException e) {
- AptanaRDTPlugin.log(e);
- } catch (FileNotFoundException e) {
- AptanaRDTPlugin.log(e);
- } catch (IOException e) {
- AptanaRDTPlugin.log(e);
- } finally {
- try {
- if (reader != null) reader.close();
- } catch (IOException e) {
- // ignore
- }
- if (file != null) {
- file.delete();
- }
- }
- return lines;
- }
-}
Deleted: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManagerContentHandler.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManagerContentHandler.java 2007-05-21 16:15:42 UTC (rev 2505)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManagerContentHandler.java 2007-05-21 16:16:52 UTC (rev 2506)
@@ -1,89 +0,0 @@
-package com.aptana.rdt.internal.gems;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-import com.aptana.rdt.core.gems.Gem;
-
-public class GemManagerContentHandler implements ContentHandler {
-
- private HashSet<Gem> gems;
- private String name;
- private String version;
- private String description;
-
- private StringBuffer data;
- private String platform;
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- for (int i = start; i < start + length; i++) {
- data.append(ch[i]);
- }
- }
-
- public void endDocument() throws SAXException {
- // do nothing
- }
-
- public void endElement(String namespaceURI, String localName, String qName)
- throws SAXException {
- if (qName.equals("name")) {
- name = data.toString();
- } else if (qName.equals("version")) {
- version = data.toString();
- } else if (qName.equals("description")) {
- description = data.toString();
- } else if (qName.equals("platform")) {
- platform = data.toString();
- } else if (qName.equals("gem")) {
- gems.add(new Gem(name, version, description, platform));
- }
- }
-
- public void endPrefixMapping(String arg0) throws SAXException {
- // do nothing
- }
-
- public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
- throws SAXException {
- // do nothing
- }
-
- public void processingInstruction(String arg0, String arg1)
- throws SAXException {
- // do nothing
- }
-
- public void setDocumentLocator(Locator arg0) {
- // do nothing
- }
-
- public void skippedEntity(String arg0) throws SAXException {
- // do nothing
- }
-
- public void startDocument() throws SAXException {
- gems = new HashSet<Gem>();
- }
-
- public void startElement(String namespaceURI, String localName,
- String qName, Attributes atts) throws SAXException {
- data = new StringBuffer();
- }
-
- public void startPrefixMapping(String arg0, String arg1)
- throws SAXException {
- // do nothing
- }
-
- public Set<Gem> getGems() {
- return Collections.unmodifiableSet(gems);
- }
-
-}
Deleted: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/LogicalGem.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/LogicalGem.java 2007-05-21 16:15:42 UTC (rev 2505)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/LogicalGem.java 2007-05-21 16:16:52 UTC (rev 2506)
@@ -1,42 +0,0 @@
-package com.aptana.rdt.internal.gems;
-
-import java.util.Collection;
-import java.util.SortedSet;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-
-import com.aptana.rdt.core.gems.Gem;
-
-public class LogicalGem extends Gem {
-
- private LogicalGem(String name, String version, String description) {
- super(name, version, description);
- }
-
- public static LogicalGem create(Collection<Gem> gems) {
- if (gems == null || gems.isEmpty()) throw new IllegalArgumentException("Need a non-null, non-empty Collection of Gems");
- String name = null;
- String description = null;
- String version = "(";
- for (Gem gem : gems) {
- if (name == null) name = gem.getName();
- if (description == null) description = gem.getDescription();
- version += gem.getVersion() + ", ";
- }
- version = version.substring(0, version.length() - 2);
- version += ')';
- // XXX Need to take platform into account!!!!!!!!
- return new LogicalGem(name, version, description);
- }
-
- public SortedSet<String> getVersions() {
- String raw = getVersion().substring(1, getVersion().length() - 1);
- SortedSet<String> version = new TreeSet<String>();
- StringTokenizer tokenizer = new StringTokenizer(raw, ",");
- while (tokenizer.hasMoreTokens()) {
- version.add(tokenizer.nextToken().trim());
- }
- return version;
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 16:15:43
|
Revision: 2505
http://svn.sourceforge.net/rubyeclipse/?rev=2505&view=rev
Author: cawilliams
Date: 2007-05-21 09:15:42 -0700 (Mon, 21 May 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/
Removed Paths:
-------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/Gem.java
Copied: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems (from rev 2461, trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems)
Deleted: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/Gem.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/Gem.java 2007-05-11 17:13:55 UTC (rev 2461)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/Gem.java 2007-05-21 16:15:42 UTC (rev 2505)
@@ -1,63 +0,0 @@
-package com.aptana.rdt.internal.gems;
-
-public class Gem implements Comparable {
-
- private String name;
- private String version;
- private String description;
- private String platform;
-
- public Gem(String name, String version, String description) {
- this(name, version, description, "ruby");
- }
-
- public Gem(String name, String version, String description, String platform) {
- if (name == null) throw new IllegalArgumentException("A Gem's name must not be null");
- if (version == null) throw new IllegalArgumentException("A Gem's version must not be null");
- this.name = name;
- this.version = version;
- this.description = description;
- this.platform = platform;
- }
-
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getPlatform() {
- return platform;
- }
-
- @Override
- public boolean equals(Object arg0) {
- if (!(arg0 instanceof Gem)) return false;
- Gem other = (Gem) arg0;
- return getName().equals(other.getName()) && getVersion().equals(other.getVersion()) && getPlatform().equals(other.getPlatform());
- }
-
- @Override
- public int hashCode() {
- return (getName().hashCode() * 100) + getVersion().hashCode();
- }
-
- public int compareTo(Object arg0) {
- if (!(arg0 instanceof Gem)) return -1;
- Gem other = (Gem) arg0;
- return toString().compareTo(other.toString());
- }
-
- @Override
- public String toString() {
- return getName().toLowerCase() + " " + getVersion() + " " + getPlatform();
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 16:06:43
|
Revision: 2504
http://svn.sourceforge.net/rubyeclipse/?rev=2504&view=rev
Author: cawilliams
Date: 2007-05-21 09:06:42 -0700 (Mon, 21 May 2007)
Log Message:
-----------
Close/Fix trac ticket #4367 - lower default severity level for code complexity warnings
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/LintOptions.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/LintOptions.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/LintOptions.java 2007-05-21 15:50:14 UTC (rev 2503)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/LintOptions.java 2007-05-21 16:06:42 UTC (rev 2504)
@@ -41,11 +41,6 @@
| MisspelledConstructor
| PossibleAccidentalBooleanAssignment
| LocalVariableMasksMethod
- | MaxArguments
- | MaxBranches
- | MaxReturns
- | MaxLocals
- | MaxLines
| UnreachableCode
| AssignmentPrecedence
| SubclassDoesntCallSuper
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 15:50:19
|
Revision: 2503
http://svn.sourceforge.net/rubyeclipse/?rev=2503&view=rev
Author: cawilliams
Date: 2007-05-21 08:50:14 -0700 (Mon, 21 May 2007)
Log Message:
-----------
make launches private, add flag to tell if we want an interactive process/console 9some we don't want to really let user know anything like listing local gems or grabbing environment), clean up code a little.
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java 2007-05-21 14:48:27 UTC (rev 2502)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java 2007-05-21 15:50:14 UTC (rev 2503)
@@ -7,7 +7,6 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
-import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -30,9 +29,9 @@
import org.eclipse.core.internal.resources.XMLWriter;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
@@ -41,12 +40,8 @@
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.osgi.service.environment.Constants;
import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
import org.rubypeople.rdt.launching.IVMInstall;
import org.rubypeople.rdt.launching.RubyRuntime;
@@ -63,27 +58,41 @@
public class GemManager implements IGemManager {
private static final String LOCAL_SWITCH = "-l";
+
private static final String LIST_COMMAND = "list";
+
private static final String INSTALL_COMMAND = "install";
+
private static final String VERSION_SWITCH = "-v";
+
private static final String UNINSTALL_COMMAND = "uninstall";
+
private static final String UPDATE_COMMAND = "update";
+
private static final String EXECUTABLE = "ruby";
+
private static final String VM_ARGS = "-e STDOUT.sync=true -e STDERR.sync=true -e load(ARGV.shift)";
private static final int TIMEOUT = 30000;
+
private static final String TIMEOUT_MSG = "Installing gem took more than 30 seconds, intentionally broke out to avoid infinite loop";
-
+
private static final String REMOTE_GEMS_CACHE_FILE = "remote_gems.xml";
+
private static final String LOCAL_GEMS_CACHE_FILE = "local_gems.xml";
+
private static final String GEM_INDEX_URL = "http://gems.rubyforge.org/yaml.Z";
private static IGemManager fgInstance;
private Set<Gem> gems;
+
private Set<Gem> remoteGems;
+
private Set<GemListener> listeners;
-
+
+ private String fGemInstallPath;
+
private GemManager() {
gems = new HashSet<Gem>();
// FIXME Somehow allow user to refresh remote gem list
@@ -97,7 +106,8 @@
remoteGems = loadLocalCache(getConfigFile(REMOTE_GEMS_CACHE_FILE));
if (remoteGems.isEmpty()) {
remoteGems = loadRemoteGems();
- storeGemCache(remoteGems, getConfigFile(REMOTE_GEMS_CACHE_FILE));
+ storeGemCache(remoteGems,
+ getConfigFile(REMOTE_GEMS_CACHE_FILE));
}
return Status.OK_STATUS;
}
@@ -111,7 +121,7 @@
gems = loadLocalCache(getConfigFile(LOCAL_GEMS_CACHE_FILE));
if (gems.isEmpty()) {
gems = loadLocalGems();
- storeGemCache(gems, getConfigFile(LOCAL_GEMS_CACHE_FILE));
+ storeGemCache(gems, getConfigFile(LOCAL_GEMS_CACHE_FILE));
}
synchronized (listeners) {
for (GemListener listener : listeners) {
@@ -173,14 +183,15 @@
}
private File getConfigFile(String fileName) {
- return AptanaRDTPlugin.getDefault().getStateLocation().append(
- fileName).toFile();
+ return AptanaRDTPlugin.getDefault().getStateLocation().append(fileName)
+ .toFile();
}
/**
* Writes each server configuration to file in XML format.
- * @param gems
*
+ * @param gems
+ *
* @param out
* the writer to use
*/
@@ -199,7 +210,7 @@
}
private Set<Gem> loadRemoteGems() {
-
+
try {
List<String> lines = new ArrayList<String>();
try {
@@ -232,8 +243,7 @@
if (version.charAt(version.length() - 1) == '"')
version = version.substring(0, version.length() - 1);
nextIsRealVersion = false;
- } else if (line.trim().equals(
- "version: !ruby/object:Gem::Version")) {
+ } else if (line.trim().equals("version: !ruby/object:Gem::Version")) {
nextIsRealVersion = true;
}
if (line.trim().startsWith("name:")) {
@@ -261,7 +271,8 @@
return gems;
}
- private List<String> getContents() throws MalformedURLException, IOException, DataFormatException {
+ private List<String> getContents() throws MalformedURLException,
+ IOException, DataFormatException {
// XXX Make sure this algorithm is returning same number of gems!!!!!
List<String> lines = new ArrayList<String>();
URL url = new URL(GEM_INDEX_URL);
@@ -273,34 +284,40 @@
int bytesToRead = content.available();
byte[] tmp = new byte[bytesToRead];
int length = content.read(tmp);
- if (length == -1) break;
- while ((index + length) > input.length) { // if we'll overflow the array, we need to expand it
+ if (length == -1)
+ break;
+ while ((index + length) > input.length) { // if we'll overflow the
+ // array, we need to
+ // expand it
byte[] newInput = new byte[input.length * 2];
System.arraycopy(input, 0, newInput, 0, input.length);
input = newInput;
- }
+ }
System.arraycopy(tmp, 0, input, index, length);
index += length;
- }
-
-// Decompress the bytes
- Inflater decompresser = new Inflater();
- decompresser.setInput(input);
- byte[] result = new byte[input.length * 20]; // XXX This is a hack. I have no idea what the length should be here
- int resultLength = decompresser.inflate(result);
- decompresser.end();
+ }
- // Decode the bytes into a String
- String outputString = new String(result, 0, resultLength);
- String[] lineArray = outputString.split("\n");
- for (int i = 0; i < lineArray.length; i++) {
- lines.add(lineArray[i]);
- }
- return lines;
+ // Decompress the bytes
+ Inflater decompresser = new Inflater();
+ decompresser.setInput(input);
+ byte[] result = new byte[input.length * 20]; // XXX This is a hack. I
+ // have no idea what the
+ // length should be here
+ int resultLength = decompresser.inflate(result);
+ decompresser.end();
+
+ // Decode the bytes into a String
+ String outputString = new String(result, 0, resultLength);
+ String[] lineArray = outputString.split("\n");
+ for (int i = 0; i < lineArray.length; i++) {
+ lines.add(lineArray[i]);
+ }
+ return lines;
}
private Set<Gem> loadLocalGems() {
- List<String> lines = launchAndRead(LIST_COMMAND + " " + LOCAL_SWITCH);
+ ILaunchConfiguration config = createGemLaunchConfiguration(LIST_COMMAND + " " + LOCAL_SWITCH, false);
+ List<String> lines = readOutput(config);
if (lines.size() > 2) {
lines.remove(0); // Remove first 3 lines from local list
lines.remove(0);
@@ -309,56 +326,6 @@
return parseOutGems(lines);
}
- private List<String> launchAndRead(String command) {
- try {
- ILaunchConfiguration config = createGemLaunchConfiguration(command);
- ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
- IProcess[] processes = launch.getProcesses();
- IProcess p = processes[0];
- IStreamsProxy proxy = p.getStreamsProxy();
- final StringBuffer output = new StringBuffer();
- IStreamMonitor monitor = proxy.getOutputStreamMonitor();
- monitor.addListener(new IStreamListener() {
- public void streamAppended(String text, IStreamMonitor monitor) {
- output.append(text);
- }
-
- });
- long start = System.currentTimeMillis();
- String lastOut = null;
- while (!p.isTerminated() || output.length() == 0) {
- Thread.yield();
- if (lastOut != null && !lastOut.equals(output.toString())) {
- start = System.currentTimeMillis(); // restart timeout if we
- // have changes in
- // output
- }
- lastOut = output.toString();
- if (System.currentTimeMillis() > start + TIMEOUT) {
- AptanaRDTPlugin.log(new Exception(TIMEOUT_MSG));
- break;
- }
- }
-
- BufferedReader reader = new BufferedReader(new StringReader(output
- .toString()));
- String line = null;
- try {
- List<String> lines = new ArrayList<String>();
- while ((line = reader.readLine()) != null) {
- lines.add(line);
- }
- return lines;
- } catch (IOException e) {
- AptanaRDTPlugin.log(e);
- }
-
- } catch (CoreException e) {
- AptanaRDTPlugin.log(e);
- }
- return new ArrayList<String>();
- }
-
private Set<Gem> parseOutGems(List<String> lines) {
Set<Gem> gems = new HashSet<Gem>();
for (int i = 0; i < lines.size();) {
@@ -384,13 +351,15 @@
return gems;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#update(com.aptana.rdt.internal.gems.Gem)
*/
public boolean update(Gem gem) {
try {
String command = UPDATE_COMMAND + " " + gem.getName();
- ILaunchConfiguration config = createGemLaunchConfiguration(command);
+ ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
config.launch(ILaunchManager.RUN_MODE, null);
} catch (CoreException e) {
AptanaRDTPlugin.log(e);
@@ -408,7 +377,7 @@
return DebugPlugin.getDefault().getLaunchManager();
}
- private ILaunchConfiguration createGemLaunchConfiguration(String arguments) {
+ private ILaunchConfiguration createGemLaunchConfiguration(String arguments, boolean interactive) {
String gemPath = getGemScriptPath();
ILaunchConfiguration config = null;
try {
@@ -428,19 +397,29 @@
wc.setAttribute(
IRubyLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
arguments);
- wc
- .setAttribute(
- IRubyLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- VM_ARGS);
+ wc.setAttribute(
+ IRubyLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
+ VM_ARGS);
Map<String, String> map = new HashMap<String, String>();
- map
- .put(IRubyLaunchConfigurationConstants.ATTR_RUBY_COMMAND,
- EXECUTABLE);
+ map.put(IRubyLaunchConfigurationConstants.ATTR_RUBY_COMMAND,
+ EXECUTABLE);
wc
.setAttribute(
IRubyLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE_SPECIFIC_ATTRS_MAP,
map);
- wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
+ wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
+ if (!interactive) {
+ wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND,
+ true);
+ wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE,
+ false);
+ IPath outFilePath = AptanaRDTPlugin.getDefault()
+ .getStateLocation();
+ outFilePath = outFilePath.append(System.currentTimeMillis()
+ + ".txt");
+ wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE,
+ outFilePath.toPortableString());
+ }
config = wc.doSave();
} catch (CoreException ce) {
// ignore for now
@@ -455,84 +434,20 @@
return path + File.separator + "bin" + File.separator + "gem";
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#installGem(com.aptana.rdt.internal.gems.Gem)
*/
public boolean installGem(Gem gem) {
try {
String command = INSTALL_COMMAND + " " + gem.getName();
- if (gem.getVersion() != null && gem.getVersion().trim().length() > 0) {
+ if (gem.getVersion() != null
+ && gem.getVersion().trim().length() > 0) {
command += " " + VERSION_SWITCH + " " + gem.getVersion();
}
- ILaunchConfiguration config = createGemLaunchConfiguration(command);
- ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
- IProcess[] processes = launch.getProcesses();
- IProcess p = processes[0];
- IStreamMonitor monitor = p.getStreamsProxy()
- .getOutputStreamMonitor();
- final StringBuffer buffer = new StringBuffer();
- monitor.addListener(new IStreamListener() {
-
- public void streamAppended(String text, IStreamMonitor monitor) {
- buffer.append(text);
- }
-
- });
- String contents = null;
- boolean wroteSelection = false;
- long start = System.currentTimeMillis();
- String lastOut = null;
- while (!p.isTerminated()) {
- contents = buffer.toString();
- if (contents != null && contents.trim().length() > 0
- && !wroteSelection) {
- // System.out.println(contents);
- if (contents.contains("Select which gem")) {
- // Parse out options
- Map<String, String> options = new HashMap<String, String>();
-
- String[] lines = contents.split("\n");
- for (int i = 0; i < lines.length; i++) {
- String line = lines[i].trim();
- if (Character.isDigit(line.charAt(0))) {
- String number = line.substring(0, line
- .indexOf('.'));
- int parenIndex = line.indexOf('(');
- if (parenIndex == -1)
- continue; // Skip or cancel option
- String platform = line.substring(
- parenIndex + 1, line.lastIndexOf(')'));
- options.put(platform, number);
- }
- }
- // Automatically select the option which matches this
- // platform.
- String myPlatform = Gem.RUBY_PLATFORM;
- if (Platform.getOS().equals(Constants.OS_WIN32)) {
- myPlatform = Gem.MSWIN32_PLATFORM;
- }
- try {
- p.getStreamsProxy().write(
- options.get(myPlatform) + "\r\n");
- wroteSelection = true;
- } catch (IOException e) {
- AptanaRDTPlugin.log(e);
- }
- }
- } else {
- Thread.yield();
- if (lastOut != null && !lastOut.equals(buffer.toString())) {
- start = System.currentTimeMillis(); // restart timeout
- // if we have
- // changes in output
- }
- if (System.currentTimeMillis() > start + TIMEOUT) {
- AptanaRDTPlugin.log(new Exception(TIMEOUT_MSG));
- break;
- }
- }
-
- }
+ ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
+ config.launch(ILaunchManager.RUN_MODE, null);
} catch (CoreException e) {
AptanaRDTPlugin.log(e);
return false;
@@ -543,16 +458,19 @@
return true;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#removeGem(com.aptana.rdt.internal.gems.Gem)
*/
public boolean removeGem(Gem gem) {
try {
String command = UNINSTALL_COMMAND + " " + gem.getName();
- if (gem.getVersion() != null && gem.getVersion().trim().length() > 0) {
+ if (gem.getVersion() != null
+ && gem.getVersion().trim().length() > 0) {
command += " " + VERSION_SWITCH + " " + gem.getVersion();
}
- ILaunchConfiguration config = createGemLaunchConfiguration(command);
+ ILaunchConfiguration config = createGemLaunchConfiguration(command, true);
config.launch(ILaunchManager.RUN_MODE, null);
} catch (CoreException e) {
AptanaRDTPlugin.log(e);
@@ -564,7 +482,9 @@
return true;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#getGems()
*/
public Set<Gem> getGems() {
@@ -577,7 +497,9 @@
return fgInstance;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#refresh()
*/
public boolean refresh() {
@@ -593,14 +515,18 @@
return false;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#addGemListener(com.aptana.rdt.internal.gems.GemManager.GemListener)
*/
public synchronized void addGemListener(GemListener listener) {
listeners.add(listener);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#getRemoteGems()
*/
public Set<Gem> getRemoteGems() {
@@ -619,51 +545,75 @@
return Collections.unmodifiableSortedSet(logical);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#gemInstalled(java.lang.String)
*/
public boolean gemInstalled(String gemName) {
Set<Gem> gems = getGems();
for (Gem gem : gems) {
- if (gem.getName().equalsIgnoreCase(gemName)) return true;
+ if (gem.getName().equalsIgnoreCase(gemName))
+ return true;
}
return false;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.aptana.rdt.internal.gems.IGemManager#removeGemListener(com.aptana.rdt.internal.gems.GemManager.GemListener)
*/
public synchronized void removeGemListener(GemListener listener) {
- listeners.remove(listener);
+ listeners.remove(listener);
}
public String getGemInstallPath() {
+ if (fGemInstallPath == null) {
+ ILaunchConfiguration config = createGemLaunchConfiguration("environment", false);
+ List<String> lines = readOutput(config);
+ if (lines == null || lines.size() < 3) return null;
+ String path = lines.get(2);
+ path = path.substring(path.indexOf("INSTALLATION DIRECTORY:") + 23);
+ fGemInstallPath = path.trim();
+ }
+ return fGemInstallPath;
+ }
+
+ private List<String> readOutput(ILaunchConfiguration config) {
+ List<String> lines = new ArrayList<String>();
+ File file = null;
+ BufferedReader reader = null;
try {
- ILaunchConfiguration config = createGemLaunchConfiguration("environment");
ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
IProcess[] processes = launch.getProcesses();
IProcess p = processes[0];
- IStreamMonitor monitor = p.getStreamsProxy()
- .getOutputStreamMonitor();
- final StringBuffer buffer = new StringBuffer();
- monitor.addListener(new IStreamListener() {
-
- public void streamAppended(String text, IStreamMonitor monitor) {
- buffer.append(text);
- }
-
- });
while (!p.isTerminated()) {
Thread.yield();
}
- String contents = buffer.toString();
- int index = contents.indexOf("INSTALLATION DIRECTORY:");
- int endIndex = contents.indexOf("\n", index);
- String path = contents.substring(index + 23, endIndex);
- return path.trim();
+ file = new File(launch
+ .getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE));
+ reader = new BufferedReader(new FileReader(file));
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ lines.add(line);
+ }
} catch(CoreException e) {
AptanaRDTPlugin.log(e);
- }
- return null;
+ } catch (FileNotFoundException e) {
+ AptanaRDTPlugin.log(e);
+ } catch (IOException e) {
+ AptanaRDTPlugin.log(e);
+ } finally {
+ try {
+ if (reader != null) reader.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ if (file != null) {
+ file.delete();
+ }
+ }
+ return lines;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-21 14:48:34
|
Revision: 2502
http://svn.sourceforge.net/rubyeclipse/?rev=2502&view=rev
Author: cawilliams
Date: 2007-05-21 07:48:27 -0700 (Mon, 21 May 2007)
Log Message:
-----------
move some of the new gems stuff to an externally visible package. extract out an interface for GEmManager, use bundle context to register IGemManager instance as a service (allows us to stop relying on singletons across plugins)
Modified Paths:
--------------
trunk/com.aptana.rdt/META-INF/MANIFEST.MF
trunk/com.aptana.rdt/src/com/aptana/rdt/AptanaRDTPlugin.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManagerContentHandler.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/LogicalGem.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/InstallGemActionDelegate.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RemoveGemActionDelegate.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/UpdateGemActionDelegate.java
trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemLabelProvider.java
trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemsView.java
trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/InstallGemDialog.java
Added Paths:
-----------
trunk/com.aptana.rdt/src/com/aptana/rdt/core/
trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/
trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/Gem.java
trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/GemListener.java
trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java
Removed Paths:
-------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/Gem.java
Modified: trunk/com.aptana.rdt/META-INF/MANIFEST.MF
===================================================================
--- trunk/com.aptana.rdt/META-INF/MANIFEST.MF 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/META-INF/MANIFEST.MF 2007-05-21 14:48:27 UTC (rev 2502)
@@ -10,7 +10,8 @@
Export-Package: com.aptana.rdt,
com.aptana.rdt.internal.parser.warnings,
com.aptana.rdt.internal.ui.preferences,
- com.aptana.rdt.internal.ui.text.ruby.hover
+ com.aptana.rdt.internal.ui.text.ruby.hover,
+ com.aptana.rdt.core.gems
Require-Bundle: org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.jface.text,
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/AptanaRDTPlugin.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/AptanaRDTPlugin.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/AptanaRDTPlugin.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -17,9 +17,10 @@
import org.rubypeople.rdt.internal.launching.LaunchingPlugin;
import org.rubypeople.rdt.internal.ui.IRubyStatusConstants;
-import com.aptana.rdt.internal.gems.Gem;
+import com.aptana.rdt.core.gems.Gem;
+import com.aptana.rdt.core.gems.GemListener;
+import com.aptana.rdt.core.gems.IGemManager;
import com.aptana.rdt.internal.gems.GemManager;
-import com.aptana.rdt.internal.gems.GemManager.GemListener;
import com.aptana.rdt.internal.ui.RubyRedMessages;
/**
@@ -215,6 +216,8 @@
*/
public void start(BundleContext context) throws Exception {
super.start(context);
+ context.registerService(IGemManager.class.getName(), GemManager.getInstance(), null);
+
Set<Gem> gems = GemManager.getInstance().getGems(); // FIXME What if user has explicity disabled using ruby-debug?!
if (gems.isEmpty()) {
GemManager.getInstance().addGemListener(new GemListener() {
Copied: trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/Gem.java (from rev 2468, trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/Gem.java)
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/Gem.java (rev 0)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/Gem.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -0,0 +1,66 @@
+package com.aptana.rdt.core.gems;
+
+public class Gem implements Comparable {
+
+ private String name;
+ private String version;
+ private String description;
+ private String platform;
+ public static final String RUBY_PLATFORM = "ruby";
+ public static final String MSWIN32_PLATFORM = "mswin32";
+
+ public Gem(String name, String version, String description) {
+ this(name, version, description, "ruby");
+ }
+
+ public Gem(String name, String version, String description, String platform) {
+ if (name == null) throw new IllegalArgumentException("A Gem's name must not be null");
+ if (version == null) throw new IllegalArgumentException("A Gem's version must not be null");
+ if (platform == null) throw new IllegalArgumentException("A Gem's platform must not be null");
+ this.name = name;
+ this.version = version;
+ this.description = description;
+ this.platform = platform;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getPlatform() {
+ return platform;
+ }
+
+ @Override
+ public boolean equals(Object arg0) {
+ if (!(arg0 instanceof Gem)) return false;
+ Gem other = (Gem) arg0;
+ return getName().equals(other.getName()) && getVersion().equals(other.getVersion()) && getPlatform().equals(other.getPlatform());
+ }
+
+ @Override
+ public int hashCode() {
+ return (getName().hashCode() * 100) + getVersion().hashCode();
+ }
+
+ public int compareTo(Object arg0) {
+ if (!(arg0 instanceof Gem)) return -1;
+ Gem other = (Gem) arg0;
+ return toString().compareTo(other.toString());
+ }
+
+ @Override
+ public String toString() {
+ return getName().toLowerCase() + " " + getVersion() + " " + getPlatform();
+ }
+
+}
Added: trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/GemListener.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/GemListener.java (rev 0)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/GemListener.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -0,0 +1,7 @@
+package com.aptana.rdt.core.gems;
+
+public interface GemListener {
+ public void gemsRefreshed();
+ public void gemAdded(Gem gem);
+ public void gemRemoved(Gem gem);
+}
Added: trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java (rev 0)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/core/gems/IGemManager.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -0,0 +1,27 @@
+package com.aptana.rdt.core.gems;
+
+import java.util.Set;
+
+public interface IGemManager {
+
+ public abstract boolean update(Gem gem);
+
+ public abstract boolean installGem(Gem gem);
+
+ public abstract boolean removeGem(Gem gem);
+
+ public abstract Set<Gem> getGems();
+
+ public abstract boolean refresh();
+
+ public abstract void addGemListener(GemListener listener);
+
+ public abstract Set<Gem> getRemoteGems();
+
+ public abstract boolean gemInstalled(String gemName);
+
+ public abstract void removeGemListener(GemListener listener);
+
+ public abstract String getGemInstallPath();
+
+}
\ No newline at end of file
Deleted: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/Gem.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/Gem.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/Gem.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -1,66 +0,0 @@
-package com.aptana.rdt.internal.gems;
-
-public class Gem implements Comparable {
-
- private String name;
- private String version;
- private String description;
- private String platform;
- static final String RUBY_PLATFORM = "ruby";
- static final String MSWIN32_PLATFORM = "mswin32";
-
- public Gem(String name, String version, String description) {
- this(name, version, description, "ruby");
- }
-
- public Gem(String name, String version, String description, String platform) {
- if (name == null) throw new IllegalArgumentException("A Gem's name must not be null");
- if (version == null) throw new IllegalArgumentException("A Gem's version must not be null");
- if (platform == null) throw new IllegalArgumentException("A Gem's platform must not be null");
- this.name = name;
- this.version = version;
- this.description = description;
- this.platform = platform;
- }
-
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getPlatform() {
- return platform;
- }
-
- @Override
- public boolean equals(Object arg0) {
- if (!(arg0 instanceof Gem)) return false;
- Gem other = (Gem) arg0;
- return getName().equals(other.getName()) && getVersion().equals(other.getVersion()) && getPlatform().equals(other.getPlatform());
- }
-
- @Override
- public int hashCode() {
- return (getName().hashCode() * 100) + getVersion().hashCode();
- }
-
- public int compareTo(Object arg0) {
- if (!(arg0 instanceof Gem)) return -1;
- Gem other = (Gem) arg0;
- return toString().compareTo(other.toString());
- }
-
- @Override
- public String toString() {
- return getName().toLowerCase() + " " + getVersion() + " " + getPlatform();
- }
-
-}
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManager.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -55,9 +55,12 @@
import org.xml.sax.XMLReader;
import com.aptana.rdt.AptanaRDTPlugin;
+import com.aptana.rdt.core.gems.Gem;
+import com.aptana.rdt.core.gems.GemListener;
+import com.aptana.rdt.core.gems.IGemManager;
import com.aptana.rdt.ui.gems.GemsMessages;
-public class GemManager {
+public class GemManager implements IGemManager {
private static final String LOCAL_SWITCH = "-l";
private static final String LIST_COMMAND = "list";
@@ -75,12 +78,12 @@
private static final String LOCAL_GEMS_CACHE_FILE = "local_gems.xml";
private static final String GEM_INDEX_URL = "http://gems.rubyforge.org/yaml.Z";
- private static GemManager fgInstance;
+ private static IGemManager fgInstance;
private Set<Gem> gems;
private Set<Gem> remoteGems;
private Set<GemListener> listeners;
-
+
private GemManager() {
gems = new HashSet<Gem>();
// FIXME Somehow allow user to refresh remote gem list
@@ -381,6 +384,9 @@
return gems;
}
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#update(com.aptana.rdt.internal.gems.Gem)
+ */
public boolean update(Gem gem) {
try {
String command = UPDATE_COMMAND + " " + gem.getName();
@@ -449,6 +455,9 @@
return path + File.separator + "bin" + File.separator + "gem";
}
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#installGem(com.aptana.rdt.internal.gems.Gem)
+ */
public boolean installGem(Gem gem) {
try {
String command = INSTALL_COMMAND + " " + gem.getName();
@@ -534,6 +543,9 @@
return true;
}
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#removeGem(com.aptana.rdt.internal.gems.Gem)
+ */
public boolean removeGem(Gem gem) {
try {
String command = UNINSTALL_COMMAND + " " + gem.getName();
@@ -552,16 +564,22 @@
return true;
}
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#getGems()
+ */
public Set<Gem> getGems() {
return Collections.unmodifiableSortedSet(new TreeSet<Gem>(gems));
}
- public static GemManager getInstance() {
+ public static IGemManager getInstance() {
if (fgInstance == null)
fgInstance = new GemManager();
return fgInstance;
}
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#refresh()
+ */
public boolean refresh() {
Set<Gem> newGems = loadLocalGems();
if (!newGems.isEmpty()) {
@@ -575,16 +593,16 @@
return false;
}
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#addGemListener(com.aptana.rdt.internal.gems.GemManager.GemListener)
+ */
public synchronized void addGemListener(GemListener listener) {
listeners.add(listener);
}
- public interface GemListener {
- public void gemsRefreshed();
- public void gemAdded(Gem gem);
- public void gemRemoved(Gem gem);
- }
-
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#getRemoteGems()
+ */
public Set<Gem> getRemoteGems() {
SortedSet<Gem> sorted = new TreeSet<Gem>(remoteGems);
SortedSet<Gem> logical = new TreeSet<Gem>();
@@ -601,6 +619,9 @@
return Collections.unmodifiableSortedSet(logical);
}
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#gemInstalled(java.lang.String)
+ */
public boolean gemInstalled(String gemName) {
Set<Gem> gems = getGems();
for (Gem gem : gems) {
@@ -609,7 +630,40 @@
return false;
}
+ /* (non-Javadoc)
+ * @see com.aptana.rdt.internal.gems.IGemManager#removeGemListener(com.aptana.rdt.internal.gems.GemManager.GemListener)
+ */
public synchronized void removeGemListener(GemListener listener) {
listeners.remove(listener);
}
+
+ public String getGemInstallPath() {
+ try {
+ ILaunchConfiguration config = createGemLaunchConfiguration("environment");
+ ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
+ IProcess[] processes = launch.getProcesses();
+ IProcess p = processes[0];
+ IStreamMonitor monitor = p.getStreamsProxy()
+ .getOutputStreamMonitor();
+ final StringBuffer buffer = new StringBuffer();
+ monitor.addListener(new IStreamListener() {
+
+ public void streamAppended(String text, IStreamMonitor monitor) {
+ buffer.append(text);
+ }
+
+ });
+ while (!p.isTerminated()) {
+ Thread.yield();
+ }
+ String contents = buffer.toString();
+ int index = contents.indexOf("INSTALLATION DIRECTORY:");
+ int endIndex = contents.indexOf("\n", index);
+ String path = contents.substring(index + 23, endIndex);
+ return path.trim();
+ } catch(CoreException e) {
+ AptanaRDTPlugin.log(e);
+ }
+ return null;
+ }
}
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManagerContentHandler.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManagerContentHandler.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/GemManagerContentHandler.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -9,6 +9,8 @@
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import com.aptana.rdt.core.gems.Gem;
+
public class GemManagerContentHandler implements ContentHandler {
private HashSet<Gem> gems;
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/LogicalGem.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/LogicalGem.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/gems/LogicalGem.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -5,6 +5,8 @@
import java.util.StringTokenizer;
import java.util.TreeSet;
+import com.aptana.rdt.core.gems.Gem;
+
public class LogicalGem extends Gem {
private LogicalGem(String name, String version, String description) {
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/InstallGemActionDelegate.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/InstallGemActionDelegate.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/InstallGemActionDelegate.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -17,7 +17,7 @@
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
-import com.aptana.rdt.internal.gems.Gem;
+import com.aptana.rdt.core.gems.Gem;
import com.aptana.rdt.internal.gems.GemManager;
import com.aptana.rdt.ui.gems.InstallGemDialog;
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RemoveGemActionDelegate.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RemoveGemActionDelegate.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/RemoveGemActionDelegate.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -18,7 +18,7 @@
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
-import com.aptana.rdt.internal.gems.Gem;
+import com.aptana.rdt.core.gems.Gem;
import com.aptana.rdt.internal.gems.GemManager;
import com.aptana.rdt.ui.gems.GemsMessages;
import com.aptana.rdt.ui.gems.GemsView;
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/UpdateGemActionDelegate.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/UpdateGemActionDelegate.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/ui/actions/UpdateGemActionDelegate.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -17,7 +17,7 @@
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
-import com.aptana.rdt.internal.gems.Gem;
+import com.aptana.rdt.core.gems.Gem;
import com.aptana.rdt.internal.gems.GemManager;
import com.aptana.rdt.ui.gems.GemsView;
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemLabelProvider.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemLabelProvider.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemLabelProvider.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -4,7 +4,7 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
-import com.aptana.rdt.internal.gems.Gem;
+import com.aptana.rdt.core.gems.Gem;
public class GemLabelProvider extends LabelProvider implements ITableLabelProvider {
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemsView.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemsView.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/GemsView.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -19,9 +19,9 @@
import org.eclipse.ui.part.ViewPart;
import org.rubypeople.rdt.ui.TableViewerSorter;
-import com.aptana.rdt.internal.gems.Gem;
+import com.aptana.rdt.core.gems.Gem;
+import com.aptana.rdt.core.gems.GemListener;
import com.aptana.rdt.internal.gems.GemManager;
-import com.aptana.rdt.internal.gems.GemManager.GemListener;
public class GemsView extends ViewPart implements GemListener {
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/InstallGemDialog.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/InstallGemDialog.java 2007-05-17 18:15:06 UTC (rev 2501)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/ui/gems/InstallGemDialog.java 2007-05-21 14:48:27 UTC (rev 2502)
@@ -26,7 +26,7 @@
import org.eclipse.swt.widgets.Text;
import org.rubypeople.rdt.ui.TableViewerSorter;
-import com.aptana.rdt.internal.gems.Gem;
+import com.aptana.rdt.core.gems.Gem;
import com.aptana.rdt.internal.gems.GemManager;
import com.aptana.rdt.internal.gems.LogicalGem;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-17 18:15:09
|
Revision: 2501
http://svn.sourceforge.net/rubyeclipse/?rev=2501&view=rev
Author: cawilliams
Date: 2007-05-17 11:15:06 -0700 (Thu, 17 May 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java 2007-05-17 18:15:04 UTC (rev 2500)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java 2007-05-17 18:15:06 UTC (rev 2501)
@@ -41,7 +41,7 @@
}
protected void createProblem(ISourcePosition position, String message) {
- String value = RubyCore.getOption(getOptionKey());
+ String value = getSeverity();
if (value != null && value.equals(RubyCore.IGNORE))
return;
CategorizedProblem problem;
@@ -51,6 +51,10 @@
problem = new Warning(position, message, getProblemID());
problems.add(problem);
}
+
+ protected String getSeverity() {
+ return RubyCore.getOption(getOptionKey());
+ }
@Override
protected Instruction visitNode(Node iVisited) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-17 18:15:07
|
Revision: 2500
http://svn.sourceforge.net/rubyeclipse/?rev=2500&view=rev
Author: cawilliams
Date: 2007-05-17 11:15:04 -0700 (Thu, 17 May 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java
trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/TC_SimilarVariableNameVisitor.java
trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/WarningVisitorTest.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java 2007-05-17 16:06:02 UTC (rev 2499)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java 2007-05-17 18:15:04 UTC (rev 2500)
@@ -7,10 +7,12 @@
import org.jruby.ast.ArgsNode;
import org.jruby.ast.BlockNode;
+import org.jruby.ast.ClassNode;
import org.jruby.ast.ClassVarAsgnNode;
import org.jruby.ast.ClassVarDeclNode;
import org.jruby.ast.ClassVarNode;
import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
import org.jruby.ast.InstAsgnNode;
import org.jruby.ast.InstVarNode;
import org.jruby.ast.ListNode;
@@ -40,10 +42,21 @@
@Override
public Instruction visitDefnNode(DefnNode iVisited) {
- enterScope();
+ enterMethod();
return super.visitDefnNode(iVisited);
}
+
+ @Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ enterMethod();
+ return super.visitDefsNode(iVisited);
+ }
+ private void enterMethod() {
+ // TODO Auto-generated method stub
+ enterScope();
+ }
+
@Override
public Instruction visitArgsNode(ArgsNode iVisited) {
ListNode list = iVisited.getArgs();
@@ -65,7 +78,7 @@
@Override
public void exitDefnNode(DefnNode iVisited) {
- exitScope();
+ exitMethod();
super.exitDefnNode(iVisited);
}
@@ -86,6 +99,7 @@
}
private void exitScope() {
+ // FIXME Only create warnings on references to variables that have no declaration
Map<String, Node> map = stack.remove(stack.size() - 1); // pop
List<String> names = new ArrayList<String>(map.keySet());
while (!names.isEmpty()) {
@@ -235,6 +249,23 @@
}
@Override
+ public void exitClassNode(ClassNode iVisited) {
+ // TODO Check for references to class and instance variables that have no declaration/assignment
+ super.exitClassNode(iVisited);
+ }
+
+ @Override
+ public void exitDefsNode(DefsNode iVisited) {
+ exitMethod();
+ super.exitDefsNode(iVisited);
+ }
+
+ private void exitMethod() {
+ // TODO Check for references to local variables that have no declaration/assignment
+ exitScope();
+ }
+
+ @Override
public Instruction visitInstAsgnNode(InstAsgnNode iVisited) {
addVar(iVisited);
return super.visitInstAsgnNode(iVisited);
Modified: trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/TC_SimilarVariableNameVisitor.java
===================================================================
--- trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/TC_SimilarVariableNameVisitor.java 2007-05-17 16:06:02 UTC (rev 2499)
+++ trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/TC_SimilarVariableNameVisitor.java 2007-05-17 18:15:04 UTC (rev 2500)
@@ -1,5 +1,7 @@
package com.aptana.rdt.internal.core.parser.warnings;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
import com.aptana.rdt.internal.parser.warnings.SimilarVariableNameVisitor;
@@ -8,7 +10,14 @@
@Override
protected RubyLintVisitor createVisitor(String code) {
- return new SimilarVariableNameVisitor(code);
+ return new SimilarVariableNameVisitor(code){
+
+ @Override
+ protected String getSeverity() {
+ return RubyCore.WARNING;
+ }
+
+ };
}
public void testEmptyHasNoProblems() throws Exception {
@@ -128,5 +137,29 @@
parse(code);
assertEquals(1, numberOfProblems());
}
+
+ public void testDontWarnAboutDeclarationOfSimilarVariableName() throws Exception {
+ String code = "class Ralph\n" +
+ " def name\n" +
+ " @local = 1\n" +
+ " @lcal = 2\n" +
+ " end\n" +
+ "end\n";
+ parse(code);
+ assertEquals(0, numberOfProblems());
+ }
+
+ public void testHandleScoping() throws Exception {
+ String code = "class Ralph\n" +
+ " def initialize(name)\n" +
+ " @name = name\n" +
+ " end\n" +
+ " def name\n" +
+ " @namee\n" +
+ " end\n" +
+ "end\n";
+ parse(code);
+ assertEquals(1, numberOfProblems());
+ }
}
Modified: trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/WarningVisitorTest.java
===================================================================
--- trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/WarningVisitorTest.java 2007-05-17 16:06:02 UTC (rev 2499)
+++ trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/WarningVisitorTest.java 2007-05-17 18:15:04 UTC (rev 2500)
@@ -13,13 +13,12 @@
public abstract class WarningVisitorTest extends TestCase {
- private MockProblemRequestor problemRequestor;
private RubyParser parser;
+ private DelegatingVisitor visitor;
@Override
protected void setUp() throws Exception {
- super.setUp();
- problemRequestor = new MockProblemRequestor();
+ super.setUp();
parser = new RubyParser();
}
@@ -27,16 +26,16 @@
Node root = parser.parse(code);
List<RubyLintVisitor> visitors = new ArrayList<RubyLintVisitor>();
visitors.add(createVisitor(code));
- DelegatingVisitor visitor = new DelegatingVisitor(visitors);
+ visitor = new DelegatingVisitor(visitors);
root.accept(visitor);
}
public int numberOfProblems() {
- return problemRequestor.numberOfProblems();
+ return visitor.getProblems().size();
}
protected IProblem getProblemAtLine(int i) {
- return problemRequestor.getProblemAtLine(i);
+ return visitor.getProblems().get(i);
}
abstract protected RubyLintVisitor createVisitor(String code);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-17 16:06:04
|
Revision: 2499
http://svn.sourceforge.net/rubyeclipse/?rev=2499&view=rev
Author: cawilliams
Date: 2007-05-17 09:06:02 -0700 (Thu, 17 May 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java 2007-05-17 16:05:38 UTC (rev 2498)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java 2007-05-17 16:06:02 UTC (rev 2499)
@@ -116,7 +116,7 @@
}
if (damerauLevenshteinDistance(modName, string) <= levenshteinThreshold(modName)) {
createProblem(map.get(name).getPosition(),
- "Variable has similar name to another in scope: Possible mis-spelling."); // FIXME Shouldn't create a problem if there is a method with this name!
+ "Variable has similar name to another in scope: Possible misspelling."); // FIXME Shouldn't create a problem if there is a method with this name!
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-05-17 16:05:45
|
Revision: 2498
http://svn.sourceforge.net/rubyeclipse/?rev=2498&view=rev
Author: cawilliams
Date: 2007-05-17 09:05:38 -0700 (Thu, 17 May 2007)
Log Message:
-----------
ignore case where variables are close but one is just a plural of the other (we just simplify that case to an 's' being added at the end).
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java 2007-05-17 15:55:56 UTC (rev 2497)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/SimilarVariableNameVisitor.java 2007-05-17 16:05:38 UTC (rev 2498)
@@ -108,6 +108,11 @@
} else { // name is local var
if (isInstanceVar(string) || isClassVar(string))
continue;
+ }
+ if (isPlural(modName, string) || isPlural(string, modName)) {
+ // check for one being plural of other, if so skip them
+ // FIXME Make this option configurable!
+ continue;
}
if (damerauLevenshteinDistance(modName, string) <= levenshteinThreshold(modName)) {
createProblem(map.get(name).getPosition(),
@@ -117,6 +122,11 @@
}
}
+ private boolean isPlural(String singular, String plural) {
+ return (singular.length() == plural.length() - 1) && (singular.equals(plural.substring(0, plural.length() - 1))) &&
+ plural.charAt(plural.length() - 1) == 's';
+ }
+
private boolean isInstanceVar(String name) {
return !isClassVar(name) && name.startsWith("@");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|