|
From: <caw...@us...> - 2007-04-13 14:44:34
|
Revision: 2308
http://svn.sourceforge.net/rubyeclipse/?rev=2308&view=rev
Author: cawilliams
Date: 2007-04-13 07:44:33 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
getting closer...
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/FieldDeclarationMatch.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * A Java search match that represents a field declaration.
+ * The element is an <code>IField</code>.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @since 3.0
+ */
+public class FieldDeclarationMatch extends SearchMatch {
+
+ /**
+ * Creates a new field declaration match.
+ *
+ * @param element the field declaration
+ * @param accuracy one of A_ACCURATE or 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
+ */
+ public FieldDeclarationMatch(IRubyElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) {
+ super(element, accuracy, offset, length, participant, resource);
+ }
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/MethodDeclarationMatch.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+
+/**
+ * A Java search match that represents a method declaration.
+ * The element is an <code>IMethod</code>.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @since 3.0
+ */
+public class MethodDeclarationMatch extends SearchMatch {
+
+ /**
+ * Creates a new method declaration match.
+ *
+ * @param element the method declaration
+ * @param accuracy one of A_ACCURATE or 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
+ */
+ public MethodDeclarationMatch(IRubyElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) {
+ super(element, accuracy, offset, length, participant, resource);
+ }
+
+}
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-04-13 14:12:19 UTC (rev 2307)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchPattern.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -3,7 +3,9 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
import org.rubypeople.rdt.internal.core.search.matching.InternalSearchPattern;
+import org.rubypeople.rdt.internal.core.search.matching.OrPattern;
import org.rubypeople.rdt.internal.core.search.matching.QualifiedTypeDeclarationPattern;
+import org.rubypeople.rdt.internal.core.search.matching.TypeReferencePattern;
import org.rubypeople.rdt.internal.core.util.CharOperation;
public abstract class SearchPattern extends InternalSearchPattern {
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/TypeDeclarationMatch.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.core.search;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+
+/**
+ * A Java search match that represents a type declaration.
+ * The element is an <code>IType</code>.
+ * <p>
+ * This class is intended to be instantiated and subclassed by clients.
+ * </p>
+ *
+ * @since 1.0
+ */
+public class TypeDeclarationMatch extends SearchMatch {
+
+ /**
+ * Creates a new type declaration match.
+ *
+ * @param element the type declaration
+ * @param accuracy one of A_ACCURATE or 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
+ */
+ public TypeDeclarationMatch(IRubyElement element, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) {
+ super(element, accuracy, offset, length, participant, resource);
+ }
+
+}
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/AndPattern.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.search.matching;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchParticipant;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.compiler.util.SimpleSet;
+import org.rubypeople.rdt.internal.core.index.EntryResult;
+import org.rubypeople.rdt.internal.core.index.Index;
+import org.rubypeople.rdt.internal.core.search.IndexQueryRequestor;
+
+/**
+ * Query the index multiple times and do an 'and' on the results.
+ */
+public abstract class AndPattern extends RubySearchPattern { // TODO should rename IntersectingPattern, and make AndPattern a true subclass
+
+public AndPattern(int patternKind, int matchRule) {
+ super(patternKind, matchRule);
+}
+public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant, IRubySearchScope scope, IProgressMonitor progressMonitor) throws IOException {
+ if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException();
+
+ this.resetQuery();
+ SimpleSet intersectedNames = null;
+ try {
+ index.startQuery();
+ do {
+ SearchPattern pattern = ((InternalSearchPattern) this).currentPattern();
+ EntryResult[] entries = ((InternalSearchPattern)pattern).queryIn(index);
+ if (entries == null) return;
+
+ SearchPattern decodedResult = pattern.getBlankPattern();
+ SimpleSet newIntersectedNames = new SimpleSet(3);
+ for (int i = 0, l = entries.length; i < l; i++) {
+ if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException();
+
+ EntryResult entry = entries[i];
+ decodedResult.decodeIndexKey(entry.getWord());
+ if (pattern.matchesDecodedKey(decodedResult)) {
+ String[] names = entry.getDocumentNames(index);
+ if (intersectedNames != null) {
+ for (int j = 0, n = names.length; j < n; j++)
+ if (intersectedNames.includes(names[j]))
+ newIntersectedNames.add(names[j]);
+ } else {
+ for (int j = 0, n = names.length; j < n; j++)
+ newIntersectedNames.add(names[j]);
+ }
+ }
+ }
+
+ if (newIntersectedNames.elementSize == 0) return;
+ intersectedNames = newIntersectedNames;
+ } while (this.hasNextQuery());
+ } finally {
+ index.stopQuery();
+ }
+
+ String containerPath = index.containerPath;
+ Object[] names = intersectedNames.values;
+ for (int i = 0, l = names.length; i < l; i++)
+ if (names[i] != null)
+ ((InternalSearchPattern) this).acceptMatch((String) names[i], containerPath, null/*no pattern*/, requestor, participant, scope); // AndPatterns cannot provide the decoded result
+}
+/**
+ * Returns whether another query must be done.
+ */
+protected abstract boolean hasNextQuery();
+/**
+ * Resets the query and prepares this pattern to be queried.
+ */
+protected abstract void resetQuery();
+}
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-04-13 14:12:19 UTC (rev 2307)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MatchLocator.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -14,12 +14,15 @@
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.FieldDeclarationMatch;
import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.MethodDeclarationMatch;
import org.rubypeople.rdt.core.search.SearchDocument;
import org.rubypeople.rdt.core.search.SearchMatch;
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.core.search.TypeDeclarationMatch;
import org.rubypeople.rdt.internal.compiler.util.SimpleLookupTable;
import org.rubypeople.rdt.internal.core.ExternalSourceFolderRoot;
import org.rubypeople.rdt.internal.core.Openable;
@@ -74,6 +77,7 @@
// Progress information
int progressStep;
int progressWorked;
+ private PossibleMatch currentPossibleMatch;
public MatchLocator(
SearchPattern pattern,
@@ -427,10 +431,53 @@
protected void locateMatches(RubyProject rubyProject, PossibleMatch[] possibleMatches, int start, int length) throws CoreException {
for (int i = start, maxUnits = start + length; i < maxUnits; i++) {
PossibleMatch possibleMatch = possibleMatches[i];
- RubyScript script = (RubyScript) possibleMatch.openable;
- this.patternLocator.reportMatches(script, this);
+ process(possibleMatch);
possibleMatch.cleanUp();
}
}
+ protected void process(PossibleMatch possibleMatch) {
+ this.currentPossibleMatch = possibleMatch;
+ RubyScript script = (RubyScript) possibleMatch.openable;
+ this.patternLocator.reportMatches(script, this);
+ this.currentPossibleMatch = null;
+ }
+
+ public SearchMatch newDeclarationMatch(
+ IRubyElement element,
+ int accuracy,
+ int offset,
+ int length,
+ SearchParticipant participant,
+ IResource resource) {
+ switch (element.getElementType()) {
+// case IRubyElement.SOURCE_FOLDER:
+// return new PackageDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ case IRubyElement.TYPE:
+ return new TypeDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ case IRubyElement.FIELD:
+ return new FieldDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ case IRubyElement.METHOD:
+ return new MethodDeclarationMatch(element, accuracy, offset, length, participant, resource);
+// case IRubyElement.LOCAL_VARIABLE:
+// return new LocalVariableDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ default:
+ return null;
+ }
+ }
+
+ public SearchMatch newDeclarationMatch(
+ IRubyElement element,
+ int accuracy,
+ int offset,
+ int length) {
+ SearchParticipant participant = getParticipant();
+ IResource resource = this.currentPossibleMatch.resource;
+ return newDeclarationMatch(element, accuracy, offset, length, participant, resource);
+ }
+
+ public SearchParticipant getParticipant() {
+ return this.currentPossibleMatch.document.getParticipant();
+ }
+
}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java 2007-04-13 14:12:19 UTC (rev 2307)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/MethodLocator.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -1,8 +1,11 @@
package org.rubypeople.rdt.internal.core.search.matching;
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.core.IMember;
import org.rubypeople.rdt.core.IMethod;
import org.rubypeople.rdt.core.IParent;
import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.RubyScript;
@@ -14,7 +17,7 @@
super(pattern);
this.pattern = pattern;
}
-
+
@Override
public void reportMatches(RubyScript script, MatchLocator locator) {
reportMatches((IParent) script, locator);
@@ -26,8 +29,17 @@
for (int i = 0; i < children.length; i++) {
IRubyElement child = children[i];
if (child.isType(IRubyElement.METHOD)) {
- int match = reportMethodDeclaration((IMethod) child);
- if (match != IMPOSSIBLE_MATCH) locator.report(locator.newMethodDeclarationMatch());
+ int accuracy = getAccuracy((IMethod) child);
+ if (accuracy != IMPOSSIBLE_MATCH) {
+ IMember member = (IMember) child;
+ ISourceRange range = member.getSourceRange();
+ try {
+ locator.report(locator.newDeclarationMatch(child, accuracy, range.getOffset(), range.getLength()));
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
if (child instanceof IParent) {
IParent parentTwo = (IParent) child;
@@ -37,27 +49,29 @@
} catch (RubyModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
- private int reportMethodDeclaration(IMethod method) {
- if (!this.pattern.findDeclarations) return IMPOSSIBLE_MATCH;
+ private int getAccuracy(IMethod method) {
+ if (!this.pattern.findDeclarations)
+ return IMPOSSIBLE_MATCH;
// Verify method name
- if (!matchesName(this.pattern.selector, method.getElementName().toCharArray())) return IMPOSSIBLE_MATCH;
-
+ if (!matchesName(this.pattern.selector, method.getElementName().toCharArray()))
+ return IMPOSSIBLE_MATCH;
+
// Verify parameter count
- boolean resolve = ((InternalSearchPattern)this.pattern).mustResolve;
if (this.pattern.parameterNames != null) {
int length = this.pattern.parameterNames.length;
- String[] args = method.getParameterNames();
+ String[] args = null;
+ try {
+ args = method.getParameterNames();
+ } catch (RubyModelException e) {
+ // ignore
+ }
int argsLength = args == null ? 0 : args.length;
- if (length != argsLength) return IMPOSSIBLE_MATCH;
-// for (int i = 0; i < argsLength; i++) {
-// if (args != null && !matchesTypeReference(this.pattern.parameterNames[i], ((Argument) args[i]).type)) {
-// return IMPOSSIBLE_MATCH;
-// }
-// }
+ if (length != argsLength)
+ return IMPOSSIBLE_MATCH;
}
// Method declaration may match pattern
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/matching/TypeReferencePattern.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.core.search.matching;
+
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.search.SearchPattern;
+import org.rubypeople.rdt.internal.core.search.indexing.IIndexConstants;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+import org.rubypeople.rdt.internal.core.util.Util;
+
+ public class TypeReferencePattern extends AndPattern implements IIndexConstants {
+
+ protected char[] qualification;
+ protected char[] simpleName;
+
+ protected char[] currentCategory;
+
+ /* Optimization: case where simpleName == null */
+ public int segmentsSize;
+ protected char[][] segments;
+ protected int currentSegment;
+
+ protected static char[][] CATEGORIES = { REF };
+
+ public TypeReferencePattern(char[] qualification, char[] simpleName, int matchRule) {
+ this(matchRule);
+
+ this.qualification = isCaseSensitive() ? qualification : CharOperation.toLowerCase(qualification);
+ this.simpleName = (isCaseSensitive() || isCamelCase()) ? simpleName : CharOperation.toLowerCase(simpleName);
+
+ if (simpleName == null)
+ this.segments = this.qualification == null ? ONE_STAR_CHAR : CharOperation.splitOn("::", this.qualification);
+ else
+ this.segments = null;
+
+ if (this.segments == null)
+ if (this.qualification == null)
+ this.segmentsSize = 0;
+ else
+ this.segmentsSize = CharOperation.occurencesOf("::", this.qualification) + 1;
+ else
+ this.segmentsSize = this.segments.length;
+
+ ((InternalSearchPattern)this).mustResolve = true; // always resolve (in case of a simple name reference being a potential match)
+ }
+ TypeReferencePattern(int matchRule) {
+ super(TYPE_REF_PATTERN, matchRule);
+ }
+ public void decodeIndexKey(char[] key) {
+ this.simpleName = key;
+ }
+ public SearchPattern getBlankPattern() {
+ return new TypeReferencePattern(R_EXACT_MATCH | R_CASE_SENSITIVE);
+ }
+ public char[] getIndexKey() {
+ if (this.simpleName != null)
+ return this.simpleName;
+
+ // Optimization, eg. type reference is 'org.eclipse.jdt.core.*'
+ if (this.currentSegment >= 0)
+ return this.segments[this.currentSegment];
+ return null;
+ }
+ public char[][] getIndexCategories() {
+ return CATEGORIES;
+ }
+ protected boolean hasNextQuery() {
+ if (this.segments == null) return false;
+
+ // Optimization, eg. type reference is 'org.eclipse.jdt.core.*'
+ // if package has at least 4 segments, don't look at the first 2 since they are mostly
+ // redundant (eg. in 'org.eclipse.jdt.core.*' 'org.eclipse' is used all the time)
+ return --this.currentSegment >= (this.segments.length >= 4 ? 2 : 0);
+ }
+
+ public boolean matchesDecodedKey(SearchPattern decodedPattern) {
+ return true; // index key is not encoded so query results all match
+ }
+
+ protected void resetQuery() {
+ /* walk the segments from end to start as it will find less potential references using 'lang' than 'java' */
+ if (this.segments != null)
+ this.currentSegment = this.segments.length - 1;
+ }
+ protected StringBuffer print(StringBuffer output) {
+ output.append("TypeReferencePattern: qualification<"); //$NON-NLS-1$
+ if (qualification != null)
+ output.append(qualification);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append(">, type<"); //$NON-NLS-1$
+ if (simpleName != null)
+ output.append(simpleName);
+ else
+ output.append("*"); //$NON-NLS-1$
+ output.append(">"); //$NON-NLS-1$
+ return super.print(output);
+ }
+}
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-04-13 14:12:19 UTC (rev 2307)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-04-13 14:44:33 UTC (rev 2308)
@@ -1469,4 +1469,28 @@
}
return resultEnd;
}
+
+public static char[][] splitOn(String divider, char[] key) {
+ String newKey = new String(key);
+ String[] result = newKey.split(divider);
+ char[][] resultEnd = new char[result.length][];
+ for (int i = 0; i < resultEnd.length; i++) {
+ resultEnd[i] = result[i].toCharArray();
+ }
+ return resultEnd;
+
}
+
+public static int occurencesOf(String toBeFound, char[] originalString) {
+ String newKey = new String(originalString);
+ int count = 0;
+ int index = newKey.indexOf(toBeFound);
+ while (index > -1) {
+ count++;
+ if (newKey.length() < index + toBeFound.length()) break;
+ newKey = newKey.substring(index + toBeFound.length());
+ index = newKey.indexOf(toBeFound);
+ }
+ return count;
+}
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|