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-13 18:17:25
|
Revision: 2147
http://svn.sourceforge.net/rubyeclipse/?rev=2147&view=rev
Author: cawilliams
Date: 2007-03-13 11:17:22 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/Scope.java
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/Scope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/Scope.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/Scope.java 2007-03-13 18:17:22 UTC (rev 2147)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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.lookup;
+
+import org.rubypeople.rdt.internal.compiler.lookup.LookupEnvironment;
+
+
+public abstract class Scope implements TypeConstants {
+
+ /* Scope kinds */
+ public final static int BLOCK_SCOPE = 1;
+ public final static int CLASS_SCOPE = 3;
+ public final static int COMPILATION_UNIT_SCOPE = 4;
+ public final static int METHOD_SCOPE = 2;
+
+ /* Argument Compatibilities */
+ public final static int NOT_COMPATIBLE = -1;
+ public final static int COMPATIBLE = 0;
+ public final static int AUTOBOX_COMPATIBLE = 1;
+ public final static int VARARGS_COMPATIBLE = 2;
+
+ /* Type Compatibilities */
+ public static final int EQUAL_OR_MORE_SPECIFIC = -1;
+ public static final int NOT_RELATED = 0;
+ public static final int MORE_GENERIC = 1;
+
+ public int kind;
+ public Scope parent;
+
+ protected Scope(int kind, Scope parent) {
+ this.kind = kind;
+ this.parent = parent;
+ }
+
+ public final TypeScope classScope() {
+ Scope scope = this;
+ do {
+ if (scope instanceof TypeScope)
+ return (TypeScope) scope;
+ scope = scope.parent;
+ } while (scope != null);
+ return null;
+ }
+
+ public final SourceModuleScope compilationUnitScope() {
+ Scope lastScope = null;
+ Scope scope = this;
+ do {
+ lastScope = scope;
+ scope = scope.parent;
+ } while (scope != null);
+ return (SourceModuleScope) lastScope;
+ }
+
+ public final TypeScope enclosingClassScope() {
+ Scope scope = this;
+ while ((scope = scope.parent) != null) {
+ if (scope instanceof TypeScope) return (TypeScope) scope;
+ }
+ return null; // may answer null if no type around
+ }
+
+ public final MethodScope enclosingMethodScope() {
+ Scope scope = this;
+ while ((scope = scope.parent) != null) {
+ if (scope instanceof MethodScope) return (MethodScope) scope;
+ }
+ return null; // may answer null if no method around
+ }
+
+ public final LookupEnvironment environment() {
+ Scope scope, unitScope = this;
+ while ((scope = unitScope.parent) != null)
+ unitScope = scope;
+ return ((SourceModuleScope) unitScope).environment;
+ }
+
+ // start position in this scope - for ordering scopes vs. variables
+ int startIndex() {
+ return 0;
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 18:17:03
|
Revision: 2146
http://svn.sourceforge.net/rubyeclipse/?rev=2146&view=rev
Author: cawilliams
Date: 2007-03-13 11:16:58 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.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
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/INameEnvironment.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/NameEnvironmentAnswer.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/BlockScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/MethodScope.java
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/TypeConstants.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/
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/util/CompoundNameVector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleNameVector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/INameEnvironment.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/INameEnvironment.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/INameEnvironment.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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;
+
+
+/**
+ * The name environment provides a callback API that the compiler can use to
+ * look up types, compilation units, and packages in the current environment.
+ * The name environment is passed to the compiler on creation.
+ */
+public interface INameEnvironment {
+ /**
+ * Find a type with the given compound name. Answer the binary form of the
+ * type if it is known to be consistent. Otherwise, answer the compilation
+ * unit which defines the type or null if the type does not exist. Types in
+ * the default package are specified as {{typeName}}.
+ *
+ * It is unknown whether the package containing the type actually exists.
+ *
+ * NOTE: This method can be used to find a member type using its internal
+ * name A$B, but the source file for A is answered if the binary file is
+ * inconsistent.
+ */
+
+ NameEnvironmentAnswer findType(char[][] compoundTypeName);
+
+ /**
+ * Find a type named <typeName> in the package <packageName>. Answer the
+ * binary form of the type if it is known to be consistent. Otherwise,
+ * answer the compilation unit which defines the type or null if the type
+ * does not exist. The default package is indicated by char[0][].
+ *
+ * It is known that the package containing the type exists.
+ *
+ * NOTE: This method can be used to find a member type using its internal
+ * name A$B, but the source file for A is answered if the binary file is
+ * inconsistent.
+ */
+
+ NameEnvironmentAnswer findType(char[] typeName, char[][] packageName);
+
+ /**
+ * Answer whether packageName is the name of a known subpackage inside the
+ * package parentPackageName. A top level package is found relative to null.
+ * The default package is always assumed to exist.
+ *
+ * For example: isPackage({{java}, {awt}}, {event}); isPackage(null,
+ * {java});
+ */
+
+ boolean isPackage(char[][] parentPackageName, char[] packageName);
+
+ /**
+ * This method cleans the environment uo. It is responsible for releasing
+ * the memory and freeing resources. Passed that point, the name environment
+ * is no longer usable.
+ *
+ * A name environment can have a long life cycle, therefore it is the
+ * responsibility of the code which created it to decide when it is a good
+ * time to clean it up.
+ */
+ void cleanup();
+
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/NameEnvironmentAnswer.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/NameEnvironmentAnswer.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/NameEnvironmentAnswer.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -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.internal.compiler.env;
+
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+
+public class NameEnvironmentAnswer {
+
+ // only one of the three can be set
+ IRubyScript compilationUnit;
+ IType[] sourceTypes;
+ AccessRestriction accessRestriction;
+
+ public NameEnvironmentAnswer(IRubyScript compilationUnit, AccessRestriction accessRestriction) {
+ this.compilationUnit = compilationUnit;
+ this.accessRestriction = accessRestriction;
+ }
+
+ public NameEnvironmentAnswer(IType[] sourceTypes, AccessRestriction accessRestriction) {
+ this.sourceTypes = sourceTypes;
+ this.accessRestriction = accessRestriction;
+ }
+ /**
+ * Returns the associated access restriction, or null if none.
+ */
+ public AccessRestriction getAccessRestriction() {
+ return this.accessRestriction;
+ }
+
+ /**
+ * Answer the compilation unit or null if the
+ * receiver represents a binary or source type.
+ */
+ public IRubyScript getCompilationUnit() {
+ return this.compilationUnit;
+ }
+
+ /**
+ * Answer the unresolved source forms for the type or null if the
+ * receiver represents a compilation unit or binary type.
+ *
+ * Multiple source forms can be answered in case the originating compilation unit did contain
+ * several type at once. Then the first type is guaranteed to be the requested type.
+ */
+ public IType[] getSourceTypes() {
+ return this.sourceTypes;
+ }
+
+ /**
+ * Answer whether the receiver contains the compilation unit which defines the type.
+ */
+ public boolean isCompilationUnit() {
+ return this.compilationUnit != null;
+ }
+
+ /**
+ * Answer whether the receiver contains the unresolved source form of the type.
+ */
+ public boolean isSourceType() {
+ return this.sourceTypes != null;
+ }
+
+ public boolean ignoreIfBetter() {
+ return this.accessRestriction != null && this.accessRestriction.ignoreIfBetter();
+ }
+
+ /*
+ * Returns whether this answer is better than the other awswer.
+ * (accessible is better than discouraged, which is better than
+ * non-accessible)
+ */
+ public boolean isBetter(NameEnvironmentAnswer otherAnswer) {
+ if (otherAnswer == null) return true;
+ if (this.accessRestriction == null) return true;
+ return otherAnswer.accessRestriction != null
+ && this.accessRestriction.getProblemId() < otherAnswer.accessRestriction.getProblemId();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/BlockScope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/BlockScope.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/BlockScope.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.lookup;
+
+public class BlockScope extends Scope {
+ // Local variable management
+ public int localIndex; // position for next variable
+ public int startIndex; // start position in this scope - for ordering
+ // scopes vs. variables
+ public int offset; // for variable allocation throughout scopes
+ public int maxOffset; // for variable allocation throughout scopes
+ // finally scopes must be shifted behind respective try&catch scope(s) so as
+ // to avoid
+ // collisions of secret variables (return address, save value).
+ public BlockScope[] shiftScopes;
+ public Scope[] subscopes = new Scope[1]; // need access from code assist
+ public int subscopeCount = 0; // need access from code assist
+
+ // record the current case statement being processed (for entire switch case
+ // block).
+ public BlockScope(BlockScope parent) {
+ this(parent, true);
+ }
+
+ public BlockScope(BlockScope parent, boolean addToParentScope) {
+ this(Scope.BLOCK_SCOPE, parent);
+ if (addToParentScope)
+ parent.addSubscope(this);
+ this.startIndex = parent.localIndex;
+ }
+
+ public BlockScope(BlockScope parent, int variableCount) {
+ this(Scope.BLOCK_SCOPE, parent);
+ parent.addSubscope(this);
+ this.startIndex = parent.localIndex;
+ }
+
+ protected BlockScope(int kind, Scope parent) {
+ super(kind, parent);
+ }
+
+ public void addSubscope(Scope childScope) {
+ if (this.subscopeCount == this.subscopes.length)
+ System.arraycopy(this.subscopes, 0, (this.subscopes = new Scope[this.subscopeCount * 2]), 0, this.subscopeCount);
+ this.subscopes[this.subscopeCount++] = childScope;
+ }
+
+ String basicToString(int tab) {
+ String newLine = "\n"; //$NON-NLS-1$
+ for (int i = tab; --i >= 0;)
+ newLine += "\t"; //$NON-NLS-1$
+ String s = newLine + "--- Block Scope ---"; //$NON-NLS-1$
+ newLine += "\t"; //$NON-NLS-1$
+ s += newLine + "startIndex = " + this.startIndex; //$NON-NLS-1$
+ return s;
+ }
+
+ public int maxShiftedOffset() {
+ int max = -1;
+ if (this.shiftScopes != null) {
+ for (int i = 0, length = this.shiftScopes.length; i < length; i++) {
+ int subMaxOffset = this.shiftScopes[i].maxOffset;
+ if (subMaxOffset > max)
+ max = subMaxOffset;
+ }
+ }
+ return max;
+ }
+
+ /*
+ * Answer the index of this scope relatively to its parent. For method
+ * scope, answers -1 (not a classScope relative position)
+ */
+ public int scopeIndex() {
+ if (this instanceof MethodScope)
+ return -1;
+ BlockScope parentScope = (BlockScope) this.parent;
+ Scope[] parentSubscopes = parentScope.subscopes;
+ for (int i = 0, max = parentScope.subscopeCount; i < max; i++) {
+ if (parentSubscopes[i] == this)
+ return i;
+ }
+ return -1;
+ }
+
+ // start position in this scope - for ordering scopes vs. variables
+ int startIndex() {
+ return this.startIndex;
+ }
+
+ public String toString() {
+ return toString(0);
+ }
+
+ public String toString(int tab) {
+ String s = basicToString(tab);
+ for (int i = 0; i < this.subscopeCount; i++)
+ if (this.subscopes[i] instanceof BlockScope)
+ s += ((BlockScope) this.subscopes[i]).toString(tab + 1) + "\n"; //$NON-NLS-1$
+ return s;
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/MethodScope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/MethodScope.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/MethodScope.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.lookup;
+
+/**
+ * Particular block scope used for methods, constructors or clinits, representing
+ * its outermost blockscope. Note also that such a scope will be provided to enclose
+ * field initializers subscopes as well.
+ */
+public class MethodScope extends BlockScope {
+
+
+ public MethodScope(Scope parent, boolean isStatic) {
+
+ super(METHOD_SCOPE, parent);
+ this.startIndex = 0;
+ }
+}
Added: 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 (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/SourceModuleScope.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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
+ * Erling Ellingsen - patch for bug 125570
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.compiler.env.lookup;
+
+import org.rubypeople.rdt.internal.compiler.lookup.LookupEnvironment;
+import org.rubypeople.rdt.internal.compiler.util.CompoundNameVector;
+import org.rubypeople.rdt.internal.compiler.util.HashtableOfObject;
+import org.rubypeople.rdt.internal.compiler.util.ObjectVector;
+import org.rubypeople.rdt.internal.compiler.util.SimpleNameVector;
+
+public class SourceModuleScope extends Scope {
+ public LookupEnvironment environment;
+ public ModuleDeclaration referenceContext;
+ public char[][] currentPackageName;
+ public HashtableOfObject typeOrPackageCache; // used in
+ // Scope.getTypeOrPackage()
+ private CompoundNameVector qualifiedReferences;
+ private SimpleNameVector simpleNameReferences;
+ private ObjectVector referencedTypes;
+ private ObjectVector referencedSuperTypes;
+ // HashtableOfType constantPoolNameUsage;
+ private int captureID = 1;
+
+ public SourceModuleScope(ModuleDeclaration unit, LookupEnvironment environment) {
+ super(COMPILATION_UNIT_SCOPE, null);
+ this.environment = environment;
+ this.referenceContext = unit;
+ unit.scope = this;
+ // this.currentPackageName = unit.currentPackage == null ?
+ // CharOperation.NO_CHAR_CHAR : unit.currentPackage.tokens;
+ // if (compilerOptions().produceReferenceInfo) {
+ this.qualifiedReferences = new CompoundNameVector();
+ this.simpleNameReferences = new SimpleNameVector();
+ this.referencedTypes = new ObjectVector();
+ this.referencedSuperTypes = new ObjectVector();
+ // } else {
+ // this.qualifiedReferences = null; // used to test if dependencies
+ // should be recorded
+ // this.simpleNameReferences = null;
+ // this.referencedTypes = null;
+ // this.referencedSuperTypes = null;
+ // }
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/TypeConstants.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/TypeConstants.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/TypeConstants.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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.lookup;
+
+// TODO should rename into TypeNames (once extracted last non name constants)
+public interface TypeConstants {
+
+ // Constants used to perform bound checks
+ int OK = 0;
+ int UNCHECKED = 1;
+ int MISMATCH = 2;
+}
Added: 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 (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/TypeScope.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.lookup;
+
+public class TypeScope extends Scope {
+
+ public TypeDeclaration referenceContext;
+
+ public TypeScope(Scope parent, TypeDeclaration context) {
+ super(CLASS_SCOPE, parent);
+ this.referenceContext = context;
+ }
+
+ /* Answer the reference type of this scope.
+ * It is the nearest enclosing type of this scope.
+ */
+ public TypeDeclaration referenceType() {
+ return referenceContext;
+ }
+
+ public String toString() {
+ if (referenceContext != null)
+ return "--- Class Scope ---\n\n";
+ return "--- Class Scope ---\n\n Binding not initialized" ; //$NON-NLS-1$
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/lookup/LookupEnvironment.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,17 @@
+package org.rubypeople.rdt.internal.compiler.lookup;
+
+import org.rubypeople.rdt.internal.compiler.env.AccessRestriction;
+import org.rubypeople.rdt.internal.compiler.env.lookup.SourceModuleScope;
+
+public class LookupEnvironment {
+ public LookupEnvironment(ITypeRequestor typeRequestor, INameEnvironment nameEnvironment) {
+ // TODO Auto-generated constructor stub
+ }
+
+ public void reset() {}
+
+ public void buildTypeScope(ModuleDeclaration unit, AccessRestriction accessRestriction) {
+ SourceModuleScope scope = new SourceModuleScope(unit, this);
+ //TODO: Add other bindings build..
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/CompoundNameVector.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/CompoundNameVector.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/CompoundNameVector.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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;
+
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public final class CompoundNameVector {
+ static int INITIAL_SIZE = 10;
+
+ public int size;
+ int maxSize;
+ char[][][] elements;
+public CompoundNameVector() {
+ maxSize = INITIAL_SIZE;
+ size = 0;
+ elements = new char[maxSize][][];
+}
+public void add(char[][] newElement) {
+ if (size == maxSize) // knows that size starts <= maxSize
+ System.arraycopy(elements, 0, (elements = new char[maxSize *= 2][][]), 0, size);
+ elements[size++] = newElement;
+}
+public void addAll(char[][][] newElements) {
+ if (size + newElements.length >= maxSize) {
+ maxSize = size + newElements.length; // assume no more elements will be added
+ System.arraycopy(elements, 0, (elements = new char[maxSize][][]), 0, size);
+ }
+ System.arraycopy(newElements, 0, elements, size, newElements.length);
+ size += newElements.length;
+}
+public boolean contains(char[][] element) {
+ for (int i = size; --i >= 0;)
+ if (CharOperation.equals(element, elements[i]))
+ return true;
+ return false;
+}
+public char[][] elementAt(int index) {
+ return elements[index];
+}
+public char[][] remove(char[][] element) {
+ // assumes only one occurrence of the element exists
+ for (int i = size; --i >= 0;)
+ if (element == elements[i]) {
+ // shift the remaining elements down one spot
+ System.arraycopy(elements, i + 1, elements, i, --size - i);
+ elements[size] = null;
+ return element;
+ }
+ return null;
+}
+public void removeAll() {
+ for (int i = size; --i >= 0;)
+ elements[i] = null;
+ size = 0;
+}
+public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < size; i++) {
+ buffer.append(CharOperation.toString(elements[i])).append("\n"); //$NON-NLS-1$
+ }
+ return buffer.toString();
+}
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleNameVector.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleNameVector.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleNameVector.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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;
+
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public final class SimpleNameVector {
+
+ static int INITIAL_SIZE = 10;
+
+ public int size;
+ int maxSize;
+ char[][] elements;
+
+ public SimpleNameVector() {
+
+ this.maxSize = INITIAL_SIZE;
+ this.size = 0;
+ this.elements = new char[this.maxSize][];
+ }
+
+ public void add(char[] newElement) {
+
+ if (this.size == this.maxSize) // knows that size starts <= maxSize
+ System.arraycopy(this.elements, 0, (this.elements = new char[this.maxSize *= 2][]), 0, this.size);
+ this.elements[size++] = newElement;
+ }
+
+ public void addAll(char[][] newElements) {
+
+ if (this.size + newElements.length >= this.maxSize) {
+ this.maxSize = this.size + newElements.length; // assume no more elements will be added
+ System.arraycopy(this.elements, 0, (this.elements = new char[this.maxSize][]), 0, this.size);
+ }
+ System.arraycopy(newElements, 0, this.elements, this.size, newElements.length);
+ this.size += newElements.length;
+ }
+
+ public void copyInto(Object[] targetArray){
+
+ System.arraycopy(this.elements, 0, targetArray, 0, this.size);
+ }
+
+ public boolean contains(char[] element) {
+
+ for (int i = this.size; --i >= 0;)
+ if (CharOperation.equals(element, this.elements[i]))
+ return true;
+ return false;
+ }
+
+ public char[] elementAt(int index) {
+ return this.elements[index];
+ }
+
+ public char[] remove(char[] element) {
+
+ // assumes only one occurrence of the element exists
+ for (int i = this.size; --i >= 0;)
+ if (element == this.elements[i]) {
+ // shift the remaining elements down one spot
+ System.arraycopy(this.elements, i + 1, this.elements, i, --this.size - i);
+ this.elements[this.size] = null;
+ return element;
+ }
+ return null;
+ }
+
+ public void removeAll() {
+
+ for (int i = this.size; --i >= 0;)
+ this.elements[i] = null;
+ this.size = 0;
+ }
+
+ public int size(){
+
+ return this.size;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < this.size; i++) {
+ buffer.append(this.elements[i]).append("\n"); //$NON-NLS-1$
+ }
+ return buffer.toString();
+ }
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-03-13 18:00:18 UTC (rev 2145)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -7,6 +7,8 @@
public class BasicSearchEngine {
+ public static final boolean VERBOSE = false;
+
/**
* @see SearchEngine#createWorkspaceScope() for detailed comment.
*/
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java 2007-03-13 18:00:18 UTC (rev 2145)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -1,13 +1,19 @@
package org.rubypeople.rdt.internal.core.search;
+import org.eclipse.core.resources.IFile;
import org.rubypeople.rdt.core.search.SearchDocument;
+import org.rubypeople.rdt.core.search.SearchParticipant;
public class RubySearchDocument extends SearchDocument {
- public RubySearchDocument(String documentPath, RubySearchParticipant participant) {
+ private IFile file;
+ protected byte[] byteContents;
+ protected char[] charContents;
+
+ public RubySearchDocument(String documentPath, SearchParticipant participant) {
super(documentPath, participant);
}
-
+
@Override
public byte[] getByteContents() {
// TODO Auto-generated method stub
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:00:18 UTC (rev 2145)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -1,12 +1,28 @@
package org.rubypeople.rdt.internal.core.search.matching;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchDocument;
+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.util.SimpleLookupTable;
import org.rubypeople.rdt.internal.core.ExternalSourceFolderRoot;
+import org.rubypeople.rdt.internal.core.Openable;
+import org.rubypeople.rdt.internal.core.RubyModelManager;
+import org.rubypeople.rdt.internal.core.RubyProject;
+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.Util;
public class MatchLocator {
@@ -18,6 +34,25 @@
public IRubySearchScope scope;
public IProgressMonitor progressMonitor;
+ public org.rubypeople.rdt.core.IRubyScript[] workingCopies;
+ public HandleFactory handleFactory;
+
+// Progress information
+ int progressStep;
+ int progressWorked;
+
+ public static class WorkingCopyDocument extends RubySearchDocument {
+ public org.rubypeople.rdt.core.IRubyScript workingCopy;
+ WorkingCopyDocument(org.rubypeople.rdt.core.IRubyScript workingCopy, SearchParticipant participant) {
+ super(workingCopy.getPath().toString(), participant);
+ this.charContents = ((RubyScript)workingCopy).getContents();
+ this.workingCopy = workingCopy;
+ }
+ public String toString() {
+ return "WorkingCopyDocument for " + getPath(); //$NON-NLS-1$
+ }
+ }
+
public static IRubyElement projectOrJarFocus(InternalSearchPattern pattern) {
return pattern == null || pattern.focus == null ? null : getProjectOrJar(pattern.focus);
}
@@ -47,4 +82,136 @@
this.progressMonitor = progressMonitor;
}
+ /**
+ * Locate the matches in the given files and report them using the search requestor.
+ */
+ public void locateMatches(SearchDocument[] searchDocuments) throws CoreException {
+ int docsLength = searchDocuments.length;
+ if (BasicSearchEngine.VERBOSE) {
+ System.out.println("Locating matches in documents ["); //$NON-NLS-1$
+ for (int i = 0; i < docsLength; i++)
+ System.out.println("\t" + searchDocuments[i]); //$NON-NLS-1$
+ System.out.println("]"); //$NON-NLS-1$
+ }
+
+ // init infos for progress increasing
+ int n = docsLength<1000 ? Math.min(Math.max(docsLength/200+1, 2),4) : 5 *(docsLength/1000);
+ this.progressStep = docsLength < n ? 1 : docsLength / n; // step should not be 0
+ this.progressWorked = 0;
+
+ // extract working copies
+ ArrayList copies = new ArrayList();
+ for (int i = 0; i < docsLength; i++) {
+ SearchDocument document = searchDocuments[i];
+ if (document instanceof WorkingCopyDocument) {
+ copies.add(((WorkingCopyDocument)document).workingCopy);
+ }
+ }
+ int copiesLength = copies.size();
+ this.workingCopies = new org.rubypeople.rdt.core.IRubyScript[copiesLength];
+ copies.toArray(this.workingCopies);
+
+ RubyModelManager manager = RubyModelManager.getRubyModelManager();
+ this.bindings = new SimpleLookupTable();
+ try {
+ // optimize access to zip files during search operation
+ manager.cacheZipFiles();
+
+ // initialize handle factory (used as a cache of handles so as to optimize space)
+ if (this.handleFactory == null)
+ this.handleFactory = new HandleFactory();
+
+ if (this.progressMonitor != null) {
+ this.progressMonitor.beginTask("", searchDocuments.length); //$NON-NLS-1$
+ }
+
+ // initialize pattern for polymorphic search (ie. method reference pattern)
+ this.patternLocator.initializePolymorphicSearch(this);
+
+ RubyProject previousJavaProject = null;
+ PossibleMatchSet matchSet = new PossibleMatchSet();
+ Util.sort(searchDocuments, new Util.Comparer() {
+ public int compare(Object a, Object b) {
+ return ((SearchDocument)a).getPath().compareTo(((SearchDocument)b).getPath());
+ }
+ });
+ int displayed = 0; // progress worked displayed
+ String previousPath = null;
+ for (int i = 0; i < docsLength; i++) {
+ if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
+ // skip duplicate paths
+ SearchDocument searchDocument = searchDocuments[i];
+ searchDocuments[i] = null; // free current document
+ String pathString = searchDocument.getPath();
+ if (i > 0 && pathString.equals(previousPath)) {
+ if (this.progressMonitor != null) {
+ this.progressWorked++;
+ if ((this.progressWorked%this.progressStep)==0) this.progressMonitor.worked(this.progressStep);
+ }
+ displayed++;
+ continue;
+ }
+ previousPath = pathString;
+
+ Openable openable;
+ org.rubypeople.rdt.core.IRubyScript workingCopy = null;
+ if (searchDocument instanceof WorkingCopyDocument) {
+ workingCopy = ((WorkingCopyDocument)searchDocument).workingCopy;
+ openable = (Openable) workingCopy;
+ } else {
+ openable = this.handleFactory.createOpenable(pathString, this.scope);
+ }
+ if (openable == null) {
+ if (this.progressMonitor != null) {
+ this.progressWorked++;
+ if ((this.progressWorked%this.progressStep)==0) this.progressMonitor.worked(this.progressStep);
+ }
+ displayed++;
+ continue; // match is outside classpath
+ }
+
+ // create new parser and lookup environment if this is a new project
+ IResource resource = null;
+ RubyProject javaProject = (RubyProject) openable.getRubyProject();
+ resource = workingCopy != null ? workingCopy.getResource() : openable.getResource();
+ if (resource == null)
+ resource = javaProject.getProject(); // case of a file in an external jar
+ if (!javaProject.equals(previousJavaProject)) {
+ // locate matches in previous project
+ if (previousJavaProject != null) {
+ try {
+ locateMatches(previousJavaProject, matchSet, i-displayed);
+ displayed = i;
+ } catch (RubyModelException e) {
+ // problem with classpath in this project -> skip it
+ }
+ matchSet.reset();
+ }
+ previousJavaProject = javaProject;
+ }
+ matchSet.add(new PossibleMatch(this, resource, openable, searchDocument, ((InternalSearchPattern) this.pattern).mustResolve));
+ }
+
+ // last project
+ if (previousJavaProject != null) {
+ try {
+ locateMatches(previousJavaProject, matchSet, docsLength-displayed);
+ } catch (RubyModelException e) {
+ // problem with classpath in last project -> ignore
+ }
+ }
+
+ if (this.progressMonitor != null)
+ this.progressMonitor.done();
+ } finally {
+ if (this.nameEnvironment != null)
+ this.nameEnvironment.cleanup();
+ manager.flushZipFiles();
+ this.bindings = null;
+ }
+ }
+
}
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:00:18 UTC (rev 2145)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/PatternLocator.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -25,8 +25,8 @@
switch (((InternalSearchPattern)pattern).kind) {
case IIndexConstants.PKG_REF_PATTERN :
return new PackageReferenceLocator((PackageReferencePattern) pattern);
- case IIndexConstants.PKG_DECL_PATTERN :
- return new PackageDeclarationLocator((PackageDeclarationPattern) pattern);
+// case IIndexConstants.PKG_DECL_PATTERN :
+// return new PackageDeclarationLocator((PackageDeclarationPattern) pattern);
case IIndexConstants.TYPE_REF_PATTERN :
return new TypeReferenceLocator((TypeReferencePattern) pattern);
case IIndexConstants.TYPE_DECL_PATTERN :
@@ -43,8 +43,8 @@
return new OrLocator((OrPattern) pattern);
case IIndexConstants.LOCAL_VAR_PATTERN :
return new LocalVariableLocator((LocalVariablePattern) pattern);
- case IIndexConstants.TYPE_PARAM_PATTERN:
- return new TypeParameterLocator((TypeParameterPattern) pattern);
+// case IIndexConstants.TYPE_PARAM_PATTERN:
+// return new TypeParameterLocator((TypeParameterPattern) pattern);
}
return null;
}
Added: 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 (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HandleFactory.java 2007-03-13 18:16:58 UTC (rev 2146)
@@ -0,0 +1,317 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.HashMap;
+import java.util.HashSet;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.rubypeople.rdt.core.ILoadpathEntry;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolder;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+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;
+
+/**
+ * Creates java element handles.
+ */
+public class HandleFactory {
+
+ /**
+ * Cache package fragment root information to optimize speed performance.
+ */
+ private String lastPkgFragmentRootPath;
+ private ISourceFolderRoot lastPkgFragmentRoot;
+
+ /**
+ * Cache package handles to optimize memory.
+ */
+ private HashtableOfArrayToObject packageHandles;
+
+ private RubyModel javaModel;
+
+ public HandleFactory() {
+ this.javaModel = RubyModelManager.getRubyModelManager().getRubyModel();
+ }
+
+
+ /**
+ * Creates an Openable handle from the given resource path.
+ * The resource path can be a path to a file in the workbench (eg. /Proj/com/ibm/jdt/core/HandleFactory.java)
+ * or a path to a file in a jar file - it then contains the path to the jar file and the path to the file in the jar
+ * (eg. c:/jdk1.2.2/jre/lib/rt.jar|java/lang/Object.class or /Proj/rt.jar|java/lang/Object.class)
+ * NOTE: This assumes that the resource path is the toString() of an IPath,
+ * in other words, it uses the IPath.SEPARATOR for file path
+ * and it uses '/' for entries in a zip file.
+ * If not null, uses the given scope as a hint for getting Ruby project handles.
+ */
+ public Openable createOpenable(String resourcePath, IRubySearchScope scope) {
+ int separatorIndex;
+ // path to a file in a directory
+ // Optimization: cache package fragment root handle and package handles
+ int rootPathLength = -1;
+ if (this.lastPkgFragmentRootPath == null
+ || !(resourcePath.startsWith(this.lastPkgFragmentRootPath)
+ && (rootPathLength = this.lastPkgFragmentRootPath.length()) > 0
+ && resourcePath.charAt(rootPathLength) == '/')) {
+ ISourceFolderRoot root= this.getPkgFragmentRoot(resourcePath);
+ if (root == null)
+ return null; // match is outside classpath
+ this.lastPkgFragmentRoot = root;
+ this.lastPkgFragmentRootPath = this.lastPkgFragmentRoot.getPath().toString();
+ this.packageHandles = new HashtableOfArrayToObject(5);
+ }
+ // create handle
+ resourcePath = resourcePath.substring(this.lastPkgFragmentRootPath.length() + 1);
+ String[] simpleNames = new Path(resourcePath).segments();
+ String[] pkgName;
+ int length = simpleNames.length-1;
+ if (length > 0) {
+ pkgName = new String[length];
+ System.arraycopy(simpleNames, 0, pkgName, 0, length);
+ } else {
+ pkgName = CharOperation.NO_STRINGS;
+ }
+ ISourceFolder pkgFragment= (ISourceFolder) this.packageHandles.get(pkgName);
+ if (pkgFragment == null) {
+ pkgFragment= ((SourceFolderRoot) this.lastPkgFragmentRoot).getSourceFolder(pkgName);
+ this.packageHandles.put(pkgName, pkgFragment);
+ }
+ String simpleName= simpleNames[length];
+ if (org.rubypeople.rdt.internal.core.util.Util.isRubyLikeFileName(simpleName)) {
+ IRubyScript unit= pkgFragment.getRubyScript(simpleName);
+ return (Openable) unit;
+ }
+ return null;
+ }
+
+ /**
+ * Returns a handle denoting the class member identified by its scope.
+ */
+ public IRubyElement createElement(ClassScope scope, IRubyScript unit, HashSet existingElements, HashMap knownScopes) {
+ return createElement(scope, scope.referenceContext.sourceStart, unit, existingElements, knownScopes);
+ }
+ /**
+ * Create handle by adding child to parent obtained by recursing into parent scopes.
+ */
+ private IRubyElement createElement(Scope scope, int elementPosition, IRubyScript unit, HashSet existingElements, HashMap knownScopes) {
+ IRubyElement newElement = (IRubyElement)knownScopes.get(scope);
+ if (newElement != null) return newElement;
+
+ switch(scope.kind) {
+ case Scope.COMPILATION_UNIT_SCOPE :
+ newElement = unit;
+ break;
+ case Scope.CLASS_SCOPE :
+ IRubyElement parentElement = createElement(scope.parent, elementPosition, unit, existingElements, knownScopes);
+ switch (parentElement.getElementType()) {
+ case IRubyElement.COMPILATION_UNIT :
+ 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.METHOD :
+ IMember member = (IMember)parentElement;
+ 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) {
+ knownScopes.put(scope, newElement);
+ }
+ break;
+ 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 {
+ // 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
+ newElement = createElement(scope.parent, elementPosition, unit, existingElements, knownScopes);
+ break;
+ }
+ return newElement;
+ }
+ /**
+ * Returns the package fragment root that corresponds to the given jar path.
+ * See createOpenable(...) for the format of the jar path string.
+ * If not null, uses the given scope as a hint for getting Ruby project handles.
+ */
+ private ISourceFolderRoot getJarPkgFragmentRoot(String jarPathString, IRubySearchScope scope) {
+
+ IPath jarPath= new Path(jarPathString);
+
+ Object target = RubyModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), jarPath, false);
+ if (target instanceof IFile) {
+ // internal jar: is it on the classpath of its project?
+ // e.g. org.eclipse.swt.win32/ws/win32/swt.jar
+ // is NOT on the classpath of org.eclipse.swt.win32
+ IFile jarFile = (IFile)target;
+ RubyProject javaProject = (RubyProject) this.javaModel.getRubyProject(jarFile);
+ ILoadpathEntry[] classpathEntries;
+ try {
+ classpathEntries = javaProject.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
+ for (int j= 0, entryCount= classpathEntries.length; j < entryCount; j++) {
+ if (classpathEntries[j].getPath().equals(jarPath)) {
+ return javaProject.getSourceFolderRoot(jarFile);
+ }
+ }
+ } catch (RubyModelException e) {
+ // ignore and try to find another project
+ }
+ }
+
+ // walk projects in the scope and find the first one that has the given jar path in its classpath
+ IRubyProject[] projects;
+ if (scope != null) {
+ IPath[] enclosingProjectsAndJars = scope.enclosingProjectsAndJars();
+ int length = enclosingProjectsAndJars.length;
+ projects = new IRubyProject[length];
+ 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())) {
+ projects[index++] = this.javaModel.getRubyProject(path.segment(0));
+ }
+ }
+ if (index < length) {
+ System.arraycopy(projects, 0, projects = new IRubyProject[index], 0, index);
+ }
+ ISourceFolderRoot root = getJarPkgFragmentRoot(jarPath, target, projects);
+ if (root != null) {
+ return root;
+ }
+ }
+
+ // not found in the scope, walk all projects
+ try {
+ projects = this.javaModel.getRubyProjects();
+ } catch (RubyModelException e) {
+ // java model is not accessible
+ return null;
+ }
+ return getJarPkgFragmentRoot(jarPath, target, projects);
+ }
+
+ private ISourceFolderRoot getJarPkgFragmentRoot(
+ IPath jarPath,
+ Object target,
+ IRubyProject[] projects) {
+ for (int i= 0, projectCount= projects.length; i < projectCount; i++) {
+ try {
+ RubyProject javaProject= (RubyProject)projects[i];
+ ILoadpathEntry[] classpathEntries= javaProject.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
+ for (int j= 0, entryCount= classpathEntries.length; j < entryCount; j++) {
+ if (classpathEntries[j].getPath().equals(jarPath)) {
+ if (target instanceof IFile) {
+ // internal jar
+ return javaProject.getSourceFolderRoot((IFile)target);
+ } else {
+ // external jar
+ return javaProject.getSourceFolderRoot0(jarPath);
+ }
+ }
+ }
+ } catch (RubyModelException e) {
+ // RubyModelException from getResolvedClasspath - a problem occured while accessing project: nothing we can do, ignore
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the package fragment root that contains the given resource path.
+ */
+ private ISourceFolderRoot getPkgFragmentRoot(String pathString) {
+
+ IPath path= new Path(pathString);
+ IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i= 0, max= projects.length; i < max; i++) {
+ try {
+ IProject project = projects[i];
+ if (!project.isAccessible()
+ || !project.hasNature(RubyCore.NATURE_ID)) continue;
+ IRubyProject javaProject= this.javaModel.getRubyProject(project);
+ ISourceFolderRoot[] roots= javaProject.getSourceFolderRoots();
+ for (int j= 0, rootCount= roots.length; j < rootCount; j++) {
+ SourceFolderRoot root= (SourceFolderRoot)roots[j];
+ if (root.getPath().isPrefixOf(path) && !Util.isExcluded(path, root.fullInclusionPatternChars(), root.fullExclusionPatternChars(), false)) {
+ return root;
+ }
+ }
+ } catch (CoreException e) {
+ // CoreException from hasNature - should not happen since we check that the project is accessible
+ // RubyModelException from getSourceFolderRoots - a problem occured while accessing project: nothing we can do, ignore
+ }
+ }
+ 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:00:21
|
Revision: 2145
http://svn.sourceforge.net/rubyeclipse/?rev=2145&view=rev
Author: cawilliams
Date: 2007-03-13 11:00:18 -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/InternalSearchPattern.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 17:39:10 UTC (rev 2144)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-03-13 18:00:18 UTC (rev 2145)
@@ -3,7 +3,7 @@
import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
import org.rubypeople.rdt.internal.core.util.CharOperation;
-public class SearchPattern extends InternalSearchPattern {
+public abstract class SearchPattern extends InternalSearchPattern {
// Rules for pattern matching: (exact, prefix, pattern) [ | case sensitive]
/**
* Match rule: The search pattern matches exactly the search result,
@@ -129,5 +129,115 @@
public static final int R_CAMELCASE_MATCH = 0x0080;
private static final int MODE_MASK = R_EXACT_MATCH | R_PREFIX_MATCH | R_PATTERN_MATCH | R_REGEXP_MATCH;
+
+ private int matchRule;
+
+ /**
+ * Creates a search pattern with the rule to apply for matching index keys.
+ * It can be exact match, prefix match, pattern match or regexp match.
+ * Rule can also be combined with a case sensitivity flag.
+ *
+ * @param matchRule one of {@link #R_EXACT_MATCH}, {@link #R_PREFIX_MATCH}, {@link #R_PATTERN_MATCH},
+ * {@link #R_REGEXP_MATCH}, {@link #R_CAMELCASE_MATCH} combined with one of following values:
+ * {@link #R_CASE_SENSITIVE}, {@link #R_ERASURE_MATCH} or {@link #R_EQUIVALENT_MATCH}.
+ * e.g. {@link #R_EXACT_MATCH} | {@link #R_CASE_SENSITIVE} if an exact and case sensitive match is requested,
+ * {@link #R_PREFIX_MATCH} if a prefix non case sensitive match is requested or {@link #R_EXACT_MATCH} | {@link #R_ERASURE_MATCH}
+ * if a non case sensitive and erasure match is requested.<br>
+ * Note that {@link #R_ERASURE_MATCH} or {@link #R_EQUIVALENT_MATCH} have no effect
+ * on non-generic types/methods search.<br>
+ * Note also that default behavior for generic types/methods search is to find exact matches.
+ */
+ public SearchPattern(int matchRule) {
+ this.matchRule = matchRule;
+ // Set full match implicit mode
+ if ((matchRule & (R_EQUIVALENT_MATCH | R_ERASURE_MATCH )) == 0) {
+ this.matchRule |= R_FULL_MATCH;
+ }
+ }
+
+ /**
+ * Returns a blank pattern that can be used as a record to decode an index key.
+ * <p>
+ * Implementors of this method should return a new search pattern that is going to be used
+ * to decode index keys.
+ * </p>
+ *
+ * @return a new blank pattern
+ * @see #decodeIndexKey(char[])
+ */
+ public abstract SearchPattern getBlankPattern();
+ /**
+ * Decode the given index key in this pattern. The decoded index key is used by
+ * {@link #matchesDecodedKey(SearchPattern)} to find out if the corresponding index entry
+ * should be considered.
+ * <p>
+ * This method should be re-implemented in subclasses that need to decode an index key.
+ * </p>
+ *
+ * @param key the given index key
+ */
+ public void decodeIndexKey(char[] key) {
+ // called from findIndexMatches(), override as necessary
+ }
+
+ /**
+ * Returns whether this pattern matches the given pattern (representing a decoded index key).
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @param decodedPattern a pattern representing a decoded index key
+ * @return whether this pattern matches the given pattern
+ */
+ public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ return true; // called from findIndexMatches(), override as necessary if index key is encoded
+ }
+
+ /**
+ * Returns an array of index categories to consider for this index query.
+ * These potential matches will be further narrowed by the match locator, but precise
+ * match locating can be expensive, and index query should be as accurate as possible
+ * so as to eliminate obvious false hits.
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @return an array of index categories
+ */
+ public char[][] getIndexCategories() {
+ return CharOperation.NO_CHAR_CHAR; // called from queryIn(), override as necessary
+ }
+
+ /**
+ * Returns a key to find in relevant index categories, if null then all index entries are matched.
+ * The key will be matched according to some match rule. These potential matches
+ * will be further narrowed by the match locator, but precise match locating can be expensive,
+ * and index query should be as accurate as possible so as to eliminate obvious false hits.
+ * <p>
+ * This method should be re-implemented in subclasses that need to narrow down the
+ * index query.
+ * </p>
+ *
+ * @return an index key from this pattern, or <code>null</code> if all index entries are matched.
+ */
+ public char[] getIndexKey() {
+ return null; // called from queryIn(), override as necessary
+ }
+
+ /**
+ * Returns the rule to apply for matching index keys. Can be exact match, prefix match, pattern match or regexp match.
+ * Rule can also be combined with a case sensitivity flag.
+ *
+ * @return one of R_EXACT_MATCH, R_PREFIX_MATCH, R_PATTERN_MATCH, R_REGEXP_MATCH combined with R_CASE_SENSITIVE,
+ * e.g. R_EXACT_MATCH | R_CASE_SENSITIVE if an exact and case sensitive match is requested,
+ * or R_PREFIX_MATCH if a prefix non case sensitive match is requested.
+ * [TODO (frederic) I hope R_ERASURE_MATCH doesn't need to be on this list. Because it would be a breaking API change.]
+ */
+ public final int getMatchRule() {
+ return this.matchRule;
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java 2007-03-13 17:39:10 UTC (rev 2144)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.java 2007-03-13 18:00:18 UTC (rev 2145)
@@ -62,7 +62,7 @@
return (SearchPattern) this;
}
String documentPath(String containerPath, String relativePath) {
- String separator = Util.isArchiveFileName(containerPath) ? IRubySearchScope.JAR_FILE_ENTRY_SEPARATOR : "/"; //$NON-NLS-1$
+ String separator = "/"; //$NON-NLS-1$
StringBuffer buffer = new StringBuffer(containerPath.length() + separator.length() + relativePath.length());
buffer.append(containerPath);
buffer.append(separator);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 17:39:12
|
Revision: 2144
http://svn.sourceforge.net/rubyeclipse/?rev=2144&view=rev
Author: cawilliams
Date: 2007-03-13 10:39:10 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
a good start on importing and modifying search stuff from JDT...
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
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/Messages.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java
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/SearchRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/SourceElementParser.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRestriction.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRule.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRuleSet.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/parser/ScannerHelper.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfIntValues.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/HashtableOfObject.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleLookupTable.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/SimpleSet.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/DiskIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/EntryResult.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/Index.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/index/MemoryIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/AbstractSearchScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexQueryRequestor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/IndexSelector.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/PatternSearchJob.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchParticipant.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubySearchScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/RubyWorkspaceScope.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/AddJarFileToIndex.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IIndexConstants.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexAllProject.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexBinaryFolder.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexManager.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/IndexRequest.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/InternalSearchDocument.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/ReadWriteMonitor.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/indexing/SourceIndexer.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/InternalSearchPattern.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/search/processing/
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/IJob.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/processing/JobManager.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java 2007-03-13 17:32:30 UTC (rev 2143)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -34,6 +34,23 @@
public interface IProblem {
/**
+ * Problem Categories
+ * The high bits of a problem ID contains information about the category of a problem.
+ * For example, (problemID & TypeRelated) != 0, indicates that this problem is type related.
+ *
+ * A problem category can help to implement custom problem filters. Indeed, when numerous problems
+ * are listed, focusing on import related problems first might be relevant.
+ *
+ * When a problem is tagged as Internal, it means that no change other than a local source code change
+ * can fix the corresponding problem. A type related problem could be addressed by changing the type
+ * involved in it.
+ */
+ int TypeRelated = 0x01000000;
+
+ int ForbiddenReference = TypeRelated + 307;
+ int DiscouragedReference = TypeRelated + 280;
+
+ /**
* Answer a localized, human-readable message string which describes the
* problem.
*
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/IRubySearchScope.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.IRubyElement;
+
+/**
+ * An <code>IRubySearchScope</code> defines where search result should be found by a
+ * <code>SearchEngine</code>. Clients must pass an instance of this interface
+ * to the <code>search(...)</code> methods. Such an instance can be created using the
+ * following factory methods on <code>SearchEngine</code>: <code>createHierarchyScope(IType)</code>,
+ * <code>createRubySearchScope(IResource[])</code>, <code>createWorkspaceScope()</code>, or
+ * clients may choose to implement this interface.
+ */
+public interface IRubySearchScope {
+/**
+ * This constant defines the separator of the resourcePath string of the <code>encloses(String)</code>
+ * method. If present in the string, it separates the path to the jar file from the path
+ * to the .class file in the jar.
+ */
+String JAR_FILE_ENTRY_SEPARATOR = "|"; //$NON-NLS-1$
+/**
+ * Include type constant (bit mask) indicating that source folders should be considered in the search scope.
+ * @since 3.0
+ */
+int SOURCES = 1;
+/**
+ * Include type constant (bit mask) indicating that application libraries should be considered in the search scope.
+ * @since 3.0
+ */
+int APPLICATION_LIBRARIES = 2;
+/**
+ * Include type constant (bit mask) indicating that system libraries should be considered in the search scope.
+ * @since 3.0
+ */
+int SYSTEM_LIBRARIES = 4;
+/**
+ * Include type constant (bit mask) indicating that referenced projects should be considered in the search scope.
+ * @since 3.0
+ */
+int REFERENCED_PROJECTS = 8;
+/**
+ * Checks whether the resource at the given path is enclosed by this scope.
+ *
+ * @param resourcePath if the resource is contained in
+ * a JAR file, the path is composed of 2 paths separated
+ * by <code>JAR_FILE_ENTRY_SEPARATOR</code>: the first path is the full OS path
+ * to the JAR (if it is an external JAR), or the workspace relative <code>IPath</code>
+ * to the JAR (if it is an internal JAR),
+ * the second path is the path to the resource inside the JAR.
+ * @return whether the resource is enclosed by this scope
+ */
+public boolean encloses(String resourcePath);
+/**
+ * Checks whether this scope encloses the given element.
+ *
+ * @param element the given element
+ * @return <code>true</code> if the element is in this scope
+ */
+public boolean encloses(IRubyElement element);
+/**
+ * Returns the paths to the enclosing projects and JARs for this search scope.
+ * <ul>
+ * <li> If the path is a project path, this is the full path of the project
+ * (see <code>IResource.getFullPath()</code>).
+ * For example, /MyProject
+ * </li>
+ * <li> If the path is a JAR path and this JAR is internal to the workspace,
+ * this is the full path of the JAR file (see <code>IResource.getFullPath()</code>).
+ * For example, /MyProject/mylib.jar
+ * </li>
+ * <li> If the path is a JAR path and this JAR is external to the workspace,
+ * this is the full OS path to the JAR file on the file system.
+ * For example, d:\libs\mylib.jar
+ * </li>
+ * </ul>
+ *
+ * @return an array of paths to the enclosing projects and JARS.
+ */
+IPath[] enclosingProjectsAndJars();
+/**
+ * Returns whether this scope contains any <code>.class</code> files (either
+ * in folders or within JARs).
+ *
+ * @return whether this scope contains any <code>.class</code> files
+ * @deprecated Use
+ * {@link org.eclipse.jdt.core.search.SearchEngine#createRubySearchScope(IRubyElement[])}
+ * with the package fragment roots that correspond to the binaries instead.
+ */
+boolean includesBinaries();
+/**
+ * Returns whether this scope includes classpaths defined by
+ * the projects of the resources of this search scope.
+ *
+ * @return whether this scope includes classpaths
+ * @deprecated Use
+ * {@link org.eclipse.jdt.core.search.SearchEngine#createRubySearchScope(IRubyElement[])}
+ * with a Ruby project instead.
+ */
+boolean includesClasspaths();
+/**
+ * Sets whether this scope contains any <code>.class</code> files (either
+ * in folders or within JARs).
+ *
+ * @param includesBinaries whether this scope contains any <code>.class</code> files
+ * @deprecated Use
+ * {@link org.eclipse.jdt.core.search.SearchEngine#createRubySearchScope(IRubyElement[])}
+ * with the package fragment roots that correspond to the binaries instead.
+ */
+public void setIncludesBinaries(boolean includesBinaries);
+/**
+ * Sets whether this scope includes the classpaths defined by
+ * the projects of the resources of this search scope.
+ *
+ * @param includesClasspaths whether this scope includes classpaths
+ * @deprecated Use
+ * {@link org.eclipse.jdt.core.search.SearchEngine#createRubySearchScope(IRubyElement[])}
+ * with a Ruby project instead.
+ */
+public void setIncludesClasspaths(boolean includesClasspaths);
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchDocument.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.rubypeople.rdt.internal.core.search.indexing.InternalSearchDocument;
+
+/**
+ * A search document encapsulates a content to be either indexed or searched in.
+ * A search particpant creates a search document.
+ * <p>
+ * This class is intended to be subclassed by clients.
+ * </p>
+ *
+ * @since 3.0
+ */
+public abstract class SearchDocument extends InternalSearchDocument {
+ private String documentPath;
+ private SearchParticipant participant;
+
+ /**
+ * Creates a new search document. The given document path is a string that uniquely identifies the document.
+ * Most of the time it is a workspace-relative path, but it can also be a file system path, or a path inside a zip file.
+ *
+ * @param documentPath the path to the document,
+ * or <code>null</code> if none
+ * @param participant the participant that creates the search document
+ */
+ protected SearchDocument(String documentPath, SearchParticipant participant) {
+ this.documentPath = documentPath;
+ this.participant = participant;
+ }
+
+ /**
+ * Adds the given index entry (category and key) coming from this
+ * document to the index. This method must be called from
+ * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
+ *
+ * @param category the category of the index entry
+ * @param key the key of the index entry
+ */
+ public void addIndexEntry(char[] category, char[] key) {
+ super.addIndexEntry(category, key);
+ }
+
+ /**
+ * Returns the contents of this document.
+ * Contents may be different from actual resource at corresponding document path,
+ * in case of preprocessing.
+ * <p>
+ * This method must be implemented in subclasses.
+ * </p><p>
+ * Note: some implementation may choose to cache the contents directly on the
+ * document for performance reason. However, this could induce scalability issues due
+ * to the fact that collections of documents are manipulated throughout the search
+ * operation, and cached contents would then consume lots of memory until they are
+ * all released at once in the end.
+ * </p>
+ *
+ * @return the contents of this document,
+ * or <code>null</code> if none
+ */
+ public abstract byte[] getByteContents();
+
+ /**
+ * Returns the contents of this document.
+ * Contents may be different from actual resource at corresponding document
+ * path due to preprocessing.
+ * <p>
+ * This method must be implemented in subclasses.
+ * </p><p>
+ * Note: some implementation may choose to cache the contents directly on the
+ * document for performance reason. However, this could induce scalability issues due
+ * to the fact that collections of documents are manipulated throughout the search
+ * operation, and cached contents would then consume lots of memory until they are
+ * all released at once in the end.
+ * </p>
+ *
+ * @return the contents of this document,
+ * or <code>null</code> if none
+ */
+ public abstract char[] getCharContents();
+
+ /**
+ * Returns the encoding for this document.
+ * <p>
+ * This method must be implemented in subclasses.
+ * </p>
+ *
+ * @return the encoding for this document,
+ * or <code>null</code> if none
+ */
+ public abstract String getEncoding();
+
+ /**
+ * Returns the participant that created this document.
+ *
+ * @return the participant that created this document
+ */
+ public final SearchParticipant getParticipant() {
+ return this.participant;
+ }
+
+ /**
+ * Returns the path to the original document to publicly mention in index
+ * or search results. This path is a string that uniquely identifies the document.
+ * Most of the time it is a workspace-relative path, but it can also be a file system path,
+ * or a path inside a zip file.
+ *
+ * @return the path to the document
+ */
+ public final String getPath() {
+ return this.documentPath;
+ }
+ /**
+ * Removes all index entries from the index for the given document.
+ * This method must be called from
+ * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
+ */
+ public void removeAllIndexEntries() {
+ super.removeAllIndexEntries();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchEngine.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchEngine.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,15 @@
+package org.rubypeople.rdt.core.search;
+
+import org.rubypeople.rdt.internal.core.search.BasicSearchEngine;
+
+public class SearchEngine {
+ /**
+ * Returns a new default Ruby search participant.
+ *
+ * @return a new default Ruby search participant
+ * @since 3.0
+ */
+ public static SearchParticipant getDefaultSearchParticipant() {
+ return BasicSearchEngine.getDefaultSearchParticipant();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchMatch.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,375 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.search.SearchEngine;
+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.core.RubyElement;
+
+/**
+ * A search match represents the result of a search query.
+ *
+ * Search matches may be accurate (<code>A_ACCURATE</code>) or they might be
+ * merely potential matches (<code>A_INACCURATE</code>). The latter occurs when
+ * a compile-time problem prevents the search engine from completely resolving
+ * the match.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @see SearchEngine#search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, org.eclipse.core.runtime.IProgressMonitor)
+ * @since 3.0
+ */
+public class SearchMatch {
+
+ /**
+ * The search result corresponds an exact match of the search pattern.
+ *
+ * @see #getAccuracy()
+ */
+ public static final int A_ACCURATE = 0;
+
+ /**
+ * The search result is potentially a match for the search pattern,
+ * but the search engine is unable to fully check it (for example, because
+ * there are errors in the code or the classpath are not correctly set).
+ *
+ * @see #getAccuracy()
+ */
+ public static final int A_INACCURATE = 1;
+
+ private Object element;
+ private int length;
+ private int offset;
+
+ private int accuracy;
+ private SearchParticipant participant;
+ private IResource resource;
+
+ private boolean insideDocComment = false;
+
+ // store the rule used while reporting the match
+ private int rule = SearchPattern.R_FULL_MATCH |
+ SearchPattern.R_EQUIVALENT_MATCH |
+ SearchPattern.R_ERASURE_MATCH;
+
+ // store other necessary information
+ private boolean raw = false;
+ private boolean implicit = false;
+
+ /**
+ * Creates a new search match.
+ * <p>
+ * Note that <code>isInsideDocComment()</code> defaults to false.
+ * </p>
+ *
+ * @param element the element that encloses or corresponds to the match,
+ * or <code>null</code> if none
+ * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ * @param offset the offset the match starts at, or -1 if unknown
+ * @param length the length of the match, or -1 if unknown
+ * @param participant the search participant that created the match
+ * @param resource the resource of the element, or <code>null</code> if none
+ */
+ public SearchMatch(
+ IRubyElement element,
+ int accuracy,
+ int offset,
+ int length,
+ SearchParticipant participant,
+ IResource resource) {
+ this.element = element;
+ this.offset = offset;
+ this.length = length;
+ this.accuracy = accuracy & A_INACCURATE;
+ if (accuracy > A_INACCURATE) {
+ this.rule = accuracy & ~A_INACCURATE; // accuracy may have also some rule information
+ }
+ this.participant = participant;
+ this.resource = resource;
+ }
+
+ /**
+ * Returns the accuracy of this search match.
+ *
+ * @return one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ */
+ public final int getAccuracy() {
+ return this.accuracy;
+ }
+
+ /**
+ * Returns the element of this search match.
+ * In case of a reference match, this is the inner-most enclosing element of the reference.
+ * In case of a declaration match, this is the declaration.
+ *
+ * @return the element of the search match, or <code>null</code> if none
+ */
+ public final Object getElement() {
+ return this.element;
+ }
+
+ /**
+ * Returns the length of this search match.
+ *
+ * @return the length of this search match, or -1 if unknown
+ */
+ public final int getLength() {
+ return this.length;
+ }
+
+ /**
+ * Returns the offset of this search match.
+ *
+ * @return the offset of this search match, or -1 if unknown
+ */
+ public final int getOffset() {
+ return this.offset;
+ }
+
+ /**
+ * Returns the search participant which issued this search match.
+ *
+ * @return the participant which issued this search match
+ */
+ public final SearchParticipant getParticipant() {
+ return this.participant;
+ }
+
+ /**
+ * Returns the resource containing this search match.
+ *
+ * @return the resource of the match, or <code>null</code> if none
+ */
+ public final IResource getResource() {
+ return this.resource;
+ }
+
+ /**
+ * Returns the rule used while creating the match.
+ *
+ * @return one of {@link SearchPattern#R_FULL_MATCH}, {@link SearchPattern#R_EQUIVALENT_MATCH}
+ * or {@link SearchPattern#R_ERASURE_MATCH}
+ * @since 3.1
+ */
+ public final int getRule() {
+ return this.rule;
+ }
+
+ /**
+ * Returns whether match element is compatible with searched pattern or not.
+ * Note that equivalent matches are also erasure ones.
+ *
+ * @return <code>true</code> if match element is compatible
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isEquivalent() {
+ return isErasure() && (this.rule & SearchPattern.R_EQUIVALENT_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether match element only has same erasure than searched pattern or not.
+ * Note that this is always true for both generic and non-generic element as soon
+ * as the accuracy is accurate.
+ *
+ * @return <code>true</code> if match element has same erasure
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isErasure() {
+ return (this.rule & SearchPattern.R_ERASURE_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether element matches exactly searched pattern or not.
+ * Note that exact matches are also erasure and equivalent ones.
+ *
+ * @return <code>true</code> if match is exact
+ * <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isExact() {
+ return isEquivalent() && (this.rule & SearchPattern.R_FULL_MATCH) != 0;
+ }
+
+ /**
+ * Returns whether the associated element is implicit or not.
+ *
+ * Note that this piece of information is currently only implemented
+ * for implicit member pair value in annotation.
+ *
+ * @return <code>true</code> if this match is associated to an implicit
+ * element and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isImplicit() {
+ return this.implicit;
+ }
+
+ /**
+ * Returns whether the associated element is a raw type/method or not.
+ *
+ * @return <code>true</code> if this match is associated to a raw
+ * type or method and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final boolean isRaw() {
+ return this.raw;
+ }
+
+ /**
+ * Returns whether this search match is inside a doc comment of a Java
+ * source file.
+ *
+ * @return <code>true</code> if this search match is inside a doc
+ * comment, and <code>false</code> otherwise
+ */
+ public final boolean isInsideDocComment() {
+ // default is outside a doc comment
+ return this.insideDocComment;
+ }
+
+ /**
+ * Sets the accuracy of this match.
+ *
+ * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
+ */
+ public final void setAccuracy (int accuracy) {
+ this.accuracy = accuracy;
+ }
+
+ /**
+ * Sets the element of this search match.
+ *
+ * @param element the element that encloses or corresponds to the match,
+ * or <code>null</code> if none
+ */
+ public final void setElement (Object element) {
+ this.element = element;
+ }
+
+ /**
+ * Sets whether this search match is inside a doc comment of a Java
+ * source file.
+ *
+ * @param insideDoc <code>true</code> if this search match is inside a doc
+ * comment, and <code>false</code> otherwise
+ */
+ public final void setInsideDocComment (boolean insideDoc) {
+ this.insideDocComment = insideDoc;
+ }
+
+ /**
+ * Sets whether the associated element is implicit or not.
+ * Typically, this is the case when match is on an implicit constructor
+ * or an implicit member pair value in annotation.
+ *
+ * @param implicit <code>true</code> if this match is associated to an implicit
+ * element and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final void setImplicit(boolean implicit) {
+ this.implicit = implicit;
+ }
+
+ /**
+ * Sets the length of this search match.
+ *
+ * @param length the length of the match, or -1 if unknown
+ */
+ public final void setLength(int length) {
+ this.length = length;
+ }
+
+ /**
+ * Sets the offset of this search match.
+ *
+ * @param offset the offset the match starts at, or -1 if unknown
+ */
+ public final void setOffset(int offset) {
+ this.offset = offset;
+ }
+
+ /**
+ * Sets the participant of this match.
+ *
+ * @param participant the search participant that created this match
+ */
+ public final void setParticipant (SearchParticipant participant) {
+ this.participant = participant;
+ }
+
+ /**
+ * Sets the resource of this match.
+ *
+ * @param resource the resource of the match, or <code>null</code> if none
+ */
+ public final void setResource (IResource resource) {
+ this.resource = resource;
+ }
+
+ /**
+ * Set the rule used while reporting the match.
+ *
+ * @param rule one of {@link SearchPattern#R_FULL_MATCH}, {@link SearchPattern#R_EQUIVALENT_MATCH}
+ * or {@link SearchPattern#R_ERASURE_MATCH}
+ * @since 3.1
+ */
+ public final void setRule(int rule) {
+ this.rule = rule;
+ }
+
+ /**
+ * Set whether the associated element is a raw type/method or not.
+ *
+ * @param raw <code>true</code> if this search match is associated to a raw
+ * type or method and <code>false</code> otherwise
+ * @since 3.1
+ */
+ public final void setRaw(boolean raw) {
+ this.raw = raw;
+ }
+
+ /* (non-javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Search match"); //$NON-NLS-1$
+ buffer.append("\n accuracy="); //$NON-NLS-1$
+ buffer.append(this.accuracy == A_ACCURATE ? "ACCURATE" : "INACCURATE"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append("\n rule="); //$NON-NLS-1$
+ if ((this.rule & SearchPattern.R_FULL_MATCH) != 0) {
+ buffer.append("EXACT"); //$NON-NLS-1$
+ } else if ((this.rule & SearchPattern.R_EQUIVALENT_MATCH) != 0) {
+ buffer.append("EQUIVALENT"); //$NON-NLS-1$
+ } else if ((this.rule & SearchPattern.R_ERASURE_MATCH) != 0) {
+ buffer.append("ERASURE"); //$NON-NLS-1$
+ }
+ buffer.append("\n raw="); //$NON-NLS-1$
+ buffer.append(this.raw);
+ buffer.append("\n offset="); //$NON-NLS-1$
+ buffer.append(this.offset);
+ buffer.append("\n length="); //$NON-NLS-1$
+ buffer.append(this.length);
+ if (this.element != null) {
+ buffer.append("\n element="); //$NON-NLS-1$
+ buffer.append(((RubyElement)getElement()).toStringWithAncestors());
+ }
+ buffer.append("\n"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchParticipant.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.rubypeople.rdt.internal.core.RubyModel;
+import org.rubypeople.rdt.internal.core.RubyModelManager;
+import org.rubypeople.rdt.internal.core.search.indexing.IndexManager;
+
+/**
+ * A search participant describes a particular extension to a generic search
+ * mechanism, permitting combined search actions which will involve all required
+ * participants.
+ * <p>
+ * A search participant is involved in the indexing phase and in the search phase.
+ * The indexing phase consists in taking one or more search documents, parse them, and
+ * add index entries in an index chosen by the participant. An index is identified by a
+ * path on disk.
+ * The search phase consists in selecting the indexes corresponding to a search pattern
+ * and a search scope, from these indexes the search infrastructure extracts the document paths
+ * that match the search pattern asking the search participant for the corresponding document,
+ * finally the search participant is asked to locate the matches precisely in these search documents.
+ * </p>
+ * <p>
+ * This class is intended to be subclassed by clients. During the indexing phase,
+ * a subclass will be called with the following requests in order:
+ * <ul>
+ * <li>{@link #scheduleDocumentIndexing(SearchDocument, IPath)}</li>
+ * <li>{@link #indexDocument(SearchDocument, IPath)}</li>
+ * </ul>
+ * During the search phase, a subclass will be called with the following requests in order:
+ * <ul>
+ * <li>{@link #selectIndexes(SearchPattern, IRubySearchScope)}</li>
+ * <li>one or more {@link #getDocument(String)}</li>
+ * <li>{@link #locateMatches(SearchDocument[], SearchPattern, IRubySearchScope, SearchRequestor, IProgressMonitor)}</li>
+ * </ul>
+ * </p>
+ *
+ * @since 3.0
+ */
+public abstract class SearchParticipant {
+
+ /**
+ * Creates a new search participant.
+ */
+ protected SearchParticipant() {
+ // do nothing
+ }
+
+ /**
+ * Notification that this participant's help is needed in a search.
+ * <p>
+ * This method should be re-implemented in subclasses that need to do something
+ * when the participant is needed in a search.
+ * </p>
+ */
+ public void beginSearching() {
+ // do nothing
+ }
+
+ /**
+ * Notification that this participant's help is no longer needed.
+ * <p>
+ * This method should be re-implemented in subclasses that need to do something
+ * when the participant is no longer needed in a search.
+ * </p>
+ */
+ public void doneSearching() {
+ // do nothing
+ }
+
+ /**
+ * Returns a displayable name of this search participant.
+ * <p>
+ * This method should be re-implemented in subclasses that need to
+ * display a meaningfull name.
+ * </p>
+ *
+ * @return the displayable name of this search participant
+ */
+ public String getDescription() {
+ return "Search participant"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns a search document for the given path.
+ * The given document path is a string that uniquely identifies the document.
+ * Most of the time it is a workspace-relative path, but it can also be a file system path, or a path inside a zip file.
+ * <p>
+ * Implementors of this method can either create an instance of their own subclass of
+ * {@link SearchDocument} or return an existing instance of such a subclass.
+ * </p>
+ *
+ * @param documentPath the path of the document.
+ * @return a search document
+ */
+ public abstract SearchDocument getDocument(String documentPath);
+
+ /**
+ * Indexes the given document in the given index. A search participant
+ * asked to index a document should parse it and call
+ * {@link SearchDocument#addIndexEntry(char[], char[])} as many times as
+ * needed to add index entries to the index. If delegating to another
+ * participant, it should use the original index location (and not the
+ * delegatee's one). In the particular case of delegating to the default
+ * search participant (see {@link SearchEngine#getDefaultSearchParticipant()}),
+ * the provided document's path must be a path ending with one of the
+ * {@link org.eclipse.jdt.core.RubyCore#getRubyLikeExtensions() Ruby-like extensions}
+ * or with '.class'.
+ * <p>
+ * The given index location must represent a path in the file system to a file that
+ * either already exists or is going to be created. If it exists, it must be an index file,
+ * otherwise its data might be overwritten.
+ * </p><p>
+ * Clients are not expected to call this method.
+ * </p>
+ *
+ * @param document the document to index
+ * @param indexLocation the location in the file system to the index
+ */
+ public abstract void indexDocument(SearchDocument document, IPath indexLocation);
+
+ /**
+ * Locates the matches in the given documents using the given search pattern
+ * and search scope, and reports them to the givenn search requestor. This
+ * method is called by the search engine once it has search documents
+ * matching the given pattern in the given search scope.
+ * <p>
+ * Note that a participant (e.g. a JSP participant) can pre-process the contents of the given documents,
+ * create its own documents whose contents are Ruby compilation units and delegate the match location
+ * to the default participant (see {@link SearchEngine#getDefaultSearchParticipant()}). Passing its own
+ * {@link SearchRequestor} this particpant can then map the match positions back to the original
+ * contents, create its own matches and report them to the original requestor.
+ * </p><p>
+ * Implementors of this method should check the progress monitor
+ * for cancelation when it is safe and appropriate to do so. The cancelation
+ * request should be propagated to the caller by throwing
+ * <code>OperationCanceledException</code>.
+ * </p>
+ *
+ * @param documents the documents to locate matches in
+ * @param pattern the search pattern to use when locating matches
+ * @param scope the scope to limit the search to
+ * @param requestor the requestor to report matches to
+ * @param monitor the progress monitor to report progress to,
+ * or <code>null</code> if no progress should be reported
+ * @throws CoreException if the requestor had problem accepting one of the matches
+ */
+ public abstract void locateMatches(SearchDocument[] documents, SearchPattern pattern, IRubySearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * Removes the index for a given path.
+ * <p>
+ * The given index location must represent a path in the file system to a file that
+ * already exists and must be an index file, otherwise nothing will be done.
+ * </p><p>
+ * It is strongly recommended to use this method instead of deleting file directly
+ * otherwise cached index will not be removed.
+ * </p>
+ *
+ * @param indexLocation the location in the file system to the index
+ * @since 3.2
+ */
+ public void removeIndex(IPath indexLocation){
+ IndexManager manager = RubyModelManager.getRubyModelManager().getIndexManager();
+ manager.removeIndexPath(indexLocation);
+ }
+
+ /**
+ * Schedules the indexing of the given document.
+ * Once the document is ready to be indexed,
+ * {@link #indexDocument(SearchDocument, IPath) indexDocument(document, indexPath)}
+ * will be called in a different thread than the caller's thread.
+ * <p>
+ * The given index location must represent a path in the file system to a file that
+ * either already exists or is going to be created. If it exists, it must be an index file,
+ * otherwise its data might be overwritten.
+ * </p><p>
+ * When the index is no longer needed, clients should use {@link #removeIndex(IPath) }
+ * to discard it.
+ * </p>
+ *
+ * @param document the document to index
+ * @param indexLocation the location on the file system of the index
+ */
+ public final void scheduleDocumentIndexing(SearchDocument document, IPath indexLocation) {
+ IPath documentPath = new Path(document.getPath());
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ Object file = RubyModel.getTarget(root, documentPath, true);
+ IPath containerPath = documentPath;
+ if (file instanceof IResource) {
+ containerPath = ((IResource)file).getProject().getFullPath();
+ } else if (file == null) {
+ containerPath = documentPath.removeLastSegments(documentPath.segmentCount()-1);
+ }
+ IndexManager manager = RubyModelManager.getRubyModelManager().getIndexManager();
+ String osIndexLocation = indexLocation.toOSString();
+ // TODO (frederic) should not have to create index manually, should expose API that recreates index instead
+ manager.ensureIndexExists(osIndexLocation, containerPath);
+ manager.scheduleDocumentIndexing(document, containerPath, osIndexLocation, this);
+ }
+
+ /**
+ * Returns the collection of index locations to consider when performing the
+ * given search query in the given scope. The search engine calls this
+ * method before locating matches.
+ * <p>
+ * An index location represents a path in the file system to a file that holds index information.
+ * </p><p>
+ * Clients are not expected to call this method.
+ * </p>
+ *
+ * @param query the search pattern to consider
+ * @param scope the given search scope
+ * @return the collection of index paths to consider
+ */
+ public abstract IPath[] selectIndexes(SearchPattern query, IRubySearchScope scope);
+}
Added: 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 (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,133 @@
+package org.rubypeople.rdt.core.search;
+
+import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public class SearchPattern extends InternalSearchPattern {
+// Rules for pattern matching: (exact, prefix, pattern) [ | case sensitive]
+ /**
+ * Match rule: The search pattern matches exactly the search result,
+ * that is, the source of the search result equals the search pattern.
+ */
+ public static final int R_EXACT_MATCH = 0;
+
+ /**
+ * Match rule: The search pattern is a prefix of the search result.
+ */
+ public static final int R_PREFIX_MATCH = 0x0001;
+
+ /**
+ * Match rule: The search pattern contains one or more wild cards ('*' or '?').
+ * A '*' wild-card can replace 0 or more characters in the search result.
+ * A '?' wild-card replaces exactly 1 character in the search result.
+ */
+ public static final int R_PATTERN_MATCH = 0x0002;
+
+ /**
+ * Match rule: The search pattern contains a regular expression.
+ */
+ public static final int R_REGEXP_MATCH = 0x0004;
+
+ /**
+ * Match rule: The search pattern matches the search result only if cases are the same.
+ * Can be combined to previous rules, e.g. {@link #R_EXACT_MATCH} | {@link #R_CASE_SENSITIVE}
+ */
+ public static final int R_CASE_SENSITIVE = 0x0008;
+
+ /**
+ * Match rule: The search pattern matches search results as raw/parameterized types/methods with same erasure.
+ * This mode has no effect on other java elements search.<br>
+ * Type search example:
+ * <ul>
+ * <li>pattern: <code>List<Exception></code></li>
+ * <li>match: <code>List<Object></code></li>
+ * </ul>
+ * Method search example:
+ * <ul>
+ * <li>declaration: <code><T>foo(T t)</code></li>
+ * <li>pattern: <code><Exception>foo(new Exception())</code></li>
+ * <li>match: <code><Object>foo(new Object())</code></li>
+ * </ul>
+ * Can be combined to all other match rules, e.g. {@link #R_CASE_SENSITIVE} | {@link #R_ERASURE_MATCH}
+ * This rule is not activated by default, so raw types or parameterized types with same erasure will not be found
+ * for pattern List<String>,
+ * Note that with this pattern, the match selection will be only on the erasure even for parameterized types.
+ * @since 3.1
+ */
+ public static final int R_ERASURE_MATCH = 0x0010;
+
+ /**
+ * Match rule: The search pattern matches search results as raw/parameterized types/methods with equivalent type parameters.
+ * This mode has no effect on other java elements search.<br>
+ * Type search example:
+ * <ul>
+ * <li>pattern: <code>List<Exception></code></li>
+ * <li>match:
+ * <ul>
+ * <li><code>List<? extends Throwable></code></li>
+ * <li><code>List<? super RuntimeException></code></li>
+ * <li><code>List<?></code></li>
+ * </ul>
+ * </li>
+ * </ul>
+ * Method search example:
+ * <ul>
+ * <li>declaration: <code><T>foo(T t)</code></li>
+ * <li>pattern: <code><Exception>foo(new Exception())</code></li>
+ * <li>match:
+ * <ul>
+ * <li><code><? extends Throwable>foo(new Exception())</code></li>
+ * <li><code><? super RuntimeException>foo(new Exception())</code></li>
+ * <li><code>foo(new Exception())</code></li>
+ * </ul>
+ * </ul>
+ * Can be combined to all other match rules, e.g. {@link #R_CASE_SENSITIVE} | {@link #R_EQUIVALENT_MATCH}
+ * This rule is not activated by default, so raw types or equivalent parameterized types will not be found
+ * for pattern List<String>,
+ * This mode is overridden by {@link #R_ERASURE_MATCH} as erasure matches obviously include equivalent ones.
+ * That means that pattern with rule set to {@link #R_EQUIVALENT_MATCH} | {@link #R_ERASURE_MATCH}
+ * will return same results than rule only set with {@link #R_ERASURE_MATCH}.
+ * @since 3.1
+ */
+ public static final int R_EQUIVALENT_MATCH = 0x0020;
+
+ /**
+ * Match rule: The search pattern matches exactly the search result,
+ * that is, the source of the search result equals the search pattern.
+ * @since 3.1
+ */
+ public static final int R_FULL_MATCH = 0x0040;
+
+ /**
+ * Match rule: The search pattern contains a Camel Case expression.
+ * <br>
+ * Examples:
+ * <ul>
+ * <li><code>NPE</code> type string pattern will match
+ * <code>NullPointerException</code> and <code>NpPermissionException</code> types,</li>
+ * <li><code>NuPoEx</code> type string pattern will only match
+ * <code>NullPointerException</code> type.</li>
+ * </ul>
+ * @see CharOperation#camelCaseMatch(char[], char[]) for a detailed explanation
+ * of Camel Case matching.
+ *<br>
+ * Can be combined to {@link #R_PREFIX_MATCH} match rule. For example,
+ * when prefix match rule is combined with Camel Case match rule,
+ * <code>"nPE"</code> pattern will match <code>nPException</code>.
+ *<br>
+ * Match rule {@link #R_PATTERN_MATCH} may also be combined but both rules
+ * will not be used simultaneously as they are mutually exclusive.
+ * Used match rule depends on whether string pattern contains specific pattern
+ * characters (e.g. '*' or '?') or not. If it does, then only Pattern match rule
+ * will be used, otherwise only Camel Case match will be used.
+ * For example, with <code>"NPE"</code> string pattern, search will only use
+ * Camel Case match rule, but with <code>N*P*E*</code> string pattern, it will
+ * use only Pattern match rule.
+ *
+ * @since 3.2
+ */
+ public static final int R_CAMELCASE_MATCH = 0x0080;
+
+ private static final int MODE_MASK = R_EXACT_MATCH | R_PREFIX_MATCH | R_PATTERN_MATCH | R_REGEXP_MATCH;
+
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchRequestor.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchRequestor.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchRequestor.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.core.search;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Collects the results from a search engine query.
+ * Clients implement a subclass to pass to <code>SearchEngine.search</code>
+ * and implement the {@link #acceptSearchMatch(SearchMatch)} method, and
+ * possibly override other life cycle methods.
+ * <p>
+ * The search engine calls <code>beginReporting()</code> when a search starts,
+ * then calls <code>acceptSearchMatch(...)</code> for each search result, and
+ * finally calls <code>endReporting()</code>. The order of the search results
+ * is unspecified and may vary from request to request; when displaying results,
+ * clients should not rely on the order but should instead arrange the results
+ * in an order that would be more meaningful to the user.
+ * </p>
+ *
+ * @see SearchEngine
+ * @since 3.0
+ */
+public abstract class SearchRequestor {
+
+ /**
+ * Accepts the given search match.
+ *
+ * @param match the found match
+ * @throws CoreException
+ */
+ public abstract void acceptSearchMatch(SearchMatch match) throws CoreException;
+
+ /**
+ * Notification sent before starting the search action.
+ * Typically, this would tell a search requestor to clear previously
+ * recorded search results.
+ * <p>
+ * The default implementation of this method does nothing. Subclasses
+ * may override.
+ * </p>
+ */
+ public void beginReporting() {
+ // do nothing
+ }
+
+ /**
+ * Notification sent after having completed the search action.
+ * Typically, this would tell a search requestor collector that no more
+ * results will be forthcomping in this search.
+ * <p>
+ * The default implementation of this method does nothing. Subclasses
+ * may override.
+ * </p>
+ */
+ public void endReporting() {
+ // do nothing
+ }
+
+ /**
+ * Intermediate notification sent when the given participant starts to
+ * contribute.
+ * <p>
+ * The default implementation of this method does nothing. Subclasses
+ * may override.
+ * </p>
+ *
+ * @param participant the participant that is starting to contribute
+ */
+ public void enterParticipant(SearchParticipant participant) {
+ // do nothing
+ }
+
+ /**
+ * Intermediate notification sent when the given participant is finished
+ * contributing.
+ * <p>
+ * The default implementation of this method does nothing. Subclasses
+ * may override.
+ * </p>
+ *
+ * @param participant the participant that finished contributing
+ */
+ public void exitParticipant(SearchParticipant participant) {
+ // do nothing
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/SourceElementParser.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/SourceElementParser.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/SourceElementParser.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,5 @@
+package org.rubypeople.rdt.internal.compiler;
+
+public class SourceElementParser {
+
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRestriction.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRestriction.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRestriction.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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;
+
+public class AccessRestriction {
+
+ private AccessRule accessRule;
+ private String[] messageTemplates;
+ public AccessRestriction(AccessRule accessRule, String [] messageTemplates) {
+ this.accessRule = accessRule;
+ this.messageTemplates = messageTemplates;
+ }
+
+ /**
+ * Returns readable description for problem reporting,
+ * message is expected to contain room for restricted type name
+ * e.g. "{0} has restricted access"
+ */
+ public String getMessageTemplate() {
+ return this.messageTemplates[0];
+ }
+
+ public String getConstructorAccessMessageTemplate() {
+ return this.messageTemplates[1];
+ }
+
+ public String getMethodAccessMessageTemplate() {
+ return this.messageTemplates[2];
+ }
+
+ public String getFieldAccessMessageTemplate() {
+ return this.messageTemplates[3];
+ }
+
+ public int getProblemId() {
+ return this.accessRule.getProblemId();
+ }
+
+ public boolean ignoreIfBetter() {
+ return this.accessRule.ignoreIfBetter();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRule.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRule.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRule.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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;
+
+import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+public class AccessRule {
+
+ public static final int IgnoreIfBetter = 0x02000000; // value must be greater than IProblem#ForbiddenReference and DiscouragedReference
+
+ public char[] pattern;
+ public int problemId;
+
+ public AccessRule(char[] pattern, int problemId) {
+ this(pattern, problemId, false);
+ }
+
+ public AccessRule(char[] pattern, int problemId, boolean keepLooking) {
+ this.pattern = pattern;
+ this.problemId = keepLooking ? problemId | IgnoreIfBetter : problemId;
+ }
+
+ public int hashCode() {
+ return this.problemId * 17 + CharOperation.hashCode(this.pattern);
+ }
+
+ public boolean equals(Object obj) {
+ if (!(obj instanceof AccessRule)) return false;
+ AccessRule other = (AccessRule) obj;
+ if (this.problemId != other.problemId) return false;
+ return CharOperation.equals(this.pattern, other.pattern);
+ }
+
+ public int getProblemId() {
+ return this.problemId & ~IgnoreIfBetter;
+ }
+
+ public boolean ignoreIfBetter() {
+ return (this.problemId & IgnoreIfBetter) != 0;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("pattern="); //$NON-NLS-1$
+ buffer.append(this.pattern);
+ switch (getProblemId()) {
+ case IProblem.ForbiddenReference:
+ buffer.append(" (NON ACCESSIBLE"); //$NON-NLS-1$
+ break;
+ case IProblem.DiscouragedReference:
+ buffer.append(" (DISCOURAGED"); //$NON-NLS-1$
+ break;
+ default:
+ buffer.append(" (ACCESSIBLE"); //$NON-NLS-1$
+ break;
+ }
+ if (ignoreIfBetter())
+ buffer.append(" | IGNORE IF BETTER"); //$NON-NLS-1$
+ buffer.append(')');
+ return buffer.toString();
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRuleSet.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRuleSet.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/AccessRuleSet.java 2007-03-13 17:39:10 UTC (rev 2144)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 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;
+
+import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+/**
+ * Definition of a set of access rules used to flag forbidden references to non API code.
+ */
+public class AccessRuleSet {
+
+ private AccessRule[] accessRules;
+ public String[] messageTemplates;
+ public static final int MESSAGE_TEMPLATES_LENGTH = 4;
+
+ /**
+ * Make a new set of access rules.
+ * @param accessRules the access rules to be contained by the new set
+ * @param messageTemplates a Sting[4] array specifying the messages for type,
+ * constructor, method and field access violation; each should contain as many
+ * placeholders as expected by the respective access violation message (that is,
+ * one for type and constructor, two for method and field); replaced by a
+ * default value if null.
+ */
+ public AccessRuleSet(AccessRule[] accessRules, String[] messageTemplates) {
+ this.accessRules = accessRules;
+ if (messageTemplates != null && messageTemplates.length == MESSAGE_TEMPLATES_LENGTH)
+ this.messageTemplates = messageTemplates;
+ else
+ this.messageTemplates = new String[] {"{0}", "{0}", "{0} {1}", "{0} {1}"}; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ /**
+ * @see java.l...
[truncated message content] |
|
From: <caw...@us...> - 2007-03-13 17:32:31
|
Revision: 2143
http://svn.sourceforge.net/rubyeclipse/?rev=2143&view=rev
Author: cawilliams
Date: 2007-03-13 10:32:30 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Create a branch for implementing an internal search engine similar to JDT or DLTK
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/
Copied: branches/search_engine/org.rubypeople.rdt.core (from rev 2142, trunk/org.rubypeople.rdt.core)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-13 17:32:27
|
Revision: 2142
http://svn.sourceforge.net/rubyeclipse/?rev=2142&view=rev
Author: cawilliams
Date: 2007-03-13 10:32:19 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Create a branch for implementing an internal search engine similar to JDT or DLTK
Added Paths:
-----------
branches/search_engine/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-03-13 15:28:40
|
Revision: 2141
http://svn.sourceforge.net/rubyeclipse/?rev=2141&view=rev
Author: mirkostocker
Date: 2007-03-13 08:28:37 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Add the feature to automagically add 'end' after class, module, def and do statements. This feature was requested in the recent Ruby / Rails IDE Comparison blog post and I think it's really nice to have. But I'm not sure if I did the whole thing 'right' so it would be nice if someone (Chris?) could review it. And don't hesitate to remove it if you don't like it :)
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/SmartTypingConfigurationBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.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-12 20:13:22 UTC (rev 2140)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-03-13 15:28:37 UTC (rev 2141)
@@ -122,6 +122,7 @@
public static String RubyEditorPreferencePage_closeStrings;
public static String RubyEditorPreferencePage_closeBrackets;
public static String RubyEditorPreferencePage_closeBraces;
+ public static String RubyEditorPreferencePage_endStatements;
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-12 20:13:22 UTC (rev 2140)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-03-13 15:28:37 UTC (rev 2141)
@@ -128,6 +128,7 @@
RubyEditorPreferencePage_closeStrings= "Double" and 'single' quoted &strings
RubyEditorPreferencePage_closeBrackets= (Parentheses) and [square] brac&kets
RubyEditorPreferencePage_closeBraces= {B&races}
+RubyEditorPreferencePage_endStatements='class', 'module', 'def' and blocks ('... do') with '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/SmartTypingConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SmartTypingConfigurationBlock.java 2007-03-12 20:13:22 UTC (rev 2140)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/SmartTypingConfigurationBlock.java 2007-03-13 15:28:37 UTC (rev 2141)
@@ -36,7 +36,8 @@
return new OverlayPreferenceStore.OverlayKey[] {
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES)
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_END_STATEMENTS)
};
}
@@ -82,6 +83,9 @@
label= PreferencesMessages.RubyEditorPreferencePage_closeBraces;
addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 0);
+
+ label= PreferencesMessages.RubyEditorPreferencePage_endStatements;
+ addCheckBox(composite, label, PreferenceConstants.EDITOR_END_STATEMENTS, 0);
}
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java 2007-03-12 20:13:22 UTC (rev 2140)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java 2007-03-13 15:28:37 UTC (rev 2141)
@@ -4,6 +4,8 @@
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Stack;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
@@ -125,6 +127,8 @@
private final static String CLOSE_BRACKETS= PreferenceConstants.EDITOR_CLOSE_BRACKETS;
/** Preference key for automatically closing braces */
private final static String CLOSE_BRACES= PreferenceConstants.EDITOR_CLOSE_BRACES;
+ /** Preference key for automatically 'end'ing statements */
+ private final static String END_STATEMENTS= PreferenceConstants.EDITOR_END_STATEMENTS;
/** Preference key for code formatter tab size */
private final static String CODE_FORMATTER_TAB_SIZE= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
/** Preference key for inserting spaces rather than tabs */
@@ -174,6 +178,7 @@
private FoldingActionGroup fFoldingGroup;
private BracketInserter fBracketInserter = new BracketInserter();
+ private EndInserter fEndInserter = new EndInserter();
private CompositeActionGroup fActionGroups;
private CompositeActionGroup fContextMenuGroup;
@@ -307,10 +312,13 @@
boolean closeBrackets= preferenceStore.getBoolean(CLOSE_BRACKETS);
boolean closeBraces= preferenceStore.getBoolean(CLOSE_BRACES);
boolean closeStrings= preferenceStore.getBoolean(CLOSE_STRINGS);
+ boolean endStatements= preferenceStore.getBoolean(END_STATEMENTS);
fBracketInserter.setCloseBracketsEnabled(closeBrackets);
fBracketInserter.setCloseBracesEnabled(closeBraces);
fBracketInserter.setCloseStringsEnabled(closeStrings);
- ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
+ fEndInserter.setEndStatementsEnabled(endStatements);
+ ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
+ ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fEndInserter);
}
}
@@ -616,10 +624,11 @@
*/
public void dispose() {
ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer instanceof ITextViewerExtension)
+ if (sourceViewer instanceof ITextViewerExtension) {
((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
+ ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fEndInserter);
+ }
-
if (fProjectionModelUpdater != null) {
fProjectionModelUpdater.uninstall();
fProjectionModelUpdater = null;
@@ -760,6 +769,11 @@
if (CLOSE_STRINGS.equals(property)) {
fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(property));
return;
+ }
+
+ if (END_STATEMENTS.equals(property)) {
+ fEndInserter.setEndStatementsEnabled(getPreferenceStore().getBoolean(property));
+ return;
}
AdaptedSourceViewer sourceViewer= (AdaptedSourceViewer) getSourceViewer();
@@ -1044,6 +1058,67 @@
}
+ private class EndInserter implements VerifyKeyListener {
+
+ /** Pattern to match lines with statements that can be completed with 'end' */
+ private final Pattern openBlockPattern =
+ Pattern.compile("(\\s*)" + // Capture the space before the statement, we need it to indent 'end'
+ "((def|class|module)\\s.*" + // Either we look for one of these statements
+ "|.*[\\S].*do[\\w|\\s]*)" + // or for an iterator, which needs at least one none-space character and 'do' with optional arguments.
+ "[^(end)]"); // And it should not contain end already.
+
+ private boolean endStatements;
+
+ public void verifyKey(VerifyEvent event) {
+ if (!event.doit || !endStatements) return;
+
+ switch (event.character) {
+ case '\n':
+ case '\r':
+ break;
+ default:
+ return;
+ }
+
+ final IDocument document = getSourceViewer().getDocument();
+ final int offset = getSourceViewer().getSelectedRange().x;
+ final int length = getSourceViewer().getSelectedRange().y;
+ try {
+ IRegion startLine = document.getLineInformationOfOffset(offset);
+ String lineContent = document.get(startLine.getOffset(), startLine.getLength());
+ Matcher matched = openBlockPattern.matcher(lineContent);
+ if(matched.matches()) {
+ String baseIndentation = matched.group(1); // 1 marks the spaces in front of the statement
+ String bodyIndentation = addOneIndentationLevel(baseIndentation);
+
+ String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, null);
+
+ String body = event.character + bodyIndentation + lineDelimiter + baseIndentation + "end";
+ document.replace(offset, length, body);
+ getSourceViewer().setSelectedRange(offset + bodyIndentation.length() + 1 /*for the newline char*/, 0);
+ event.doit = false;
+ }
+ } catch (BadLocationException e) {
+ RubyPlugin.log(e);
+ }
+ }
+
+ private String addOneIndentationLevel(String indentation) {
+ if(RubyCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR).equals(RubyCore.SPACE)) {
+ for(int i = 0; i < Integer.parseInt(RubyCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE)); i++) {
+ indentation += ' ';
+ }
+ } else {
+ indentation += '\t';
+ }
+ return indentation;
+ }
+
+ public void setEndStatementsEnabled(boolean endStatements) {
+ this.endStatements = endStatements;
+ }
+ }
+
private class BracketInserter implements VerifyKeyListener, ILinkedModeListener {
private boolean fCloseBrackets = true;
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-12 20:13:22 UTC (rev 2140)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-03-13 15:28:37 UTC (rev 2141)
@@ -557,6 +557,15 @@
* @since 2.1
*/
public final static String EDITOR_CLOSE_BRACES = "closeBraces"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the 'end' should be inserted
+ * automatically.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_END_STATEMENTS = "endStatements"; //$NON-NLS-1$
/**
* A named preference that controls whether occurrences are marked in the
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-12 20:13:23
|
Revision: 2140
http://svn.sourceforge.net/rubyeclipse/?rev=2140&view=rev
Author: cawilliams
Date: 2007-03-12 13:13:22 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.xml
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-03-12 20:12:36 UTC (rev 2139)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-03-12 20:13:22 UTC (rev 2140)
@@ -367,27 +367,6 @@
class="org.rubypeople.rdt.internal.ui.infoviews.RIView"
id="org.rubypeople.rdt.ui.views.RIView">
</view>
- <view
- name="Rails API"
- icon="icons/full/elcl16/help.gif"
- category="org.rubypeople.rdt.ui.ruby"
- class="org.rubypeople.rdt.internal.ui.infoviews.RailsAPIView"
- id="org.rubypeople.rdt.ui.views.RailsAPIView">
- </view>
- <view
- name="Ruby Core API"
- icon="icons/full/elcl16/help.gif"
- category="org.rubypeople.rdt.ui.ruby"
- class="org.rubypeople.rdt.internal.ui.infoviews.RubyCoreAPIView"
- id="org.rubypeople.rdt.ui.views.RubyCoreAPIView">
- </view>
- <view
- name="Ruby Standard Library API"
- icon="icons/full/elcl16/help.gif"
- category="org.rubypeople.rdt.ui.ruby"
- class="org.rubypeople.rdt.internal.ui.infoviews.RubyStdLibAPIView"
- id="org.rubypeople.rdt.ui.views.RubyStdLibAPIView">
- </view>
</extension>
<extension point="org.eclipse.ui.editors">
<editor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-12 20:12:40
|
Revision: 2139
http://svn.sourceforge.net/rubyeclipse/?rev=2139&view=rev
Author: cawilliams
Date: 2007-03-12 13:12:36 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
use memento tokens to save and re-create open external ruby scripts.
Now when we open an "external" script which is on laodpath we use a special editor input which allows us to do outline and other things on it.
Also, when the file is still open and user closes workspace, it will save tokens to be able to re-create the portion of the model necessary for that script.
Finally, we can take those tokens and re-create the actual model objects from it. Yeah!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElement.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolderRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ImportContainer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Member.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElement.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyImport.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyType.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceRefElement.java
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/MementoTokenizer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInputFactory.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElement.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElement.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElement.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -252,4 +252,6 @@
// TODO (philippe) predicate shouldn't throw an exception
boolean isStructureKnown() throws RubyModelException;
+ public String getHandleIdentifier();
+
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolderRoot.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolderRoot.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolderRoot.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -3,7 +3,13 @@
import org.eclipse.core.runtime.IProgressMonitor;
public interface ISourceFolderRoot extends IParent, IRubyElement, IOpenable {
+
/**
+ * Empty root path
+ */
+ String DEFAULT_PACKAGEROOT_PATH = ""; //$NON-NLS-1$
+
+ /**
* Returns whether this package fragment root is external
* to the workbench (that is, a local file), and has no
* underlying resource.
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -43,6 +43,7 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.rubypeople.rdt.internal.core.BatchOperation;
+import org.rubypeople.rdt.internal.core.DefaultWorkingCopyOwner;
import org.rubypeople.rdt.internal.core.LoadpathAttribute;
import org.rubypeople.rdt.internal.core.LoadpathEntry;
import org.rubypeople.rdt.internal.core.RubyCorePreferenceInitializer;
@@ -58,6 +59,7 @@
import org.rubypeople.rdt.internal.core.search.ExperimentalIndex;
import org.rubypeople.rdt.internal.core.symbols.ISymbolFinder;
import org.rubypeople.rdt.internal.core.symbols.SymbolIndex;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Util;
public class RubyCore extends Plugin {
@@ -1370,4 +1372,39 @@
return newContainerEntry(path, LoadpathEntry.NO_EXTRA_ATTRIBUTES, isExported);
}
+ /**
+ * Returns the Ruby model element corresponding to the given handle identifier
+ * generated by <code>IRubyElement.getHandleIdentifier()</code>, or
+ * <code>null</code> if unable to create the associated element.
+ *
+ * @param handleIdentifier the given handle identifier
+ * @return the Ruby element corresponding to the handle identifier
+ */
+ public static IRubyElement create(String handleIdentifier) {
+ return create(handleIdentifier, DefaultWorkingCopyOwner.PRIMARY);
+ }
+
+ /**
+ * Returns the Ruby model element corresponding to the given handle identifier
+ * generated by <code>IRubyElement.getHandleIdentifier()</code>, or
+ * <code>null</code> if unable to create the associated element.
+ * If the returned Ruby element is an <code>ICompilationUnit</code>, its owner
+ * is the given owner if such a working copy exists, otherwise the compilation unit
+ * is a primary compilation unit.
+ *
+ * @param handleIdentifier the given handle identifier
+ * @param owner the owner of the returned compilation unit, ignored if the returned
+ * element is not a compilation unit
+ * @return the Ruby element corresponding to the handle identifier
+ * @since 3.0
+ */
+ public static IRubyElement create(String handleIdentifier, WorkingCopyOwner owner) {
+ if (handleIdentifier == null) {
+ return null;
+ }
+ MementoTokenizer memento = new MementoTokenizer(handleIdentifier);
+ RubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
+ return model.getHandleFromMemento(memento, owner);
+ }
+
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -646,5 +646,10 @@
return false;
}
+ public String getHandleIdentifier() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalSourceFolder.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -8,6 +8,8 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Messages;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -62,4 +64,18 @@
}
return new ExternalRubyScript(this, name, DefaultWorkingCopyOwner.PRIMARY);
}
+
+ /*
+ * @see RubyElement
+ */
+ public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) {
+ switch (token.charAt(0)) {
+ case JEM_RUBYSCRIPT:
+ if (!memento.hasMoreTokens()) return this;
+ String classFileName = memento.nextToken();
+ RubyElement classFile = new ExternalRubyScript(this, classFileName, owner);
+ return classFile.getHandleFromMemento(memento, owner);
+ }
+ return null;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ImportContainer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ImportContainer.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ImportContainer.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -12,10 +12,13 @@
import org.rubypeople.rdt.core.IImportContainer;
import org.rubypeople.rdt.core.IImportDeclaration;
+import org.rubypeople.rdt.core.IParent;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.ISourceReference;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
/**
@@ -101,4 +104,29 @@
buffer.append(" (not open)"); //$NON-NLS-1$
}
}
+
+/*
+ * @see RubyElement
+ */
+public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
+ switch (token.charAt(0)) {
+ case JEM_COUNT:
+ return getHandleUpdatingCountFromMemento(memento, workingCopyOwner);
+ case JEM_IMPORTDECLARATION:
+ if (memento.hasMoreTokens()) {
+ String importName = memento.nextToken();
+ RubyElement importDecl = (RubyElement)getImport(importName);
+ return importDecl.getHandleFromMemento(memento, workingCopyOwner);
+ } else {
+ return this;
+ }
+ }
+ return null;
}
+/**
+ * @see RubyElement#getHandleMemento()
+ */
+protected char getHandleMementoDelimiter() {
+ return RubyElement.JEM_IMPORTDECLARATION;
+}
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Member.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Member.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Member.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -12,9 +12,11 @@
import org.rubypeople.rdt.core.IMember;
import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.IType;
-import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
/**
* @see IMember
@@ -117,4 +119,66 @@
return;
}
}
+
+ /*
+ * @see RubyElement
+ */
+ public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
+ switch (token.charAt(0)) {
+ case JEM_COUNT:
+ return getHandleUpdatingCountFromMemento(memento, workingCopyOwner);
+ case JEM_TYPE:
+ String typeName;
+ if (memento.hasMoreTokens()) {
+ typeName = memento.nextToken();
+ char firstChar = typeName.charAt(0);
+ if (firstChar == JEM_FIELD || firstChar == JEM_METHOD || firstChar == JEM_TYPE || firstChar == JEM_COUNT) {
+ token = typeName;
+ typeName = ""; //$NON-NLS-1$
+ } else {
+ token = null;
+ }
+ } else {
+ typeName = ""; //$NON-NLS-1$
+ token = null;
+ }
+ RubyElement type = (RubyElement)getType(typeName, 1);
+ if (token == null) {
+ return type.getHandleFromMemento(memento, workingCopyOwner);
+ } else {
+ return type.getHandleFromMemento(token, memento, workingCopyOwner);
+ }
+// case JEM_LOCALVARIABLE:
+// if (!memento.hasMoreTokens()) return this;
+// String varName = memento.nextToken();
+// if (!memento.hasMoreTokens()) return this;
+// memento.nextToken(); // JEM_COUNT
+// if (!memento.hasMoreTokens()) return this;
+// int declarationStart = Integer.parseInt(memento.nextToken());
+// if (!memento.hasMoreTokens()) return this;
+// memento.nextToken(); // JEM_COUNT
+// if (!memento.hasMoreTokens()) return this;
+// int declarationEnd = Integer.parseInt(memento.nextToken());
+// if (!memento.hasMoreTokens()) return this;
+// memento.nextToken(); // JEM_COUNT
+// if (!memento.hasMoreTokens()) return this;
+// int nameStart = Integer.parseInt(memento.nextToken());
+// if (!memento.hasMoreTokens()) return this;
+// memento.nextToken(); // JEM_COUNT
+// if (!memento.hasMoreTokens()) return this;
+// int nameEnd = Integer.parseInt(memento.nextToken());
+// if (!memento.hasMoreTokens()) return this;
+// memento.nextToken(); // JEM_COUNT
+// if (!memento.hasMoreTokens()) return this;
+// String typeSignature = memento.nextToken();
+// return new LocalVariable(this, varName, declarationStart, declarationEnd, nameStart, nameEnd, typeSignature);
+ }
+ return null;
+ }
+ /**
+ * @see JavaElement#getHandleMemento()
+ */
+ protected char getHandleMementoDelimiter() {
+ return RubyElement.JEM_TYPE;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElement.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElement.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElement.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -43,6 +43,8 @@
import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.ISourceReference;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Util;
/**
@@ -51,6 +53,18 @@
*/
public abstract class RubyElement extends PlatformObject implements IRubyElement {
+ public static final char JEM_ESCAPE = '\\';
+ public static final char JEM_RUBYPROJECT = '=';
+ public static final char JEM_SOURCEFOLDERROOT = '/';
+ public static final char JEM_SOURCE_FOLDER = '<';
+ public static final char JEM_FIELD = '^';
+ public static final char JEM_METHOD = '~';
+ public static final char JEM_RUBYSCRIPT = '{';
+ public static final char JEM_TYPE = '[';
+ public static final char JEM_IMPORTDECLARATION = '#';
+ public static final char JEM_COUNT = '!';
+ public static final char JEM_LOCALVARIABLE = '@';
+
public static final IRubyElement[] NO_ELEMENTS = new IRubyElement[0];
protected static final Object NO_INFO = new Object();
@@ -529,4 +543,65 @@
public Node findNode(Node cuAST) {
return null; // works only inside a ruby script
}
+
+ /*
+ * Creates a Ruby element handle from the given memento.
+ * The given token is the current delimiter indicating the type of the next token(s).
+ * The given working copy owner is used only for ruby script handles.
+ */
+ public abstract IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner);
+ /*
+ * Creates a Ruby element handle from the given memento.
+ * The given working copy owner is used only for ruby script handles.
+ */
+ public IRubyElement getHandleFromMemento(MementoTokenizer memento, WorkingCopyOwner owner) {
+ if (!memento.hasMoreTokens()) return this;
+ String token = memento.nextToken();
+ return getHandleFromMemento(token, memento, owner);
+ }
+ /**
+ * @see IJavaElement
+ */
+ public String getHandleIdentifier() {
+ return getHandleMemento();
+ }
+ /**
+ * @see JavaElement#getHandleMemento()
+ */
+ public String getHandleMemento(){
+ StringBuffer buff = new StringBuffer();
+ getHandleMemento(buff);
+ return buff.toString();
+ }
+ protected void getHandleMemento(StringBuffer buff) {
+ ((RubyElement)getParent()).getHandleMemento(buff);
+ buff.append(getHandleMementoDelimiter());
+ escapeMementoName(buff, getElementName());
+ }
+ /**
+ * Returns the <code>char</code> that marks the start of this handles
+ * contribution to a memento.
+ */
+ protected abstract char getHandleMementoDelimiter();
+
+ protected void escapeMementoName(StringBuffer buffer, String mementoName) {
+ for (int i = 0, length = mementoName.length(); i < length; i++) {
+ char character = mementoName.charAt(i);
+ switch (character) {
+ case JEM_ESCAPE:
+ case JEM_COUNT:
+ case JEM_RUBYPROJECT:
+ case JEM_SOURCEFOLDERROOT:
+ case JEM_SOURCE_FOLDER:
+ case JEM_FIELD:
+ case JEM_METHOD:
+ case JEM_RUBYSCRIPT:
+ case JEM_TYPE:
+ case JEM_IMPORTDECLARATION:
+ case JEM_LOCALVARIABLE:
+ buffer.append(JEM_ESCAPE);
+ }
+ buffer.append(character);
+ }
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyImport.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyImport.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyImport.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -24,6 +24,7 @@
*/
package org.rubypeople.rdt.internal.core;
+import org.eclipse.core.runtime.Assert;
import org.rubypeople.rdt.core.IImportDeclaration;
import org.rubypeople.rdt.core.IRubyElement;
@@ -60,5 +61,26 @@
public String getElementName() {
return this.name;
}
+
+ /**
+ * @see RubyElement#getHandleMemento(StringBuffer)
+ * For import declarations, the handle delimiter is associated to the import container already
+ */
+ protected void getHandleMemento(StringBuffer buff) {
+ ((RubyElement)getParent()).getHandleMemento(buff);
+ escapeMementoName(buff, getElementName());
+ if (this.occurrenceCount > 1) {
+ buff.append(JEM_COUNT);
+ buff.append(this.occurrenceCount);
+ }
+ }
+ /**
+ * @see RubyElement#getHandleMemento()
+ */
+ protected char getHandleMementoDelimiter() {
+ // For import declarations, the handle delimiter is associated to the import container already
+ Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
+ return 0;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -24,6 +25,8 @@
import org.rubypeople.rdt.core.IRubyModel;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Messages;
/**
@@ -256,4 +259,32 @@
return null;
}
+/*
+ * @see RubyElement
+ */
+public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) {
+ switch (token.charAt(0)) {
+ case JEM_RUBYPROJECT:
+ if (!memento.hasMoreTokens()) return this;
+ String projectName = memento.nextToken();
+ RubyElement project = (RubyElement)getRubyProject(projectName);
+ return project.getHandleFromMemento(memento, owner);
+ }
+ return null;
}
+/**
+ * @see RubyElement#getHandleMemento(StringBuffer)
+ */
+protected void getHandleMemento(StringBuffer buff) {
+ buff.append(getElementName());
+}
+/**
+ * Returns the <code>char</code> that marks the start of this handles
+ * contribution to a memento.
+ */
+protected char getHandleMementoDelimiter(){
+ Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
+ return 0;
+}
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -57,8 +57,10 @@
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
import org.rubypeople.rdt.internal.compiler.CategorizedProblem;
import org.rubypeople.rdt.internal.compiler.util.ObjectVector;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Messages;
import org.rubypeople.rdt.internal.core.util.Util;
import org.w3c.dom.Element;
@@ -2408,4 +2410,44 @@
return getAllSourceFolderRoots(null /*no reverse map*/);
}
+
+ /*
+ * @see RubyElement
+ */
+ public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) {
+ switch (token.charAt(0)) {
+ case JEM_SOURCEFOLDERROOT:
+ String rootPath = ISourceFolderRoot.DEFAULT_PACKAGEROOT_PATH;
+ token = null;
+ while (memento.hasMoreTokens()) {
+ token = memento.nextToken();
+ char firstChar = token.charAt(0);
+ if (firstChar != JEM_SOURCE_FOLDER && firstChar != JEM_COUNT) {
+ rootPath += token;
+ } else {
+ break;
+ }
+ }
+ IPath path = new Path(rootPath);
+ RubyElement root;
+ if(path.isAbsolute()) {
+ root = (RubyElement) getPackageFragmentRoot0(path);
+ } else
+ root = (RubyElement)getSourceFolderRoot(path);
+ if (token != null && token.charAt(0) == JEM_SOURCE_FOLDER) {
+ return root.getHandleFromMemento(token, memento, owner);
+ } else {
+ return root.getHandleFromMemento(memento, owner);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the <code>char</code> that marks the start of this handles
+ * contribution to a memento.
+ */
+ protected char getHandleMementoDelimiter() {
+ return JEM_RUBYPROJECT;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -58,6 +58,7 @@
import org.rubypeople.rdt.internal.codeassist.CompletionEngine;
import org.rubypeople.rdt.internal.core.buffer.BufferManager;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -644,4 +645,28 @@
CompletionEngine engine = new CompletionEngine(requestor);
engine.complete(this, offset);
}
+
+ /*
+ * @see RubyElement
+ */
+ public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
+ switch (token.charAt(0)) {
+ case JEM_IMPORTDECLARATION:
+ RubyElement container = (RubyElement)getImportContainer();
+ return container.getHandleFromMemento(token, memento, workingCopyOwner);
+ case JEM_TYPE:
+ if (!memento.hasMoreTokens()) return this;
+ String typeName = memento.nextToken();
+ RubyElement type = (RubyElement)getType(typeName);
+ return type.getHandleFromMemento(memento, workingCopyOwner);
+ }
+ return null;
+ }
+
+ /**
+ * @see RubyElement#getHandleMementoDelimiter()
+ */
+ protected char getHandleMementoDelimiter() {
+ return RubyElement.JEM_RUBYSCRIPT;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyType.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyType.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyType.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -36,6 +36,8 @@
import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
/**
* @author Chris
@@ -212,5 +214,71 @@
}
return getElementName();
}
+
+ /*
+ * @see RubyElement
+ */
+ public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
+ switch (token.charAt(0)) {
+ case JEM_COUNT:
+ return getHandleUpdatingCountFromMemento(memento, workingCopyOwner);
+ case JEM_FIELD:
+ if (!memento.hasMoreTokens()) return this;
+ String fieldName = memento.nextToken();
+ RubyElement field = (RubyElement)getField(fieldName);
+ return field.getHandleFromMemento(memento, workingCopyOwner);
+ case JEM_METHOD:
+ if (!memento.hasMoreTokens()) return this;
+ String selector = memento.nextToken();
+ ArrayList params = new ArrayList();
+ nextParam: while (memento.hasMoreTokens()) {
+ token = memento.nextToken();
+ switch (token.charAt(0)) {
+ case JEM_TYPE:
+ break nextParam;
+ case JEM_METHOD:
+ if (!memento.hasMoreTokens()) return this;
+ String param = memento.nextToken();
+ StringBuffer buffer = new StringBuffer();
+ params.add(buffer.toString() + param);
+ break;
+ default:
+ break nextParam;
+ }
+ }
+ String[] parameters = new String[params.size()];
+ params.toArray(parameters);
+ RubyElement method = (RubyElement)getMethod(selector, parameters);
+ switch (token.charAt(0)) {
+ case JEM_TYPE:
+ case JEM_LOCALVARIABLE:
+ return method.getHandleFromMemento(token, memento, workingCopyOwner);
+ default:
+ return method;
+ }
+ case JEM_TYPE:
+ String typeName;
+ if (memento.hasMoreTokens()) {
+ typeName = memento.nextToken();
+ char firstChar = typeName.charAt(0);
+ if (firstChar == JEM_FIELD || firstChar == JEM_METHOD || firstChar == JEM_TYPE || firstChar == JEM_COUNT) {
+ token = typeName;
+ typeName = ""; //$NON-NLS-1$
+ } else {
+ token = null;
+ }
+ } else {
+ typeName = ""; //$NON-NLS-1$
+ token = null;
+ }
+ RubyElement type = (RubyElement)getType(typeName);
+ if (token == null) {
+ return type.getHandleFromMemento(memento, workingCopyOwner);
+ } else {
+ return type.getHandleFromMemento(token, memento, workingCopyOwner);
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -17,6 +17,7 @@
import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Messages;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -221,5 +222,25 @@
}
return new RubyScript(this, name, DefaultWorkingCopyOwner.PRIMARY);
}
+
+ /*
+ * @see RubyElement
+ */
+ public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) {
+ switch (token.charAt(0)) {
+ case JEM_RUBYSCRIPT:
+ if (!memento.hasMoreTokens()) return this;
+ String cuName = memento.nextToken();
+ RubyElement cu = new RubyScript(this, cuName, owner);
+ return cu.getHandleFromMemento(memento, owner);
+ }
+ return null;
+ }
+ /**
+ * @see RubyElement#getHandleMementoDelimiter()
+ */
+ protected char getHandleMementoDelimiter() {
+ return RubyElement.JEM_SOURCE_FOLDER;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -18,7 +18,9 @@
import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
import org.rubypeople.rdt.internal.core.util.CharOperation;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Util;
public class SourceFolderRoot extends Openable implements ISourceFolderRoot {
@@ -278,4 +280,61 @@
String[] names = Util.getTrimmedSimpleNames(packName);
return getSourceFolder(names);
}
+
+ /**
+ * @see RubyElement#getHandleMemento()
+ */
+ protected char getHandleMementoDelimiter() {
+ return RubyElement.JEM_SOURCEFOLDERROOT;
+ }
+ /*
+ * @see RubyElement
+ */
+ public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) {
+ switch (token.charAt(0)) {
+ case JEM_SOURCE_FOLDER:
+ String pkgName;
+ if (memento.hasMoreTokens()) {
+ pkgName = memento.nextToken();
+ char firstChar = pkgName.charAt(0);
+ if (firstChar == JEM_RUBYSCRIPT || firstChar == JEM_COUNT) {
+ token = pkgName;
+ pkgName = ISourceFolder.DEFAULT_PACKAGE_NAME;
+ } else {
+ token = null;
+ }
+ } else {
+ pkgName = ISourceFolder.DEFAULT_PACKAGE_NAME;
+ token = null;
+ }
+ RubyElement pkg = (RubyElement)getSourceFolder(pkgName);
+ if (token == null) {
+ return pkg.getHandleFromMemento(memento, owner);
+ } else {
+ return pkg.getHandleFromMemento(token, memento, owner);
+ }
+ }
+ return null;
+ }
+ /**
+ * @see RubyElement#getHandleMemento(StringBuffer)
+ */
+ protected void getHandleMemento(StringBuffer buff) {
+ IPath path;
+ IResource underlyingResource = getResource();
+ if (underlyingResource != null) {
+ // internal jar or regular root
+ if (getResource().getProject().equals(getRubyProject().getProject())) {
+ path = underlyingResource.getProjectRelativePath();
+ } else {
+ path = underlyingResource.getFullPath();
+ }
+ } else {
+ // external jar
+ path = getPath();
+ }
+ ((RubyElement)getParent()).getHandleMemento(buff);
+ buff.append(getHandleMementoDelimiter());
+ escapeMementoName(buff, path.toString());
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceRefElement.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceRefElement.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceRefElement.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -17,7 +17,9 @@
import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.ISourceReference;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
import org.rubypeople.rdt.internal.core.util.DOMFinder;
+import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
/**
* @author cawilliams
@@ -173,5 +175,35 @@
if (!(o instanceof SourceRefElement)) return false;
return this.occurrenceCount == ((SourceRefElement) o).occurrenceCount && super.equals(o);
}
+
+ /*
+ * Update the occurence count of the receiver and creates a Ruby element handle from the given memento.
+ * The given working copy owner is used only for compilation unit handles.
+ */
+ public IRubyElement getHandleUpdatingCountFromMemento(MementoTokenizer memento, WorkingCopyOwner owner) {
+ if (!memento.hasMoreTokens()) return this;
+ this.occurrenceCount = Integer.parseInt(memento.nextToken());
+ if (!memento.hasMoreTokens()) return this;
+ String token = memento.nextToken();
+ return getHandleFromMemento(token, memento, owner);
+ }
+
+ /*
+ * @see RubyElement
+ */
+ public IRubyElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner workingCopyOwner) {
+ switch (token.charAt(0)) {
+ case JEM_COUNT:
+ return getHandleUpdatingCountFromMemento(memento, workingCopyOwner);
+ }
+ return this;
+ }
+ protected void getHandleMemento(StringBuffer buff) {
+ super.getHandleMemento(buff);
+ if (this.occurrenceCount > 1) {
+ buff.append(JEM_COUNT);
+ buff.append(this.occurrenceCount);
+ }
+ }
}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/MementoTokenizer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/MementoTokenizer.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/MementoTokenizer.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 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.util;
+
+import org.rubypeople.rdt.internal.core.RubyElement;
+
+public class MementoTokenizer {
+ private static final String COUNT = Character.toString(RubyElement.JEM_COUNT);
+ private static final String JAVAPROJECT = Character.toString(RubyElement.JEM_RUBYPROJECT);
+ private static final String PACKAGEFRAGMENTROOT = Character.toString(RubyElement.JEM_SOURCEFOLDERROOT);
+ private static final String PACKAGEFRAGMENT = Character.toString(RubyElement.JEM_SOURCE_FOLDER);
+ private static final String FIELD = Character.toString(RubyElement.JEM_FIELD);
+ private static final String METHOD = Character.toString(RubyElement.JEM_METHOD);
+ private static final String COMPILATIONUNIT = Character.toString(RubyElement.JEM_RUBYSCRIPT);
+ private static final String TYPE = Character.toString(RubyElement.JEM_TYPE);
+ private static final String IMPORTDECLARATION = Character.toString(RubyElement.JEM_IMPORTDECLARATION);
+ private static final String LOCALVARIABLE = Character.toString(RubyElement.JEM_LOCALVARIABLE);
+
+ private final char[] memento;
+ private final int length;
+ private int index = 0;
+
+ public MementoTokenizer(String memento) {
+ this.memento = memento.toCharArray();
+ this.length = this.memento.length;
+ }
+
+ public boolean hasMoreTokens() {
+ return this.index < this.length;
+ }
+
+ public String nextToken() {
+ int start = this.index;
+ StringBuffer buffer = null;
+ switch (this.memento[this.index++]) {
+ case RubyElement.JEM_ESCAPE:
+ buffer = new StringBuffer();
+ buffer.append(this.memento[this.index]);
+ start = ++this.index;
+ break;
+ case RubyElement.JEM_COUNT:
+ return COUNT;
+ case RubyElement.JEM_RUBYPROJECT:
+ return JAVAPROJECT;
+ case RubyElement.JEM_SOURCEFOLDERROOT:
+ return PACKAGEFRAGMENTROOT;
+ case RubyElement.JEM_SOURCE_FOLDER:
+ return PACKAGEFRAGMENT;
+ case RubyElement.JEM_FIELD:
+ return FIELD;
+ case RubyElement.JEM_METHOD:
+ return METHOD;
+ case RubyElement.JEM_RUBYSCRIPT:
+ return COMPILATIONUNIT;
+ case RubyElement.JEM_TYPE:
+ return TYPE;
+ case RubyElement.JEM_IMPORTDECLARATION:
+ return IMPORTDECLARATION;
+ case RubyElement.JEM_LOCALVARIABLE:
+ return LOCALVARIABLE;
+ }
+ loop: while (this.index < this.length) {
+ switch (this.memento[this.index]) {
+ case RubyElement.JEM_ESCAPE:
+ if (buffer == null) buffer = new StringBuffer();
+ buffer.append(this.memento, start, this.index - start);
+ start = ++this.index;
+ break;
+ case RubyElement.JEM_COUNT:
+ case RubyElement.JEM_RUBYPROJECT:
+ case RubyElement.JEM_SOURCEFOLDERROOT:
+ case RubyElement.JEM_SOURCE_FOLDER:
+ case RubyElement.JEM_FIELD:
+ case RubyElement.JEM_METHOD:
+ case RubyElement.JEM_RUBYSCRIPT:
+ case RubyElement.JEM_TYPE:
+ case RubyElement.JEM_IMPORTDECLARATION:
+ case RubyElement.JEM_LOCALVARIABLE:
+ break loop;
+ }
+ this.index++;
+ }
+ if (buffer != null) {
+ buffer.append(this.memento, start, this.index - start);
+ return buffer.toString();
+ } else {
+ return new String(this.memento, start, this.index - start);
+ }
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-03-12 20:12:36 UTC (rev 2139)
@@ -367,6 +367,27 @@
class="org.rubypeople.rdt.internal.ui.infoviews.RIView"
id="org.rubypeople.rdt.ui.views.RIView">
</view>
+ <view
+ name="Rails API"
+ icon="icons/full/elcl16/help.gif"
+ category="org.rubypeople.rdt.ui.ruby"
+ class="org.rubypeople.rdt.internal.ui.infoviews.RailsAPIView"
+ id="org.rubypeople.rdt.ui.views.RailsAPIView">
+ </view>
+ <view
+ name="Ruby Core API"
+ icon="icons/full/elcl16/help.gif"
+ category="org.rubypeople.rdt.ui.ruby"
+ class="org.rubypeople.rdt.internal.ui.infoviews.RubyCoreAPIView"
+ id="org.rubypeople.rdt.ui.views.RubyCoreAPIView">
+ </view>
+ <view
+ name="Ruby Standard Library API"
+ icon="icons/full/elcl16/help.gif"
+ category="org.rubypeople.rdt.ui.ruby"
+ class="org.rubypeople.rdt.internal.ui.infoviews.RubyStdLibAPIView"
+ id="org.rubypeople.rdt.ui.views.RubyStdLibAPIView">
+ </view>
</extension>
<extension point="org.eclipse.ui.editors">
<editor
@@ -840,6 +861,9 @@
<factory
id="org.rubypeople.rdt.ui.externalRubyFileEditorInputFactory"
class="org.rubypeople.rdt.internal.ui.rubyeditor.RubyExternalEditorFactory"/>
+ <factory
+ id="org.rubypeople.rdt.ui.RubyScriptEditorInputFactory"
+ class="org.rubypeople.rdt.internal.ui.rubyeditor.RubyScriptEditorInputFactory"/>
</extension>
<extension
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java 2007-03-12 19:30:56 UTC (rev 2138)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -83,10 +83,10 @@
}
public String getFactoryId() {
- return RubyExternalEditorFactory.FACTORY_ID;
+ return RubyScriptEditorInputFactory.ID;
}
public void saveState(IMemento memento) {
- memento.putString(RubyExternalEditorFactory.MEMENTO_ABSOLUTE_PATH_KEY, fScript.getFile().getAbsolutePath()); //$NON-NLS-1$
+ RubyScriptEditorInputFactory.saveState(memento, this);
}
}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInputFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInputFactory.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInputFactory.java 2007-03-12 20:12:36 UTC (rev 2139)
@@ -0,0 +1,35 @@
+package org.rubypeople.rdt.internal.ui.rubyeditor;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+
+public class RubyScriptEditorInputFactory implements IElementFactory {
+
+ public final static String ID= "org.rubypeople.rdt.ui.RubyScriptEditorInputFactory"; //$NON-NLS-1$
+ public final static String KEY= "org.rubypeople.rdt.ui.RubyScriptIdentifier"; //$NON-NLS-1$
+
+ /**
+ * @see IElementFactory#createElement
+ */
+ public IAdaptable createElement(IMemento memento) {
+ String identifier= memento.getString(KEY);
+ if (identifier != null) {
+ IRubyElement element= RubyCore.create(identifier);
+ try {
+ return EditorUtility.getEditorInput(element);
+ } catch (RubyModelException x) {
+ }
+ }
+ return null;
+ }
+
+ public static void saveState(IMemento memento, RubyScriptEditorInput input) {
+ IRubyScript c= input.getRubyScript();
+ memento.putString(KEY, c.getHandleIdentifier());
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-12 19:30:58
|
Revision: 2138
http://svn.sourceforge.net/rubyeclipse/?rev=2138&view=rev
Author: cawilliams
Date: 2007-03-12 12:30:56 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
temp fix for opening up external files that were still open from last session of workspace
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java 2007-03-12 16:15:52 UTC (rev 2137)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java 2007-03-12 19:30:56 UTC (rev 2138)
@@ -87,6 +87,6 @@
}
public void saveState(IMemento memento) {
- // TODO Auto-generated method stub
+ memento.putString(RubyExternalEditorFactory.MEMENTO_ABSOLUTE_PATH_KEY, fScript.getFile().getAbsolutePath()); //$NON-NLS-1$
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-12 16:17:12
|
Revision: 2137
http://svn.sourceforge.net/rubyeclipse/?rev=2137&view=rev
Author: cawilliams
Date: 2007-03-12 09:15:52 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
peg RC1 to a later subversion revision
Modified Paths:
--------------
trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties
Modified: trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties
===================================================================
--- trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties 2007-03-12 15:53:26 UTC (rev 2136)
+++ trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties 2007-03-12 16:15:52 UTC (rev 2137)
@@ -2,6 +2,6 @@
#Mon Mar 05 11:38:44 EST 2007
buildType=S
version=0.9.0
-version.qualifier=200703051037
-fetchTag=2088
+version.qualifier=200703121154
+fetchTag=2136
buildTypePresentation=RC1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-12 15:53:49
|
Revision: 2136
http://svn.sourceforge.net/rubyeclipse/?rev=2136&view=rev
Author: cawilliams
Date: 2007-03-12 08:53:26 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
fix broken test
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-03-12 15:14:15 UTC (rev 2135)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java 2007-03-12 15:53:26 UTC (rev 2136)
@@ -83,7 +83,7 @@
buffer.append(new Path(interpreter.getInstallLocation().getAbsolutePath()).append("bin").append("ruby").toOSString());
buffer.append("\" ");
buffer.append(INTERPRETER_ARGUMENTS);
- if (!debug) buffer.append(" -e STDOUT.sync=true -e STDERR.sync=true -e load(ARGV.shift)");
+ if (!debug) buffer.append(" -e STDOUT.sync=true -e STDERR.sync=true -e load($0=ARGV.shift)");
buffer.append(" -I \"");
buffer.append(project.getLocation().toOSString());
buffer.append("\"");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-12 15:14:19
|
Revision: 2135
http://svn.sourceforge.net/rubyeclipse/?rev=2135&view=rev
Author: cawilliams
Date: 2007-03-12 08:14:15 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
support more functionality for external ruby scripts that may be on the loadpath (so "external" meaning outside the workspace, but also part of libraries used by the project) -
this allows us to provide outlines for these extneral library scripts. (there's still a disconnect between extnerl off the loadpath and external on the loadpath).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyDocumentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyScriptEditorInput.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java 2007-03-12 14:34:14 UTC (rev 2134)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalRubyScript.java 2007-03-12 15:14:15 UTC (rev 2135)
@@ -92,15 +92,14 @@
}
private char[] findSource() {
- File file = getFile();
- byte[] bytes;
+ String source = null;
try {
- bytes = Util.getFileByteContent(file);
- } catch (IOException e) {
+ source = getSource();
+ } catch (RubyModelException e) {
RubyCore.log(e);
- return new char[0];
}
- return new String(bytes).toCharArray();
+ if (source == null) return new char[0];
+ return source.toCharArray();
}
@Override
@@ -113,4 +112,17 @@
public IPath getPath() {
return getParent().getPath().append(getElementName());
}
+
+ @Override
+ public String getSource() throws RubyModelException {
+ File file = getFile();
+ byte[] bytes;
+ try {
+ bytes = Util.getFileByteContent(file);
+ } catch (IOException e) {
+ RubyCore.log(e);
+ return null;
+ }
+ return new String(bytes);
+ }
}
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-12 14:34:14 UTC (rev 2134)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-03-12 15:14:15 UTC (rev 2135)
@@ -53,6 +53,7 @@
import org.rubypeople.rdt.internal.ui.rdocexport.RDocUtility;
import org.rubypeople.rdt.internal.ui.rubyeditor.DocumentAdapter;
import org.rubypeople.rdt.internal.ui.rubyeditor.RubyDocumentProvider;
+import org.rubypeople.rdt.internal.ui.rubyeditor.RubyScriptDocumentProvider;
import org.rubypeople.rdt.internal.ui.rubyeditor.WorkingCopyManager;
import org.rubypeople.rdt.internal.ui.symbols.BlockingSymbolFinder;
import org.rubypeople.rdt.internal.ui.text.IRubyColorConstants;
@@ -93,6 +94,7 @@
private boolean new060ViewsOpened;
private ImageDescriptorRegistry fImageDescriptorRegistry;
private MembersOrderPreferenceCache fMembersOrderPreferenceCache;
+ private RubyScriptDocumentProvider fExternalRubyDocumentProvider;
public RubyPlugin() {
super();
@@ -494,4 +496,10 @@
// initialized on startup
return fMembersOrderPreferenceCache;
}
+
+ public synchronized RubyScriptDocumentProvider getExternalDocumentProvider() {
+ if (fExternalRubyDocumentProvider == null)
+ fExternalRubyDocumentProvider= new RubyScriptDocumentProvider();
+ return fExternalRubyDocumentProvider;
+ }
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java 2007-03-12 14:34:14 UTC (rev 2134)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java 2007-03-12 15:14:15 UTC (rev 2135)
@@ -143,7 +143,7 @@
return new FileEditorInput((IFile) resource);
}
if (element instanceof ExternalRubyScript)
- return new ExternalRubyFileEditorInput(((ExternalRubyScript) element).getFile());
+ return new RubyScriptEditorInput(((ExternalRubyScript) element));
element= element.getParent();
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyDocumentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyDocumentProvider.java 2007-03-12 14:34:14 UTC (rev 2134)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/ExternalRubyDocumentProvider.java 2007-03-12 15:14:15 UTC (rev 2135)
@@ -65,8 +65,7 @@
IDocument document,
boolean overwrite)
throws CoreException {
-
-
+ // do nothing
}
protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyScriptEditorInput.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyScriptEditorInput.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyScriptEditorInput.java 2007-03-12 15:14:15 UTC (rev 2135)
@@ -0,0 +1,8 @@
+package org.rubypeople.rdt.internal.ui.rubyeditor;
+
+import org.eclipse.ui.IEditorInput;
+import org.rubypeople.rdt.core.IRubyScript;
+
+public interface IRubyScriptEditorInput extends IEditorInput {
+ public IRubyScript getRubyScript();
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java 2007-03-12 14:34:14 UTC (rev 2134)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java 2007-03-12 15:14:15 UTC (rev 2135)
@@ -87,7 +87,6 @@
import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
import org.rubypeople.rdt.internal.ui.text.PreferencesAdapter;
import org.rubypeople.rdt.internal.ui.text.RubyPairMatcher;
-import org.rubypeople.rdt.ui.IWorkingCopyManager;
import org.rubypeople.rdt.ui.PreferenceConstants;
import org.rubypeople.rdt.ui.RubyUI;
import org.rubypeople.rdt.ui.text.RubySourceViewerConfiguration;
@@ -341,15 +340,24 @@
* @see org.eclipse.ui.editors.text.TextEditor#doSetInput(org.eclipse.ui.IEditorInput)
*/
protected void doSetInput(IEditorInput input) throws CoreException {
+ if (input instanceof IRubyScriptEditorInput) {
+ setDocumentProvider(RubyPlugin.getDefault().getExternalDocumentProvider());
+ } else {
+ setDocumentProvider(RubyPlugin.getDefault().getRubyDocumentProvider());
+ }
super.doSetInput(input);
setOutlinePageInput(fOutlinePage, input);
}
protected void setOutlinePageInput(RubyOutlinePage page, IEditorInput input) {
- if (page != null) {
- IWorkingCopyManager manager = RubyPlugin.getDefault().getWorkingCopyManager();
- page.setInput(manager.getWorkingCopy(input));
- }
+ if (page == null)
+ return;
+
+ IRubyElement re= getInputRubyElement();
+ if (re != null && re.exists())
+ page.setInput(re);
+ else
+ page.setInput(null);
}
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
@@ -437,8 +445,6 @@
}
}
-
-
/**
* Returns the Ruby element wrapped by this editors input.
*
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java 2007-03-12 15:14:15 UTC (rev 2135)
@@ -0,0 +1,341 @@
+package org.rubypeople.rdt.internal.ui.rubyeditor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ISynchronizable;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.editors.text.FileDocumentProvider;
+import org.rubypeople.rdt.core.ElementChangedEvent;
+import org.rubypeople.rdt.core.IElementChangedListener;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyElementDelta;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
+import org.rubypeople.rdt.ui.text.RubyTextTools;
+
+public class RubyScriptDocumentProvider extends FileDocumentProvider {
+ /**
+ * An input change listener to request the editor to reread the input.
+ */
+ public interface InputChangeListener {
+ void inputChanged(IRubyScriptEditorInput input);
+ }
+
+ /**
+ * Synchronizes the document with external resource changes.
+ */
+ protected class RubyScriptSynchronizer implements IElementChangedListener {
+
+ protected IRubyScriptEditorInput fInput;
+ protected ISourceFolderRoot fSourceFolderRoot;
+
+ /**
+ * Default constructor.
+ */
+ public RubyScriptSynchronizer(IRubyScriptEditorInput input) {
+
+ fInput= input;
+
+ IRubyElement parent= fInput.getRubyScript().getParent();
+ while (parent != null && !(parent instanceof ISourceFolderRoot)) {
+ parent= parent.getParent();
+ }
+ fSourceFolderRoot= (ISourceFolderRoot) parent;
+ }
+
+ /**
+ * Installs the synchronizer.
+ */
+ public void install() {
+ RubyCore.addElementChangedListener(this);
+ }
+
+ /**
+ * Uninstalls the synchronizer.
+ */
+ public void uninstall() {
+ RubyCore.removeElementChangedListener(this);
+ }
+
+ /*
+ * @see IElementChangedListener#elementChanged
+ */
+ public void elementChanged(ElementChangedEvent e) {
+ check(fSourceFolderRoot, e.getDelta());
+ }
+
+ /**
+ * Recursively check whether the class file has been deleted.
+ * Returns true if delta processing can be stopped.
+ */
+ protected boolean check(ISourceFolderRoot input, IRubyElementDelta delta) {
+ IRubyElement element= delta.getElement();
+
+ if ((delta.getKind() & IRubyElementDelta.REMOVED) != 0 || (delta.getFlags() & IRubyElementDelta.F_CLOSED) != 0) {
+ // http://dev.eclipse.org/bugs/show_bug.cgi?id=19023
+ if (element.equals(input.getRubyProject()) || element.equals(input)) {
+ handleDeleted(fInput);
+ return true;
+ }
+ }
+
+ if (((delta.getFlags() & IRubyElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) && input.equals(element)) {
+ handleDeleted(fInput);
+ return true;
+ }
+
+ if (((delta.getFlags() & IRubyElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) && input.equals(element)) {
+ handleDeleted(fInput);
+ return true;
+ }
+
+ IRubyElementDelta[] subdeltas= delta.getAffectedChildren();
+ for (int i= 0; i < subdeltas.length; i++) {
+ if (check(input, subdeltas[i]))
+ return true;
+ }
+
+ if ((delta.getFlags() & IRubyElementDelta.F_SOURCEDETACHED) != 0 ||
+ (delta.getFlags() & IRubyElementDelta.F_SOURCEATTACHED) != 0)
+ {
+ IRubyScript file= fInput != null ? fInput.getRubyScript() : null;
+ IRubyProject project= input != null ? input.getRubyProject() : null;
+
+ boolean isOnClasspath= false;
+ if (file != null && project != null)
+ isOnClasspath= project.isOnLoadpath(file);
+
+ if (isOnClasspath) {
+ fireInputChanged(fInput);
+ return false;
+ } else {
+ handleDeleted(fInput);
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+
+ /**
+ * Correcting the visibility of <code>FileSynchronizer</code>.
+ */
+ protected class _FileSynchronizer extends FileSynchronizer {
+ public _FileSynchronizer(IFileEditorInput fileEditorInput) {
+ super(fileEditorInput);
+ }
+ }
+
+ /**
+ * Bundle of all required informations.
+ */
+ protected class RubyScriptInfo extends FileInfo {
+
+ RubyScriptSynchronizer fRubyScriptSynchronizer= null;
+
+ RubyScriptInfo(IDocument document, IAnnotationModel model, _FileSynchronizer fileSynchronizer) {
+ super(document, model, fileSynchronizer);
+ }
+
+ RubyScriptInfo(IDocument document, IAnnotationModel model, RubyScriptSynchronizer classFileSynchronizer) {
+ super(document, model, null);
+ fRubyScriptSynchronizer= classFileSynchronizer;
+ }
+ }
+
+ /** Input change listeners. */
+ private List fInputListeners= new ArrayList();
+
+ /**
+ * Creates a new document provider.
+ */
+ public RubyScriptDocumentProvider() {
+ super();
+ }
+
+ /*
+ * @see StorageDocumentProvider#setDocumentContent(IDocument, IEditorInput)
+ */
+ protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException {
+ if (editorInput instanceof IRubyScriptEditorInput) {
+ IRubyScript rubyScript= ((IRubyScriptEditorInput) editorInput).getRubyScript();
+ document.set(rubyScript.getSource());
+ return true;
+ }
+ return super.setDocumentContent(document, editorInput, encoding);
+ }
+
+ /**
+ * Creates an annotation model derived from the given class file editor input.
+ *
+ * @param classFileEditorInput the editor input from which to query the annotations
+ * @return the created annotation model
+ * @exception CoreException if the editor input could not be accessed
+ */
+ protected IAnnotationModel createRubyScriptAnnotationModel(IRubyScriptEditorInput classFileEditorInput) throws CoreException {
+// IResource resource= null;
+// IRubyScript classFile= classFileEditorInput.getRubyScript();
+//
+// IResourceLocator locator= (IResourceLocator) classFile.getAdapter(IResourceLocator.class);
+// if (locator != null)
+// resource= locator.getContainingResource(classFile);
+//
+// if (resource != null) {
+// RubyScriptMarkerAnnotationModel model= new RubyScriptMarkerAnnotationModel(resource);
+// model.setRubyScript(classFile);
+// return model;
+// }
+//
+// return null;
+ return new ExternalFileRubyAnnotationModel();
+ }
+
+ /*
+ * @see org.eclipse.ui.editors.text.StorageDocumentProvider#createEmptyDocument()
+ * @since 3.1
+ */
+ protected IDocument createEmptyDocument() {
+ IDocument document= FileBuffers.getTextFileBufferManager().createEmptyDocument(null);
+ if (document instanceof ISynchronizable)
+ ((ISynchronizable)document).setLockObject(new Object());
+ return document;
+ }
+
+ /*
+ * @see AbstractDocumentProvider#createDocument(Object)
+ */
+ protected IDocument createDocument(Object element) throws CoreException {
+ IDocument document= super.createDocument(element);
+ if (document != null) {
+ RubyTextTools tools= RubyPlugin.getDefault().getRubyTextTools();
+ tools.setupRubyDocumentPartitioner(document, IRubyPartitions.RUBY_PARTITIONING);
+ }
+ return document;
+ }
+
+ /*
+ * @see AbstractDocumentProvider#createElementInfo(Object)
+ */
+ protected ElementInfo createElementInfo(Object element) throws CoreException {
+
+ if (element instanceof IRubyScriptEditorInput) {
+
+ IRubyScriptEditorInput input = (IRubyScriptEditorInput) element;
+// ExternalRubyScriptEditorInput external= null;
+// if (input instanceof ExternalRubyScriptEditorInput)
+// external= (ExternalRubyScriptEditorInput) input;
+//
+// if (external != null) {
+// try {
+// refreshFile(external.getFile());
+// } catch (CoreException x) {
+// handleCoreException(x, JavaEditorMessages.RubyScriptDocumentProvider_error_createElementInfo);
+// }
+// }
+
+ IDocument d= createDocument(input);
+ IAnnotationModel m= createRubyScriptAnnotationModel(input);
+
+// if (external != null) {
+// RubyScriptInfo info= new RubyScriptInfo(d, m, (_FileSynchronizer) null);
+// info.fModificationStamp= computeModificationStamp(external.getFile());
+// info.fEncoding= getPersistedEncoding(element);
+// return info;
+// } else
+ if (input instanceof RubyScriptEditorInput) {
+ RubyScriptSynchronizer s= new RubyScriptSynchronizer(input);
+ s.install();
+ RubyScriptInfo info= new RubyScriptInfo(d, m, s);
+ info.fEncoding= getPersistedEncoding(element);
+ return info;
+ }
+ }
+
+ return null;
+ }
+
+ /*
+ * @see FileDocumentProvider#disposeElementInfo(Object, ElementInfo)
+ */
+ protected void disposeElementInfo(Object element, ElementInfo info) {
+ RubyScriptInfo classFileInfo= (RubyScriptInfo) info;
+ if (classFileInfo.fRubyScriptSynchronizer != null) {
+ classFileInfo.fRubyScriptSynchronizer.uninstall();
+ classFileInfo.fRubyScriptSynchronizer= null;
+ }
+
+ super.disposeElementInfo(element, info);
+ }
+
+ /*
+ * @see AbstractDocumentProvider#doSaveDocument(IProgressMonitor, Object, IDocument)
+ */
+ protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document) throws CoreException {
+ }
+
+
+ /*
+ * @see org.eclipse.ui.texteditor.IDocumentProviderExtension3#isSynchronized(java.lang.Object)
+ * @since 3.0
+ */
+ public boolean isSynchronized(Object element) {
+ Object elementInfo= getElementInfo(element);
+ if (elementInfo instanceof RubyScriptInfo) {
+ IRubyScriptEditorInput input= (IRubyScriptEditorInput)element;
+ IResource resource;
+ try {
+ resource= input.getRubyScript().getUnderlyingResource();
+ } catch (RubyModelException e) {
+ return true;
+ }
+ return resource == null || resource.isSynchronized(IResource.DEPTH_ZERO);
+ }
+ return false;
+ }
+
+ /**
+ * Handles the deletion of the element underlying the given class file editor input.
+ * @param input the editor input
+ */
+ protected void handleDeleted(IRubyScriptEditorInput input) {
+ fireElementDeleted(input);
+ }
+
+ /**
+ * Fires input changes to input change listeners.
+ */
+ protected void fireInputChanged(IRubyScriptEditorInput input) {
+ List list= new ArrayList(fInputListeners);
+ for (Iterator i = list.iterator(); i.hasNext();)
+ ((InputChangeListener) i.next()).inputChanged(input);
+ }
+
+ /**
+ * Adds an input change listener.
+ */
+ public void addInputChangeListener(InputChangeListener listener) {
+ fInputListeners.add(listener);
+ }
+
+ /**
+ * Removes an input change listener.
+ */
+ public void removeInputChangeListener(InputChangeListener listener) {
+ fInputListeners.remove(listener);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptDocumentProvider.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyScriptEditorInput.java 2007-03-12 15:14:15 UTC (rev 2135)
@@ -0,0 +1,92 @@
+package org.rubypeople.rdt.internal.ui.rubyeditor;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.core.ExternalRubyScript;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+
+public class RubyScriptEditorInput implements IRubyScriptEditorInput, IPersistableElement {
+
+ private ExternalRubyScript fScript;
+
+ public RubyScriptEditorInput(ExternalRubyScript script) {
+ this.fScript = script;
+ }
+
+ public IRubyScript getRubyScript() {
+ return fScript;
+ }
+
+ /*
+ * @see Object#equals(Object)
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!(obj instanceof RubyScriptEditorInput))
+ return false;
+ RubyScriptEditorInput other= (RubyScriptEditorInput) obj;
+ return fScript.equals(other.fScript);
+ }
+
+ /*
+ * @see Object#hashCode
+ */
+ public int hashCode() {
+ return fScript.hashCode();
+ }
+
+ /*
+ * @see IEditorInput#getPersistable()
+ */
+ public IPersistableElement getPersistable() {
+ return this;
+ }
+
+ /*
+ * @see IEditorInput#getName()
+ */
+ public String getName() {
+ return fScript.getElementName();
+ }
+
+ /*
+ * @see IEditorInput#getToolTipText()
+ */
+ public String getToolTipText() {
+ return fScript.getElementName();
+ }
+
+ /*
+ * @see IEditorInput#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor() {
+ return RubyPluginImages.DESC_OBJS_SCRIPT;
+ }
+
+ /*
+ * @see IEditorInput#exists()
+ */
+ public boolean exists() {
+ return fScript.exists();
+ }
+
+ /*
+ * @see IAdaptable#getAdapter(Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == IRubyScript.class)
+ return fScript;
+ return fScript.getAdapter(adapter);
+ }
+
+ public String getFactoryId() {
+ return RubyExternalEditorFactory.FACTORY_ID;
+ }
+
+ public void saveState(IMemento memento) {
+ // TODO Auto-generated method stub
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-12 14:34:15
|
Revision: 2134
http://svn.sourceforge.net/rubyeclipse/?rev=2134&view=rev
Author: cawilliams
Date: 2007-03-12 07:34:14 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-03-12 12:07:36 UTC (rev 2133)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-03-12 14:34:14 UTC (rev 2134)
@@ -1416,7 +1416,7 @@
pkg = root.getSourceFolder(ISourceFolder.DEFAULT_PACKAGE_NAME);
if (VERBOSE){
- System.out.println("WARNING : creating unit element outside classpath ("+ Thread.currentThread()+"): " + file.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$
+ System.out.println("WARNING : creating unit element outside loadpath ("+ Thread.currentThread()+"): " + file.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$
}
}
return pkg.getRubyScript(file.getName());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-03-12 12:07:40
|
Revision: 2133
http://svn.sourceforge.net/rubyeclipse/?rev=2133&view=rev
Author: mirkostocker
Date: 2007-03-12 05:07:36 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
use the new interface where possible
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/encapsulatefield/EncapsulateFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/FormatSourceConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlineclass/InlineClassConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergeclasspartsinfile/MergeClassPartsInFileConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergewithexternalclassparts/MergeWithExternalClassPartsConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movefield/MoveFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MoveMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/RenameLocalConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/LocalVarFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_RefactoringConditionChecker.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -143,7 +143,7 @@
protected void checkFinalConditions() {
}
- public abstract void init(Object configObj);
+ public abstract void init(IRefactoringConfig configObj);
public IRefactoringConfig getConfig() {
return config;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -40,6 +40,7 @@
import org.jruby.ast.MethodDefNode;
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -58,7 +59,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
config = (TempToFieldConfig) configObj;
rootNode = config.getDocumentProvider().getActiveFileRootNode();
Node selectedNode = findSelectedNode(LocalAsgnNode.class, LocalVarNode.class, DVarNode.class, DAsgnNode.class);
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/encapsulatefield/EncapsulateFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/encapsulatefield/EncapsulateFieldConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/encapsulatefield/EncapsulateFieldConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -36,6 +36,7 @@
import org.jruby.ast.Node;
import org.jruby.ast.SymbolNode;
import org.jruby.ast.types.INameNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
@@ -51,7 +52,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
config = (EncapsulateFieldConfig) configObj;
rootNode = config.getDocumentProvider().getActiveFileRootNode();
config.setSelectedInstNode(findSelectedInstNode(config.getCaretPosition()));
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -55,6 +55,7 @@
import org.jruby.ast.WhileNode;
import org.jruby.ast.YieldNode;
import org.jruby.ast.ZSuperNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -71,7 +72,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (ExtractMethodConfig) configObj;
initEnclosingNodes();
if (!NodeProvider.isEmptyNode(config.getSelectedNodes()) && config.getExtractMethodHelper() == null ) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/FormatSourceConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/FormatSourceConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/FormatSourceConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -28,6 +28,7 @@
package org.rubypeople.rdt.refactoring.core.formatsource;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
public class FormatSourceConditionChecker extends RefactoringConditionChecker {
@@ -38,7 +39,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (FormatSourceConfig) configObj;
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlineclass/InlineClassConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlineclass/InlineClassConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlineclass/InlineClassConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -37,6 +37,7 @@
import org.jruby.ast.Node;
import org.jruby.lexer.yacc.ISourcePosition;
import org.rubypeople.rdt.refactoring.classnodeprovider.ClassNodeProvider;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
@@ -57,7 +58,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (InlineClassConfig) configObj;
docProvider = config.getDocumentProvider();
intiSourceClass();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -40,6 +40,7 @@
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -56,7 +57,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (InlineTempConfig) configObj;
rootNode = config.getDocumentProvider().getActiveFileRootNode();
int caretPosition = config.getCaretPosition();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -38,6 +38,7 @@
import org.jruby.ast.types.INameNode;
import org.jruby.parser.StaticScope;
import org.rubypeople.rdt.refactoring.classnodeprovider.IncludedClassesProvider;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -54,7 +55,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (InlineMethodConfig) configObj;
if(!(findSelectedCall(config.getPos()) && findTargetClass(config.getTargetClassFinder()) && findMethodDefinition())) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergeclasspartsinfile/MergeClassPartsInFileConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergeclasspartsinfile/MergeClassPartsInFileConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergeclasspartsinfile/MergeClassPartsInFileConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -34,6 +34,7 @@
import java.util.Collection;
import org.rubypeople.rdt.refactoring.classnodeprovider.IncludedClassesProvider;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.PartialClassNodeWrapper;
@@ -46,7 +47,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (MergeClassPartInFileConfig) configObj;
config.setClassNodeProvider(new IncludedClassesProvider(config.getDocumentProvider()));
initSelectableClasses();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergewithexternalclassparts/MergeWithExternalClassPartsConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergewithexternalclassparts/MergeWithExternalClassPartsConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergewithexternalclassparts/MergeWithExternalClassPartsConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -30,6 +30,7 @@
package org.rubypeople.rdt.refactoring.core.mergewithexternalclassparts;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
public class MergeWithExternalClassPartsConditionChecker extends RefactoringConditionChecker {
@@ -40,7 +41,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (MergeWithExternalClassPartConfig) configObj;
config.setClassNodeProvider(config.getDocumentProvider().getIncludedClassNodeProvider());
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movefield/MoveFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movefield/MoveFieldConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movefield/MoveFieldConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -32,6 +32,7 @@
import java.util.TreeSet;
import org.rubypeople.rdt.refactoring.classnodeprovider.AllFilesClassNodeProvider;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
@@ -49,7 +50,7 @@
}
@Override
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
config = (MoveFieldConfig) configObj;
try {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MoveMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MoveMethodConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MoveMethodConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -37,6 +37,7 @@
import org.jruby.ast.MethodDefNode;
import org.jruby.ast.Node;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -55,7 +56,7 @@
}
@Override
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (MoveMethodConfig) configObj;
Node rootNode = config.getDocumentProvider().getActiveFileRootNode();
int caretPos = config.getCaretPosition();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -30,6 +30,7 @@
package org.rubypeople.rdt.refactoring.core.rename;
import org.rubypeople.rdt.refactoring.core.IRefactoringConditionChecker;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.renameclass.RenameClassConditionChecker;
import org.rubypeople.rdt.refactoring.core.renameclass.RenameClassConfig;
@@ -88,7 +89,7 @@
}
@Override
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
RenameConfig config = (RenameConfig) configObj;
int offset = config.getOffset();
IDocumentProvider docProvider = config.getDocumentProvider();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -29,6 +29,7 @@
package org.rubypeople.rdt.refactoring.core.renameclass;
import org.jruby.ast.ClassNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
import org.rubypeople.rdt.refactoring.documentprovider.DocumentWithIncluding;
@@ -45,7 +46,7 @@
}
@Override
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
config = (RenameClassConfig) configObj;
config.setDocumentWithIncludingProvider(new DocumentWithIncluding(config.getDocumentProvider()));
ClassNodeWrapper classNode = null;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -38,6 +38,7 @@
import org.jruby.ast.RootNode;
import org.rubypeople.rdt.refactoring.classnodeprovider.ClassNodeProvider;
import org.rubypeople.rdt.refactoring.classnodeprovider.IncludedClassesProvider;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -61,7 +62,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (RenameFieldConfig) configObj;
config.setDocProvider(new DocumentWithIncluding(config.getDocumentProvider()));
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/RenameLocalConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/RenameLocalConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/RenameLocalConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -42,6 +42,7 @@
import org.jruby.ast.RootNode;
import org.jruby.ast.types.INameNode;
import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -70,7 +71,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
config = (RenameLocalConfig) configObj;
RootNode rootNode = config.getDocumentProvider().getActiveFileRootNode();
Node selectedNode = SelectionNodeProvider.getSelectedNodeOfType(rootNode, config.getCaretPosition(), SELECTED_NODE_TYPES);
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -38,6 +38,7 @@
import org.jruby.ast.Node;
import org.jruby.ast.SymbolNode;
import org.rubypeople.rdt.refactoring.classnodeprovider.ClassNodeProvider;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -60,7 +61,7 @@
@Override
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (RenameMethodConfig)configObj;
config.setDocProvider(new DocumentWithIncluding(config.getDocumentProvider()));
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/LocalVarFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/LocalVarFinder.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/LocalVarFinder.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -41,6 +41,7 @@
import org.jruby.ast.types.INameNode;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
+import org.rubypeople.rdt.refactoring.core.inlinemethod.TargetClassFinder;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
import org.rubypeople.rdt.refactoring.util.NodeUtil;
@@ -52,8 +53,7 @@
Node rootNode = doc.getActiveFileRootNode();
- INameNode selectedAssignment = (INameNode) SelectionNodeProvider.getSelectedNodeOfType(rootNode, caretPosition, LocalAsgnNode.class, DAsgnNode.class);
-
+ INameNode selectedAssignment = findAssignment(doc, caretPosition, rootNode);
if (selectedAssignment == null) {
return null;
}
@@ -64,6 +64,22 @@
return createLocalVariableUsages(gatherLocalAssignments(selectedAssignment));
}
+ private INameNode findAssignment(IDocumentProvider doc, int caretPosition, Node rootNode) {
+ INameNode selectedAssignment = (INameNode) SelectionNodeProvider.getSelectedNodeOfType(rootNode, caretPosition, LocalAsgnNode.class, DAsgnNode.class);
+
+ if (selectedAssignment == null) {
+
+ final LocalVarNode selectedLocalVar = (LocalVarNode) SelectionNodeProvider.getSelectedNodeOfType(rootNode, caretPosition, LocalVarNode.class);
+
+ if(selectedLocalVar == null)
+ return null;
+
+ selectedAssignment = new TargetClassFinder().localAsgnFromLocalVar(selectedLocalVar, doc);
+ }
+
+ return selectedAssignment;
+ }
+
private ArrayList<LocalVarUsage> createLocalVariableUsages(ArrayList<AssignableNode> myAsgns) {
ArrayList<LocalVarUsage> foundNodes = new ArrayList<LocalVarUsage>();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -28,6 +28,7 @@
package org.rubypeople.rdt.refactoring.core.splittemp;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
public class SplitTempConditionChecker extends RefactoringConditionChecker {
@@ -38,7 +39,7 @@
super(config);
}
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
this.config = (SplitTempConfig) configObj;
config.setLocalVariablesFinder(new LocalVarFinder());
config.setLocalUsages(config.getLocalVariablesFinder().findLocalUsages(config.getDocumentProvider(), config.getCaretPsition()));
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_RefactoringConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_RefactoringConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_RefactoringConditionChecker.java 2007-03-12 12:07:36 UTC (rev 2133)
@@ -17,7 +17,7 @@
@Override
- public void init(Object configObj) {
+ public void init(IRefactoringConfig configObj) {
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
Revision: 2132
http://svn.sourceforge.net/rubyeclipse/?rev=2132&view=rev
Author: callandor1983
Date: 2007-03-12 04:54:59 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
removed spare argument form constructor form RefactoringConditionChecker.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_RefactoringConditionChecker.java
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_RefactoringConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_RefactoringConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/TC_RefactoringConditionChecker.java 2007-03-12 11:54:59 UTC (rev 2132)
@@ -10,10 +10,12 @@
public class TC_RefactoringConditionChecker extends TestCase {
private final class TestConditionChecker extends RefactoringConditionChecker {
- private TestConditionChecker(IDocumentProvider provider, IRefactoringConfig config) {
- super(provider, config);
+ private TestConditionChecker(final IDocumentProvider provider) {
+ super(getDefaultConfig(provider));
}
+
+
@Override
public void init(Object configObj) {
}
@@ -25,7 +27,7 @@
public void testSyntaxErrors() {
- RefactoringConditionChecker checker = new TestConditionChecker(new StringDocumentProvider("errorous_dummy_doc.rb", "class Test; en"), null);
+ RefactoringConditionChecker checker = new TestConditionChecker(new StringDocumentProvider("errorous_dummy_doc.rb", "class Test; en"));
assertEquals(1, checker.getInitialMessages().get(IRefactoringConditionChecker.ERRORS).size());
assertEquals(0, checker.getInitialMessages().get(IRefactoringConditionChecker.WARNING).size());
}
@@ -35,11 +37,22 @@
StringDocumentProvider stringDocumentProvider = new StringDocumentProvider("dummy_doc_wit_errorous_include.rb", "class Test; end");
stringDocumentProvider.addFile("other", "class Test; en");
- RefactoringConditionChecker checker = new TestConditionChecker(stringDocumentProvider, null);
+ RefactoringConditionChecker checker = new TestConditionChecker(stringDocumentProvider);
assertEquals(0, checker.getInitialMessages().get(IRefactoringConditionChecker.ERRORS).size());
assertEquals(0, checker.getInitialMessages().get(IRefactoringConditionChecker.WARNING).size());
assertEquals(0, checker.getFinalMessages().get(IRefactoringConditionChecker.ERRORS).size());
assertEquals(1, checker.getFinalMessages().get(IRefactoringConditionChecker.WARNING).size());
}
+
+ private static IRefactoringConfig getDefaultConfig(final IDocumentProvider provider) {
+ return new IRefactoringConfig() {
+
+ public IDocumentProvider getDocumentProvider() {
+ return provider;
+ }
+
+ public void setDocumentProvider(IDocumentProvider doc) {
+ }};
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cal...@us...> - 2007-03-12 11:47:52
|
Revision: 2131
http://svn.sourceforge.net/rubyeclipse/?rev=2131&view=rev
Author: callandor1983
Date: 2007-03-12 04:47:50 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
removed spare argument form constructor form RefactoringConditionChecker.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/encapsulatefield/EncapsulateFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/FormatSourceConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlineclass/InlineClassConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergeclasspartsinfile/MergeClassPartsInFileConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergewithexternalclassparts/MergeWithExternalClassPartsConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movefield/MoveFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MoveMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/RenameLocalConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/RefactoringConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -44,8 +44,8 @@
private IDocumentProvider docProvider;
private final IRefactoringConfig config;
- public RefactoringConditionChecker(IDocumentProvider docProvider, IRefactoringConfig config) {
- this.docProvider = docProvider;
+ public RefactoringConditionChecker(IRefactoringConfig config) {
+ this.docProvider = config.getDocumentProvider();
this.config = config;
initMessages();
addLocalInitialErrors();
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -55,7 +55,7 @@
private RootNode rootNode;
public TempToFieldConditionChecker(TempToFieldConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/encapsulatefield/EncapsulateFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/encapsulatefield/EncapsulateFieldConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/encapsulatefield/EncapsulateFieldConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -48,7 +48,7 @@
private Node rootNode;
public EncapsulateFieldConditionChecker(EncapsulateFieldConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -68,7 +68,7 @@
private ExtractMethodConfig config;
public ExtractMethodConditionChecker(ExtractMethodConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/FormatSourceConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/FormatSourceConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/formatsource/FormatSourceConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -35,7 +35,7 @@
private FormatSourceConfig config;
public FormatSourceConditionChecker(FormatSourceConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlineclass/InlineClassConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlineclass/InlineClassConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlineclass/InlineClassConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -54,7 +54,7 @@
private ClassNodeWrapper selectedClass;
public InlineClassConditionChecker(InlineClassConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -53,7 +53,7 @@
private RootNode rootNode;
public InlineTempConditionChecker(InlineTempConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/InlineMethodConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -51,7 +51,7 @@
public InlineMethodConditionChecker(InlineMethodConfig config) {
- super(config.getDocumentProvider(),config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergeclasspartsinfile/MergeClassPartsInFileConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergeclasspartsinfile/MergeClassPartsInFileConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergeclasspartsinfile/MergeClassPartsInFileConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -43,7 +43,7 @@
private MergeClassPartInFileConfig config;
public MergeClassPartsInFileConditionChecker(MergeClassPartInFileConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergewithexternalclassparts/MergeWithExternalClassPartsConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergewithexternalclassparts/MergeWithExternalClassPartsConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/mergewithexternalclassparts/MergeWithExternalClassPartsConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -37,7 +37,7 @@
private MergeWithExternalClassPartConfig config;
public MergeWithExternalClassPartsConditionChecker(MergeWithExternalClassPartConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movefield/MoveFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movefield/MoveFieldConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movefield/MoveFieldConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -45,7 +45,7 @@
private MoveFieldConfig config;
public MoveFieldConditionChecker(MoveFieldConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
@Override
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MoveMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MoveMethodConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/movemethod/MoveMethodConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -51,7 +51,7 @@
private MoveMethodConfig config;
public MoveMethodConditionChecker(MoveMethodConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
@Override
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/rename/RenameConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -58,7 +58,7 @@
private RefactoringConditionChecker classConditionChecker;
public RenameConditionChecker(RenameConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
@Override
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renameclass/RenameClassConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -41,7 +41,7 @@
private RenameClassConfig config;
public RenameClassConditionChecker(RenameClassConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
@Override
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamefield/RenameFieldConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -58,7 +58,7 @@
private RootNode rootNode;
public RenameFieldConditionChecker(RenameFieldConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/RenameLocalConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/RenameLocalConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamelocal/RenameLocalConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -67,7 +67,7 @@
private RenameLocalConfig config;
public RenameLocalConditionChecker(RenameLocalConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/RenameMethodConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -55,7 +55,7 @@
private RenameMethodConfig config;
public RenameMethodConditionChecker(RenameMethodConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java 2007-03-12 11:47:50 UTC (rev 2131)
@@ -35,7 +35,7 @@
private SplitTempConfig config;
public SplitTempConditionChecker(SplitTempConfig config) {
- super(config.getDocumentProvider(), config);
+ super(config);
}
public void init(Object configObj) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cal...@us...> - 2007-03-12 11:39:39
|
Revision: 2130
http://svn.sourceforge.net/rubyeclipse/?rev=2130&view=rev
Author: callandor1983
Date: 2007-03-12 04:39:36 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
inline local: parentheses are now set if selected callNode contains only one argument.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodBodyStatementReplacer.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/OccurenceReplaceSelectionPage.java
trunk/org.rubypeople.rdt.refactoring.tests/.classpath
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/JRubyRefactoringUtils.java
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_result
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_source
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/JRubyRefactoringUtils.java
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/JRubyRefactoringUtils.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/JRubyRefactoringUtils.java 2007-03-12 09:25:00 UTC (rev 2129)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/JRubyRefactoringUtils.java 2007-03-12 11:39:36 UTC (rev 2130)
@@ -1,106 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring;
-
-import org.jruby.ast.ArgsNode;
-import org.jruby.ast.ArgumentNode;
-import org.jruby.ast.CallNode;
-import org.jruby.ast.ListNode;
-import org.jruby.ast.MethodDefNode;
-import org.jruby.ast.Node;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
-
-public abstract class JRubyRefactoringUtils {
-
- public static boolean isParameter(LocalNodeWrapper selectedItem, MethodDefNode enclosingMethod) {
- return isParameter(enclosingMethod.getScope().getVariables()[selectedItem.getId()], enclosingMethod);
- }
-
- public static boolean isParameter(String name, MethodDefNode enclosingMethod) {
- ArgsNode argsNode = enclosingMethod.getArgsNode();
- ListNode argumentList = argsNode.getArgs();
-
- if (argumentList == null) {
- return false;
- }
-
- for (Object currentArg : argumentList.childNodes()) {
- if (currentArg instanceof ArgumentNode) {
- ArgumentNode arg = (ArgumentNode) currentArg;
- if (arg.getName().equals(name)) {
- return true;
- }
- }
- }
- return false;
- }
-
-
- public static boolean isMathematicalExpression(Node node) {
-
- if (!(node instanceof CallNode)) {
- return false;
- }
-
- String name = ((CallNode) node).getName();
-
- String[] operators = new String[] { "**", "!", "+", "-", "*", "/", "%", ">>", "<<", "&", "^", "|", "+@", "-@", "<=>", ">", "<", ">=", "<=", "==", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$
- "===", "~", "&&" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- for (String currentOp : operators) {
- if (name.equals(currentOp)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean hasSamePosition(Node node1, Node node2){
- String file1 = node1.getPosition().getFile();
- String file2 = node2.getPosition().getFile();
- if(!file1.equals(file2)){
- return false;
- }
-
- int start1 = node1.getPosition().getStartOffset();
- int start2 = node2.getPosition().getStartOffset();
- if(start1 != start2){
- return false;
- }
-
- int end1 = node1.getPosition().getEndOffset();
- int end2 = node2.getPosition().getEndOffset();
- if(end1 != end2){
- return false;
- }
- return true;
- }
-}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java 2007-03-12 09:25:00 UTC (rev 2129)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
@@ -40,7 +40,6 @@
import org.jruby.ast.MethodDefNode;
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
-import org.rubypeople.rdt.refactoring.JRubyRefactoringUtils;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
@@ -48,6 +47,7 @@
import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.FieldNodeWrapper;
import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
public class TempToFieldConditionChecker extends RefactoringConditionChecker {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java 2007-03-12 09:25:00 UTC (rev 2129)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java 2007-03-12 11:39:36 UTC (rev 2130)
@@ -40,11 +40,11 @@
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
import org.jruby.lexer.yacc.ISourcePosition;
-import org.rubypeople.rdt.refactoring.JRubyRefactoringUtils;
import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
import org.rubypeople.rdt.refactoring.util.NodeUtil;
public class InlineTempConditionChecker extends RefactoringConditionChecker {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java 2007-03-12 09:25:00 UTC (rev 2129)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java 2007-03-12 11:39:36 UTC (rev 2130)
@@ -33,7 +33,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import org.rubypeople.rdt.refactoring.JRubyRefactoringUtils;
import org.rubypeople.rdt.refactoring.core.SelectionInformation;
import org.rubypeople.rdt.refactoring.core.extractmethod.ExtractMethodConditionChecker;
import org.rubypeople.rdt.refactoring.core.extractmethod.ExtractMethodConfig;
@@ -42,6 +41,7 @@
import org.rubypeople.rdt.refactoring.editprovider.EditProvider;
import org.rubypeople.rdt.refactoring.editprovider.MultiEditProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
public class TempInliner extends MultiEditProvider {
@@ -78,7 +78,7 @@
private EditProvider replaceWithValueProvider(LocalNodeWrapper targetNode) {
boolean addBrackets = JRubyRefactoringUtils.isMathematicalExpression(config.getDefinitionNode().getValueNode());
- return new TempValueReplaceProvider(targetNode, config.getDefinitionNode(), addBrackets);
+ return new TempValueReplaceProvider(targetNode, config, addBrackets);
}
private EditProvider extractMethodProvider() {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java 2007-03-12 09:25:00 UTC (rev 2129)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java 2007-03-12 11:39:36 UTC (rev 2130)
@@ -30,10 +30,18 @@
package org.rubypeople.rdt.refactoring.core.inlinelocal;
+
+import org.jruby.ast.CallNode;
import org.jruby.ast.Node;
+import org.jruby.ast.visitor.rewriter.DefaultFormatHelper;
+import org.jruby.ast.visitor.rewriter.FormatHelper;
import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.refactoring.core.NodeProvider;
import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
public class TempValueReplaceProvider extends ReplaceEditProvider {
@@ -43,9 +51,12 @@
private boolean addBrackets;
- public TempValueReplaceProvider(LocalNodeWrapper targetNode, LocalNodeWrapper inlinedNode, boolean addBrackets) {
+ private InlineTempConfig config;
+
+ public TempValueReplaceProvider(LocalNodeWrapper targetNode, InlineTempConfig config, boolean addBrackets) {
super(false);
- this.inlinedNode = inlinedNode;
+ this.config = config;
+ this.inlinedNode = config.getDefinitionNode();
this.targetNode = targetNode;
this.addBrackets = addBrackets;
}
@@ -72,4 +83,36 @@
}
return super.getFormatedNode(document);
}
+
+ @Override
+ protected FormatHelper getFormatHelper() {
+ if(callNeedsBrackets()) {
+ return new DefaultFormatHelper() {
+
+ @Override
+ public String afterCallArguments() {
+ return ")";
+ }
+
+ @Override
+ public String beforeCallArguments() {
+ return "(";
+ }};
+ } else {
+ return super.getFormatHelper();
+ }
+ }
+
+ private boolean callNeedsBrackets() {
+ Node targetEnclosingNode = NodeProvider.findParentNode(config.getDocumentProvider().getActiveFileRootNode(), targetNode.getWrappedNode());
+ boolean isTargetEnclosingNodeCallNode = NodeUtil.nodeAssignableFrom(targetEnclosingNode, MethodCallNodeWrapper.METHOD_CALL_NODE_CLASSES());
+ if(NodeUtil.nodeAssignableFrom(targetEnclosingNode, CallNode.class)) {
+ isTargetEnclosingNodeCallNode &= !JRubyRefactoringUtils.isMathematicalExpression(targetEnclosingNode);
+ }
+ boolean isInlinedNodeCallNode = NodeUtil.nodeAssignableFrom(inlinedNode.getValueNode(), MethodCallNodeWrapper.METHOD_CALL_NODE_CLASSES());
+ if(NodeUtil.nodeAssignableFrom(inlinedNode.getValueNode(), CallNode.class)) {
+ isInlinedNodeCallNode &= !JRubyRefactoringUtils.isMathematicalExpression(inlinedNode.getValueNode());
+ }
+ return isTargetEnclosingNodeCallNode && isInlinedNodeCallNode;
+ }
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodBodyStatementReplacer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodBodyStatementReplacer.java 2007-03-12 09:25:00 UTC (rev 2129)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinemethod/MethodBodyStatementReplacer.java 2007-03-12 11:39:36 UTC (rev 2130)
@@ -75,7 +75,11 @@
Collection<Node> varNodes = null;
do {
varNodes = NodeProvider.gatherNodesOfTypeInAktScopeNode(result.getActiveFileRootNode().getBodyNode(), InstVarNode.class, InstAsgnNode.class);
-
+ for(Node actVarNode : new ArrayList<Node>(varNodes)) {
+ if(((INameNode)actVarNode).getName().equals(object)) {
+ varNodes.remove(actVarNode);
+ }
+ }
if(varNodes.isEmpty()) {
continue;
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/OccurenceReplaceSelectionPage.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/OccurenceReplaceSelectionPage.java 2007-03-12 09:25:00 UTC (rev 2129)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/OccurenceReplaceSelectionPage.java 2007-03-12 11:39:36 UTC (rev 2130)
@@ -43,11 +43,11 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.jruby.lexer.yacc.ISourcePosition;
-import org.rubypeople.rdt.refactoring.JRubyRefactoringUtils;
import org.rubypeople.rdt.refactoring.core.renamemethod.NodeSelector;
import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
import org.rubypeople.rdt.refactoring.nodewrapper.INodeWrapper;
import org.rubypeople.rdt.refactoring.ui.RdtCodeViewer;
+import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
public class OccurenceReplaceSelectionPage extends RefactoringWizardPage {
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/JRubyRefactoringUtils.java (from rev 2109, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/JRubyRefactoringUtils.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/JRubyRefactoringUtils.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/util/JRubyRefactoringUtils.java 2007-03-12 11:39:36 UTC (rev 2130)
@@ -0,0 +1,106 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.util;
+
+import org.jruby.ast.ArgsNode;
+import org.jruby.ast.ArgumentNode;
+import org.jruby.ast.CallNode;
+import org.jruby.ast.ListNode;
+import org.jruby.ast.MethodDefNode;
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+
+public abstract class JRubyRefactoringUtils {
+
+ public static boolean isParameter(LocalNodeWrapper selectedItem, MethodDefNode enclosingMethod) {
+ return isParameter(enclosingMethod.getScope().getVariables()[selectedItem.getId()], enclosingMethod);
+ }
+
+ public static boolean isParameter(String name, MethodDefNode enclosingMethod) {
+ ArgsNode argsNode = enclosingMethod.getArgsNode();
+ ListNode argumentList = argsNode.getArgs();
+
+ if (argumentList == null) {
+ return false;
+ }
+
+ for (Object currentArg : argumentList.childNodes()) {
+ if (currentArg instanceof ArgumentNode) {
+ ArgumentNode arg = (ArgumentNode) currentArg;
+ if (arg.getName().equals(name)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ public static boolean isMathematicalExpression(Node node) {
+
+ if (!(node instanceof CallNode)) {
+ return false;
+ }
+
+ String name = ((CallNode) node).getName();
+
+ String[] operators = new String[] { "**", "!", "+", "-", "*", "/", "%", ">>", "<<", "&", "^", "|", "+@", "-@", "<=>", ">", "<", ">=", "<=", "==", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$
+ "===", "~", "&&" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ for (String currentOp : operators) {
+ if (name.equals(currentOp)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean hasSamePosition(Node node1, Node node2){
+ String file1 = node1.getPosition().getFile();
+ String file2 = node2.getPosition().getFile();
+ if(!file1.equals(file2)){
+ return false;
+ }
+
+ int start1 = node1.getPosition().getStartOffset();
+ int start2 = node2.getPosition().getStartOffset();
+ if(start1 != start2){
+ return false;
+ }
+
+ int end1 = node1.getPosition().getEndOffset();
+ int end2 = node2.getPosition().getEndOffset();
+ if(end1 != end2){
+ return false;
+ }
+ return true;
+ }
+}
Modified: trunk/org.rubypeople.rdt.refactoring.tests/.classpath
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/.classpath 2007-03-12 09:25:00 UTC (rev 2129)
+++ trunk/org.rubypeople.rdt.refactoring.tests/.classpath 2007-03-12 11:39:36 UTC (rev 2130)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry excluding="*" kind="src" path="resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_properties 2007-03-12 11:39:36 UTC (rev 2130)
@@ -0,0 +1,3 @@
+caretPosition=67
+replaceWithQuery=false
+newMethodName=
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_result
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_result (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_result 2007-03-12 11:39:36 UTC (rev 2130)
@@ -0,0 +1,5 @@
+ def read_content(url)
+ FeedTools::Feed.open(url).items.each do |item|
+ #...
+ end
+ end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_source
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_source (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/inlinetemp/inline_temp_test_11.test_source 2007-03-12 11:39:36 UTC (rev 2130)
@@ -0,0 +1,6 @@
+ def read_content(url)
+ feed = FeedTools::Feed.open(url)
+ feed.items.each do |item|
+ #...
+ end
+ end
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-03-12 09:25:04
|
Revision: 2129
http://svn.sourceforge.net/rubyeclipse/?rev=2129&view=rev
Author: mirkostocker
Date: 2007-03-12 02:25:00 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
parameter renaming in extract method didn't work anymore because of the new back button implementation
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConfig.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-03-12 07:57:06 UTC (rev 2128)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConditionChecker.java 2007-03-12 09:25:00 UTC (rev 2129)
@@ -74,7 +74,7 @@
public void init(Object configObj) {
this.config = (ExtractMethodConfig) configObj;
initEnclosingNodes();
- if (!NodeProvider.isEmptyNode(config.getSelectedNodes())) {
+ if (!NodeProvider.isEmptyNode(config.getSelectedNodes()) && config.getExtractMethodHelper() == null ) {
config.setExtractedMethodHelper(new ExtractedMethodHelper(config));
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConfig.java 2007-03-12 07:57:06 UTC (rev 2128)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractmethod/ExtractMethodConfig.java 2007-03-12 09:25:00 UTC (rev 2129)
@@ -131,4 +131,7 @@
this.docProvider = doc;
}
+ public ExtractedMethodHelper getExtractMethodHelper() {
+ return extractMethodHelper;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-03-12 07:57:09
|
Revision: 2128
http://svn.sourceforge.net/rubyeclipse/?rev=2128&view=rev
Author: mirkostocker
Date: 2007-03-12 00:57:06 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
Fix the rename method back button (edit providers shouldn't use fields to store intermediate data..)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/MethodRenamer.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/MethodRenamer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/MethodRenamer.java 2007-03-09 20:39:58 UTC (rev 2127)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/renamemethod/MethodRenamer.java 2007-03-12 07:57:06 UTC (rev 2128)
@@ -59,7 +59,6 @@
public class MethodRenamer implements IMultiFileEditProvider {
private RenameMethodConfig config;
- private MultiFileEditProvider fileEdits;
public Collection<String> getAllMethodsFromClass() {
Collection<String> names = new ArrayList<String>();
@@ -75,7 +74,6 @@
public MethodRenamer(RenameMethodConfig config){
this.config = config;
- fileEdits = new MultiFileEditProvider();
Collection<MethodCallNodeWrapper> probableClass = getCallCandidatesInClass();
probableClass.addAll(getSubsequentCalls());
@@ -84,18 +82,20 @@
public Collection<FileMultiEditProvider> getFileEditProviders(){
- addDefinitionRenamer();
+ MultiFileEditProvider fileEdits = new MultiFileEditProvider();
- addCallRenamers();
+ addDefinitionRenamer(fileEdits);
+ addCallRenamers(fileEdits);
+
if(!config.getTargetMethod().isClassMethod()){
- addSymbolRenamers();
+ addSymbolRenamers(fileEdits);
}
return fileEdits.getFileEditProviders();
}
- private void addSymbolRenamers() {
+ private void addSymbolRenamers(MultiFileEditProvider fileEdits) {
if(config.getTargetMethod().isClassMethod()){
return;
}
@@ -106,7 +106,7 @@
}
}
- private void addCallRenamers() {
+ private void addCallRenamers(MultiFileEditProvider fileEdits) {
for(INodeWrapper currentCandidate : config.getSelectedCalls()){
String file = currentCandidate.getWrappedNode().getPosition().getFile();
@@ -116,8 +116,8 @@
}
}
- private void addDefinitionRenamer() {
- if(config.getSelectedClass()==null || config.getTargetMethod().isClassMethod()){
+ private void addDefinitionRenamer(MultiFileEditProvider fileEdits) {
+ if(config.getSelectedClass() == null || config.getTargetMethod().isClassMethod()){
String file = config.getDocumentProvider().getActiveFileName();
MethodNameArgumentItem argumentItem = new MethodNameArgumentItem(config.getTargetMethod().getWrappedNode().getNameNode());
fileEdits.addEditProvider(new FileEditProvider(file, new MethodRenameEditProvider(argumentItem, config.getNewName())));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-09 20:40:07
|
Revision: 2127
http://svn.sourceforge.net/rubyeclipse/?rev=2127&view=rev
Author: cawilliams
Date: 2007-03-09 12:39:58 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
add task marker to remind me - we need to get at module methods (particularly inside Module, like "include") that we aren't generating right now!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/ruby/core_stubber.rb
Modified: trunk/org.rubypeople.rdt.launching/ruby/core_stubber.rb
===================================================================
--- trunk/org.rubypeople.rdt.launching/ruby/core_stubber.rb 2007-03-09 20:39:21 UTC (rev 2126)
+++ trunk/org.rubypeople.rdt.launching/ruby/core_stubber.rb 2007-03-09 20:39:58 UTC (rev 2127)
@@ -50,6 +50,7 @@
f << "\n"
klass.included_modules.each {|mod| f << " include #{mod.to_s}\n" unless mod.to_s == "Kernel" && klass.to_s != "Object"}
f << "\n"
+ # FIXME We aren't grabbing some important methods inside Module (like "include")
klass.methods(false).each do |method_name|
method = eval("#{klass}").method(method_name) rescue nil
print_method(f, method, method_name.to_s, true)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-09 20:39:23
|
Revision: 2126
http://svn.sourceforge.net/rubyeclipse/?rev=2126&view=rev
Author: cawilliams
Date: 2007-03-09 12:39:21 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
cleanup task markers, extract constants
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:37:00 UTC (rev 2125)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:39:21 UTC (rev 2126)
@@ -57,6 +57,8 @@
public class CompletionEngine {
private static final String OBJECT = "Object";
private static final String CONSTRUCTOR_INVOKE_NAME = "new";
+ private static final String CONSTRUCTOR_DEFINITION_NAME = "initialize";
+
private CompletionRequestor fRequestor;
private CompletionContext fContext;
@@ -132,7 +134,6 @@
private void suggestGlobals() {
Set<String> globals = ExperimentalIndex.getGlobalNames();
- // TODO Sort?
for (String name : globals) {
if (!fContext.prefixStartsWith(name))
continue;
@@ -143,7 +144,6 @@
private void suggestTypeNames() {
Set<String> types = ExperimentalIndex.getTypeNames();
- // TODO Sort?
for (String name : types) {
if (!fContext.prefixStartsWith(name))
continue;
@@ -161,7 +161,6 @@
private void suggestConstantNames() {
Set<String> types = ExperimentalIndex.getConstantNames();
- // TODO Sort?
for (String name : types) {
if (!fContext.prefixStartsWith(name))
continue;
@@ -359,26 +358,6 @@
return;
}
- // XXX rubyType may not be in script, but rather be defined in another
- // script
- // IType rubyType = new RubyType( (RubyElement)script, typeName );
- // Better method:
- // Find the named type
- // IType rubyType = findTypeFromAllProjects(typeName, script);
-
- // System.out.println(" -- Located RubyType info.");
- // System.out.println(" -- Superclass: " + rubyType.getSuperclassName()
- // );
-
- // if ( rubyType != null ) {
- // String[] includedModuleNames = rubyType.getIncludedModuleNames();
- // if ( includedModuleNames != null ) {
- // for ( String moduleName : rubyType.getIncludedModuleNames() ) {
- // System.out.println(" -- Includes module: " + moduleName);
- // }
- // }
- // }
-
// Get superclass and add its public members
List<Node> superclassNodes = getSuperclassNodes(typeNode);
for (Node superclassNode : superclassNodes) {
@@ -545,7 +524,6 @@
}
private class NodeMethod implements IMethod {
-
private MethodDefNode node;
public NodeMethod(MethodDefNode methodDefinition) {
@@ -557,12 +535,11 @@
}
public int getVisibility() throws RubyModelException {
- // TODO Auto-generated method stub
return IMethod.PUBLIC;
}
public boolean isConstructor() {
- return node.getName().equals("initialize");
+ return node.getName().equals(CONSTRUCTOR_DEFINITION_NAME);
}
public boolean isSingleton() {
@@ -570,17 +547,14 @@
}
public boolean exists() {
- // TODO Auto-generated method stub
return false;
}
public IRubyElement getAncestor(int ancestorType) {
- // TODO Auto-generated method stub
return null;
}
public IResource getCorrespondingResource() throws RubyModelException {
- // TODO Auto-generated method stub
return null;
}
@@ -593,52 +567,42 @@
}
public IOpenable getOpenable() {
- // TODO Auto-generated method stub
return null;
}
public IRubyElement getParent() {
- // TODO Auto-generated method stub
return null;
}
public IPath getPath() {
- // TODO Auto-generated method stub
return null;
}
public IRubyElement getPrimaryElement() {
- // TODO Auto-generated method stub
return null;
}
public IResource getResource() {
- // TODO Auto-generated method stub
return null;
}
public IRubyModel getRubyModel() {
- // TODO Auto-generated method stub
return null;
}
public IRubyProject getRubyProject() {
- // TODO Auto-generated method stub
return null;
}
public IResource getUnderlyingResource() throws RubyModelException {
- // TODO Auto-generated method stub
return null;
}
public boolean isReadOnly() {
- // TODO Auto-generated method stub
return false;
}
public boolean isStructureKnown() throws RubyModelException {
- // TODO Auto-generated method stub
return false;
}
@@ -647,47 +611,38 @@
}
public Object getAdapter(Class adapter) {
- // TODO Auto-generated method stub
return null;
}
public IType getDeclaringType() {
- // TODO Auto-generated method stub
return null;
}
public ISourceRange getNameRange() throws RubyModelException {
- // TODO Auto-generated method stub
return null;
}
public IRubyScript getRubyScript() {
- // TODO Auto-generated method stub
return null;
}
public IType getType(String name, int occurrenceCount) {
- // TODO Auto-generated method stub
return null;
}
public String getSource() throws RubyModelException {
- // TODO Auto-generated method stub
return null;
}
public ISourceRange getSourceRange() throws RubyModelException {
- // TODO Auto-generated method stub
return null;
}
public IRubyElement[] getChildren() throws RubyModelException {
- // TODO Auto-generated method stub
return null;
}
public boolean hasChildren() throws RubyModelException {
- // TODO Auto-generated method stub
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-09 20:37:02
|
Revision: 2125
http://svn.sourceforge.net/rubyeclipse/?rev=2125&view=rev
Author: cawilliams
Date: 2007-03-09 12:37:00 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
extract constant
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:36:36 UTC (rev 2124)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:37:00 UTC (rev 2125)
@@ -55,6 +55,7 @@
import org.rubypeople.rdt.internal.ti.util.ScopedNodeLocator;
public class CompletionEngine {
+ private static final String OBJECT = "Object";
private static final String CONSTRUCTOR_INVOKE_NAME = "new";
private CompletionRequestor fRequestor;
private CompletionContext fContext;
@@ -109,9 +110,9 @@
IMember element = (IMember) script.getElementAt(fContext.getOffset());
IType type = null;
if (element == null) {
- // DWe're in the top level, so we're in "Object"
+ // We're in the top level, so we're in "Object"
RubyElementRequestor requestor = new RubyElementRequestor(script);
- IType[] types = requestor.findType("Object");
+ IType[] types = requestor.findType(OBJECT);
if (types != null && types.length > 0) type = types[0];
} else {
type = element.getDeclaringType();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-09 20:36:46
|
Revision: 2124
http://svn.sourceforge.net/rubyeclipse/?rev=2124&view=rev
Author: cawilliams
Date: 2007-03-09 12:36:36 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
handle completion in top level
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:24:09 UTC (rev 2123)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:36:36 UTC (rev 2124)
@@ -107,7 +107,16 @@
private void suggestMethodsForEnclosingType(IRubyScript script) throws RubyModelException {
IMember element = (IMember) script.getElementAt(fContext.getOffset());
- IType type = element.getDeclaringType();
+ IType type = null;
+ if (element == null) {
+ // DWe're in the top level, so we're in "Object"
+ RubyElementRequestor requestor = new RubyElementRequestor(script);
+ IType[] types = requestor.findType("Object");
+ if (types != null && types.length > 0) type = types[0];
+ } else {
+ type = element.getDeclaringType();
+ }
+ if (type == null) return;
List<CompletionProposal> list = sort(suggestMethods(100, type));
for (CompletionProposal proposal : list) {
fRequestor.accept(proposal);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-09 20:25:06
|
Revision: 2123
http://svn.sourceforge.net/rubyeclipse/?rev=2123&view=rev
Author: cawilliams
Date: 2007-03-09 12:24:09 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
do some more code completion tweaking
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:17:06 UTC (rev 2122)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-03-09 20:24:09 UTC (rev 2123)
@@ -67,9 +67,7 @@
this.fRequestor.beginReporting();
fContext = new CompletionContext(script, offset);
if (fContext.emptyPrefix()) { // no prefix, so we could suggest anything
- suggestTypeNames();
- suggestConstantNames();
- suggestGlobals();
+ suggestMethodsForEnclosingType(script);
getDocumentsRubyElementsInScope();
} else {
if (fContext.isConstant()) { // type or constant
@@ -94,15 +92,9 @@
// FIXME If we're invoked on the class declaration (it's super class) don't do this!
// FIXME Traverse the IRubyElement model, not nodes (and don't reparse)?
if (fContext.isMethodInvokationOrLocal()) {
- // Grab all the methods in this type and it's super/module.
- IMember element = (IMember) script.getElementAt(fContext.getOffset());
- IType type = element.getDeclaringType();
- List<CompletionProposal> list = sort(suggestMethods(100, type));
- for (CompletionProposal proposal : list) {
- fRequestor.accept(proposal);
- }
+ suggestMethodsForEnclosingType(script);
}
- // FIXME WHat about instance and class variables?
+ // FIXME What about instance and class variables?
// getDocumentsRubyElementsInScope();
}
if (fContext.isGlobal()) { // looks like a global
@@ -113,6 +105,15 @@
fContext = null;
}
+ private void suggestMethodsForEnclosingType(IRubyScript script) throws RubyModelException {
+ IMember element = (IMember) script.getElementAt(fContext.getOffset());
+ IType type = element.getDeclaringType();
+ List<CompletionProposal> list = sort(suggestMethods(100, type));
+ for (CompletionProposal proposal : list) {
+ fRequestor.accept(proposal);
+ }
+ }
+
private List<CompletionProposal> sort(Map<String, CompletionProposal> proposals) {
List<CompletionProposal> list = new ArrayList<CompletionProposal>(proposals.values());
Collections.sort(list, new CompletionProposalComparator());
@@ -171,13 +172,12 @@
}
}
proposals.putAll(addModuleMethods(confidence, type));
- proposals.putAll(addSuperClassMethods(confidence, type));
+ if (!type.isModule()) proposals.putAll(addSuperClassMethods(confidence, type));
return proposals;
}
private Map<String, CompletionProposal> addModuleMethods(int confidence, IType type) {
Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
- if (type.isModule()) return proposals;
String[] modules = null;
try {
modules = type.getIncludedModuleNames();
@@ -204,7 +204,6 @@
Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
String superClass = type.getSuperclassName();
if (superClass == null) return proposals;
- if (type.isModule() && superClass.equals("Module")) return proposals;
RubyElementRequestor requestor = new RubyElementRequestor(type.getRubyScript());
IType[] supers = requestor.findType(superClass);
for (int i = 0; i < supers.length; i++) {
@@ -495,6 +494,7 @@
// Find source and parse
RubyType rubyType = (RubyType) type;
String source = rubyType.getSource();
+ if (source == null) return new ArrayList<Node>(0);
// FIXME Why does the parser balk on \r chars?
source = source.replace('\r', ' ');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|