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-03-14 20:24:03
|
Revision: 2172
http://svn.sourceforge.net/rubyeclipse/?rev=2172&view=rev
Author: cawilliams
Date: 2007-03-14 13:23:54 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 20:23:49
|
Revision: 2171
http://svn.sourceforge.net/rubyeclipse/?rev=2171&view=rev
Author: cawilliams
Date: 2007-03-14 13:23:48 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd
Modified: trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-03-14 20:15:38 UTC (rev 2170)
+++ trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-03-14 20:23:48 UTC (rev 2171)
@@ -54,5 +54,6 @@
org.rubypeople.rdt.launching,
org.eclipse.search,
org.jruby,
- org.eclipse.compare
+ org.eclipse.compare,
+ org.eclipse.core.expressions
Eclipse-LazyStart: true
Modified: trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd
===================================================================
--- trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd 2007-03-14 20:15:38 UTC (rev 2170)
+++ trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd 2007-03-14 20:23:48 UTC (rev 2171)
@@ -8,16 +8,14 @@
<documentation>
This extension point allows to add a Quick Fix processor to offer new Quick Fixes on Ruby problems.
<p>
-Since 3.2 an extension can specify which problem marker types it can handle. It will only get problems of these types to process.
-If no handled marker type are specified, the processor will only get problems of types org.rubypeople.rdt.core.problem, org.rubypeople.rdt.core.buildpath_problem and org.rubypeople.rdt.core.task (compatible to the behaviour prior to 3.2).
+An extension can specify which problem marker types it can handle. It will only get problems of these types to process.
+If no handled marker type are specified, the processor will only get problems of types org.rubypeople.rdt.core.problem, org.rubypeople.rdt.core.buildpath_problem and org.rubypeople.rdt.core.task.
</p>
<p>
This extension point supports the <code>enablement</code> tag. Properties to test on are:
<dl>
-<li>compilationUnit: type IRubyScript; the compilation unit the quick assist is applied on</li>
-
+<li>rubyScript: type IRubyScript; the compilation unit the quick assist is applied on</li>
<li>projectNatures: type Collection; all project natures of the current project</li>
-<li>sourceLevel: type String; the source compliance of the current project</li>
</dl>
</p>
</documentation>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 20:15:40
|
Revision: 2170
http://svn.sourceforge.net/rubyeclipse/?rev=2170&view=rev
Author: cawilliams
Date: 2007-03-14 13:15:38 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
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-03-14 20:12:39 UTC (rev 2169)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-03-14 20:15:38 UTC (rev 2170)
@@ -18,6 +18,7 @@
editorPopupExtender=Editor Popup Extender
foldingStructureProviders=Folding Structure Providers
textHoverProvider=TextHover Provider
+quickFixProcessorExtensionPoint=Quick Fix Processor
rubyDocumentFactory=Ruby Document Factory
rubyDocumentSetupParticipant=Ruby Document Setup Participant
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 20:12:42
|
Revision: 2169
http://svn.sourceforge.net/rubyeclipse/?rev=2169&view=rev
Author: cawilliams
Date: 2007-03-14 13:12:39 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
start adding stuff to allow quick fix extensions
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.xml
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IInvocationContext.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IProblemLocation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IQuickFixProcessor.java
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-03-14 17:58:05 UTC (rev 2168)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-03-14 20:12:39 UTC (rev 2169)
@@ -7,6 +7,7 @@
<extension-point id="foldingStructureProviders" name="%foldingStructureProviders" schema="schema/foldingStructureProviders.exsd"/>
<extension-point id="editorPopupExtender" name="%editorPopupExtender" schema="schema/org.rubypeople.rdt.ui.editorPopupExtender.exsd"/>
<extension-point id="rubyTemplateProvider" name="Ruby template provider" schema="schema/rubyTemplateProvider.exsd"/>
+ <extension-point id="quickFixProcessors" name="%quickFixProcessorExtensionPoint" schema="schema/quickFixProcessors.exsd"/>
<extension
point="org.eclipse.ui.preferencePages">
Added: trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd
===================================================================
--- trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd (rev 0)
+++ trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd 2007-03-14 20:12:39 UTC (rev 2169)
@@ -0,0 +1,194 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.rubypeople.rdt.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.rubypeople.rdt.ui" id="quickFixProcessors" name="Quick Fix Processor"/>
+ </appInfo>
+ <documentation>
+ This extension point allows to add a Quick Fix processor to offer new Quick Fixes on Ruby problems.
+<p>
+Since 3.2 an extension can specify which problem marker types it can handle. It will only get problems of these types to process.
+If no handled marker type are specified, the processor will only get problems of types org.rubypeople.rdt.core.problem, org.rubypeople.rdt.core.buildpath_problem and org.rubypeople.rdt.core.task (compatible to the behaviour prior to 3.2).
+</p>
+<p>
+This extension point supports the <code>enablement</code> tag. Properties to test on are:
+<dl>
+<li>compilationUnit: type IRubyScript; the compilation unit the quick assist is applied on</li>
+
+<li>projectNatures: type Collection; all project natures of the current project</li>
+<li>sourceLevel: type String; the source compliance of the current project</li>
+</dl>
+</p>
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="quickFixProcessor" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="quickFixProcessor">
+ <complexType>
+ <sequence>
+ <element ref="enablement"/>
+ <element ref="handledMarkerTypes" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ Unique identifier for the Quick Fix processor
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ Localized name of the Quick Fix processor.
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the name of the class that implements this Quick Fix processor. The
+class must be public and implement
+<samp>org.eclipse.jdt.ui.text.java.IQuickFixProcessor</samp>
+with a public 0-argument constructor.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="handledMarkerTypes">
+ <annotation>
+ <documentation>
+ Specifies the marker types of the problems this quick fix processor can handle.
+If no handled marker type are specified, the processor will get problems of types org.eclipse.jdt.core.problem, org.eclipse.jdt.core.buildpath_problem and org.eclipse.jdt.core.task.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="markerType" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="markerType">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The marker type id of the marker that can be handled by this processor
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ The following is an example of a Quick Fix processor contribution:
+
+<p>
+<pre>
+ <extension point="org.rubypeople.rdt.ui.quickFixProcessors">
+ <quickFixProcessor
+ id="AdvancedQuickFixProcessor"
+ name="Advanced Quick Fix Processor"
+ requiredSourceLevel="1.5"
+ class="com.example.AdvancedQuickFixProcessor">
+ <handledMarkerTypes>
+ <markerType id="org.eclipse.myplugin.audits"/>
+ </handledMarkerTypes>
+ <enablement>
+ <with variable="projectNatures">
+ <iterate operator="or">
+ <equals value="org.eclipse.jdt.core.javanature"/>
+ </iterate>
+ </with>
+ </enablement>
+ </quickFixProcessor>
+ </extension>
+</pre>
+</p>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ Extension point since 3.0. Element <code>handledMarkerTypes</code> since 3.2.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The contributed class must implement <code>org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor</code>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2001, 2006 IBM Corporation and others.<br>
+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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IInvocationContext.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IInvocationContext.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IInvocationContext.java 2007-03-14 20:12:39 UTC (rev 2169)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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.ui.text.ruby;
+
+import org.jruby.ast.Node;
+import org.jruby.ast.RootNode;
+import org.rubypeople.rdt.core.IRubyScript;
+
+/**
+ * Context information for quick fix and quick assist processors.
+ * <p>
+ * Note: this interface is not intended to be implemented.
+ * </p>
+ *
+ * @since 1.0.0
+ */
+public interface IInvocationContext {
+
+ /**
+ * @return Returns the current ruby script.
+ */
+ IRubyScript getRubyScript();
+
+ /**
+ * @return Returns the offset of the current selection
+ */
+ int getSelectionOffset();
+
+ /**
+ * @return Returns the length of the current selection
+ */
+ int getSelectionLength();
+
+ /**
+ * Returns an AST of the compilation unit, possibly only a partial AST focused on the selection
+ * offset (see {@link org.eclipse.jdt.core.dom.ASTParser#setFocalPosition(int)}).
+ * The returned AST is shared and therefore protected and cannot be modified.
+ * The client must check the AST API level and do nothing if they are given an AST
+ * they can't handle. (see {@link org.eclipse.jdt.core.dom.AST#apiLevel()}).
+ * @return Returns the root of the AST corresponding to the current compilation unit.
+ */
+ RootNode getASTRoot();
+
+ /**
+ * Convenience method to evaluate the AST node covering the current selection.
+ * @return Returns the node that covers the location of the problem
+ */
+ Node getCoveringNode();
+
+ /**
+ * Convenience method to evaluate the AST node that is covered by the current selection.
+ * @return Returns the node that is covered by the location of the problem
+ */
+ Node getCoveredNode();
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IProblemLocation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IProblemLocation.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IProblemLocation.java 2007-03-14 20:12:39 UTC (rev 2169)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.ui.text.ruby;
+
+import org.jruby.ast.Node;
+import org.jruby.ast.RootNode;
+
+/**
+ * Problem information for quick fix and quick assist processors.
+ * <p>
+ * Note: this interface is not intended to be implemented.
+ * </p>
+ *
+ * @since 3.0
+ */
+public interface IProblemLocation {
+
+ /**
+ * Returns the start offset of the problem.
+ *
+ * @return the start offset of the problem
+ */
+ int getOffset();
+
+ /**
+ * Returns the length of the problem.
+ *
+ * @return the length of the problem
+ */
+ int getLength();
+
+ /**
+ * Returns the marker type of this problem.
+ *
+ * @return The marker type of the problem.
+ * @since 3.2
+ */
+ String getMarkerType();
+
+ /**
+ * Returns the id of problem. Note that problem ids are defined per problem marker type.
+ * See {@link org.eclipse.jdt.core.compiler.IProblem} for id definitions for problems of type
+ * <code>org.eclipse.jdt.core.problem</code> and <code>org.eclipse.jdt.core.task</code>.
+ *
+ * @return The id of the problem.
+ */
+ int getProblemId();
+
+ /**
+ * Returns the original arguments recorded into the problem.
+ *
+ * @return String[] Returns the problem arguments.
+ */
+ String[] getProblemArguments();
+
+ /**
+ * Returns if the problem has error severity.
+ *
+ * @return <code>true</code> if the problem has error severity
+ */
+ boolean isError();
+
+ /**
+ * Convenience method to evaluate the AST node covering this problem.
+ *
+ * @param astRoot The root node of the current AST
+ * @return Returns the node that covers the location of the problem
+ */
+ Node getCoveringNode(RootNode astRoot);
+
+ /**
+ * Convenience method to evaluate the AST node covered by this problem.
+ *
+ * @param astRoot The root node of the current AST
+ * @return Returns the node that is covered by the location of the problem
+ */
+ Node getCoveredNode(RootNode astRoot);
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IQuickFixProcessor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IQuickFixProcessor.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IQuickFixProcessor.java 2007-03-14 20:12:39 UTC (rev 2169)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.ui.text.ruby;
+
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.core.IRubyScript;
+
+
+/**
+ * Interface to be implemented by contributors to the extension point
+ * <code>org.eclipse.jdt.ui.quickFixProcessors</code>.
+ * <p>Since 3.2, each extension specifies the marker types it can handle, and {@link #hasCorrections(ICompilationUnit, int)} and
+ * {@link #getCorrections(IInvocationContext, IProblemLocation[])} are called if (and only if) quick fix is
+ * required for a problem of these types.</p>
+ * <p>Note, if a extension does not specify marker types it will be only called for problem of type
+ * <code>org.eclipse.jdt.core.problem</code>, <code>org.eclipse.jdt.core.buildpath_problem</code>
+ * and <code>org.eclipse.jdt.core.task</code>; compatible with the behavior prior to 3.2</p>
+ *
+ * @since 3.0
+ */
+public interface IQuickFixProcessor {
+
+ /**
+ * Returns <code>true</code> if the processor has proposals for the given problem. This test should be an
+ * optimistic guess and be very cheap.
+ *
+ * @param unit the compilation unit
+ * @param problemId the problem Id. The id is of a problem of the problem type(s) this processor specified in
+ * the extension point.
+ * @return <code>true</code> if the processor has proposals for the given problem
+ */
+ boolean hasCorrections(IRubyScript unit, int problemId);
+
+ /**
+ * Collects corrections or code manipulations for the given context.
+ *
+ * @param context Defines current compilation unit, position and a shared AST
+ * @param locations Problems are the current location.
+ * @return the corrections applicable at the location or <code>null</code> if no proposals
+ * can be offered
+ * @throws CoreException CoreException can be thrown if the operation fails
+ */
+ IRubyCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException;
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 17:58:06
|
Revision: 2168
http://svn.sourceforge.net/rubyeclipse/?rev=2168&view=rev
Author: cawilliams
Date: 2007-03-14 10:58:05 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java 2007-03-14 17:54:55 UTC (rev 2167)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java 2007-03-14 17:58:05 UTC (rev 2168)
@@ -44,6 +44,16 @@
assertToken(IRubyColorConstants.RUBY_KEYWORD, 12, 3);
}
+ public void testMultipleCommentsInARow() {
+ String code = "# comment one\n#comment two\nclass Chris\nend\n";
+ setUpScanner(code);
+ assertToken(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT, 0, 27);
+ assertToken(IRubyColorConstants.RUBY_KEYWORD, 27, 5);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 32, 6);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 38, 1);
+ assertToken(IRubyColorConstants.RUBY_KEYWORD, 39, 3);
+ }
+
public void testCommentAfterEnd() {
String code = "class Chris\nend # comment\n";
setUpScanner(code);
@@ -54,7 +64,7 @@
assertToken(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT, 15, 10);
}
- public void testCommentAfterEndYeah() {
+ public void testCommentAfterEndWhileEditing() {
String code = "=begin\r\n" +
"c\r\n" +
"=end\r\n" +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 17:54:56
|
Revision: 2167
http://svn.sourceforge.net/rubyeclipse/?rev=2167&view=rev
Author: cawilliams
Date: 2007-03-14 10:54:55 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TS_InternalUiText.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TS_InternalUiText.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TS_InternalUiText.java 2007-03-14 17:51:01 UTC (rev 2166)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TS_InternalUiText.java 2007-03-14 17:54:55 UTC (rev 2167)
@@ -3,12 +3,15 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.rubypeople.rdt.internal.ui.text.ruby.TC_RubyTokenScanner;
+
public class TS_InternalUiText {
public static Test suite() {
TestSuite suite = new TestSuite("org.rubypeople.rdt.internal.ui.text");
suite.addTestSuite(TC_RubyPartitionScanner.class);
suite.addTestSuite(RubyPartitionScannerTest.class);
suite.addTestSuite(TC_RubyWordFinder.class);
+ suite.addTestSuite(TC_RubyTokenScanner.class);
return suite;
}
}
Added: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/TC_RubyTokenScanner.java 2007-03-14 17:54:55 UTC (rev 2167)
@@ -0,0 +1,72 @@
+package org.rubypeople.rdt.internal.ui.text.ruby;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.rules.IToken;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.IRubyColorConstants;
+import org.rubypeople.rdt.internal.ui.text.RubyColorManager;
+
+public class TC_RubyTokenScanner extends TestCase {
+
+ private RubyTokenScanner fScanner;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ RubyColorManager colorManager = new RubyColorManager(false);
+ fScanner = new RubyTokenScanner(colorManager, RubyPlugin.getDefault().getPreferenceStore());
+ }
+
+ private void setUpScanner(String code) {
+ setUpScanner(code, 0, code.length());
+ }
+
+ private void setUpScanner(String code, int offset, int length) {
+ Document doc = new Document(code);
+ fScanner.setRange(doc, offset, length);
+ }
+
+ private void assertToken(String color, int offset, int length) {
+ IToken token = fScanner.nextToken();
+ assertEquals("Offsets don't match", offset, fScanner.getTokenOffset());
+ assertEquals("Lengths don't match", length, fScanner.getTokenLength());
+ assertEquals("Colors don't match", fScanner.getToken(color), token);
+ }
+
+ public void testSimpleClassDefinition() {
+ String code = "class Chris\nend\n";
+ setUpScanner(code);
+ assertToken(IRubyColorConstants.RUBY_KEYWORD, 0, 5);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 5, 6);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 11, 1);
+ assertToken(IRubyColorConstants.RUBY_KEYWORD, 12, 3);
+ }
+
+ public void testCommentAfterEnd() {
+ String code = "class Chris\nend # comment\n";
+ setUpScanner(code);
+ assertToken(IRubyColorConstants.RUBY_KEYWORD, 0, 5);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 5, 6);
+ assertToken(IRubyColorConstants.RUBY_DEFAULT, 11, 1);
+ assertToken(IRubyColorConstants.RUBY_KEYWORD, 12, 3);
+ assertToken(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT, 15, 10);
+ }
+
+ public void testCommentAfterEndYeah() {
+ String code = "=begin\r\n" +
+"c\r\n" +
+"=end\r\n" +
+"#hmm\r\n" +
+"#comment here why is ths\r\n" +
+"class Chris\r\n" +
+" def thing\r\n" +
+" end #ocmm \r\n" +
+"end";
+ setUpScanner(code, 75, 14);
+ assertToken(IRubyColorConstants.RUBY_KEYWORD, 75, 5);
+ assertToken(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT, 80, 7);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 17:51:02
|
Revision: 2166
http://svn.sourceforge.net/rubyeclipse/?rev=2166&view=rev
Author: cawilliams
Date: 2007-03-14 10:51:01 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/ruby/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 17:49:32
|
Revision: 2165
http://svn.sourceforge.net/rubyeclipse/?rev=2165&view=rev
Author: cawilliams
Date: 2007-03-14 10:49:30 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
fix some odd behavior when multiple lines of comments follow one after the other. Also handle comments at end of file
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TC_RubyPartitionScanner.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java 2007-03-14 15:45:09 UTC (rev 2164)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java 2007-03-14 17:49:30 UTC (rev 2165)
@@ -153,7 +153,7 @@
}
}
- protected Token getToken(String key) {
+ public Token getToken(String key) {
if (fNeedsLazyColorLoading) resolveProxyAttributes();
return (Token) fTokenMap.get(key);
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-14 15:45:09 UTC (rev 2164)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-14 17:49:30 UTC (rev 2165)
@@ -109,8 +109,14 @@
}
List comments = result.getCommentNodes();
if (comments != null && !comments.isEmpty()) {
- CommentNode comment = (CommentNode) comments.remove(comments.size() - 1); // Grab last comment
- tokenLength = comment.getContent().length() + 1;
+ CommentNode comment;
+ while (!comments.isEmpty()) {
+ comment = (CommentNode) comments.remove(0);
+ // Grab comment and add it's length to our running tally
+ tokenLength += comment.getContent().length() + 1;
+ }
+ // FIXME What if we have two lines of comments in a row?
+// tokenLength = comment.getContent().length() + 1;
fSavedToken = returnValue;
fSavedOffset = oldOffset + tokenLength;
if (!isEOF) fSavedLength = getOffset() - fSavedOffset;
@@ -138,7 +144,7 @@
}
@Override
- protected Token getToken(String key) {
+ public Token getToken(String key) {
if (isInRegexp)
return super.getToken(IRubyColorConstants.RUBY_REGEXP);
if (isInString)
@@ -186,6 +192,10 @@
lexer.reset();
lexer.setState(LexState.EXPR_BEG);
parserSupport.initTopLocalVariables();
+ lastWasComment = false;
+ fSavedLength = -1;
+ fSavedToken = null;
+ fSavedOffset = -1;
if (offset == 0) {
isInRegexp = false;
isInString = false;
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TC_RubyPartitionScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TC_RubyPartitionScanner.java 2007-03-14 15:45:09 UTC (rev 2164)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TC_RubyPartitionScanner.java 2007-03-14 17:49:30 UTC (rev 2165)
@@ -29,14 +29,6 @@
assert(true);
}
- public void testPartitioningOfSingleLineComment() {
- String source = "# This is a comment\n";
-
- assertEquals(RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT, this.getContentType(source, 0));
- assertEquals(RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT, this.getContentType(source, 1));
- assertEquals(RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT, this.getContentType(source, 18));
- }
-
public void testRecognizeSpecialCase() {
String source = "a,b=?#,'This is not a comment!'\n";
@@ -67,90 +59,5 @@
assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 2));
assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 10));
}
-
- public void testHereDocWithSpacesOK() {
- String source = "puts <<-TEST\nMyName\n\tTEST\nputs 'ab'";
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 5));
-
- source = "puts <<-TEST\nMyName\n TEST\nputs 'ab'";
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 5));
-
- source = "puts <<-'ax%&'\nMyName\n ax%&";
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 5));
- }
- public void testHereDocOK() {
- String source = "puts <<TEST\nMyName\nTEST";
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 5));
-
- source = "puts <<-TEST\nMyName\nTEST\nputs 'ab'";
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 5));
-
- source = "puts <<\"TEST\"\nMyName\nTEST";
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 5));
-
- source = "puts <<'TEST'\nMyName\nTEST";
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 5));
-
- source = "puts <<-'ax%&'\nMyName\nax%&";
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 5));
-
- }
-
- public void testNoHereDoc() {
-
- // space after <<
- String source = "puts << 'abc'";
-
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 5));
- // normaler String
- assertEquals(RubyPartitionScanner.RUBY_STRING, this.getContentType(source, 9));
-
- // end not on first column
- source = "puts <<HERE\n HERE" ;
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 5));
-
- source = "puts <<-"; // whatever that means in ruby
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 5));
-
- // recognize keyword end although there is no matching HERE
- // this assures that there are no tokens eaten
- source = "puts <<HERE\nend\n" ;
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 14));
-
- source = "puts <<'abc'\ntest" ;
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 6));
-
- source = "puts <<'abc'\ntest\nabd" ;
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 6));
- }
-
- public void testRecognizeDivision() {
- String source = "1/3 #This is a comment\n";
-
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 0));
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 3));
- assertEquals(RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT, this.getContentType(source, 5));
- }
-
- public void testRecognizeOddballCharacters() {
- String source = "?\" #comment\n";
-
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 0));
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 2));
- assertEquals(RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT, this.getContentType(source, 5));
-
- source = "?' #comment\n";
-
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 0));
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 2));
- assertEquals(RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT, this.getContentType(source, 5));
-
- source = "?/ #comment\n";
-
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 0));
- assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 2));
- assertEquals(RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT, this.getContentType(source, 5));
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 15:45:13
|
Revision: 2164
http://svn.sourceforge.net/rubyeclipse/?rev=2164&view=rev
Author: cawilliams
Date: 2007-03-14 08:45:09 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/NumberSignDetector.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/GlobalDetector.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/IdentifierDetector.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/InstanceVariableDetector.java
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/NumberSignDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/NumberSignDetector.java 2007-03-14 14:58:09 UTC (rev 2163)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/NumberSignDetector.java 2007-03-14 15:45:09 UTC (rev 2164)
@@ -1,18 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text;
-
-import org.eclipse.jface.text.rules.IWordDetector;
-
-public class NumberSignDetector implements IWordDetector {
-
- public NumberSignDetector() {
- super();
- }
-
- public boolean isWordStart(char c) {
- return isWordPart(c) ;
- }
-
- public boolean isWordPart(char c) {
- return '#' == c;
- }
-}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2007-03-14 14:58:09 UTC (rev 2163)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2007-03-14 15:45:09 UTC (rev 2164)
@@ -5,7 +5,6 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
-import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IPartitionTokenScanner;
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IRule;
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/GlobalDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/GlobalDetector.java 2007-03-14 14:58:09 UTC (rev 2163)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/GlobalDetector.java 2007-03-14 15:45:09 UTC (rev 2164)
@@ -1,9 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-public class GlobalDetector extends IdentifierDetector {
-
- public boolean isWordStart(char c) {
- return c == '$';
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/IdentifierDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/IdentifierDetector.java 2007-03-14 14:58:09 UTC (rev 2163)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/IdentifierDetector.java 2007-03-14 15:45:09 UTC (rev 2164)
@@ -1,20 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-import org.eclipse.jface.text.rules.IWordDetector;
-
-
-public class IdentifierDetector implements IWordDetector {
-
- public boolean isWordStart(char c) {
- if (c == '_') return true;
- return Character.isLetter(c);
- }
-
- public boolean isWordPart(char c) {
- if (c == '_') return true;
- if (Character.isWhitespace(c)) return false;
- if (Character.isDigit(c)) return true;
- return Character.isLetter(c);
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/InstanceVariableDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/InstanceVariableDetector.java 2007-03-14 14:58:09 UTC (rev 2163)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/InstanceVariableDetector.java 2007-03-14 15:45:09 UTC (rev 2164)
@@ -1,9 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-public class InstanceVariableDetector extends IdentifierDetector {
-
- public boolean isWordStart(char c) {
- return c == '@';
- }
-
-}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-14 14:58:09 UTC (rev 2163)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-14 15:45:09 UTC (rev 2164)
@@ -112,8 +112,9 @@
CommentNode comment = (CommentNode) comments.remove(comments.size() - 1); // Grab last comment
tokenLength = comment.getContent().length() + 1;
fSavedToken = returnValue;
- fSavedOffset = comment.getPosition().getEndOffset();
- fSavedLength = lexerSource.getOffset() - fSavedOffset;
+ fSavedOffset = oldOffset + tokenLength;
+ if (!isEOF) fSavedLength = getOffset() - fSavedOffset;
+ else fSavedLength = 0;
lastWasComment = true;
return getToken(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 14:58:12
|
Revision: 2163
http://svn.sourceforge.net/rubyeclipse/?rev=2163&view=rev
Author: cawilliams
Date: 2007-03-14 07:58:09 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Merge over changes from syntax branch r2078:HEAD into trunk
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyColorConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubyTextTools.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/HereDocPatternRule.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/PercentSyntaxRule.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/CharacterRule.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCodeScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyNumberRule.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleCharacterPrefixRule.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleTokenRubyCodeScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SymbolRule.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -286,7 +286,11 @@
store.setDefault(RUBY_DEFAULT + PreferenceConstants.EDITOR_ITALIC_SUFFIX, false);
PreferenceConverter.setDefault(store, RUBY_KEYWORD, new RGB(164, 53, 122));
store.setDefault(RUBY_KEYWORD + PreferenceConstants.EDITOR_BOLD_SUFFIX, true);
- store.setDefault(RUBY_KEYWORD + PreferenceConstants.EDITOR_ITALIC_SUFFIX, false);
+ store.setDefault(RUBY_KEYWORD + PreferenceConstants.EDITOR_ITALIC_SUFFIX, false);
+ PreferenceConverter.setDefault(store, RUBY_ERROR, new RGB(255, 255, 255));
+ store.setDefault(RUBY_ERROR + PreferenceConstants.EDITOR_BOLD_SUFFIX, true);
+ store.setDefault(RUBY_ERROR + PreferenceConstants.EDITOR_ITALIC_SUFFIX, false);
+ PreferenceConverter.setDefault(store, RUBY_ERROR + PreferenceConstants.EDITOR_BG_SUFFIX, new RGB(255, 0, 0));
PreferenceConverter.setDefault(store, RUBY_STRING, new RGB(42, 0, 255));
store.setDefault(RUBY_STRING + PreferenceConstants.EDITOR_BOLD_SUFFIX, false);
store.setDefault(RUBY_STRING + PreferenceConstants.EDITOR_ITALIC_SUFFIX, false);
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/HereDocPatternRule.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/HereDocPatternRule.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/HereDocPatternRule.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -1,96 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text;
-
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.PatternRule;
-
-public class HereDocPatternRule extends PatternRule {
-
- public HereDocPatternRule(IToken token) {
- // TODO: escape char OK?
- // FIXME We need to only handle exact cases, not <<=
-
- // Correct cases:
- // (http://www.zenspider.com/Languages/Ruby/QuickRef.html#8)
- // <<identifier - interpolated, goes until identifier
- // <<"identifier" - same thing
- // <<'identifier' - no interpolation
- // <<-identifier - you can indent the identifier by using "-" in front
- super("<<", "", token, (char) -1, false, false);
- }
-
- protected boolean endSequenceDetected(ICharacterScanner scanner) {
- char firstChar = (char) scanner.read();
-
- if (Character.isWhitespace(firstChar)) { return false; }
-
- boolean indentedKeyword = false;
- if (firstChar == '-') {
- indentedKeyword = true;
- firstChar = (char) scanner.read();
- }
- boolean isQuoted = false;
- char quote = ' ';
- if (firstChar == '\'' || firstChar == '"') {
- isQuoted = true;
- quote = firstChar;
- firstChar = (char) scanner.read();
- }
- String keyword = readKeyword(scanner, firstChar);
- if (keyword.length() == 0) { return false; }
- if (isQuoted && !(keyword.charAt(keyword.length() - 1) == quote)) { return false; }
- if (isQuoted) {
- fEndSequence = removeEndQuote(keyword).toCharArray();
- } else {
- fEndSequence = keyword.toCharArray();
- }
- boolean result = super.endSequenceDetected(scanner);
- if (!result) { return false; }
-
- if(indentedKeyword) {
- rewindToBeginOfLine(scanner);
- char lastChar;
- do {
- lastChar = (char) scanner.read();
- }
- while(Character.isWhitespace(lastChar));
-
- String newKeyword = readKeyword(scanner, lastChar);
-
- if(isQuoted)
- return removeEndQuote(keyword).equals(newKeyword);
- else
- return keyword.equals(newKeyword);
-
- } else {
- return scanner.getColumn() == fEndSequence.length;
- }
- }
-
- private String removeEndQuote(String keyword) {
- return keyword.substring(0, keyword.length() - 1);
- }
-
- private void rewindToBeginOfLine(ICharacterScanner scanner) {
- char readChar = 0;
- while (readChar != '\n') {
- scanner.unread();
- scanner.unread();
- readChar = (char) scanner.read();
- }
- }
-
- private String readKeyword(ICharacterScanner scanner, char firstChar) {
- String keyword = "";
- char c = firstChar;
- do {
- if ((byte) c == ICharacterScanner.EOF || Character.isWhitespace(c)) {
- break;
- }
- keyword += c;
- c = (char) scanner.read();
- } while (true);
- return keyword;
- }
-
-}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyColorConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyColorConstants.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyColorConstants.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -4,6 +4,7 @@
public static final String RUBY_COLOR_PREFIX = "color_ruby_";
public static final String RUBY_DEFAULT = RUBY_COLOR_PREFIX + "default";
public static final String RUBY_KEYWORD = RUBY_COLOR_PREFIX + "keyword";
+ public static final String RUBY_ERROR = RUBY_COLOR_PREFIX + "error";
public static final String RUBY_STRING = RUBY_COLOR_PREFIX + "string";
public static final String RUBY_REGEXP = RUBY_COLOR_PREFIX + "regexp";
public static final String RUBY_COMMAND = RUBY_COLOR_PREFIX + "command";
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/PercentSyntaxRule.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/PercentSyntaxRule.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/PercentSyntaxRule.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -1,127 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text;
-
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-
-public class PercentSyntaxRule implements IRule {
-
- public IToken evaluate(ICharacterScanner scanner) {
- int c = scanner.read();
- if (((char) c) == '%') {
- c = scanner.read(); // get next char
- switch ((char) c) {
- case 'r': // regular expression
- return detectToken(scanner, IRubyPartitions.RUBY_REGEX);
- case 'x': // commands
- return detectToken(scanner, IRubyPartitions.RUBY_COMMAND);
- case 'q':
- case 'Q': // strings
- return detectToken(scanner, IRubyPartitions.RUBY_STRING);
- case 'w':
- case 'W': // Array of strings
- scanner.unread();
- scanner.unread();
- // FIXME Mark the individual elements as strings
- return Token.UNDEFINED;
- default: // special case of string (no letter following percent)
- scanner.unread();
- return detectToken(scanner, IRubyPartitions.RUBY_STRING);
- }
- }
- scanner.unread();
- return Token.UNDEFINED;
- }
-
- private IToken detectToken(ICharacterScanner scanner, String tokenType) {
- int c = scanner.read(); // get delimeter
- int lastChar = c;
- char endChar = getMatchingBracket((char) c);
- // Read until EOF, End character or EOL
- while (true) {
- c = scanner.read();
- // FIXME This is a big hack. Expression substitution actually needs to be returned as normal ruby code (and repartitioned)
- if ((char) c == '#') { // Try to handle expression substitution
- int d = scanner.read();
- if ((char) d == '{') {
- // read until '}'
- do {
- d = scanner.read();
- if (d == ICharacterScanner.EOF) {
- return new Token(tokenType);
- }
- } while ((char) d != '}');
- continue;
- } else if ((char) d == '@' || (char) d == '$') {
- // read until whitespace
- do {
- d = scanner.read();
- } while ((char) d != ' ');
- continue;
- } else {// not expression subst.
- scanner.unread();
- }
- }
-
- // TODO Stop at EOL,char[][] originalDelimiters=
- // scanner.getLegalLineDelimiters();
- if (c == ICharacterScanner.EOF)
- break; // we're done
- if ((char) c == endChar && ((char) lastChar != '\\'))
- break; // we found matching bracket
- lastChar = c;
- }
- return new Token(tokenType);
- }
-
- /**
- * Returns whether the next characters to be read by the character scanner
- * are an exact match with the given sequence. No escape characters are
- * allowed within the sequence. If specified the sequence is considered to
- * be found when reading the EOF character.
- *
- * @param scanner
- * the character scanner to be used
- * @param sequence
- * the sequence to be detected
- * @param eofAllowed
- * indicated whether EOF terminates the pattern
- * @return <code>true</code> if the given sequence has been detected
- */
- protected boolean sequenceDetected(ICharacterScanner scanner,
- char[] sequence, boolean eofAllowed) {
- for (int i = 1; i < sequence.length; i++) {
- int c = scanner.read();
- if (c == ICharacterScanner.EOF && eofAllowed) {
- return true;
- } else if (c != sequence[i]) {
- // Non-matching character detected, rewind the scanner back to
- // the start.
- // Do not unread the first character.
- scanner.unread();
- for (int j = i - 1; j > 0; j--)
- scanner.unread();
- return false;
- }
- }
-
- return true;
- }
-
- private char getMatchingBracket(char c) {
- switch (c) {
- case '(':
- return ')';
- case '{':
- return '}';
- case '[':
- return ']';
- case '<':
- return '>';
- default:
- return c;
- }
- }
-
-}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -10,11 +10,7 @@
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.IWordDetector;
-import org.eclipse.jface.text.rules.PatternRule;
-import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WordPatternRule;
public class RubyPartitionScanner extends BufferedRuleBasedScanner implements
IPartitionTokenScanner {
@@ -25,16 +21,11 @@
/** The offset of the partition inside which to resume. */
protected int fPartitionOffset;
- public final static String RUBY_STRING = IRubyPartitions.RUBY_STRING;
public final static String RUBY_MULTI_LINE_COMMENT = IRubyPartitions.RUBY_MULTI_LINE_COMMENT;
- public static final String RUBY_SINGLE_LINE_COMMENT = IRubyPartitions.RUBY_SINGLE_LINE_COMMENT;
- public static final String RUBY_REGULAR_EXPRESSION = IRubyPartitions.RUBY_REGEX;
- public static final String RUBY_COMMAND = IRubyPartitions.RUBY_COMMAND;
- public static final String HERE_DOC = "partition_scanner_here_doc";
- public static final String[] LEGAL_CONTENT_TYPES = { RUBY_STRING,
- RUBY_MULTI_LINE_COMMENT, RUBY_SINGLE_LINE_COMMENT,
- RUBY_REGULAR_EXPRESSION, RUBY_COMMAND };
+ public static final String[] LEGAL_CONTENT_TYPES = {
+ RUBY_MULTI_LINE_COMMENT
+ };
public RubyPartitionScanner() {
super();
@@ -42,79 +33,10 @@
}
protected void initialize() {
- IToken string = new Token(RUBY_STRING);
IToken multiLineComment = new Token(RUBY_MULTI_LINE_COMMENT);
- IToken singleLineComment = new Token(RUBY_SINGLE_LINE_COMMENT);
- IToken regexp = new Token(RUBY_REGULAR_EXPRESSION);
- IToken command = new Token(RUBY_COMMAND);
- IToken hereDoc = new Token(RUBY_STRING);
List rules = new ArrayList();
-
- // TODO Fix this to be able to recognize variable substitution inside
- // strings (and therefore have quotes inside them which don't end the
- // partition)
-
- // Strings
- rules.add(new PatternRule("\"", "\"", string, '\\', false, false));
- rules.add(new PatternRule("'", "'", string, '\\', false, false));
-
- // Regular expressions
- // TODO Work with options: 's', 'u', 'e', 'n', 'x', 'm', 'o', 'i'
- rules.add(new SingleLineRule("/", "/", regexp, '\\'));
-
- // Commands
- rules.add(new SingleLineRule("`", "`", command, '\\'));
-
- // Catch all the wacky Percent Syntax (Strings/commands/regexps)
- rules.add(new PercentSyntaxRule());
-
- // Single line comments
- // ?# evaluates to the ascii value of #
- rules.add(new WordPatternRule(new NumberSignDetector(), "?", "#",
- Token.UNDEFINED));
- // ugly hacks to make ?" and ?' recognized as characters
- rules.add(new WordPatternRule(new IWordDetector() {
-
- public boolean isWordPart(char c) {
- return c == '"';
- }
-
- public boolean isWordStart(char c) {
- return c == '?';
- }
-
- }, "?", "\"", Token.UNDEFINED));
- rules.add(new WordPatternRule(new IWordDetector() {
-
- public boolean isWordPart(char c) {
- return c == '\'';
- }
-
- public boolean isWordStart(char c) {
- return c == '?';
- }
-
- }, "?", "'", Token.UNDEFINED));
- rules.add(new WordPatternRule(new IWordDetector() {
-
- public boolean isWordPart(char c) {
- return c == '/';
- }
-
- public boolean isWordStart(char c) {
- return c == '?';
- }
-
- }, "?", "/", Token.UNDEFINED));
-
- rules.add(new EndOfLineRule("#", singleLineComment));
rules.add(new DocumentationCommentRule(multiLineComment));
- rules.add(new HereDocPatternRule(hereDoc));
-
- // FIXME Create Hyrbid of RuleBasedPartitionScanner which allows IRule
- // or IPredicateRule and will only evaluate IPredicateRules if success
- // token matches content type
IRule[] result = new IRule[rules.size()];
rules.toArray(result);
setRules(result);
Copied: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java (from rev 2162, branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java)
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyTokenScanner.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -0,0 +1,296 @@
+package org.rubypeople.rdt.internal.ui.text.ruby;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.StringConverter;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.ITokenScanner;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.text.IColorManager;
+import org.rubypeople.rdt.ui.text.IColorManagerExtension;
+
+public abstract class AbstractRubyTokenScanner implements ITokenScanner {
+
+ private String[] fPropertyNamesColor;
+ private String[] fPropertyNamesBgColor;
+ private String[] fPropertyNamesBold;
+ private String[] fPropertyNamesItalic;
+ private String[] fPropertyNamesStrikethrough;
+ private String[] fPropertyNamesUnderline;
+ private IColorManager fColorManager;
+ private IPreferenceStore fPreferenceStore;
+ private boolean fNeedsLazyColorLoading;
+ private Map fTokenMap = new HashMap();
+
+ /**
+ * Creates an abstract Ruby scanner.
+ */
+ public AbstractRubyTokenScanner(IColorManager manager, IPreferenceStore store) {
+ super();
+ fColorManager = manager;
+ fPreferenceStore = store;
+ }
+
+ /**
+ * Returns the preference store.
+ *
+ * @return the preference store.
+ *
+ * @since 3.0
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ return fPreferenceStore;
+ }
+
+ /**
+ * Returns an array of preference keys which define the tokens used in the
+ * rules of this scanner.
+ * <p>
+ * The preference key is used access the color in the preference store and
+ * in the color manager.
+ * </p>
+ * <p>
+ * Preference key +{@link PreferenceConstants#EDITOR_BOLD_SUFFIX}is used
+ * to retrieve whether the token is rendered in bold.
+ * </p>
+ * <p>
+ * Preference key +{@link PreferenceConstants#EDITOR_ITALIC_SUFFIX}is used
+ * to retrieve whether the token is rendered in italic.
+ * </p>
+ */
+ abstract protected String[] getTokenProperties();
+
+ public final void initialize() {
+ fPropertyNamesColor = getTokenProperties();
+ int length = fPropertyNamesColor.length;
+ fPropertyNamesBgColor = new String[length];
+ fPropertyNamesBold = new String[length];
+ fPropertyNamesItalic = new String[length];
+ fPropertyNamesStrikethrough = new String[length];
+ fPropertyNamesUnderline = new String[length];
+
+ for (int i= 0; i < length; i++) {
+ fPropertyNamesBgColor[i]= getBGKey(fPropertyNamesColor[i]);
+ fPropertyNamesBold[i]= getBoldKey(fPropertyNamesColor[i]);
+ fPropertyNamesItalic[i]= getItalicKey(fPropertyNamesColor[i]);
+ fPropertyNamesStrikethrough[i]= getStrikethroughKey(fPropertyNamesColor[i]);
+ fPropertyNamesUnderline[i]= getUnderlineKey(fPropertyNamesColor[i]);
+ }
+
+ fNeedsLazyColorLoading = Display.getCurrent() == null;
+ for (int i = 0; i < length; i++) {
+ if (fNeedsLazyColorLoading)
+ addTokenWithProxyAttribute(fPropertyNamesColor[i], fPropertyNamesBgColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]);
+ else
+ addToken(fPropertyNamesColor[i], fPropertyNamesBgColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]);
+ }
+ }
+
+ protected String getBoldKey(String colorKey) {
+ return colorKey + PreferenceConstants.EDITOR_BOLD_SUFFIX;
+ }
+
+ protected String getBGKey(String colorKey) {
+ return colorKey + PreferenceConstants.EDITOR_BG_SUFFIX;
+ }
+
+ protected String getItalicKey(String colorKey) {
+ return colorKey + PreferenceConstants.EDITOR_ITALIC_SUFFIX;
+ }
+
+ protected String getStrikethroughKey(String colorKey) {
+ return colorKey + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
+ }
+
+ protected String getUnderlineKey(String colorKey) {
+ return colorKey + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
+ }
+
+ private void addTokenWithProxyAttribute(String colorKey, String bgColorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
+ fTokenMap.put(colorKey, new Token(createTextAttribute(null, null, boldKey, italicKey, strikethroughKey, underlineKey)));
+ }
+
+ private void resolveProxyAttributes() {
+ if (fNeedsLazyColorLoading && Display.getCurrent() != null) {
+ for (int i = 0; i < fPropertyNamesColor.length; i++) {
+ addToken(fPropertyNamesColor[i], fPropertyNamesBgColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]);
+ }
+ fNeedsLazyColorLoading = false;
+ }
+ }
+
+ private void addToken(String colorKey, String bgColorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
+ bindColor(colorKey);
+ bindColor(bgColorKey);
+
+ if (!fNeedsLazyColorLoading)
+ fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, bgColorKey, boldKey, italicKey, strikethroughKey, underlineKey)));
+ else {
+ Token token = ((Token) fTokenMap.get(colorKey));
+ if (token != null) token.setData(createTextAttribute(colorKey, bgColorKey, boldKey, italicKey, strikethroughKey, underlineKey));
+ }
+ }
+
+ private void bindColor(String colorKey) {
+ if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) {
+ RGB rgb = PreferenceConverter.getColor(fPreferenceStore, colorKey);
+ if (rgb == PreferenceConverter.COLOR_DEFAULT_DEFAULT) return;
+
+ if (fColorManager instanceof IColorManagerExtension) {
+ IColorManagerExtension ext = (IColorManagerExtension) fColorManager;
+ ext.unbindColor(colorKey);
+ ext.bindColor(colorKey, rgb);
+ }
+ }
+ }
+
+ protected Token getToken(String key) {
+ if (fNeedsLazyColorLoading) resolveProxyAttributes();
+ return (Token) fTokenMap.get(key);
+ }
+
+ /**
+ * Create a text attribute based on the given color, bold and italic
+ * preference keys.
+ *
+ * @param colorKey
+ * the color preference key
+ * @param colorKey
+ * the color preference key
+ * @param boldKey
+ * the bold preference key
+ * @param italicKey
+ * the italic preference key
+ * @param strikethroughKey
+ * the strikethrough preference key
+ * @param underlineKey
+ * the underline preference key
+ * @return the created text attribute
+ * @since 0.9.0
+ */
+ private TextAttribute createTextAttribute(String colorKey, String bgColorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
+ Color color= null;
+ if (colorKey != null)
+ color= fColorManager.getColor(colorKey);
+
+ Color bgColor= null;
+ if (bgColorKey != null)
+ bgColor= fColorManager.getColor(bgColorKey);
+
+ int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
+ if (fPreferenceStore.getBoolean(italicKey))
+ style |= SWT.ITALIC;
+
+ if (fPreferenceStore.getBoolean(strikethroughKey))
+ style |= TextAttribute.STRIKETHROUGH;
+
+ if (fPreferenceStore.getBoolean(underlineKey))
+ style |= TextAttribute.UNDERLINE;
+
+ return new TextAttribute(color, bgColor, style);
+ }
+
+ public boolean affectsBehavior(PropertyChangeEvent event) {
+ return indexOf(event.getProperty()) >= 0;
+ }
+
+ public void adaptToPreferenceChange(PropertyChangeEvent event) {
+ // New
+ String p = event.getProperty();
+ int index = indexOf(p);
+ Token token = getToken(fPropertyNamesColor[index]);
+ if (fPropertyNamesColor[index].equals(p))
+ adaptToColorChange(token, event);
+ if (fPropertyNamesBgColor[index].equals(p))
+ adaptToBgColorChange(token, event);
+ else if (fPropertyNamesBold[index].equals(p))
+ adaptToStyleChange(token, event, SWT.BOLD);
+ else if (fPropertyNamesItalic[index].equals(p))
+ adaptToStyleChange(token, event, SWT.ITALIC);
+ else if (fPropertyNamesStrikethrough[index].equals(p))
+ adaptToStyleChange(token, event, TextAttribute.STRIKETHROUGH);
+ else if (fPropertyNamesUnderline[index].equals(p))
+ adaptToStyleChange(token, event, TextAttribute.UNDERLINE);
+ }
+
+ private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) {
+ boolean eventValue = false;
+ Object value = event.getNewValue();
+ if (value instanceof Boolean)
+ eventValue = ((Boolean) value).booleanValue();
+ else if (IPreferenceStore.TRUE.equals(value)) eventValue = true;
+
+ Object data = token.getData();
+ if (data instanceof TextAttribute) {
+ TextAttribute oldAttr = (TextAttribute) data;
+ boolean activeValue = (oldAttr.getStyle() & styleAttribute) == styleAttribute;
+ if (activeValue != eventValue) token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
+ }
+ }
+
+ private void adaptToColorChange(Token token, PropertyChangeEvent event) {
+ adaptToSomeColorChange(token, event, true);
+ }
+
+ private void adaptToBgColorChange(Token token, PropertyChangeEvent event) {
+ adaptToSomeColorChange(token, event, false);
+ }
+
+ private void adaptToSomeColorChange(Token token, PropertyChangeEvent event, boolean isForeground) {
+ RGB rgb = null;
+
+ Object value = event.getNewValue();
+ if (value instanceof RGB)
+ rgb = (RGB) value;
+ else if (value instanceof String) rgb = StringConverter.asRGB((String) value);
+
+ if (rgb != null) {
+
+ String property = event.getProperty();
+ Color color = fColorManager.getColor(property);
+
+ if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) {
+ IColorManagerExtension ext = (IColorManagerExtension) fColorManager;
+
+ ext.unbindColor(property);
+ ext.bindColor(property, rgb);
+
+ color = fColorManager.getColor(property);
+ }
+
+ Object data = token.getData();
+ if (data instanceof TextAttribute) {
+ TextAttribute oldAttr = (TextAttribute) data;
+ Color foreGround;
+ Color backGround;
+ if (!isForeground) {
+ foreGround = oldAttr.getForeground();
+ backGround = color;
+ } else {
+ foreGround = color;
+ backGround = oldAttr.getBackground();
+ }
+ token.setData(new TextAttribute(foreGround, backGround, oldAttr.getStyle()));
+ }
+ }
+ }
+
+ private int indexOf(String property) {
+ if (property != null) {
+ int length = fPropertyNamesColor.length;
+ for (int i = 0; i < length; i++) {
+ if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBgColor[i]) || property.equals(fPropertyNamesBold[i]) || property.equals(fPropertyNamesItalic[i]) || property.equals(fPropertyNamesStrikethrough[i]) || property.equals(fPropertyNamesUnderline[i])) return i;
+ }
+ }
+ return -1;
+ }
+}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/CharacterRule.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/CharacterRule.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/CharacterRule.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -1,20 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-import org.eclipse.jface.text.rules.IToken;
-
-public class CharacterRule extends SingleCharacterPrefixRule {
-
- private static final char PREFIX = '?';
- private static final int WORD_LENGTH = 2;
-
- /**
- * Creates a rule which will return the specified token when a character
- * sequence is detected.
- *
- * @param token
- * the token to be returned
- */
- public CharacterRule(IToken token) {
- super(PREFIX, token, WORD_LENGTH, 2);
- }
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCodeScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCodeScanner.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCodeScanner.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -1,81 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.IWordDetector;
-import org.eclipse.jface.text.rules.WordRule;
-import org.rubypeople.rdt.internal.ui.text.IRubyColorConstants;
-import org.rubypeople.rdt.internal.ui.text.RubyWordDetector;
-import org.rubypeople.rdt.ui.text.IColorManager;
-import org.rubypeople.rdt.ui.text.RubyTextTools;
-
-public class RubyCodeScanner extends AbstractRubyScanner {
-
- protected String[] keywords;
-
- private static String[] fgTokenProperties = { IRubyColorConstants.RUBY_KEYWORD,
- IRubyColorConstants.RUBY_DEFAULT, IRubyColorConstants.RUBY_FIXNUM,
- IRubyColorConstants.RUBY_CHARACTER, IRubyColorConstants.RUBY_SYMBOL,
- IRubyColorConstants.RUBY_INSTANCE_VARIABLE, IRubyColorConstants.RUBY_GLOBAL
- // TODO Add Ability to set colors for return and operators
- // IRubyColorConstants.RUBY_METHOD_NAME,
- // IRubyColorConstants.RUBY_KEYWORD_RETURN,
- // IRubyColorConstants.RUBY_OPERATOR
- };
-
- /**
- * Creates a Ruby code scanner
- *
- * @param manager
- * the color manager
- * @param store
- * the preference store
- */
- public RubyCodeScanner(IColorManager manager, IPreferenceStore store) {
- super(manager, store);
- initialize();
- }
-
- /*
- * @see AbstractRubyScanner#getTokenProperties()
- */
- protected String[] getTokenProperties() {
- return fgTokenProperties;
- }
-
- protected List createRules() {
- List rules = new ArrayList();
-
- rules.add(new CharacterRule(getToken(IRubyColorConstants.RUBY_CHARACTER)));
-
- IToken fixnumToken = getToken(IRubyColorConstants.RUBY_FIXNUM);
- rules.add(new RubyNumberRule(fixnumToken));
-
- rules.add(new SymbolRule(getToken(IRubyColorConstants.RUBY_SYMBOL)));
-
- //rules.add(new ClassVariableRule(getToken(IRubyColorConstants.RUBY_CLASS_VARIABLE)));
-
- IToken defToken = getToken(IRubyColorConstants.RUBY_DEFAULT);
- setDefaultReturnToken(getToken(IRubyColorConstants.RUBY_DEFAULT));
-
- IWordDetector instanceVarDetector = new InstanceVariableDetector();
- WordRule instanceVarRule = new WordRule(instanceVarDetector, getToken(IRubyColorConstants.RUBY_INSTANCE_VARIABLE));
- rules.add(instanceVarRule);
-
- WordRule gloablRule = new WordRule(new GlobalDetector(), getToken(IRubyColorConstants.RUBY_GLOBAL));
- rules.add(gloablRule);
-
- IWordDetector wordDetector = new RubyWordDetector();
- WordRule wordRule = new WordRule(wordDetector, defToken);
- IToken token = getToken(IRubyColorConstants.RUBY_KEYWORD);
- String[] keywords = RubyTextTools.getKeyWords();
- for (int keyWordIndex = 0; keyWordIndex < keywords.length; keyWordIndex++)
- wordRule.addWord(keywords[keyWordIndex], token);
- rules.add(wordRule);
-
- return rules;
- }
-}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyNumberRule.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyNumberRule.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyNumberRule.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -1,48 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.NumberRule;
-import org.eclipse.jface.text.rules.Token;
-
-public class RubyNumberRule extends NumberRule {
-
- public RubyNumberRule(IToken token){
- super(token);
- }
-
- /*
- * @see IRule#evaluate(ICharacterScanner)
- */
- public IToken evaluate(ICharacterScanner scanner) {
- int c= scanner.read();
- if (Character.isDigit((char)c)) {
- scanner.unread();
- scanner.unread();
- c = scanner.read();
- if ( Character.isLetter((char)c) || ((char)c) == '_'){
- do {
- c= scanner.read();
- } while (Character.isDigit((char) c));
- scanner.unread();
- return Token.UNDEFINED;
- }
- c = scanner.read();
- if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
- do {
- c= scanner.read();
- } while (Character.isDigit((char) c));
- if ( Character.isLetter((char)c) || ((char)c) == '_' ){
- scanner.unread();
- return Token.UNDEFINED;
- }
- scanner.unread();
- return fToken;
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-
-}
Copied: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java (from rev 2162, branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java)
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -0,0 +1,209 @@
+package org.rubypeople.rdt.internal.ui.text.ruby;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.jruby.ast.CommentNode;
+import org.jruby.lexer.yacc.LexState;
+import org.jruby.lexer.yacc.LexerSource;
+import org.jruby.lexer.yacc.RubyYaccLexer;
+import org.jruby.lexer.yacc.SyntaxException;
+import org.jruby.parser.ParserSupport;
+import org.jruby.parser.RubyParserConfiguration;
+import org.jruby.parser.RubyParserResult;
+import org.jruby.parser.Tokens;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.IRubyColorConstants;
+import org.rubypeople.rdt.ui.text.IColorManager;
+
+public class RubyTokenScanner extends AbstractRubyTokenScanner {
+
+ protected String[] keywords;
+
+ private static String[] fgTokenProperties = { IRubyColorConstants.RUBY_KEYWORD, IRubyColorConstants.RUBY_DEFAULT,
+ IRubyColorConstants.RUBY_FIXNUM, IRubyColorConstants.RUBY_CHARACTER, IRubyColorConstants.RUBY_SYMBOL,
+ IRubyColorConstants.RUBY_INSTANCE_VARIABLE, IRubyColorConstants.RUBY_GLOBAL, IRubyColorConstants.RUBY_STRING,
+ IRubyColorConstants.RUBY_REGEXP, IRubyColorConstants.RUBY_ERROR, IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT
+ // TODO Add Ability to set colors for return and operators
+ // IRubyColorConstants.RUBY_METHOD_NAME,
+ // IRubyColorConstants.RUBY_KEYWORD_RETURN,
+ // IRubyColorConstants.RUBY_OPERATOR
+ };
+
+ private RubyYaccLexer lexer;
+ private LexerSource lexerSource;
+ private ParserSupport parserSupport;
+ private int tokenLength;
+ private int oldOffset;
+ private boolean isInRegexp;
+ private boolean isInString;
+ private RubyParserResult result;
+ private int origOffset;
+ private int origLength;
+ private String contents;
+
+ private IToken fSavedToken = null;
+ private int fSavedLength = -1;
+ private int fSavedOffset = -1;
+
+ private boolean lastWasComment;
+
+ public RubyTokenScanner(IColorManager manager, IPreferenceStore store) {
+ super(manager, store);
+ lexer = new RubyYaccLexer();
+ parserSupport = new ParserSupport();
+ parserSupport.setConfiguration(new RubyParserConfiguration());
+ result = new RubyParserResult();
+ parserSupport.setResult(result);
+ lexer.setParserSupport(parserSupport);
+ initialize();
+ }
+
+ public int getTokenLength() {
+ if (lastWasComment) {
+ lastWasComment = false;
+ return tokenLength;
+ }
+ if (fSavedLength != -1) {
+ int length = fSavedLength;
+ fSavedLength = -1;
+ return length;
+ }
+ return tokenLength;
+ }
+
+ public int getTokenOffset() {
+ if (lastWasComment) {
+ return oldOffset;
+ }
+ if (fSavedOffset != -1) {
+ int offset = fSavedOffset;
+ fSavedOffset = -1;
+ return offset;
+ }
+ return oldOffset;
+ }
+
+ public IToken nextToken() {
+ if (fSavedToken != null) {
+ IToken returnToken = fSavedToken;
+ fSavedToken = null;
+ return returnToken;
+ }
+ oldOffset = getOffset();
+ tokenLength = 0;
+ IToken returnValue = getToken(IRubyColorConstants.RUBY_DEFAULT);
+ boolean isEOF = false;
+ try {
+ isEOF = !lexer.advance();
+ if (isEOF) {
+ returnValue = Token.EOF;
+ } else {
+ returnValue = token(lexer.token());
+ }
+ List comments = result.getCommentNodes();
+ if (comments != null && !comments.isEmpty()) {
+ CommentNode comment = (CommentNode) comments.remove(comments.size() - 1); // Grab last comment
+ tokenLength = comment.getContent().length() + 1;
+ fSavedToken = returnValue;
+ fSavedOffset = comment.getPosition().getEndOffset();
+ fSavedLength = lexerSource.getOffset() - fSavedOffset;
+ lastWasComment = true;
+ return getToken(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT);
+ }
+ } catch (SyntaxException se) {
+ if (lexerSource.getOffset() - origLength == 0)
+ return Token.EOF; // return eof if we hit a problem found at
+ // end of parsing
+ else
+ tokenLength = getOffset() - oldOffset;
+ return getToken(IRubyColorConstants.RUBY_ERROR);
+ } catch (IOException e) {
+ RubyPlugin.log(e);
+ }
+ if (!isEOF)
+ tokenLength = getOffset() - oldOffset;
+ return returnValue;
+ }
+
+ private int getOffset() {
+ return lexerSource.getOffset() + origOffset;
+ }
+
+ @Override
+ protected Token getToken(String key) {
+ if (isInRegexp)
+ return super.getToken(IRubyColorConstants.RUBY_REGEXP);
+ if (isInString)
+ return super.getToken(IRubyColorConstants.RUBY_STRING);
+ return super.getToken(key);
+ }
+
+ private IToken token(int i) {
+ if (i >= 257 && i <= 303)
+ return getToken(IRubyColorConstants.RUBY_KEYWORD);
+ switch (i) {
+ case Tokens.tSYMBEG:
+ return getToken(IRubyColorConstants.RUBY_SYMBOL);
+ case Tokens.tGVAR:
+ return getToken(IRubyColorConstants.RUBY_GLOBAL);
+ case Tokens.tIVAR:
+ case Tokens.tCVAR: // FIXME Allow for unique coloring of class variables...
+ return getToken(IRubyColorConstants.RUBY_INSTANCE_VARIABLE);
+ case Tokens.tFLOAT:
+ case Tokens.tINTEGER:
+ // A character is marked as an integer, lets check for that special case...
+ if ((((oldOffset - origOffset) + 1) < contents.length()) && (contents.charAt((oldOffset - origOffset) + 1) == '?'))
+ return getToken(IRubyColorConstants.RUBY_CHARACTER);
+ return getToken(IRubyColorConstants.RUBY_FIXNUM);
+ case Tokens.tSTRING_CONTENT:
+ return getToken(IRubyColorConstants.RUBY_STRING);
+ case Tokens.tSTRING_BEG:
+ isInString = true;
+ return getToken(IRubyColorConstants.RUBY_STRING);
+ case Tokens.tSTRING_END:
+ isInString = false;
+ return getToken(IRubyColorConstants.RUBY_STRING);
+ case Tokens.tREGEXP_BEG:
+ isInRegexp = true;
+ return getToken(IRubyColorConstants.RUBY_REGEXP);
+ case Tokens.tREGEXP_END:
+ isInRegexp = false;
+ return getToken(IRubyColorConstants.RUBY_REGEXP);
+ default:
+ return getToken(IRubyColorConstants.RUBY_DEFAULT);
+ }
+ }
+
+ public void setRange(IDocument document, int offset, int length) {
+ lexer.reset();
+ lexer.setState(LexState.EXPR_BEG);
+ parserSupport.initTopLocalVariables();
+ if (offset == 0) {
+ isInRegexp = false;
+ isInString = false;
+ }
+ try {
+ contents = document.get(offset, length);
+ lexerSource = new LexerSource("filename", new StringReader(contents));
+ lexer.setSource(lexerSource);
+ } catch (BadLocationException e) {
+ RubyPlugin.log(e);
+ }
+ origOffset = offset;
+ origLength = length;
+ }
+
+ /*
+ * @see AbstractRubyScanner#getTokenProperties()
+ */
+ protected String[] getTokenProperties() {
+ return fgTokenProperties;
+ }
+}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleCharacterPrefixRule.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleCharacterPrefixRule.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleCharacterPrefixRule.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -1,94 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.rules.ICharacterScanner;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.Token;
-
-/**
- * This is a base class for recognizing tokens where a single character prefix
- * can determine if the word is of a particular token type. The token ends at
- * EOF, EOL or whitespace.
- *
- * @author cawilliams
- *
- */
-public class SingleCharacterPrefixRule implements IRule {
-
- protected char fPrefix;
- protected IToken fToken;
- protected int fMinLength;
- protected int fMaxLength;
- private StringBuffer fWord;
-
- public SingleCharacterPrefixRule(char prefix, IToken token, int minLength, int maxLength) {
- fPrefix = prefix;
- Assert.isNotNull(token);
- fToken = token;
- Assert.isLegal(minLength >= 1);
- fMinLength = minLength;
- Assert.isLegal(maxLength >= 1);
- fMaxLength = maxLength;
- }
-
- public IToken evaluate(ICharacterScanner scanner) {
- int c = scanner.read();
- int length = 1;
- fWord = new StringBuffer();
- if (((char) c) == fPrefix) {
- fWord.append(((char) c));
- // Now read until we hit EOF, EOL or whitespace
- while (true) {
- c = scanner.read();
- if (!isValidCharacter(c, length)) {
- if (!isValidEndCharacter(c, length))
- scanner.unread();
- else {
- fWord.append(((char) c));
- length++;
- }
- if (!lengthInRange(length) || !wordValid(fWord.toString())) return Token.UNDEFINED;
- return fToken;
- }
- fWord.append(((char) c));
- length++;
- }
- }
-
- scanner.unread();
- return Token.UNDEFINED;
- }
-
- protected boolean wordValid(String word) {
- return true;
- }
-
- protected boolean isValidEndCharacter(int c, int length) {
- return false;
- }
-
- /**
- * Determine if the current character is valid for the rule. Return false if
- * the character is not a part of the token. This is not applied to the
- * single character prefix.
- *
- * @param c
- * @param index
- * @return
- */
- protected boolean isValidCharacter(int c, int index) {
- return c != ICharacterScanner.EOF && !Character.isWhitespace((char) c);
- }
-
- /**
- * Determine if the length of the token is valid.
- *
- * @param length
- * @return
- */
- protected boolean lengthInRange(int length) {
- return (length >= fMinLength) && (length <= fMaxLength);
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleTokenRubyCodeScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleTokenRubyCodeScanner.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleTokenRubyCodeScanner.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -1,33 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.rubypeople.rdt.ui.text.IColorManager;
-
-public class SingleTokenRubyCodeScanner extends AbstractRubyScanner {
-
- private String[] fProperty;
-
- public SingleTokenRubyCodeScanner(IColorManager manager, IPreferenceStore store, String property) {
- super(manager, store);
- fProperty = new String[] { property};
- initialize();
- }
-
- /*
- * @see AbstractRubyScanner#getTokenProperties()
- */
- protected String[] getTokenProperties() {
- return fProperty;
- }
-
- /*
- * @see AbstractRubyScanner#createRules()
- */
- protected List createRules() {
- setDefaultReturnToken(getToken(fProperty[0]));
- return null;
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SymbolRule.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SymbolRule.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SymbolRule.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -1,36 +0,0 @@
-package org.rubypeople.rdt.internal.ui.text.ruby;
-
-import org.eclipse.jface.text.rules.IToken;
-
-/**
- * A rule which will return the given Token for Ruby symbols.
- *
- * @author cawilliams
- *
- */
-public class SymbolRule extends SingleCharacterPrefixRule {
-
- private static final char PREFIX = ':';
-
- public SymbolRule(IToken token) {
- super(PREFIX, token, 2, Integer.MAX_VALUE);
- }
-
- protected boolean isValidCharacter(int c, int index) {
- if (!super.isValidCharacter(c, index))
- return false;
-
- // Symbols can only contain word characters (a-zA-Z0-9_)
- // TODO which special method names contain brackets?
- return Character.isLetterOrDigit((char) c) || c == '_';
- }
-
- protected boolean isValidEndCharacter(int c, int length) {
- return c == '?' || c == '!';
- }
-
- protected boolean wordValid(String word) {
- return !Character.isDigit(word.charAt(1));
- }
-
-}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -57,11 +57,11 @@
import org.rubypeople.rdt.internal.ui.text.comment.RubyCommentAutoIndentStrategy;
import org.rubypeople.rdt.internal.ui.text.hyperlinks.RubyHyperLinkDetector;
import org.rubypeople.rdt.internal.ui.text.ruby.AbstractRubyScanner;
-import org.rubypeople.rdt.internal.ui.text.ruby.RubyCodeScanner;
+import org.rubypeople.rdt.internal.ui.text.ruby.AbstractRubyTokenScanner;
import org.rubypeople.rdt.internal.ui.text.ruby.RubyCompletionProcessor;
import org.rubypeople.rdt.internal.ui.text.ruby.RubyFormattingStrategy;
import org.rubypeople.rdt.internal.ui.text.ruby.RubyReconcilingStrategy;
-import org.rubypeople.rdt.internal.ui.text.ruby.SingleTokenRubyCodeScanner;
+import org.rubypeople.rdt.internal.ui.text.ruby.RubyTokenScanner;
import org.rubypeople.rdt.internal.ui.text.ruby.hover.RubyCodeTextHover;
public class RubySourceViewerConfiguration extends
@@ -85,11 +85,9 @@
*/
private IColorManager fColorManager;
- protected AbstractRubyScanner fCodeScanner;
+ protected AbstractRubyTokenScanner fCodeScanner;
- protected AbstractRubyScanner fMultilineCommentScanner, fSinglelineCommentScanner, fStringScanner;
- private SingleTokenRubyCodeScanner fRegexpScanner;
- private SingleTokenRubyCodeScanner fCommandScanner;
+ protected AbstractRubyScanner fMultilineCommentScanner;
private RubyDoubleClickSelector fRubyDoubleClickSelector;
private RubyCompletionProcessor fRubyCp;
@@ -180,11 +178,7 @@
*/
public boolean affectsTextPresentation(PropertyChangeEvent event) {
return fCodeScanner.affectsBehavior(event)
- || fMultilineCommentScanner.affectsBehavior(event)
- || fSinglelineCommentScanner.affectsBehavior(event)
- || fStringScanner.affectsBehavior(event)
- || fRegexpScanner.affectsBehavior(event)
- || fCommandScanner.affectsBehavior(event);
+ || fMultilineCommentScanner.affectsBehavior(event);
}
/**
@@ -207,14 +201,6 @@
fCodeScanner.adaptToPreferenceChange(event);
if (fMultilineCommentScanner.affectsBehavior(event))
fMultilineCommentScanner.adaptToPreferenceChange(event);
- if (fSinglelineCommentScanner.affectsBehavior(event))
- fSinglelineCommentScanner.adaptToPreferenceChange(event);
- if (fStringScanner.affectsBehavior(event))
- fStringScanner.adaptToPreferenceChange(event);
- if (fRegexpScanner.affectsBehavior(event))
- fRegexpScanner.adaptToPreferenceChange(event);
- if (fCommandScanner.affectsBehavior(event))
- fCommandScanner.adaptToPreferenceChange(event);
}
/**
@@ -247,17 +233,9 @@
*/
private void initializeScanners() {
Assert.isTrue(isNewSetup());
- fCodeScanner = new RubyCodeScanner(getColorManager(), fPreferenceStore);
+ fCodeScanner = new RubyTokenScanner(getColorManager(), fPreferenceStore);
fMultilineCommentScanner = new RubyCommentScanner(getColorManager(),
fPreferenceStore, IRubyColorConstants.RUBY_MULTI_LINE_COMMENT);
- fSinglelineCommentScanner = new RubyCommentScanner(getColorManager(),
- fPreferenceStore, IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT);
- fStringScanner = new SingleTokenRubyCodeScanner(getColorManager(),
- fPreferenceStore, IRubyColorConstants.RUBY_STRING);
- fRegexpScanner = new SingleTokenRubyCodeScanner(getColorManager(),
- fPreferenceStore, IRubyColorConstants.RUBY_REGEXP);
- fCommandScanner = new SingleTokenRubyCodeScanner(getColorManager(),
- fPreferenceStore, IRubyColorConstants.RUBY_COMMAND);
}
/**
@@ -288,37 +266,13 @@
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
- dr = new DefaultDamagerRepairer(getSinglelineCommentScanner());
- reconciler
- .setDamager(dr, RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT);
- reconciler.setRepairer(dr,
- RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT);
-
dr = new DefaultDamagerRepairer(getMultilineCommentScanner());
reconciler.setDamager(dr, RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT);
reconciler
.setRepairer(dr, RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT);
-
- dr = new DefaultDamagerRepairer(getStringScanner());
- reconciler.setDamager(dr, RubyPartitionScanner.RUBY_STRING);
- reconciler.setRepairer(dr, RubyPartitionScanner.RUBY_STRING);
-
- dr = new DefaultDamagerRepairer(getRegexpScanner());
- reconciler.setDamager(dr, RubyPartitionScanner.RUBY_REGULAR_EXPRESSION);
- reconciler
- .setRepairer(dr, RubyPartitionScanner.RUBY_REGULAR_EXPRESSION);
-
- dr = new DefaultDamagerRepairer(getCommandScanner());
- reconciler.setDamager(dr, RubyPartitionScanner.RUBY_COMMAND);
- reconciler.setRepairer(dr, RubyPartitionScanner.RUBY_COMMAND);
-
return reconciler;
}
- private ITokenScanner getCommandScanner() {
- return fCommandScanner;
- }
-
protected ITokenScanner getCodeScanner() {
return fCodeScanner;
}
@@ -327,23 +281,9 @@
return fMultilineCommentScanner;
}
- protected ITokenScanner getSinglelineCommentScanner() {
- return fSinglelineCommentScanner;
- }
-
- protected ITokenScanner getStringScanner() {
- return fStringScanner;
- }
-
- protected ITokenScanner getRegexpScanner() {
- return fRegexpScanner;
- }
-
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
- RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT,
- RubyPartitionScanner.RUBY_STRING,
- RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT };
+ RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT };
}
/*
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubyTextTools.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubyTextTools.java 2007-03-14 13:54:14 UTC (rev 2162)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubyTextTools.java 2007-03-14 14:58:09 UTC (rev 2163)
@@ -21,8 +21,8 @@
import org.rubypeople.rdt.internal.ui.text.RubyCommentScanner;
import org.rubypeople.rdt.internal.ui.text.RubyPartitionScanner;
import org.rubypeople.rdt.internal.ui.text.ruby.AbstractRubyScanner;
-import org.rubypeople.rdt.internal.ui.text.ruby.RubyCodeScanner;
-import org.rubypeople.rdt.internal.ui.text.ruby.SingleTokenRubyCodeScanner;
+import org.rubypeople.rdt.internal.ui.text.ruby.AbstractRubyTokenScanner;
+import org.rubypeople.rdt.internal.ui.text.ruby.RubyTokenScanner;
public class RubyTextTools {
@@ -45,15 +45,12 @@
protected static String[] keywords;
protected RubyColorManager fColorManager;
protected RubyPartitionScanner partitionScanner;
- protected AbstractRubyScanner fCodeScanner;
- protected AbstractRubyScanner fMultilineCommentScanner, fSinglelineCommentScanner,
- stringScanner;
+ protected AbstractRubyTokenScanner fCodeScanner;
+ protected AbstractRubyScanner fMultilineCommentScanner, fSinglelineCommentScanner;
private IPreferenceStore fPreferenceStore;
private Preferences fCorePreferenceStore;
/** The preference change listener */
private PreferenceListener fPreferenceListener = new PreferenceListener();
- private SingleTokenRubyCodeScanner fRegexpScanner;
- private SingleTokenRubyCodeScanner fCommandScanner;
/**
* Creates a new Ruby text tools collection.
@@ -108,17 +105,11 @@
fColorManager = new RubyColorManager(autoDisposeOnDisplayDispose);
partitionScanner = new RubyPartitionScanner();
- fCodeScanner = new RubyCodeScanner(fColorManager, store);
+ fCodeScanner = new RubyTokenScanner(fColorManager, store);
fMultilineCommentScanner = new RubyCommentScanner(fColorManager, store, coreStore,
IRubyColorConstants.RUBY_MULTI_LINE_COMMENT);
fSinglelineCommentScanner = new RubyCommentScanner(fColorManager, store, coreStore,
IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT);
- stringScanner = new SingleTokenRubyCodeScanner(fColorManager, store,
- IRubyColorConstants.RUBY_STRING);
- fRegexpScanner = new SingleTokenRubyCodeScanner(fColorManager, store,
- IRubyColorConstants.RUBY_REGEXP);
- fCommandScanner = new SingleTokenRubyCodeScanner(fColorManager, store,
- IRubyColorConstants.RUBY_COMMAND);
fPreferenceStore = store;
fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
@@ -142,10 +133,7 @@
if (fMultilineCommentScanner.affectsBehavior(event))
fMultilineCommentScanner.adaptToPreferenceChange(event);
if (fSinglelineCommentScanner.affectsBehavior(event))
- fSinglelineCommentScanner.adaptToPreferenceChange(event);
- if (stringScanner.affectsBehavior(event)) stringScanner.adaptToPreferenceChange(event);
- if (fRegexpScanner.affectsBehavior(event)) fRegexpScanner.adaptToPreferenceChange(event);
- if (fCommandScanner.affectsBehavior(event)) fCommandScanner.adaptToPreferenceChange(event);
+ fSinglelineCommentScanner.adaptToPreferenceChange(event);
}
public IDocumentPartitioner createDocumentPartitioner() {
@@ -161,7 +149,7 @@
* @deprecated As of 0.8.0, replaced by
* {@link RubySourceViewerConfiguration#getCodeScanner()}
*/
- public AbstractRubyScanner getCodeScanner() {
+ public AbstractRubyTokenScanner getCodeScanner() {
return fCodeScanner;
}
@@ -181,14 +169,6 @@
return fSinglelineCommentScanner;
}
- /**
- * @deprecated As of 0.8.0, replaced by
- * {@link RubySourceViewerConfiguration#getStringScanner()}
- */
- public ITokenScanner getStringScanner() {
- return stringScanner;
- }
-
public IPreferenceStore getPreferenceStore() {
return RubyPlugin.getDefault().getPreferenceStore();
}
@@ -212,9 +192,7 @@
public boolean affectsTextPresentation(PropertyChangeEvent event) {
return fCodeScanner.affectsBehavior(event)
|| fMultilineCommentScanner.affectsBehavior(event)
- || fSinglelineCommentScanner.affectsBehavior(event)
- || stringScanner.affectsBehavior(event) || fRegexpScanner.affectsBehavior(event)
- || fCommandScanner.affectsBehavior(event);
+ || fSinglelineCommentScanner.affectsBehavior(event);
}
/**
@@ -246,9 +224,6 @@
fCodeScanner = null;
fMultilineCommentScanner = null;
fSinglelineCommentScanner = null;
- stringScanner = null;
- fRegexpScanner = null;
- fCommandScanner = null;
// fJavaDocScanner= null;
partitionScanner = null;
@@ -271,22 +246,6 @@
}
/**
- * @deprecated As of 0.8.0, replaced by
- * {@link RubySourceViewerConfiguration#getRegexpScanner()}
- */
- public ITokenScanner getRegexpScanner() {
- return fRegexpScanner;
- }
-
- /**
- * @deprecated As of 0.8.0, replaced by
- * {@link RubySourceViewerConfiguration#getCommandScanner()}
- */
- public ITokenScanner getCommandScanner() {
- return fCommandScanner;
- }
-
- /**
* Returns the color manager which is used to manage any Ruby-specific
* colors needed for such things like syntax highlighting.
* <p>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tc...@us...> - 2007-03-14 14:34:31
|
Revision: 2162
http://svn.sourceforge.net/rubyeclipse/?rev=2162&view=rev
Author: tcorbat
Date: 2007-03-14 06:54:14 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Adapted ListNode access, as in new JRuby version iterator() of ListNode is not available anymore. Replaced .iterator() calls with .childNodes().iterator(). Should be working like before.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/DOMFinder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceHelper.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/ScopedNodeLocator.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -239,7 +239,7 @@
handleNode(iVisited);
visitNode(iVisited.getBlockArgNode());
if (iVisited.getOptArgs() != null) {
- visitIter(iVisited.getOptArgs().iterator());
+ visitIter(iVisited.getOptArgs().childNodes().iterator());
}
return null;
}
@@ -263,7 +263,7 @@
*/
public Instruction visitArrayNode(ArrayNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -325,7 +325,7 @@
*/
public Instruction visitBlockNode(BlockNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -675,7 +675,7 @@
*/
public Instruction visitDRegxNode(DRegexpNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -686,7 +686,7 @@
*/
public Instruction visitDStrNode(DStrNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -697,7 +697,7 @@
*/
public Instruction visitDSymbolNode(DSymbolNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -720,7 +720,7 @@
*/
public Instruction visitDXStrNode(DXStrNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -966,7 +966,7 @@
}
else if (argsNode instanceof ArrayNode) {
ArrayNode arrayNode = (ArrayNode) iVisited.getArgsNode();
- iter = arrayNode.iterator();
+ iter = arrayNode.childNodes().iterator();
}
for (; iter.hasNext();) {
Node mixinNameNode = (Node) iter.next();
@@ -974,7 +974,7 @@
mixins.add( ((StrNode)mixinNameNode).getValue().toString() );
}
if ( mixinNameNode instanceof DStrNode ) {
- Node next = (Node)((DStrNode)mixinNameNode).iterator().next();
+ Node next = (Node)((DStrNode)mixinNameNode).childNodes().iterator().next();
if ( next instanceof StrNode ) {
mixins.add( ((StrNode)next).getValue().toString() );
}
@@ -1011,10 +1011,10 @@
* @return
*/
private String getString(ArrayNode node) {
- Object tmp = node.iterator().next();
+ Object tmp = node.childNodes().iterator().next();
if (tmp instanceof DStrNode) {
DStrNode dstrNode = (DStrNode) tmp;
- tmp = dstrNode.iterator().next();
+ tmp = dstrNode.childNodes().iterator().next();
}
if (tmp instanceof StrNode) {
StrNode strNode = (StrNode) tmp;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -47,7 +47,5 @@
} finally {
IoUtils.closeQuietly(contents);
}
-
}
-
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/InOrderVisitor.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -161,7 +161,7 @@
handleNode(iVisited);
acceptNode(iVisited.getBlockArgNode());
if (iVisited.getOptArgs() != null) {
- visitIter(iVisited.getOptArgs().iterator());
+ visitIter(iVisited.getOptArgs().childNodes().iterator());
}
return null;
}
@@ -185,7 +185,7 @@
*/
public Instruction visitArrayNode(ArrayNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -247,7 +247,7 @@
*/
public Instruction visitBlockNode(BlockNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -403,7 +403,7 @@
*/
public Instruction visitDRegxNode(DRegexpNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -414,7 +414,7 @@
*/
public Instruction visitDStrNode(DStrNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -425,7 +425,7 @@
*/
public Instruction visitDSymbolNode(DSymbolNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -446,7 +446,7 @@
*/
public Instruction visitDXStrNode(DXStrNode iVisited) {
handleNode(iVisited);
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/ASTUtil.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -73,7 +73,7 @@
private static List<String> getArguments(ListNode argList) {
if (argList == null) return new ArrayList<String>();
List<String> arguments = new ArrayList<String>();
- for (Iterator iter = argList.iterator(); iter.hasNext();) {
+ for (Iterator iter = argList.childNodes().iterator(); iter.hasNext();) {
Object node = iter.next();
if (node instanceof ArgumentNode) {
arguments.add(((ArgumentNode) node).getName());
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/DOMFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/DOMFinder.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/DOMFinder.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -138,7 +138,7 @@
public Instruction visitArgsNode(ArgsNode iVisited) {
visitNode(iVisited.getBlockArgNode());
if (iVisited.getOptArgs() != null) {
- visitIter(iVisited.getOptArgs().iterator());
+ visitIter(iVisited.getOptArgs().childNodes().iterator());
}
return null;
}
@@ -151,7 +151,7 @@
}
public Instruction visitArrayNode(ArrayNode iVisited) {
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
@@ -173,7 +173,7 @@
}
public Instruction visitBlockNode(BlockNode iVisited) {
- visitIter(iVisited.iterator());
+ visitIter(iVisited.childNodes().iterator());
return null;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/DefaultTypeInferrer.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -336,7 +336,7 @@
int argNumber = 0;
ListNode args = argsNode.getArgs();
if (args == null) return -1; // no args. Maybe we should check arity instead?
- for (Iterator iter = args.iterator(); iter.hasNext();) {
+ for (Iterator iter = args.childNodes().iterator(); iter.hasNext();) {
ArgumentNode arg = (ArgumentNode) iter.next();
if (arg.getName().equals(argName)) {
break;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceHelper.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceHelper.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/TypeInferenceHelper.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -42,7 +42,7 @@
public int getArgIndex(ListNode listNode, String argName)
{
int argNumber = 0;
- for ( Iterator iter = listNode.iterator(); iter.hasNext();) {
+ for ( Iterator iter = listNode.childNodes().iterator(); iter.hasNext();) {
if (((ArgumentNode)iter.next()).getName().equals(argName)) { return argNumber; }
argNumber++;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/AttributeLocator.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -69,7 +69,7 @@
Node argsNode = fCallNode.getArgsNode();
if ( argsNode instanceof ArrayNode ) {
ArrayNode arrayNode = (ArrayNode)argsNode;
- for (Iterator iter = arrayNode.iterator(); iter.hasNext();) {
+ for (Iterator iter = arrayNode.childNodes().iterator(); iter.hasNext();) {
Node argNode = (Node) iter.next();
// The nodes are found - record them!
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/OffsetNodeLocator.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -62,7 +62,7 @@
{
ArgsNode argsNode = (ArgsNode)node;
if ( argsNode.getArgsCount() > 0 ) {
- for (Iterator iter = argsNode.getArgs().iterator(); iter.hasNext();) {
+ for (Iterator iter = argsNode.getArgs().childNodes().iterator(); iter.hasNext();) {
ArgumentNode argNode = (ArgumentNode) iter.next();
if ( nodeDoesSpanOffset(argNode, offset) ) {
// System.out.println("Refining " + node.getClass().getSimpleName() + "["+node.getPosition().getStartOffset() + ".." + node.getPosition().getEndOffset() + "] to " + argNode.getClass().getSimpleName() + "["+argNode.getPosition().getStartOffset() + ".." + argNode.getPosition().getEndOffset() + "]");
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/ScopedNodeLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/ScopedNodeLocator.java 2007-03-14 13:37:47 UTC (rev 2161)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/ti/util/ScopedNodeLocator.java 2007-03-14 13:54:14 UTC (rev 2162)
@@ -69,7 +69,7 @@
public Instruction visitArgsNode(ArgsNode iVisited) {
if ( iVisited.getArgsCount() > 0 )
{
- for (Iterator iter = iVisited.getArgs().iterator(); iter.hasNext();) {
+ for (Iterator iter = iVisited.getArgs().childNodes().iterator(); iter.hasNext();) {
ArgumentNode argNode = (ArgumentNode) iter.next();
if ( acceptor.doesAccept(argNode))
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 13:37:51
|
Revision: 2161
http://svn.sourceforge.net/rubyeclipse/?rev=2161&view=rev
Author: cawilliams
Date: 2007-03-14 06:37:47 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
single lien comments must be handl;ed by the lexer, so we can't partition them into separate content types. Also, they get eaten up by the lexer in an odd way.
When we grab a token, check if there was a comment eaten as well. If so, save the real token for next go-around and return the comment token first.
Modified Paths:
--------------
branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
Modified: branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
===================================================================
--- branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2007-03-14 08:16:07 UTC (rev 2160)
+++ branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2007-03-14 13:37:47 UTC (rev 2161)
@@ -22,10 +22,9 @@
protected int fPartitionOffset;
public final static String RUBY_MULTI_LINE_COMMENT = IRubyPartitions.RUBY_MULTI_LINE_COMMENT;
- public static final String RUBY_SINGLE_LINE_COMMENT = IRubyPartitions.RUBY_SINGLE_LINE_COMMENT;
public static final String[] LEGAL_CONTENT_TYPES = {
- RUBY_MULTI_LINE_COMMENT, RUBY_SINGLE_LINE_COMMENT,
+ RUBY_MULTI_LINE_COMMENT
};
public RubyPartitionScanner() {
@@ -35,14 +34,8 @@
protected void initialize() {
IToken multiLineComment = new Token(RUBY_MULTI_LINE_COMMENT);
- IToken singleLineComment = new Token(RUBY_SINGLE_LINE_COMMENT);
List rules = new ArrayList();
- // Single line comments
- // ?# evaluates to the ascii value of #
-// rules.add(new WordPatternRule(new NumberSignDetector(), "?", "#",
-// Token.UNDEFINED));
- rules.add(new EndOfLineRule("#", singleLineComment));
rules.add(new DocumentationCommentRule(multiLineComment));
IRule[] result = new IRule[rules.size()];
rules.toArray(result);
Modified: branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-14 08:16:07 UTC (rev 2160)
+++ branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-14 13:37:47 UTC (rev 2161)
@@ -2,12 +2,14 @@
import java.io.IOException;
import java.io.StringReader;
+import java.util.List;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.Token;
+import org.jruby.ast.CommentNode;
import org.jruby.lexer.yacc.LexState;
import org.jruby.lexer.yacc.LexerSource;
import org.jruby.lexer.yacc.RubyYaccLexer;
@@ -24,7 +26,10 @@
protected String[] keywords;
- private static String[] fgTokenProperties = { IRubyColorConstants.RUBY_KEYWORD, IRubyColorConstants.RUBY_DEFAULT, IRubyColorConstants.RUBY_FIXNUM, IRubyColorConstants.RUBY_CHARACTER, IRubyColorConstants.RUBY_SYMBOL, IRubyColorConstants.RUBY_INSTANCE_VARIABLE, IRubyColorConstants.RUBY_GLOBAL, IRubyColorConstants.RUBY_STRING, IRubyColorConstants.RUBY_REGEXP, IRubyColorConstants.RUBY_ERROR
+ private static String[] fgTokenProperties = { IRubyColorConstants.RUBY_KEYWORD, IRubyColorConstants.RUBY_DEFAULT,
+ IRubyColorConstants.RUBY_FIXNUM, IRubyColorConstants.RUBY_CHARACTER, IRubyColorConstants.RUBY_SYMBOL,
+ IRubyColorConstants.RUBY_INSTANCE_VARIABLE, IRubyColorConstants.RUBY_GLOBAL, IRubyColorConstants.RUBY_STRING,
+ IRubyColorConstants.RUBY_REGEXP, IRubyColorConstants.RUBY_ERROR, IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT
// TODO Add Ability to set colors for return and operators
// IRubyColorConstants.RUBY_METHOD_NAME,
// IRubyColorConstants.RUBY_KEYWORD_RETURN,
@@ -43,6 +48,12 @@
private int origLength;
private String contents;
+ private IToken fSavedToken = null;
+ private int fSavedLength = -1;
+ private int fSavedOffset = -1;
+
+ private boolean lastWasComment;
+
public RubyTokenScanner(IColorManager manager, IPreferenceStore store) {
super(manager, store);
lexer = new RubyYaccLexer();
@@ -55,14 +66,36 @@
}
public int getTokenLength() {
+ if (lastWasComment) {
+ lastWasComment = false;
+ return tokenLength;
+ }
+ if (fSavedLength != -1) {
+ int length = fSavedLength;
+ fSavedLength = -1;
+ return length;
+ }
return tokenLength;
}
public int getTokenOffset() {
+ if (lastWasComment) {
+ return oldOffset;
+ }
+ if (fSavedOffset != -1) {
+ int offset = fSavedOffset;
+ fSavedOffset = -1;
+ return offset;
+ }
return oldOffset;
}
public IToken nextToken() {
+ if (fSavedToken != null) {
+ IToken returnToken = fSavedToken;
+ fSavedToken = null;
+ return returnToken;
+ }
oldOffset = getOffset();
tokenLength = 0;
IToken returnValue = getToken(IRubyColorConstants.RUBY_DEFAULT);
@@ -74,14 +107,23 @@
} else {
returnValue = token(lexer.token());
}
- lexer.getStrTerm();
+ List comments = result.getCommentNodes();
+ if (comments != null && !comments.isEmpty()) {
+ CommentNode comment = (CommentNode) comments.remove(comments.size() - 1); // Grab last comment
+ tokenLength = comment.getContent().length() + 1;
+ fSavedToken = returnValue;
+ fSavedOffset = comment.getPosition().getEndOffset();
+ fSavedLength = lexerSource.getOffset() - fSavedOffset;
+ lastWasComment = true;
+ return getToken(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT);
+ }
} catch (SyntaxException se) {
if (lexerSource.getOffset() - origLength == 0)
return Token.EOF; // return eof if we hit a problem found at
// end of parsing
else
tokenLength = getOffset() - oldOffset;
- return new Token(IRubyColorConstants.RUBY_ERROR);
+ return getToken(IRubyColorConstants.RUBY_ERROR);
} catch (IOException e) {
RubyPlugin.log(e);
}
Modified: branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
===================================================================
--- branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2007-03-14 08:16:07 UTC (rev 2160)
+++ branches/syntax/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2007-03-14 13:37:47 UTC (rev 2161)
@@ -87,7 +87,7 @@
protected AbstractRubyTokenScanner fCodeScanner;
- protected AbstractRubyScanner fMultilineCommentScanner, fSinglelineCommentScanner;
+ protected AbstractRubyScanner fMultilineCommentScanner;
private RubyDoubleClickSelector fRubyDoubleClickSelector;
private RubyCompletionProcessor fRubyCp;
@@ -178,8 +178,7 @@
*/
public boolean affectsTextPresentation(PropertyChangeEvent event) {
return fCodeScanner.affectsBehavior(event)
- || fMultilineCommentScanner.affectsBehavior(event)
- || fSinglelineCommentScanner.affectsBehavior(event);
+ || fMultilineCommentScanner.affectsBehavior(event);
}
/**
@@ -202,8 +201,6 @@
fCodeScanner.adaptToPreferenceChange(event);
if (fMultilineCommentScanner.affectsBehavior(event))
fMultilineCommentScanner.adaptToPreferenceChange(event);
- if (fSinglelineCommentScanner.affectsBehavior(event))
- fSinglelineCommentScanner.adaptToPreferenceChange(event);
}
/**
@@ -239,8 +236,6 @@
fCodeScanner = new RubyTokenScanner(getColorManager(), fPreferenceStore);
fMultilineCommentScanner = new RubyCommentScanner(getColorManager(),
fPreferenceStore, IRubyColorConstants.RUBY_MULTI_LINE_COMMENT);
- fSinglelineCommentScanner = new RubyCommentScanner(getColorManager(),
- fPreferenceStore, IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT);
}
/**
@@ -271,12 +266,6 @@
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
- dr = new DefaultDamagerRepairer(getSinglelineCommentScanner());
- reconciler
- .setDamager(dr, RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT);
- reconciler.setRepairer(dr,
- RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT);
-
dr = new DefaultDamagerRepairer(getMultilineCommentScanner());
reconciler.setDamager(dr, RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT);
reconciler
@@ -292,14 +281,9 @@
return fMultilineCommentScanner;
}
- protected ITokenScanner getSinglelineCommentScanner() {
- return fSinglelineCommentScanner;
- }
-
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
- RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT,
- RubyPartitionScanner.RUBY_SINGLE_LINE_COMMENT };
+ RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT };
}
/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-03-14 08:16:09
|
Revision: 2160
http://svn.sourceforge.net/rubyeclipse/?rev=2160&view=rev
Author: mirkostocker
Date: 2007-03-14 01:16:07 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
enable the smart home/end feature, fixes #173
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RubyEditorAppearanceConfigurationBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-03-13 20:30:12 UTC (rev 2159)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-03-14 08:16:07 UTC (rev 2160)
@@ -123,6 +123,7 @@
public static String RubyEditorPreferencePage_closeBrackets;
public static String RubyEditorPreferencePage_closeBraces;
public static String RubyEditorPreferencePage_endStatements;
+ public static String RubyEditorPreferencePage_smartHomeEnd;
public static String ProblemSeveritiesPreferencePage_title;
public static String ProblemSeveritiesConfigurationBlock_needsbuild_title;
public static String ProblemSeveritiesConfigurationBlock_needsfullbuild_message;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-03-13 20:30:12 UTC (rev 2159)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-03-14 08:16:07 UTC (rev 2160)
@@ -129,6 +129,7 @@
RubyEditorPreferencePage_closeBrackets= (Parentheses) and [square] brac&kets
RubyEditorPreferencePage_closeBraces= {B&races}
RubyEditorPreferencePage_endStatements='class', 'module', 'def' and blocks ('... do') with 'end'
+RubyEditorPreferencePage_smartHomeEnd= &Smart caret positioning at line start and end
SmartTypingConfigurationBlock_autoclose_title=Automatically close
SmartTypingConfigurationBlock_annotationReporting_link=Also see the <a href="org.eclipse.ui.editors.preferencePages.Spelling">spell checking</a> preferences.
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RubyEditorAppearanceConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RubyEditorAppearanceConfigurationBlock.java 2007-03-13 20:30:12 UTC (rev 2159)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RubyEditorAppearanceConfigurationBlock.java 2007-03-14 08:16:07 UTC (rev 2160)
@@ -74,6 +74,7 @@
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND));
@@ -189,6 +190,9 @@
String label;
+ label= PreferencesMessages.RubyEditorPreferencePage_smartHomeEnd;
+ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 0);
+
label= PreferencesMessages.RubyEditorPreferencePage_analyseAnnotationsWhileTyping;
addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-03-13 20:30:12 UTC (rev 2159)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-03-14 08:16:07 UTC (rev 2160)
@@ -15,6 +15,7 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.rubypeople.rdt.core.ILoadpathEntry;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
@@ -568,6 +569,16 @@
public final static String EDITOR_END_STATEMENTS = "endStatements"; //$NON-NLS-1$
/**
+ * A named preference that controls whether the 'smart home-end' feature is
+ * enabled.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ */
+ public final static String EDITOR_SMART_HOME_END= AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END;
+
+ /**
* A named preference that controls whether occurrences are marked in the
* editor.
* <p>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
Revision: 2159
http://svn.sourceforge.net/rubyeclipse/?rev=2159&view=rev
Author: cawilliams
Date: 2007-03-13 13:30:12 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java 2007-03-13 19:15:56 UTC (rev 2158)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java 2007-03-13 20:30:12 UTC (rev 2159)
@@ -165,9 +165,9 @@
char[][] extractMethodArguments(IMethod method) {
String[] argumentsSignatures = null;
BindingKey key;
- if (method.isResolved() && (key = new BindingKey(method.getKey())).isParameterizedType()) {
- argumentsSignatures = key.getTypeArguments();
- } else {
+// if (method.isResolved() && (key = new BindingKey(method.getKey())).isParameterizedType()) {
+// argumentsSignatures = key.getTypeArguments();
+// } else {
try {
ITypeParameter[] parameters = method.getTypeParameters();
if (parameters != null) {
@@ -185,7 +185,7 @@
// do nothing
}
return null;
- }
+// }
// Parameterized method
if (argumentsSignatures != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 19:16:11
|
Revision: 2158
http://svn.sourceforge.net/rubyeclipse/?rev=2158&view=rev
Author: cawilliams
Date: 2007-03-13 12:15:56 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-03-13 18:55:31 UTC (rev 2157)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-03-13 19:15:56 UTC (rev 2158)
@@ -240,4 +240,55 @@
return this.matchRule;
}
+ /**
+ * Returns whether the given name matches the given pattern.
+ * <p>
+ * This method should be re-implemented in subclasses that need to define how
+ * a name matches a pattern.
+ * </p>
+ *
+ * @param pattern the given pattern, or <code>null</code> to represent "*"
+ * @param name the given name
+ * @return whether the given name matches the given pattern
+ */
+ public boolean matchesName(char[] pattern, char[] name) {
+ if (pattern == null) return true; // null is as if it was "*"
+ if (name != null) {
+ boolean isCaseSensitive = (this.matchRule & R_CASE_SENSITIVE) != 0;
+ boolean isCamelCase = (this.matchRule & R_CAMELCASE_MATCH) != 0;
+ int matchMode = this.matchRule & MODE_MASK;
+ boolean sameLength = pattern.length == name.length;
+ boolean canBePrefix = name.length >= pattern.length;
+ boolean matchFirstChar = !isCaseSensitive || pattern.length == 0 || (name.length > 0 && pattern[0] == name[0]);
+ if (isCamelCase && matchFirstChar && CharOperation.camelCaseMatch(pattern, name)) {
+ return true;
+ }
+ switch (matchMode) {
+ case R_EXACT_MATCH :
+ case R_FULL_MATCH :
+ if (!isCamelCase) {
+ if (sameLength && matchFirstChar) {
+ return CharOperation.equals(pattern, name, isCaseSensitive);
+ }
+ break;
+ }
+ // fall through next case to match as prefix if camel case failed
+ case R_PREFIX_MATCH :
+ if (canBePrefix && matchFirstChar) {
+ return CharOperation.prefixEquals(pattern, name, isCaseSensitive);
+ }
+ break;
+
+ case R_PATTERN_MATCH :
+ if (!isCaseSensitive)
+ pattern = CharOperation.toLowerCase(pattern);
+ return CharOperation.match(pattern, name, isCaseSensitive);
+
+ case R_REGEXP_MATCH :
+ // TODO (frederic) implement regular expression match
+ return true;
+ }
+ }
+ return false;
+ }
}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/ConstructorPattern.java 2007-03-13 19:15:56 UTC (rev 2158)
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * 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.matching;
+
+import java.io.IOException;
+
+import org.rubypeople.rdt.core.Flags;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.index.EntryResult;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+public class ConstructorPattern extends RubySearchPattern implements IIndexConstants {
+
+protected boolean findDeclarations;
+protected boolean findReferences;
+
+public char[] declaringQualification;
+public char[] declaringSimpleName;
+
+public char[][] parameterQualifications;
+public char[][] parameterSimpleNames;
+public int parameterCount;
+public boolean varargs = false;
+
+// Signatures and arguments for generic search
+char[][][] parametersTypeSignatures;
+char[][][][] parametersTypeArguments;
+boolean constructorParameters = false;
+char[][] constructorArguments;
+
+protected static char[][] REF_CATEGORIES = { CONSTRUCTOR_REF };
+protected static char[][] REF_AND_DECL_CATEGORIES = { CONSTRUCTOR_REF, CONSTRUCTOR_DECL };
+protected static char[][] DECL_CATEGORIES = { CONSTRUCTOR_DECL };
+
+/**
+ * Constructor entries are encoded as TypeName '/' Arity:
+ * e.g. 'X/0'
+ */
+public static char[] createIndexKey(char[] typeName, int argCount) {
+ char[] countChars = argCount < 10
+ ? COUNTS[argCount]
+ : ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
+ return CharOperation.concat(typeName, countChars);
+}
+
+ConstructorPattern(int matchRule) {
+ super(CONSTRUCTOR_PATTERN, matchRule);
+}
+public ConstructorPattern(
+ boolean findDeclarations,
+ boolean findReferences,
+ char[] declaringSimpleName,
+ char[] declaringQualification,
+ char[][] parameterQualifications,
+ char[][] parameterSimpleNames,
+ int matchRule) {
+
+ this(matchRule);
+
+ this.findDeclarations = findDeclarations;
+ this.findReferences = findReferences;
+
+ this.declaringQualification = isCaseSensitive() ? declaringQualification : CharOperation.toLowerCase(declaringQualification);
+ this.declaringSimpleName = (isCaseSensitive() || isCamelCase()) ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
+ if (parameterSimpleNames != null) {
+ this.parameterCount = parameterSimpleNames.length;
+ boolean synthetic = this.parameterCount>0 && declaringQualification != null && CharOperation.equals(CharOperation.concat(parameterQualifications[0], parameterSimpleNames[0], '.'), declaringQualification);
+ int offset = 0;
+ if (synthetic) {
+ // skip first synthetic parameter
+ this.parameterCount--;
+ offset++;
+ }
+ this.parameterQualifications = new char[this.parameterCount][];
+ this.parameterSimpleNames = new char[this.parameterCount][];
+ for (int i = 0; i < this.parameterCount; i++) {
+ this.parameterQualifications[i] = isCaseSensitive() ? parameterQualifications[i+offset] : CharOperation.toLowerCase(parameterQualifications[i+offset]);
+ this.parameterSimpleNames[i] = isCaseSensitive() ? parameterSimpleNames[i+offset] : CharOperation.toLowerCase(parameterSimpleNames[i+offset]);
+ }
+ } else {
+ this.parameterCount = -1;
+ }
+ ((InternalSearchPattern)this).mustResolve = mustResolve();
+}
+/*
+ * Instanciate a method pattern with signatures for generics search
+ */
+public ConstructorPattern(
+ boolean findDeclarations,
+ boolean findReferences,
+ char[] declaringSimpleName,
+ char[] declaringQualification,
+ char[][] parameterQualifications,
+ char[][] parameterSimpleNames,
+ String[] parameterSignatures,
+ IMethod method,
+// boolean varargs,
+ int matchRule) {
+
+ this(findDeclarations,
+ findReferences,
+ declaringSimpleName,
+ declaringQualification,
+ parameterQualifications,
+ parameterSimpleNames,
+ matchRule);
+
+ // Set flags
+ try {
+ this.varargs = (method.getFlags() & Flags.AccVarargs) != 0;
+ } catch (RubyModelException e) {
+ // do nothing
+ }
+
+ // Get unique key for parameterized constructors
+ String genericDeclaringTypeSignature = null;
+ String key;
+ if (method.isResolved() && new BindingKey(key = method.getKey()).isParameterizedType()) {
+ genericDeclaringTypeSignature = Util.getDeclaringTypeSignature(key);
+ } else {
+ constructorParameters = true;
+ }
+
+ // Store type signature and arguments for declaring type
+ if (genericDeclaringTypeSignature != null) {
+ this.typeSignatures = Util.splitTypeLevelsSignature(genericDeclaringTypeSignature);
+ setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
+ } else {
+ storeTypeSignaturesAndArguments(method.getDeclaringType());
+ }
+
+ // store type signatures and arguments for method parameters type
+ if (parameterSignatures != null) {
+ int length = parameterSignatures.length;
+ if (length > 0) {
+ parametersTypeSignatures = new char[length][][];
+ parametersTypeArguments = new char[length][][][];
+ for (int i=0; i<length; i++) {
+ parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
+ parametersTypeArguments[i] = Util.getAllTypeArguments(parametersTypeSignatures[i]);
+ }
+ }
+ }
+
+ // Store type signatures and arguments for method
+ constructorArguments = extractMethodArguments(method);
+ if (hasConstructorArguments()) ((InternalSearchPattern)this).mustResolve = true;
+}
+/*
+ * Instanciate a method pattern with signatures for generics search
+ */
+public ConstructorPattern(
+ boolean findDeclarations,
+ boolean findReferences,
+ char[] declaringSimpleName,
+ char[] declaringQualification,
+ String declaringSignature,
+ char[][] parameterQualifications,
+ char[][] parameterSimpleNames,
+ String[] parameterSignatures,
+ char[][] arguments,
+ int matchRule) {
+
+ this(findDeclarations,
+ findReferences,
+ declaringSimpleName,
+ declaringQualification,
+ parameterQualifications,
+ parameterSimpleNames,
+ matchRule);
+
+ // Store type signature and arguments for declaring type
+ if (declaringSignature != null) {
+ typeSignatures = Util.splitTypeLevelsSignature(declaringSignature);
+ setTypeArguments(Util.getAllTypeArguments(typeSignatures));
+ }
+
+ // Store type signatures and arguments for method parameters type
+ if (parameterSignatures != null) {
+ int length = parameterSignatures.length;
+ if (length > 0) {
+ parametersTypeSignatures = new char[length][][];
+ parametersTypeArguments = new char[length][][][];
+ for (int i=0; i<length; i++) {
+ parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
+ parametersTypeArguments[i] = Util.getAllTypeArguments(parametersTypeSignatures[i]);
+ }
+ }
+ }
+
+ // Store type signatures and arguments for method
+ constructorArguments = arguments;
+ if (arguments == null || arguments.length == 0) {
+ if (getTypeArguments() != null && getTypeArguments().length > 0) {
+ constructorArguments = getTypeArguments()[0];
+ }
+ }
+ if (hasConstructorArguments()) ((InternalSearchPattern)this).mustResolve = true;
+}
+public void decodeIndexKey(char[] key) {
+ int last = key.length - 1;
+ this.parameterCount = 0;
+ this.declaringSimpleName = null;
+ int power = 1;
+ for (int i=last; i>=0; i--) {
+ if (key[i] == SEPARATOR) {
+ System.arraycopy(key, 0, this.declaringSimpleName = new char[i], 0, i);
+ break;
+ }
+ if (i == last) {
+ this.parameterCount = key[i] - '0';
+ } else {
+ power *= 10;
+ this.parameterCount += power * (key[i] - '0');
+ }
+ }
+}
+public SearchPattern getBlankPattern() {
+ return new ConstructorPattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
+}
+public char[][] getIndexCategories() {
+ if (this.findReferences)
+ return this.findDeclarations ? REF_AND_DECL_CATEGORIES : REF_CATEGORIES;
+ if (this.findDeclarations)
+ return DECL_CATEGORIES;
+ return CharOperation.NO_CHAR_CHAR;
+}
+boolean hasConstructorArguments() {
+ return constructorArguments != null && constructorArguments.length > 0;
+}
+boolean hasConstructorParameters() {
+ return constructorParameters;
+}
+public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ ConstructorPattern pattern = (ConstructorPattern) decodedPattern;
+
+ return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
+ && matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
+}
+protected boolean mustResolve() {
+ if (this.declaringQualification != null) return true;
+
+ // parameter types
+ if (this.parameterSimpleNames != null)
+ for (int i = 0, max = this.parameterSimpleNames.length; i < max; i++)
+ if (this.parameterQualifications[i] != null) return true;
+ return this.findReferences; // need to check resolved default constructors and explicit constructor calls
+}
+EntryResult[] queryIn(Index index) throws IOException {
+ char[] key = this.declaringSimpleName; // can be null
+ int matchRule = getMatchRule();
+
+ switch(getMatchMode()) {
+ case R_EXACT_MATCH :
+ if (this.isCamelCase) break;
+ if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs)
+ key = createIndexKey(this.declaringSimpleName, this.parameterCount);
+ else { // do a prefix query with the declaringSimpleName
+ matchRule &= ~R_EXACT_MATCH;
+ matchRule |= R_PREFIX_MATCH;
+ }
+ break;
+ case R_PREFIX_MATCH :
+ // do a prefix query with the declaringSimpleName
+ break;
+ case R_PATTERN_MATCH :
+ if (this.parameterCount >= 0 && !this.varargs)
+ key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
+ else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
+ key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
+ // else do a pattern query with just the declaringSimpleName
+ break;
+ case R_REGEXP_MATCH :
+ // TODO (frederic) implement regular expression match
+ break;
+ }
+
+ return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
+}
+protected StringBuffer print(StringBuffer output) {
+ if (this.findDeclarations) {
+ output.append(this.findReferences
+ ? "ConstructorCombinedPattern: " //$NON-NLS-1$
+ : "ConstructorDeclarationPattern: "); //$NON-NLS-1$
+ } else {
+ output.append("ConstructorReferencePattern: "); //$NON-NLS-1$
+ }
+ if (declaringQualification != null)
+ output.append(declaringQualification).append('.');
+ if (declaringSimpleName != null)
+ output.append(declaringSimpleName);
+ else if (declaringQualification != null)
+ output.append("*"); //$NON-NLS-1$
+
+ output.append('(');
+ if (parameterSimpleNames == null) {
+ output.append("..."); //$NON-NLS-1$
+ } else {
+ for (int i = 0, max = parameterSimpleNames.length; i < max; i++) {
+ if (i > 0) output.append(", "); //$NON-NLS-1$
+ if (parameterQualifications[i] != null) output.append(parameterQualifications[i]).append('.');
+ if (parameterSimpleNames[i] == null) output.append('*'); else output.append(parameterSimpleNames[i]);
+ }
+ }
+ output.append(')');
+ return super.print(output);
+}
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 18:55:31 UTC (rev 2157)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 19:15:56 UTC (rev 2158)
@@ -8,6 +8,7 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.IRubySearchScope;
import org.rubypeople.rdt.core.search.SearchDocument;
@@ -15,6 +16,7 @@
import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.core.search.SearchRequestor;
import org.rubypeople.rdt.internal.compiler.env.INameEnvironment;
+import org.rubypeople.rdt.internal.compiler.impl.ITypeRequestor;
import org.rubypeople.rdt.internal.compiler.lookup.LookupEnvironment;
import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
import org.rubypeople.rdt.internal.core.ExternalSourceFolderRoot;
@@ -25,10 +27,32 @@
import org.rubypeople.rdt.internal.core.search.BasicSearchEngine;
import org.rubypeople.rdt.internal.core.search.RubySearchDocument;
import org.rubypeople.rdt.internal.core.util.HandleFactory;
+import org.rubypeople.rdt.internal.core.util.Messages;
import org.rubypeople.rdt.internal.core.util.Util;
-public class MatchLocator {
+public class MatchLocator implements ITypeRequestor {
+ public static final int MAX_AT_ONCE;
+ static {
+ long maxMemory = Runtime.getRuntime().maxMemory();
+ int ratio = (int) Math.round(((double) maxMemory) / (64 * 0x100000));
+ switch (ratio) {
+ case 0:
+ case 1:
+ MAX_AT_ONCE = 100;
+ break;
+ case 2:
+ MAX_AT_ONCE = 200;
+ break;
+ case 3:
+ MAX_AT_ONCE = 300;
+ break;
+ default:
+ MAX_AT_ONCE = 400;
+ break;
+ }
+ }
+
// permanent state
public SearchPattern pattern;
public PatternLocator patternLocator;
@@ -222,5 +246,123 @@
this.bindings = null;
}
}
+
+ /**
+ * Locate the matches amongst the possible matches.
+ */
+ protected void locateMatches(RubyProject javaProject, PossibleMatchSet matchSet, int expected) throws CoreException {
+ PossibleMatch[] possibleMatches = matchSet.getPossibleMatches(javaProject.getSourceFolderRoots());
+ int length = possibleMatches.length;
+ // increase progress from duplicate matches not stored in matchSet while adding...
+ if (this.progressMonitor != null && expected>length) {
+ this.progressWorked += expected-length;
+ this.progressMonitor.worked( expected-length);
+ }
+ // locate matches (processed matches are limited to avoid problem while using VM default memory heap size)
+ for (int index = 0; index < length;) {
+ int max = Math.min(MAX_AT_ONCE, length - index);
+ locateMatches(javaProject, possibleMatches, index, max);
+ index += max;
+ }
+ this.patternLocator.clear();
+ }
+
+ protected void locateMatches(RubyProject javaProject, PossibleMatch[] possibleMatches, int start, int length) throws CoreException {
+ initialize(javaProject, length);
+ // create and resolve binding (equivalent to beginCompilation() in Compiler)
+ boolean mustResolvePattern = ((InternalSearchPattern)this.pattern).mustResolve;
+ boolean mustResolve = mustResolvePattern;
+ this.patternLocator.mayBeGeneric = this.options.sourceLevel >= ClassFileConstants.JDK1_5;
+ boolean bindingsWereCreated = mustResolve;
+ try {
+ for (int i = start, maxUnits = start + length; i < maxUnits; i++) {
+ PossibleMatch possibleMatch = possibleMatches[i];
+ try {
+ if (!parseAndBuildBindings(possibleMatch, mustResolvePattern)) continue;
+ // Currently we only need to resolve over pattern flag if there's potential parameterized types
+ if (this.patternLocator.mayBeGeneric) {
+ // If pattern does not resolve then rely on possible match node set resolution
+ // which may have been modified while locator was adding possible matches to it
+ if (!mustResolvePattern && !mustResolve) {
+ mustResolve = possibleMatch.nodeSet.mustResolve;
+ bindingsWereCreated = mustResolve;
+ }
+ } else {
+ // Reset matching node resolution with pattern one if there's no potential parameterized type
+ // to minimize side effect on previous search behavior
+ possibleMatch.nodeSet.mustResolve = mustResolvePattern;
+ }
+ // possible match node resolution has been merged with pattern one, so rely on it to know
+ // whether we need to process compilation unit now or later
+ if (!possibleMatch.nodeSet.mustResolve) {
+ if (this.progressMonitor != null) {
+ this.progressWorked++;
+ if ((this.progressWorked%this.progressStep)==0) this.progressMonitor.worked(this.progressStep);
+ }
+ process(possibleMatch, bindingsWereCreated);
+ if (this.numberOfMatches>0 && this.matchesToProcess[this.numberOfMatches-1] == possibleMatch) {
+ // forget last possible match as it was processed
+ this.numberOfMatches--;
+ }
+ }
+ } finally {
+ if (!possibleMatch.nodeSet.mustResolve)
+ possibleMatch.cleanUp();
+ }
+ }
+ if (mustResolve)
+ this.lookupEnvironment.completeTypeBindings();
+
+ // create hierarchy resolver if needed
+ IType focusType = getFocusType();
+ if (focusType == null) {
+ this.hierarchyResolver = null;
+ } else if (!createHierarchyResolver(focusType, possibleMatches)) {
+ // focus type is not visible, use the super type names instead of the bindings
+ if (computeSuperTypeNames(focusType) == null) return;
+ }
+ } catch (AbortCompilation e) {
+ bindingsWereCreated = false;
+ }
+
+ if (!mustResolve) {
+ return;
+ }
+
+ // possible match resolution
+ for (int i = 0; i < this.numberOfMatches; i++) {
+ if (this.progressMonitor != null && this.progressMonitor.isCanceled())
+ throw new OperationCanceledException();
+ PossibleMatch possibleMatch = this.matchesToProcess[i];
+ this.matchesToProcess[i] = null; // release reference to processed possible match
+ try {
+ process(possibleMatch, bindingsWereCreated);
+ } catch (AbortCompilation e) {
+ // problem with class path: it could not find base classes
+ // continue and try next matching openable reporting innacurate matches (since bindings will be null)
+ bindingsWereCreated = false;
+ } catch (RubyModelException e) {
+ // problem with class path: it could not find base classes
+ // continue and try next matching openable reporting innacurate matches (since bindings will be null)
+ bindingsWereCreated = false;
+ } finally {
+ if (this.progressMonitor != null) {
+ this.progressWorked++;
+ if ((this.progressWorked%this.progressStep)==0) this.progressMonitor.worked(this.progressStep);
+ }
+ if (this.options.verbose)
+ System.out.println(
+ Messages.bind(Messages.compilation_done,
+ new String[] {
+ String.valueOf(i + 1),
+ String.valueOf(this.numberOfMatches),
+ new String(possibleMatch.parsedUnit.getFileName())
+ }));
+ // cleanup compilation unit result
+ possibleMatch.cleanUp();
+ }
+ }
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java 2007-03-13 18:55:31 UTC (rev 2157)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java 2007-03-13 19:15:56 UTC (rev 2158)
@@ -65,4 +65,11 @@
}
return null;
}
+
+ /*
+ * Clear caches
+ */
+ protected void clear() {
+ // nothing to clear by default
+ }
}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/RubySearchPattern.java 2007-03-13 19:15:56 UTC (rev 2158)
@@ -0,0 +1,205 @@
+package org.rubypeople.rdt.internal.core.search.matching;
+
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public class RubySearchPattern extends SearchPattern {
+
+
+ /*
+ * Whether this pattern is case sensitive.
+ */
+ boolean isCaseSensitive;
+
+ /*
+ * Whether this pattern is camel case.
+ */
+ boolean isCamelCase;
+
+ /**
+ * One of following pattern value:
+ * <ul>
+ * <li>{@link #R_EXACT_MATCH}</li>
+ * <li>{@link #R_PREFIX_MATCH}</li>
+ * <li>{@link #R_PATTERN_MATCH}</li>
+ * <li>{@link #R_REGEXP_MATCH}</li>
+ * <li>{@link #R_CAMELCASE_MATCH}</li>
+ * </ul>
+ */
+ int matchMode;
+
+ /**
+ * One of {@link #R_ERASURE_MATCH}, {@link #R_EQUIVALENT_MATCH}, {@link #R_FULL_MATCH}.
+ */
+ int matchCompatibility;
+
+ /**
+ * Mask used on match rule for match mode.
+ */
+ public static final int MATCH_MODE_MASK = R_EXACT_MATCH | R_PREFIX_MATCH | R_PATTERN_MATCH | R_REGEXP_MATCH;
+
+ /**
+ * Mask used on match rule for generic relevance.
+ */
+ public static final int MATCH_COMPATIBILITY_MASK = R_ERASURE_MATCH | R_EQUIVALENT_MATCH | R_FULL_MATCH;
+
+ // Signatures and arguments for parameterized types search
+ char[][] typeSignatures;
+ private char[][][] typeArguments;
+ private int flags = 0;
+ static final int HAS_TYPE_ARGUMENTS = 1;
+
+ protected RubySearchPattern(int patternKind, int matchRule) {
+ super(matchRule);
+ ((InternalSearchPattern)this).kind = patternKind;
+ // Use getMatchRule() instead of matchRule as super constructor may modify its value
+ // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=81377
+ int rule = getMatchRule();
+ this.isCaseSensitive = (rule & R_CASE_SENSITIVE) != 0;
+ this.isCamelCase = (rule & R_CAMELCASE_MATCH) != 0;
+ this.matchCompatibility = rule & MATCH_COMPATIBILITY_MASK;
+ this.matchMode = rule & MATCH_MODE_MASK;
+ }
+
+ public SearchPattern getBlankPattern() {
+ return null;
+ }
+
+ int getMatchMode() {
+ return this.matchMode;
+ }
+
+ boolean isCamelCase() {
+ return this.isCamelCase;
+ }
+
+ boolean isCaseSensitive () {
+ return this.isCaseSensitive;
+ }
+
+ boolean isErasureMatch() {
+ return (this.matchCompatibility & R_ERASURE_MATCH) != 0;
+ }
+
+ boolean isEquivalentMatch() {
+ return (this.matchCompatibility & R_EQUIVALENT_MATCH) != 0;
+ }
+
+ /**
+ * @return Returns the typeArguments.
+ */
+ final char[][][] getTypeArguments() {
+ return typeArguments;
+ }
+
+ /**
+ * Returns whether the pattern has signatures or not.
+ * If pattern {@link #typeArguments} field, this field shows that it was built
+ * on a generic source type.
+ * @return true if {@link #typeSignatures} field is not null and has a length greater than 0.
+ */
+ public final boolean hasSignatures() {
+ return this.typeSignatures != null && this.typeSignatures.length > 0;
+ }
+
+ /**
+ * Returns whether the pattern includes type arguments information or not.
+ * @return default is false
+ */
+ public final boolean hasTypeArguments() {
+ return (this.flags & HAS_TYPE_ARGUMENTS) != 0;
+ }
+
+ /**
+ * Returns whether the pattern includes type parameters information or not.
+ * @return true if {@link #typeArguments} contains type parameters instead
+ * type arguments signatures.
+ */
+ public final boolean hasTypeParameters() {
+ return !hasSignatures() && hasTypeArguments();
+ }
+
+ protected StringBuffer print(StringBuffer output) {
+ output.append(", "); //$NON-NLS-1$
+ if (hasTypeArguments() && hasSignatures()) {
+ output.append("signature:\""); //$NON-NLS-1$
+ output.append(this.typeSignatures[0]);
+ output.append("\", "); //$NON-NLS-1$
+ }
+ if (this.isCamelCase) {
+ output.append("camel case + "); //$NON-NLS-1$
+ }
+ switch(getMatchMode()) {
+ case R_EXACT_MATCH :
+ output.append("exact match,"); //$NON-NLS-1$
+ break;
+ case R_PREFIX_MATCH :
+ output.append("prefix match,"); //$NON-NLS-1$
+ break;
+ case R_PATTERN_MATCH :
+ output.append("pattern match,"); //$NON-NLS-1$
+ break;
+ case R_REGEXP_MATCH :
+ output.append("regexp match, "); //$NON-NLS-1$
+ break;
+ }
+ if (isCaseSensitive())
+ output.append(" case sensitive"); //$NON-NLS-1$
+ else
+ output.append(" case insensitive"); //$NON-NLS-1$
+ if ((this.matchCompatibility & R_ERASURE_MATCH) != 0) {
+ output.append(", erasure only"); //$NON-NLS-1$
+ }
+ if ((this.matchCompatibility & R_EQUIVALENT_MATCH) != 0) {
+ output.append(", equivalent oronly"); //$NON-NLS-1$
+ }
+ return output;
+ }
+
+ /*
+// * Extract method arguments using unique key for parameterized methods
+ * and type parameters for non-generic ones.
+ */
+ char[][] extractMethodArguments(IMethod method) {
+ String[] argumentsSignatures = null;
+ BindingKey key;
+ if (method.isResolved() && (key = new BindingKey(method.getKey())).isParameterizedType()) {
+ argumentsSignatures = key.getTypeArguments();
+ } else {
+ try {
+ ITypeParameter[] parameters = method.getTypeParameters();
+ if (parameters != null) {
+ int length = parameters.length;
+ if (length > 0) {
+ char[][] arguments = new char[length][];
+ for (int i=0; i<length; i++) {
+ arguments[i] = Signature.createTypeSignature(parameters[i].getElementName(), false).toCharArray();
+ }
+ return arguments;
+ }
+ }
+ }
+ catch (RubyModelException jme) {
+ // do nothing
+ }
+ return null;
+ }
+
+ // Parameterized method
+ if (argumentsSignatures != null) {
+ int length = argumentsSignatures.length;
+ if (length > 0) {
+ char[][] methodArguments = new char[length][];
+ for (int i=0; i<length; i++) {
+ methodArguments[i] = argumentsSignatures[i].toCharArray();
+ CharOperation.replace(methodArguments[i], new char[] { '$', '/' }, '.');
+ }
+ return methodArguments;
+ }
+ }
+ return null;
+ }
+
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-03-13 18:55:31 UTC (rev 2157)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-03-13 19:15:56 UTC (rev 2158)
@@ -1511,4 +1511,155 @@
char[] result = concatWith(array, '.');
return new String(result);
}
+
+ /**
+ * Answers the concatenation of the two arrays. It answers null if the two arrays are null.
+ * If the first array is null, then the second array is returned.
+ * If the second array is null, then the first array is returned.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = { 'a' }
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = null
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = { ' b' }
+ * => result = { ' a' , ' b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param second the second array to concatenate
+ * @return the concatenation of the two arrays, or null if the two arrays are null.
+ */
+ public static final char[] concat(char[] first, char[] second) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+
+ int length1 = first.length;
+ int length2 = second.length;
+ char[] result = new char[length1 + length2];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ return result;
+ }
+
+ /**
+ * Answers the result of a char[] conversion to lowercase. Answers null if the given chars array is null.
+ * <br>
+ * NOTE: If no conversion was necessary, then answers back the argument one.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * chars = { 'a' , 'b' }
+ * result => { 'a' , 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'A', 'b' }
+ * result => { 'a' , 'b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param chars the chars to convert
+ * @return the result of a char[] conversion to lowercase
+ */
+ final static public char[] toLowerCase(char[] chars) {
+ if (chars == null)
+ return null;
+ int length = chars.length;
+ char[] lowerChars = null;
+ for (int i = 0; i < length; i++) {
+ char c = chars[i];
+ char lc = ScannerHelper.toLowerCase(c);
+ if ((c != lc) || (lowerChars != null)) {
+ if (lowerChars == null) {
+ System.arraycopy(
+ chars,
+ 0,
+ lowerChars = new char[length],
+ 0,
+ i);
+ }
+ lowerChars[i] = lc;
+ }
+ }
+ return lowerChars == null ? chars : lowerChars;
+ }
+
+ /**
+ * Replace all occurrences of characters to be replaced with the remplacement character in the
+ * given array.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { 'a' , 'b', 'b', 'c', 'a', 'b', 'c', 'a' }
+ * toBeReplaced = { 'b', 'c' }
+ * replacementChar = 'a'
+ * result => No returned value, but array is now equals to { 'a' , 'a', 'a', 'a', 'a', 'a', 'a', 'a' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param toBeReplaced characters to be replaced
+ * @param replacementChar the replacement character
+ * @throws NullPointerException if arrays are null.
+ * @since 3.1
+ */
+ public static final void replace(char[] array, char[] toBeReplaced, char replacementChar) {
+ replace(array, toBeReplaced, replacementChar, 0, array.length);
+ }
+
+ /**
+ * Replace all occurrences of characters to be replaced with the remplacement character in the
+ * given array from the start position (inclusive) to the end position (exclusive).
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { 'a' , 'b', 'b', 'c', 'a', 'b', 'c', 'a' }
+ * toBeReplaced = { 'b', 'c' }
+ * replacementChar = 'a'
+ * start = 4
+ * end = 8
+ * result => No returned value, but array is now equals to { 'a' , 'b', 'b', 'c', 'a', 'a', 'a', 'a' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param toBeReplaced characters to be replaced
+ * @param replacementChar the replacement character
+ * @param start the given start position (inclusive)
+ * @param end the given end position (exclusive)
+ * @throws NullPointerException if arrays are null.
+ * @since 3.2
+ */
+ public static final void replace(char[] array, char[] toBeReplaced, char replacementChar, int start, int end) {
+ for (int i = end; --i >= start;)
+ for (int j = toBeReplaced.length; --j >= 0;)
+ if (array[i] == toBeReplaced[j])
+ array[i] = replacementChar;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:55:33
|
Revision: 2157
http://svn.sourceforge.net/rubyeclipse/?rev=2157&view=rev
Author: cawilliams
Date: 2007-03-13 11:55:31 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 18:53:47 UTC (rev 2156)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 18:55:31 UTC (rev 2157)
@@ -14,6 +14,8 @@
import org.rubypeople.rdt.core.search.SearchParticipant;
import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.core.search.SearchRequestor;
+import org.rubypeople.rdt.internal.compiler.env.INameEnvironment;
+import org.rubypeople.rdt.internal.compiler.lookup.LookupEnvironment;
import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
import org.rubypeople.rdt.internal.core.ExternalSourceFolderRoot;
import org.rubypeople.rdt.internal.core.Openable;
@@ -35,6 +37,10 @@
public IRubySearchScope scope;
public IProgressMonitor progressMonitor;
+// the following is valid for the current project
+ public INameEnvironment nameEnvironment;
+ public LookupEnvironment lookupEnvironment;
+
public org.rubypeople.rdt.core.IRubyScript[] workingCopies;
public HandleFactory handleFactory;
@@ -118,7 +124,7 @@
this.bindings = new SimpleLookupTable();
try {
// optimize access to zip files during search operation
- manager.cacheZipFiles();
+// manager.cacheZipFiles();
// initialize handle factory (used as a cache of handles so as to optimize space)
if (this.handleFactory == null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:54:00
|
Revision: 2156
http://svn.sourceforge.net/rubyeclipse/?rev=2156&view=rev
Author: cawilliams
Date: 2007-03-13 11:53:47 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/TypeDeclaration.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/TypeDeclaration.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/TypeDeclaration.java 2007-03-13 18:49:54 UTC (rev 2155)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/TypeDeclaration.java 2007-03-13 18:53:47 UTC (rev 2156)
@@ -1,5 +1,13 @@
package org.rubypeople.rdt.internal.compiler.ast;
+import org.jruby.ast.Node;
+
public class TypeDeclaration {
+
+ public int sourceStart;
+
+ public TypeDeclaration(Node node) {
+ this.sourceStart = node.getPosition().getStartOffset();
+ }
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java 2007-03-13 18:49:54 UTC (rev 2155)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java 2007-03-13 18:53:47 UTC (rev 2156)
@@ -236,9 +236,9 @@
int index = 0;
for (int i = 0; i < length; i++) {
IPath path = enclosingProjectsAndJars[i];
- if (!org.rubypeople.rdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment())) {
+// if (!org.rubypeople.rdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment())) {
projects[index++] = this.javaModel.getRubyProject(path.segment(0));
- }
+// }
}
if (index < length) {
System.arraycopy(projects, 0, projects = new IRubyProject[index], 0, index);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
Revision: 2155
http://svn.sourceforge.net/rubyeclipse/?rev=2155&view=rev
Author: cawilliams
Date: 2007-03-13 11:49:54 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java 2007-03-13 18:46:57 UTC (rev 2154)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java 2007-03-13 18:49:54 UTC (rev 2155)
@@ -15,6 +15,7 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.search.SearchDocument;
+import org.rubypeople.rdt.internal.compiler.ast.ModuleDeclaration;
import org.rubypeople.rdt.internal.compiler.env.IRubyScript;
import org.rubypeople.rdt.internal.core.Openable;
import org.rubypeople.rdt.internal.core.RubyScript;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:47:07
|
Revision: 2154
http://svn.sourceforge.net/rubyeclipse/?rev=2154&view=rev
Author: cawilliams
Date: 2007-03-13 11:46:57 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/SourceModuleScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/TypeScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/lookup/LookupEnvironment.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/ModuleDeclaration.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/TypeDeclaration.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/impl/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/impl/ITypeRequestor.java
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/ModuleDeclaration.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/ModuleDeclaration.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/ModuleDeclaration.java 2007-03-13 18:46:57 UTC (rev 2154)
@@ -0,0 +1,9 @@
+package org.rubypeople.rdt.internal.compiler.ast;
+
+import org.rubypeople.rdt.internal.compiler.env.lookup.Scope;
+
+public class ModuleDeclaration {
+
+ public Scope scope;
+
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/TypeDeclaration.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/TypeDeclaration.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ast/TypeDeclaration.java 2007-03-13 18:46:57 UTC (rev 2154)
@@ -0,0 +1,5 @@
+package org.rubypeople.rdt.internal.compiler.ast;
+
+public class TypeDeclaration {
+
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/SourceModuleScope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/SourceModuleScope.java 2007-03-13 18:42:18 UTC (rev 2153)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/SourceModuleScope.java 2007-03-13 18:46:57 UTC (rev 2154)
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.rubypeople.rdt.internal.compiler.env.lookup;
+import org.rubypeople.rdt.internal.compiler.ast.ModuleDeclaration;
import org.rubypeople.rdt.internal.compiler.lookup.LookupEnvironment;
import org.rubypeople.rdt.internal.compiler.util.CompoundNameVector;
import org.rubypeople.rdt.internal.compiler.util.HashtableOfObject;
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/TypeScope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/TypeScope.java 2007-03-13 18:42:18 UTC (rev 2153)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/TypeScope.java 2007-03-13 18:46:57 UTC (rev 2154)
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.rubypeople.rdt.internal.compiler.env.lookup;
+import org.rubypeople.rdt.internal.compiler.ast.TypeDeclaration;
+
public class TypeScope extends Scope {
public TypeDeclaration referenceContext;
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/impl/ITypeRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/impl/ITypeRequestor.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/impl/ITypeRequestor.java 2007-03-13 18:46:57 UTC (rev 2154)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.compiler.impl;
+
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.internal.compiler.env.AccessRestriction;
+import org.rubypeople.rdt.internal.compiler.env.IRubyScript;
+
+public interface ITypeRequestor {
+ /**
+ * Accept the requested type's compilation unit.
+ */
+ void accept(IRubyScript unit, AccessRestriction accessRestriction);
+
+ /**
+ * Accept the unresolved source forms for the requested type.
+ * Note that the multiple source forms can be answered, in case the target compilation unit
+ * contains multiple types. The first one is then guaranteed to be the one corresponding to the
+ * requested type.
+ */
+ void accept(IType[] sourceType, PackageBinding packageBinding, AccessRestriction accessRestriction);
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/lookup/LookupEnvironment.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/lookup/LookupEnvironment.java 2007-03-13 18:42:18 UTC (rev 2153)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/lookup/LookupEnvironment.java 2007-03-13 18:46:57 UTC (rev 2154)
@@ -1,7 +1,10 @@
package org.rubypeople.rdt.internal.compiler.lookup;
+import org.rubypeople.rdt.internal.compiler.ast.ModuleDeclaration;
import org.rubypeople.rdt.internal.compiler.env.AccessRestriction;
+import org.rubypeople.rdt.internal.compiler.env.INameEnvironment;
import org.rubypeople.rdt.internal.compiler.env.lookup.SourceModuleScope;
+import org.rubypeople.rdt.internal.compiler.impl.ITypeRequestor;
public class LookupEnvironment {
public LookupEnvironment(ITypeRequestor typeRequestor, INameEnvironment nameEnvironment) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:42:20
|
Revision: 2153
http://svn.sourceforge.net/rubyeclipse/?rev=2153&view=rev
Author: cawilliams
Date: 2007-03-13 11:42:18 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java 2007-03-13 18:41:12 UTC (rev 2152)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java 2007-03-13 18:42:18 UTC (rev 2153)
@@ -69,7 +69,7 @@
// remove existing node at same position from set
// (case of recovery that created the same node several time
// see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
- long key = (((long) node.sourceStart()) << 32) + node.getPosition().getEndOffset();
+ long key = (((long) node.getPosition().getStartOffset()) << 32) + node.getPosition().getEndOffset();
Node existing = (Node) this.possibleMatchingNodesKeys.get(key);
if (existing != null && existing.getClass().equals(node.getClass()))
this.possibleMatchingNodesSet.remove(existing);
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java 2007-03-13 18:41:12 UTC (rev 2152)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java 2007-03-13 18:42:18 UTC (rev 2153)
@@ -5,6 +5,23 @@
public class PatternLocator {
+ /* match levels */
+ public static final int IMPOSSIBLE_MATCH = 0;
+ public static final int INACCURATE_MATCH = 1;
+ public static final int POSSIBLE_MATCH = 2;
+ public static final int ACCURATE_MATCH = 3;
+ public static final int ERASURE_MATCH = 4;
+
+// Possible rule match flavors
+// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=79866
+ protected static final int POSSIBLE_FULL_MATCH = POSSIBLE_MATCH | (SearchPattern.R_FULL_MATCH<<16);
+ protected static final int POSSIBLE_PREFIX_MATCH = POSSIBLE_MATCH | (SearchPattern.R_PREFIX_MATCH<<16);
+ protected static final int POSSIBLE_PATTERN_MATCH = POSSIBLE_MATCH | (SearchPattern.R_PATTERN_MATCH<<16);
+ protected static final int POSSIBLE_REGEXP_MATCH = POSSIBLE_MATCH | (SearchPattern.R_REGEXP_MATCH<<16);
+ protected static final int POSSIBLE_CAMELCASE_MATCH = POSSIBLE_MATCH | (SearchPattern.R_CAMELCASE_MATCH<<16);
+ protected static final int NODE_SET_MASK = 0xFF;
+ protected static final int POSSIBLE_MATCH_MASK = ~NODE_SET_MASK;
+
/* match container */
public static final int COMPILATION_UNIT_CONTAINER = 1;
public static final int CLASS_CONTAINER = 2;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
Revision: 2152
http://svn.sourceforge.net/rubyeclipse/?rev=2152&view=rev
Author: cawilliams
Date: 2007-03-13 11:41:12 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java 2007-03-13 18:39:28 UTC (rev 2151)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java 2007-03-13 18:41:12 UTC (rev 2152)
@@ -69,7 +69,7 @@
// remove existing node at same position from set
// (case of recovery that created the same node several time
// see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
- long key = (((long) node.sourceStart()) << 32) + node.sourceEnd();
+ long key = (((long) node.sourceStart()) << 32) + node.getPosition().getEndOffset();
Node existing = (Node) this.possibleMatchingNodesKeys.get(key);
if (existing != null && existing.getClass().equals(node.getClass()))
this.possibleMatchingNodesSet.remove(existing);
@@ -86,7 +86,7 @@
// remove existing node at same position from set
// (case of recovery that created the same node several time
// see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
- long key = (((long) node.sourceStart()) << 32) + node.sourceEnd();
+ long key = (((long) node.getPosition().getStartOffset()) << 32) + node.getPosition().getEndOffset();
Node existing = (Node) this.matchingNodesKeys.get(key);
if (existing != null && existing.getClass().equals(node.getClass()))
this.matchingNodes.removeKey(existing);
@@ -99,13 +99,13 @@
Object[] nodes = this.possibleMatchingNodesSet.values;
for (int i = 0, l = nodes.length; i < l; i++) {
Node node = (Node) nodes[i];
- if (node != null && start <= node.sourceStart() && node.sourceEnd() <= end)
+ if (node != null && start <= node.getPosition().getStartOffset() && node.getPosition().getEndOffset() <= end)
return true;
}
nodes = this.matchingNodes.keyTable;
for (int i = 0, l = nodes.length; i < l; i++) {
Node node = (Node) nodes[i];
- if (node != null && start <= node.sourceStart() && node.sourceEnd() <= end)
+ if (node != null && start <= node.getPosition().getStartOffset() && node.getPosition().getEndOffset() <= end)
return true;
}
return false;
@@ -120,7 +120,7 @@
Object[] keyTable = this.matchingNodes.keyTable;
for (int i = 0, l = keyTable.length; i < l; i++) {
Node node = (Node) keyTable[i];
- if (node != null && start <= node.sourceStart() && node.sourceEnd() <= end) {
+ if (node != null && start <= node.getPosition().getStartOffset() && node.getPosition().getEndOffset() <= end) {
if (nodes == null)
nodes = new ArrayList();
nodes.add(node);
@@ -133,7 +133,7 @@
// sort nodes by source starts
Util.Comparer comparer = new Util.Comparer() {
public int compare(Object o1, Object o2) {
- return ((Node) o1).sourceStart() - ((Node) o2).sourceStart();
+ return ((Node) o1).getPosition().getStartOffset() - ((Node) o2).getPosition().getStartOffset();
}
};
Util.sort(result, comparer);
@@ -141,7 +141,7 @@
}
public Object removePossibleMatch(Node node) {
- long key = (((long) node.sourceStart()) << 32) + node.sourceEnd();
+ long key = (((long) node.getPosition().getStartOffset()) << 32) + node.getPosition().getEndOffset();
Node existing = (Node) this.possibleMatchingNodesKeys.get(key);
if (existing == null)
return null;
@@ -150,7 +150,7 @@
}
public Object removeTrustedMatch(Node node) {
- long key = (((long) node.sourceStart()) << 32) + node.sourceEnd();
+ long key = (((long) node.getPosition().getStartOffset()) << 32) + node.getPosition().getEndOffset();
Node existing = (Node) this.matchingNodesKeys.get(key);
if (existing == null)
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:39:42
|
Revision: 2151
http://svn.sourceforge.net/rubyeclipse/?rev=2151&view=rev
Author: cawilliams
Date: 2007-03-13 11:39:28 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-03-13 18:35:20 UTC (rev 2150)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-03-13 18:39:28 UTC (rev 2151)
@@ -1485,4 +1485,30 @@
System.arraycopy(array, start, result, 0, end - start);
return result;
}
+
+ /**
+ * Answers a string which is the concatenation of the given array using the '.' as a separator.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { { 'a' } , { 'b' } }
+ * result => "a.b"
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { { ' ', 'a' } , { 'b' } }
+ * result => " a.b"
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param array the given array
+ * @return a string which is the concatenation of the given array using the '.' as a separator
+ */
+ final static public String toString(char[][] array) {
+ char[] result = concatWith(array, '.');
+ return new String(result);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:35:27
|
Revision: 2150
http://svn.sourceforge.net/rubyeclipse/?rev=2150&view=rev
Author: cawilliams
Date: 2007-03-13 11:35:20 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/IDependent.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/IRubyScript.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatchSet.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-03-13 18:22:14 UTC (rev 2149)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -317,6 +317,7 @@
private static final boolean VERBOSE = false;
+ public static final boolean DEBUG = false;
private SymbolIndex symbolIndex;
private ISymbolFinder symbolFinder;
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/IDependent.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/IDependent.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/IDependent.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.compiler.env;
+
+/**
+ * This represents the target file of a type dependency.
+ *
+ * All implementors of this interface are containers for types or types
+ * themselves which must be able to identify their source file name when file
+ * dependencies are collected.
+ */
+public interface IDependent {
+ char JAR_FILE_ENTRY_SEPARATOR = '|';
+
+ /**
+ * Answer the file name which defines the type.
+ *
+ * The path part (optional) must be separated from the actual file proper
+ * name by a separator suitable for the type (java.io.File.separator for
+ * example), e.g. "c:\\source\\com\\p\\X.java" or "/com/p/Y.java".
+ *
+ * The path to the zip or jar file (optional) must be separated from the
+ * actual path part by JAR_FILE_ENTRY_SEPARATOR, e.g.
+ * "c:\\lib\\some.jar|/com/p/X.class" or "/lib/some.zip|/com/q/Y.class".
+ *
+ * The proper file name includes the suffix extension (e.g. ".java")
+ * e.g. "c:/org/eclipse/jdt/internal/compileri/env/IDependent.java"
+ *
+ * Return null if no file defines the type.
+ */
+
+ char[] getFileName();
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/IRubyScript.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/IRubyScript.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/IRubyScript.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -0,0 +1,24 @@
+package org.rubypeople.rdt.internal.compiler.env;
+
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.IRubyElement;
+
+public interface IRubyScript extends IDependent {
+
+ /**
+ * Answer the name of the package according to the directory structure or
+ * null if package consistency checks should be ignored. For example, {java,
+ * lang}.
+ */
+ IPath getScriptFolder();
+
+ /**
+ * Answer the contents of the compilation unit.
+ *
+ * In normal use, the contents are requested twice. Once during the initial
+ * lite parsing step, then again for the more detailed parsing step.
+ */
+ String getSourceContents();
+
+ IRubyElement getRubyElement();
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfLong.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.compiler.util;
+
+
+ /**
+ * Hashtable for non-zero long keys.
+ */
+
+public final class HashtableOfLong {
+ // to avoid using Enumerations, walk the individual tables skipping nulls
+ public long[] keyTable;
+ public Object[] valueTable;
+
+ public int elementSize; // number of elements in the table
+ int threshold;
+public HashtableOfLong() {
+ this(13);
+}
+public HashtableOfLong(int size) {
+ this.elementSize = 0;
+ this.threshold = size; // size represents the expected number of elements
+ int extraRoom = (int) (size * 1.75f);
+ if (this.threshold == extraRoom)
+ extraRoom++;
+ this.keyTable = new long[extraRoom];
+ this.valueTable = new Object[extraRoom];
+}
+public boolean containsKey(long key) {
+ int length = keyTable.length,
+ index = ((int)(key >>> 32)) % length;
+ long currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key)
+ return true;
+ if (++index == length) {
+ index = 0;
+ }
+ }
+ return false;
+}
+public Object get(long key) {
+ int length = keyTable.length,
+ index = ((int)(key >>> 32)) % length;
+ long currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key) return valueTable[index];
+ if (++index == length) {
+ index = 0;
+ }
+ }
+ return null;
+}
+public Object put(long key, Object value) {
+ int length = keyTable.length,
+ index = ((int)(key >>> 32)) % length;
+ long currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key) return valueTable[index] = value;
+ if (++index == length) {
+ index = 0;
+ }
+ }
+ keyTable[index] = key;
+ valueTable[index] = value;
+
+ // assumes the threshold is never equal to the size of the table
+ if (++elementSize > threshold)
+ rehash();
+ return value;
+}
+private void rehash() {
+ HashtableOfLong newHashtable = new HashtableOfLong(elementSize * 2); // double the number of expected elements
+ long currentKey;
+ for (int i = keyTable.length; --i >= 0;)
+ if ((currentKey = keyTable[i]) != 0)
+ newHashtable.put(currentKey, valueTable[i]);
+
+ this.keyTable = newHashtable.keyTable;
+ this.valueTable = newHashtable.valueTable;
+ this.threshold = newHashtable.threshold;
+}
+public int size() {
+ return elementSize;
+}
+public String toString() {
+ String s = ""; //$NON-NLS-1$
+ Object object;
+ for (int i = 0, length = valueTable.length; i < length; i++)
+ if ((object = valueTable[i]) != null)
+ s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
+ return s;
+}
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 18:22:14 UTC (rev 2149)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -41,6 +41,8 @@
// Progress information
int progressStep;
int progressWorked;
+
+ SimpleLookupTable bindings;
public static class WorkingCopyDocument extends RubySearchDocument {
public org.rubypeople.rdt.core.IRubyScript workingCopy;
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchingNodeSet.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * 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.matching;
+
+import java.util.ArrayList;
+
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.search.SearchMatch;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.compiler.util.HashtableOfLong;
+import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
+import org.rubypeople.rdt.internal.compiler.util.SimpleSet;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+/**
+ * A set of matches and possible matches, which need to be resolved.
+ */
+public class MatchingNodeSet {
+ /**
+ * Map of matching ast nodes that don't need to be resolved to their
+ * accuracy level. Each node is removed as it is reported.
+ */
+ public SimpleLookupTable matchingNodes = new SimpleLookupTable(3); // node ->
+ // accuracy
+ private HashtableOfLong matchingNodesKeys = new HashtableOfLong(3); // sourceRange
+ // ->
+ // node
+ static Integer EXACT_MATCH = new Integer(SearchMatch.A_ACCURATE);
+ static Integer POTENTIAL_MATCH = new Integer(SearchMatch.A_INACCURATE);
+ static Integer ERASURE_MATCH = new Integer(SearchPattern.R_ERASURE_MATCH);
+ /**
+ * Set of possible matching ast nodes. They need to be resolved to determine
+ * if they really match the search pattern.
+ */
+ public SimpleSet possibleMatchingNodesSet = new SimpleSet(7);
+ private HashtableOfLong possibleMatchingNodesKeys = new HashtableOfLong(7);
+
+ public MatchingNodeSet() {
+ super();
+ }
+
+ public int addMatch(Node node, int matchLevel) {
+ switch (matchLevel & PatternLocator.NODE_SET_MASK) {
+ case PatternLocator.INACCURATE_MATCH:
+ addTrustedMatch(node, POTENTIAL_MATCH);
+ break;
+ case PatternLocator.POSSIBLE_MATCH:
+ addPossibleMatch(node);
+ break;
+ case PatternLocator.ERASURE_MATCH:
+ addTrustedMatch(node, ERASURE_MATCH);
+ break;
+ case PatternLocator.ACCURATE_MATCH:
+ addTrustedMatch(node, EXACT_MATCH);
+ }
+ return matchLevel;
+ }
+
+ public void addPossibleMatch(Node node) {
+ // remove existing node at same position from set
+ // (case of recovery that created the same node several time
+ // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
+ long key = (((long) node.sourceStart()) << 32) + node.sourceEnd();
+ Node existing = (Node) this.possibleMatchingNodesKeys.get(key);
+ if (existing != null && existing.getClass().equals(node.getClass()))
+ this.possibleMatchingNodesSet.remove(existing);
+ // add node to set
+ this.possibleMatchingNodesSet.add(node);
+ this.possibleMatchingNodesKeys.put(key, node);
+ }
+
+ public void addTrustedMatch(Node node, boolean isExact) {
+ addTrustedMatch(node, isExact ? EXACT_MATCH : POTENTIAL_MATCH);
+ }
+
+ void addTrustedMatch(Node node, Integer level) {
+ // remove existing node at same position from set
+ // (case of recovery that created the same node several time
+ // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
+ long key = (((long) node.sourceStart()) << 32) + node.sourceEnd();
+ Node existing = (Node) this.matchingNodesKeys.get(key);
+ if (existing != null && existing.getClass().equals(node.getClass()))
+ this.matchingNodes.removeKey(existing);
+ // map node to its accuracy level
+ this.matchingNodes.put(node, level);
+ this.matchingNodesKeys.put(key, node);
+ }
+
+ protected boolean hasPossibleNodes(int start, int end) {
+ Object[] nodes = this.possibleMatchingNodesSet.values;
+ for (int i = 0, l = nodes.length; i < l; i++) {
+ Node node = (Node) nodes[i];
+ if (node != null && start <= node.sourceStart() && node.sourceEnd() <= end)
+ return true;
+ }
+ nodes = this.matchingNodes.keyTable;
+ for (int i = 0, l = nodes.length; i < l; i++) {
+ Node node = (Node) nodes[i];
+ if (node != null && start <= node.sourceStart() && node.sourceEnd() <= end)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the matching nodes that are in the given range in the source
+ * order.
+ */
+ public Node[] matchingNodes(int start, int end) {
+ ArrayList nodes = null;
+ Object[] keyTable = this.matchingNodes.keyTable;
+ for (int i = 0, l = keyTable.length; i < l; i++) {
+ Node node = (Node) keyTable[i];
+ if (node != null && start <= node.sourceStart() && node.sourceEnd() <= end) {
+ if (nodes == null)
+ nodes = new ArrayList();
+ nodes.add(node);
+ }
+ }
+ if (nodes == null)
+ return null;
+ Node[] result = new Node[nodes.size()];
+ nodes.toArray(result);
+ // sort nodes by source starts
+ Util.Comparer comparer = new Util.Comparer() {
+ public int compare(Object o1, Object o2) {
+ return ((Node) o1).sourceStart() - ((Node) o2).sourceStart();
+ }
+ };
+ Util.sort(result, comparer);
+ return result;
+ }
+
+ public Object removePossibleMatch(Node node) {
+ long key = (((long) node.sourceStart()) << 32) + node.sourceEnd();
+ Node existing = (Node) this.possibleMatchingNodesKeys.get(key);
+ if (existing == null)
+ return null;
+ this.possibleMatchingNodesKeys.put(key, null);
+ return this.possibleMatchingNodesSet.remove(node);
+ }
+
+ public Object removeTrustedMatch(Node node) {
+ long key = (((long) node.sourceStart()) << 32) + node.sourceEnd();
+ Node existing = (Node) this.matchingNodesKeys.get(key);
+ if (existing == null)
+ return null;
+ this.matchingNodesKeys.put(key, null);
+ return this.matchingNodes.removeKey(node);
+ }
+
+ public String toString() {
+ // TODO (jerome) should show both tables
+ StringBuffer result = new StringBuffer();
+ result.append("Exact matches:"); //$NON-NLS-1$
+ Object[] keyTable = this.matchingNodes.keyTable;
+ Object[] valueTable = this.matchingNodes.valueTable;
+ for (int i = 0, l = keyTable.length; i < l; i++) {
+ Node node = (Node) keyTable[i];
+ if (node == null)
+ continue;
+ result.append("\n\t"); //$NON-NLS-1$
+ switch (((Integer) valueTable[i]).intValue()) {
+ case SearchMatch.A_ACCURATE:
+ result.append("ACCURATE_MATCH: "); //$NON-NLS-1$
+ break;
+ case SearchMatch.A_INACCURATE:
+ result.append("INACCURATE_MATCH: "); //$NON-NLS-1$
+ break;
+ case SearchPattern.R_ERASURE_MATCH:
+ result.append("ERASURE_MATCH: "); //$NON-NLS-1$
+ break;
+ }
+ //node.print(0, result);
+ if (RubyCore.DEBUG) {
+ System.err.println("TODO: Add node print...");
+ }
+ }
+ result.append("\nPossible matches:"); //$NON-NLS-1$
+ Object[] nodes = this.possibleMatchingNodesSet.values;
+ for (int i = 0, l = nodes.length; i < l; i++) {
+ Node node = (Node) nodes[i];
+ if (node == null)
+ continue;
+ result.append("\nPOSSIBLE_MATCH: "); //$NON-NLS-1$
+ //node.print(0, result);
+ if (RubyCore.DEBUG) {
+ System.err.println("TODO: Add node print...");
+ }
+ }
+ return result.toString();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatch.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * 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.matching;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.search.SearchDocument;
+import org.rubypeople.rdt.internal.compiler.env.IRubyScript;
+import org.rubypeople.rdt.internal.core.Openable;
+import org.rubypeople.rdt.internal.core.RubyScript;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public class PossibleMatch implements IRubyScript {
+ public static final String NO_SOURCE_FILE_NAME = "NO SOURCE FILE NAME"; //$NON-NLS-1$
+ public IResource resource;
+ public Openable openable;
+ public MatchingNodeSet nodeSet;
+ public char[][] compoundName;
+ public ModuleDeclaration parsedUnit;
+ public SearchDocument document;
+ private String sourceFileName;
+ private String source;
+
+ public PossibleMatch(MatchLocator locator, IResource resource, Openable openable, SearchDocument document) {
+ this.resource = resource;
+ this.openable = openable;
+ this.document = document;
+ this.nodeSet = new MatchingNodeSet();
+ char[] qualifiedName = getQualifiedName();
+ if (qualifiedName != null)
+ this.compoundName = CharOperation.splitOn('.', qualifiedName);
+ }
+
+ public void cleanUp() {
+ this.source = null;
+ if (this.parsedUnit != null) {
+ //this.parsedUnit.cleanUp();
+ this.parsedUnit = null;
+ }
+ this.nodeSet = null;
+ }
+
+ public boolean equals(Object obj) {
+ if (this.compoundName == null)
+ return super.equals(obj);
+ if (!(obj instanceof PossibleMatch))
+ return false;
+ // By using the compoundName of the source file, multiple .class files
+ // (A, A$M...) are considered equal
+ // Even .class files for secondary types and their nested types
+ return CharOperation.equals(this.compoundName, ((PossibleMatch) obj).compoundName);
+ }
+
+ public String getSourceContents() {
+ if (this.source != null)
+ return this.source;
+ return this.source = new String(this.document.getCharContents());
+ }
+
+ /**
+ * The exact openable file name. In particular, will be the originating
+ * .class file for binary openable with attached source.
+ *
+ * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()
+ * @see PackageReferenceLocator#isDeclaringPackageFragment(IPackageFragment,
+ * org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding)
+ */
+ public char[] getFileName() {
+ return this.openable.getElementName().toCharArray();
+ }
+
+ public char[] getMainTypeName() {
+ // The file is no longer opened to get its name => remove fix for bug
+ // 32182
+ return this.compoundName[this.compoundName.length - 1];
+ }
+
+ public char[][] getPackageName() {
+ int length = this.compoundName.length;
+ if (length <= 1)
+ return CharOperation.NO_CHAR_CHAR;
+ return CharOperation.subarray(this.compoundName, 0, length - 1);
+ }
+
+ /*
+ * Returns the fully qualified name of the main type of the compilation unit
+ * or the main type of the .java file that defined the class file.
+ */
+ private char[] getQualifiedName() {
+ if (this.openable instanceof RubyScript) {
+ // get file name
+ String fileName = this.openable.getElementName(); // working copy
+ // on a .class
+ // file may not
+ // have a
+ // resource, so
+ // use the
+ // element name
+ // get main type name
+ char[] mainTypeName = fileName.toCharArray();
+ RubyScript cu = (RubyScript) this.openable;
+ return cu.getType(new String(mainTypeName)).getFullyQualifiedName().toCharArray();
+ }
+ if (RubyCore.DEBUG) {
+ System.err.println("TODO: Code review here...");
+ }
+ return null;
+ }
+
+ /*
+ * Returns the source file name of the class file. Returns
+ * NO_SOURCE_FILE_NAME if not found.
+ */
+ private String getSourceFileName() {
+ if (this.sourceFileName != null)
+ return this.sourceFileName;
+ this.sourceFileName = NO_SOURCE_FILE_NAME;
+ return this.sourceFileName;
+ }
+
+ public int hashCode() {
+ if (this.compoundName == null)
+ return super.hashCode();
+ int hashCode = 0;
+ for (int i = 0, length = this.compoundName.length; i < length; i++)
+ hashCode += CharOperation.hashCode(this.compoundName[i]);
+ return hashCode;
+ }
+
+ public String toString() {
+ return this.openable == null ? "Fake PossibleMatch" : this.openable.toString(); //$NON-NLS-1$
+ }
+
+ public IRubyElement getRubyElement() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IPath getScriptFolder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatchSet.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatchSet.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PossibleMatchSet.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.matching;
+
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.internal.compiler.util.ObjectVector;
+import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
+
+/**
+ * A set of PossibleMatches that is sorted by package fragment roots.
+ */
+public class PossibleMatchSet {
+
+private SimpleLookupTable rootsToPossibleMatches = new SimpleLookupTable(5);
+private int elementCount = 0;
+
+public void add(PossibleMatch possibleMatch) {
+ IPath path = possibleMatch.openable.getSourceFolderRoot().getPath();
+ ObjectVector possibleMatches = (ObjectVector) this.rootsToPossibleMatches.get(path);
+ if (possibleMatches != null) {
+ if (possibleMatches.contains(possibleMatch)) return;
+ } else {
+ this.rootsToPossibleMatches.put(path, possibleMatches = new ObjectVector());
+ }
+
+ possibleMatches.add(possibleMatch);
+ this.elementCount++;
+}
+public PossibleMatch[] getPossibleMatches(ISourceFolderRoot[] roots) {
+ PossibleMatch[] result = new PossibleMatch[this.elementCount];
+ int index = 0;
+ for (int i = 0, length = roots.length; i < length; i++) {
+ ObjectVector possibleMatches = (ObjectVector) this.rootsToPossibleMatches.get(roots[i].getPath());
+ if (possibleMatches != null) {
+ possibleMatches.copyInto(result, index);
+ index += possibleMatches.size();
+ }
+ }
+ if (index < this.elementCount)
+ System.arraycopy(result, 0, result = new PossibleMatch[index], 0, index);
+ return result;
+}
+public void reset() {
+ this.rootsToPossibleMatches = new SimpleLookupTable(5);
+ this.elementCount = 0;
+}
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-03-13 18:22:14 UTC (rev 2149)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-03-13 18:35:20 UTC (rev 2150)
@@ -1428,4 +1428,61 @@
name.length,
isCaseSensitive);
}
+
+ /**
+ * Answers a new array which is a copy of the given array starting at the
+ * given start and ending at the given end. The given start is inclusive and
+ * the given end is exclusive. Answers null if start is greater than end, if
+ * start is lower than 0 or if end is greater than the length of the given
+ * array. If end equals -1, it is converted to the array length. <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li>
+ *
+ * <pre>
+ * array = { { 'a' } , { 'b' } }
+ * start = 0
+ * end = 1
+ * result => { { 'a' } }
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * array = { { 'a' } , { 'b' } }
+ * start = 0
+ * end = -1
+ * result => { { 'a' }, { 'b' } }
+ * </pre>
+ *
+ * </li>
+ * </ol>
+ *
+ * @param array
+ * the given array
+ * @param start
+ * the given starting index
+ * @param end
+ * the given ending index
+ * @return a new array which is a copy of the given array starting at the
+ * given start and ending at the given end
+ * @throws NullPointerException
+ * if the given array is null
+ */
+ public static final char[][] subarray(char[][] array, int start, int end) {
+ if (end == -1)
+ end = array.length;
+ if (start > end)
+ return null;
+ if (start < 0)
+ return null;
+ if (end > array.length)
+ return null;
+
+ char[][] result = new char[end - start][];
+ System.arraycopy(array, start, result, 0, end - start);
+ return result;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:22:15
|
Revision: 2149
http://svn.sourceforge.net/rubyeclipse/?rev=2149&view=rev
Author: cawilliams
Date: 2007-03-13 11:22:14 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 18:18:56 UTC (rev 2148)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 18:22:14 UTC (rev 2149)
@@ -22,6 +22,7 @@
import org.rubypeople.rdt.internal.core.RubyScript;
import org.rubypeople.rdt.internal.core.search.BasicSearchEngine;
import org.rubypeople.rdt.internal.core.search.RubySearchDocument;
+import org.rubypeople.rdt.internal.core.util.HandleFactory;
import org.rubypeople.rdt.internal.core.util.Util;
public class MatchLocator {
@@ -209,7 +210,7 @@
} finally {
if (this.nameEnvironment != null)
this.nameEnvironment.cleanup();
- manager.flushZipFiles();
+// manager.flushZipFiles();
this.bindings = null;
}
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java 2007-03-13 18:18:56 UTC (rev 2148)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java 2007-03-13 18:22:14 UTC (rev 2149)
@@ -30,7 +30,9 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.internal.compiler.env.lookup.MethodScope;
import org.rubypeople.rdt.internal.compiler.env.lookup.Scope;
+import org.rubypeople.rdt.internal.compiler.env.lookup.TypeScope;
import org.rubypeople.rdt.internal.core.Openable;
import org.rubypeople.rdt.internal.core.RubyModel;
import org.rubypeople.rdt.internal.core.RubyModelManager;
@@ -38,9 +40,6 @@
import org.rubypeople.rdt.internal.core.SourceFolderRoot;
import org.rubypeople.rdt.internal.core.SourceRefElement;
-import sun.reflect.generics.scope.ClassScope;
-import sun.reflect.generics.scope.MethodScope;
-
/**
* Creates java element handles.
*/
@@ -117,7 +116,7 @@
/**
* Returns a handle denoting the class member identified by its scope.
*/
- public IRubyElement createElement(ClassScope scope, IRubyScript unit, HashSet existingElements, HashMap knownScopes) {
+ public IRubyElement createElement(TypeScope scope, IRubyScript unit, HashSet existingElements, HashMap knownScopes) {
return createElement(scope, scope.referenceContext.sourceStart, unit, existingElements, knownScopes);
}
/**
@@ -162,35 +161,35 @@
case Scope.METHOD_SCOPE :
IType parentType = (IType) createElement(scope.parent, elementPosition, unit, existingElements, knownScopes);
MethodScope methodScope = (MethodScope) scope;
- if (methodScope.isInsideInitializer()) {
- // inside field or initializer, must find proper one
- TypeDeclaration type = methodScope.referenceType();
- int occurenceCount = 1;
- for (int i = 0, length = type.fields.length; i < length; i++) {
- FieldDeclaration field = type.fields[i];
- if (field.declarationSourceStart < elementPosition && field.declarationSourceEnd > elementPosition) {
- switch (field.getKind()) {
- case AbstractVariableDeclaration.FIELD :
- case AbstractVariableDeclaration.ENUM_CONSTANT :
- newElement = parentType.getField(new String(field.name));
- break;
- case AbstractVariableDeclaration.INITIALIZER :
- newElement = parentType.getInitializer(occurenceCount);
- break;
- }
- break;
- } else if (field.getKind() == AbstractVariableDeclaration.INITIALIZER) {
- occurenceCount++;
- }
- }
- } else {
+// if (methodScope.isInsideInitializer()) {
+// // inside field or initializer, must find proper one
+// TypeDeclaration type = methodScope.referenceType();
+// int occurenceCount = 1;
+// for (int i = 0, length = type.fields.length; i < length; i++) {
+// FieldDeclaration field = type.fields[i];
+// if (field.declarationSourceStart < elementPosition && field.declarationSourceEnd > elementPosition) {
+// switch (field.getKind()) {
+// case AbstractVariableDeclaration.FIELD :
+//// case AbstractVariableDeclaration.ENUM_CONSTANT :
+// newElement = parentType.getField(new String(field.name));
+// break;
+//// case AbstractVariableDeclaration.INITIALIZER :
+//// newElement = parentType.getInitializer(occurenceCount);
+//// break;
+// }
+// break;
+//// } else if (field.getKind() == AbstractVariableDeclaration.INITIALIZER) {
+//// occurenceCount++;
+// }
+// }
+// } else {
// method element
AbstractMethodDeclaration method = methodScope.referenceMethod();
newElement = parentType.getMethod(new String(method.selector), Util.typeParameterSignatures(method));
if (newElement != null) {
knownScopes.put(scope, newElement);
}
- }
+// }
break;
case Scope.BLOCK_SCOPE :
// standard block, no element per se
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:18:57
|
Revision: 2148
http://svn.sourceforge.net/rubyeclipse/?rev=2148&view=rev
Author: cawilliams
Date: 2007-03-13 11:18:56 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-03-13 18:17:22 UTC (rev 2147)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-03-13 18:18:56 UTC (rev 2148)
@@ -2208,10 +2208,10 @@
}
public ISourceFolderRoot getSourceFolderRoot(String string) {
- return getPackageFragmentRoot0(RubyProject.canonicalizedPath(new Path(string)));
+ return getSourceFolderRoot0(RubyProject.canonicalizedPath(new Path(string)));
}
- private ISourceFolderRoot getPackageFragmentRoot0(IPath path) {
+ public ISourceFolderRoot getSourceFolderRoot0(IPath path) {
return new ExternalSourceFolderRoot(path, this);
}
@@ -2431,7 +2431,7 @@
IPath path = new Path(rootPath);
RubyElement root;
if(path.isAbsolute()) {
- root = (RubyElement) getPackageFragmentRoot0(path);
+ root = (RubyElement) getSourceFolderRoot0(path);
} else
root = (RubyElement)getSourceFolderRoot(path);
if (token != null && token.charAt(0) == JEM_SOURCE_FOLDER) {
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java 2007-03-13 18:17:22 UTC (rev 2147)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java 2007-03-13 18:18:56 UTC (rev 2148)
@@ -30,13 +30,13 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.internal.compiler.env.lookup.Scope;
import org.rubypeople.rdt.internal.core.Openable;
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.SourceFolderRoot;
import org.rubypeople.rdt.internal.core.SourceRefElement;
-import org.rubypeople.rdt.internal.ti.Scope;
import sun.reflect.generics.scope.ClassScope;
import sun.reflect.generics.scope.MethodScope;
@@ -134,25 +134,25 @@
case Scope.CLASS_SCOPE :
IRubyElement parentElement = createElement(scope.parent, elementPosition, unit, existingElements, knownScopes);
switch (parentElement.getElementType()) {
- case IRubyElement.COMPILATION_UNIT :
+ case IRubyElement.SCRIPT :
newElement = ((IRubyScript)parentElement).getType(new String(scope.enclosingSourceType().sourceName));
break;
case IRubyElement.TYPE :
newElement = ((IType)parentElement).getType(new String(scope.enclosingSourceType().sourceName));
break;
case IRubyElement.FIELD :
- case IRubyElement.INITIALIZER :
+// case IRubyElement.INITIALIZER :
case IRubyElement.METHOD :
IMember member = (IMember)parentElement;
- if (member.isBinary()) {
- return null;
- } else {
+// if (member.isBinary()) {
+// return null;
+// } else {
newElement = member.getType(new String(scope.enclosingSourceType().sourceName), 1);
// increment occurrence count if collision is detected
if (newElement != null) {
while (!existingElements.add(newElement)) ((SourceRefElement)newElement).occurrenceCount++;
}
- }
+// }
break;
}
if (newElement != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|