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-08-24 17:05:20
|
Revision: 3072
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3072&view=rev
Author: cawilliams
Date: 2007-08-24 10:05:15 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
an initial cut at #4846 - Create a Call Hierarchy View
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchy.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchy.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchy.java 2007-08-24 17:05:15 UTC (rev 3072)
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * 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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchEngine;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.rubyeditor.ASTProvider;
+import org.rubypeople.rdt.internal.ui.util.StringMatcher;
+
+public class CallHierarchy {
+ private static final String PREF_USE_IMPLEMENTORS= "PREF_USE_IMPLEMENTORS"; //$NON-NLS-1$
+ private static final String PREF_USE_FILTERS = "PREF_USE_FILTERS"; //$NON-NLS-1$
+ private static final String PREF_FILTERS_LIST = "PREF_FILTERS_LIST"; //$NON-NLS-1$
+
+ private static final String DEFAULT_IGNORE_FILTERS = "java.*,javax.*"; //$NON-NLS-1$
+ private static CallHierarchy fgInstance;
+ private IRubySearchScope fSearchScope;
+ private StringMatcher[] fFilters;
+
+ public static CallHierarchy getDefault() {
+ if (fgInstance == null) {
+ fgInstance = new CallHierarchy();
+ }
+
+ return fgInstance;
+ }
+
+ public boolean isSearchUsingImplementorsEnabled() {
+ IPreferenceStore settings = RubyPlugin.getDefault().getPreferenceStore();
+
+ return settings.getBoolean(PREF_USE_IMPLEMENTORS);
+ }
+
+ public void setSearchUsingImplementorsEnabled(boolean enabled) {
+ IPreferenceStore settings = RubyPlugin.getDefault().getPreferenceStore();
+
+ settings.setValue(PREF_USE_IMPLEMENTORS, enabled);
+ }
+
+ public Collection getImplementingMethods(IMethod method) {
+// FIXME Implement this!
+// if (isSearchUsingImplementorsEnabled()) {
+// IRubyElement[] result = Implementors.getInstance().searchForImplementors(new IRubyElement[] {
+// method
+// }, new NullProgressMonitor());
+//
+// if ((result != null) && (result.length > 0)) {
+// return Arrays.asList(result);
+// }
+// }
+
+ return new ArrayList(0);
+ }
+
+ public Collection getInterfaceMethods(IMethod method) {
+ // FIXME Implement this!
+// if (isSearchUsingImplementorsEnabled()) {
+// IRubyElement[] result = Implementors.getInstance().searchForInterfaces(new IRubyElement[] {
+// method
+// }, new NullProgressMonitor());
+//
+// if ((result != null) && (result.length > 0)) {
+// return Arrays.asList(result);
+// }
+// }
+
+ return new ArrayList(0);
+ }
+
+ public MethodWrapper getCallerRoot(IMethod method) {
+ return new CallerMethodWrapper(null, new MethodCall(method));
+ }
+
+ public MethodWrapper getCalleeRoot(IMethod method) {
+ return new CalleeMethodWrapper(null, new MethodCall(method));
+ }
+
+ public static CallLocation getCallLocation(Object element) {
+ CallLocation callLocation = null;
+
+ if (element instanceof MethodWrapper) {
+ MethodWrapper methodWrapper = (MethodWrapper) element;
+ MethodCall methodCall = methodWrapper.getMethodCall();
+
+ if (methodCall != null) {
+ callLocation = methodCall.getFirstCallLocation();
+ }
+ } else if (element instanceof CallLocation) {
+ callLocation = (CallLocation) element;
+ }
+
+ return callLocation;
+ }
+
+ public IRubySearchScope getSearchScope() {
+ if (fSearchScope == null) {
+ fSearchScope= SearchEngine.createWorkspaceScope();
+ }
+
+ return fSearchScope;
+ }
+
+ public void setSearchScope(IRubySearchScope searchScope) {
+ this.fSearchScope = searchScope;
+ }
+
+ /**
+ * Checks whether the fully qualified name is ignored by the set filters.
+ *
+ * @param fullyQualifiedName
+ *
+ * @return True if the fully qualified name is ignored.
+ */
+ public boolean isIgnored(String fullyQualifiedName) {
+ if ((getIgnoreFilters() != null) && (getIgnoreFilters().length > 0)) {
+ for (int i = 0; i < getIgnoreFilters().length; i++) {
+ String fullyQualifiedName1 = fullyQualifiedName;
+
+ if (getIgnoreFilters()[i].match(fullyQualifiedName1)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public boolean isFilterEnabled() {
+ IPreferenceStore settings = RubyPlugin.getDefault().getPreferenceStore();
+ return settings.getBoolean(PREF_USE_FILTERS);
+ }
+
+ public void setFilterEnabled(boolean filterEnabled) {
+ IPreferenceStore settings = RubyPlugin.getDefault().getPreferenceStore();
+ settings.setValue(PREF_USE_FILTERS, filterEnabled);
+ }
+
+ /**
+ * Returns the current filters as a string.
+ */
+ public String getFilters() {
+ IPreferenceStore settings = RubyPlugin.getDefault().getPreferenceStore();
+
+ return settings.getString(PREF_FILTERS_LIST);
+ }
+
+ public void setFilters(String filters) {
+ fFilters = null;
+
+ IPreferenceStore settings = RubyPlugin.getDefault().getPreferenceStore();
+ settings.setValue(PREF_FILTERS_LIST, filters);
+ }
+
+ /**
+ * Returns filters for packages which should not be included in the search results.
+ *
+ * @return StringMatcher[]
+ */
+ private StringMatcher[] getIgnoreFilters() {
+ if (fFilters == null) {
+ String filterString = null;
+
+ if (isFilterEnabled()) {
+ filterString = getFilters();
+
+ if (filterString == null) {
+ filterString = DEFAULT_IGNORE_FILTERS;
+ }
+ }
+
+ if (filterString != null) {
+ fFilters = parseList(filterString);
+ } else {
+ fFilters = null;
+ }
+ }
+
+ return fFilters;
+ }
+
+ /**
+ * Parses the comma separated string into an array of StringMatcher objects
+ *
+ * @return list
+ */
+ private static StringMatcher[] parseList(String listString) {
+ List list = new ArrayList(10);
+ StringTokenizer tokenizer = new StringTokenizer(listString, ","); //$NON-NLS-1$
+
+ while (tokenizer.hasMoreTokens()) {
+ String textFilter = tokenizer.nextToken().trim();
+ list.add(new StringMatcher(textFilter, false, false));
+ }
+
+ return (StringMatcher[]) list.toArray(new StringMatcher[list.size()]);
+ }
+
+ static Node getRubyScriptNode(IMember member, boolean resolveBindings) {
+ IRubyScript icu= member.getRubyScript();
+ if (icu != null && icu.exists()) {
+ return ASTProvider.getASTProvider().getAST(icu, ASTProvider.WAIT_YES, null);
+ }
+ return null;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-24 17:02:43
|
Revision: 3071
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3071&view=rev
Author: cawilliams
Date: 2007-08-24 10:02:38 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
an initial cut at #4846 - Create a Call Hierarchy View
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IType.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchEngine.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/Openable.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyMethod.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/search/BasicSearchEngine.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/HierarchyScope.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java 2007-08-24 17:02:19 UTC (rev 3070)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -45,4 +45,6 @@
public int getNumberOfParameters() throws RubyModelException;
+ public boolean isPrivate() throws RubyModelException;
+
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IType.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IType.java 2007-08-24 17:02:19 UTC (rev 3070)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IType.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -210,4 +210,25 @@
*/
ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws RubyModelException;
+ /**
+ * Creates and returns a type hierarchy for this type containing
+ * this type, all of its supertypes, and all its subtypes in the workspace,
+ * considering types in the working copies with the given owner.
+ * In other words, the owner's working copies will take
+ * precedence over their original compilation units in the workspace.
+ * <p>
+ * Note that if a working copy is empty, it will be as if the original compilation
+ * unit had been deleted.
+ * <p>
+ *
+ * @param owner the owner of working copies that take precedence over their original compilation units
+ * @param monitor the given progress monitor
+ * @return a type hierarchy for this type containing
+ * this type, all of its supertypes, and all its subtypes in the workspace
+ * @exception RubyModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource.
+ * @since 3.0
+ */
+ ITypeHierarchy newTypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor) throws RubyModelException;
+
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchEngine.java 2007-08-24 17:02:19 UTC (rev 3070)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/search/SearchEngine.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -3,6 +3,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
import org.rubypeople.rdt.internal.core.search.BasicSearchEngine;
@@ -142,7 +143,7 @@
/**
* Searches for matches of a given search pattern. Search patterns can be created using helper
- * methods (from a String pattern or a Java element) and encapsulate the description of what is
+ * methods (from a String pattern or a Ruby element) and encapsulate the description of what is
* being searched (for example, search method declarations in a case sensitive way).
*
* @param pattern the pattern to search
@@ -160,4 +161,17 @@
this.basicEngine.search(pattern, participants, scope, requestor, monitor);
}
+ /**
+ * Returns a Ruby search scope limited to the hierarchy of the given type.
+ * The Ruby elements resulting from a search with this scope will
+ * be types in this hierarchy, or members of the types in this hierarchy.
+ *
+ * @param type the focus of the hierarchy scope
+ * @return a new hierarchy scope
+ * @exception RubyModelException if the hierarchy could not be computed on the given type
+ */
+ public static IRubySearchScope createHierarchyScope(IType type) throws RubyModelException {
+ return BasicSearchEngine.createHierarchyScope(type);
+ }
+
}
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-08-24 17:02:19 UTC (rev 3070)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -926,5 +926,9 @@
return null;
}
+ public boolean isPrivate() throws RubyModelException {
+ return false;
+ }
+
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java 2007-08-24 17:02:19 UTC (rev 3070)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -102,7 +102,7 @@
IBuffer buffer = getBufferManager().getBuffer(this);
if (buffer == null) {
// try to (re)open a buffer
- buffer = openBuffer(null);
+ buffer = openBuffer(null, info);
}
return buffer;
}
@@ -113,8 +113,9 @@
* Opens a buffer on the contents of this element, and returns the buffer,
* or returns <code>null</code> if opening fails. By default, do nothing -
* subclasses that have buffers must override as required.
+ * @param info
*/
- protected IBuffer openBuffer(IProgressMonitor pm) {
+ protected IBuffer openBuffer(IProgressMonitor pm, Object info) throws RubyModelException {
return null;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyMethod.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyMethod.java 2007-08-24 17:02:19 UTC (rev 3070)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyMethod.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -135,5 +135,9 @@
}
return method;
}
+
+ public boolean isPrivate() throws RubyModelException {
+ return getVisibility() == PRIVATE;
+ }
}
\ No newline at end of file
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-08-24 17:02:19 UTC (rev 3070)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyType.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -328,6 +328,20 @@
}
/**
+ * @see IType#newTypeHierarchy(WorkingCopyOwner, IProgressMonitor)
+ */
+ public ITypeHierarchy newTypeHierarchy(
+ WorkingCopyOwner owner,
+ IProgressMonitor monitor)
+ throws RubyModelException {
+
+ IRubyScript[] workingCopies = RubyModelManager.getRubyModelManager().getWorkingCopies(owner, true/*add primary working copies*/);
+ CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(this, workingCopies, SearchEngine.createWorkspaceScope(), true);
+ op.runOperation(monitor);
+ return op.getResult();
+ }
+
+ /**
* @see IType
*/
public ITypeHierarchy newSupertypeHierarchy(IProgressMonitor monitor) throws RubyModelException {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-08-24 17:02:19 UTC (rev 3070)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -561,4 +561,18 @@
}
return buffer.toString();
}
+
+ /**
+ * @see SearchEngine#createHierarchyScope(IType) for detailed comment.
+ */
+ public static IRubySearchScope createHierarchyScope(IType type) throws RubyModelException {
+ return createHierarchyScope(type, DefaultWorkingCopyOwner.PRIMARY);
+ }
+
+ /**
+ * @see SearchEngine#createHierarchyScope(IType,WorkingCopyOwner) for detailed comment.
+ */
+ public static IRubySearchScope createHierarchyScope(IType type, WorkingCopyOwner owner) throws RubyModelException {
+ return new HierarchyScope(type, owner);
+ }
}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/HierarchyScope.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/HierarchyScope.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/HierarchyScope.java 2007-08-24 17:02:38 UTC (rev 3071)
@@ -0,0 +1,307 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.ILoadpathEntry;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyElementDelta;
+import org.rubypeople.rdt.core.IRubyModel;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.internal.core.RubyElement;
+import org.rubypeople.rdt.internal.core.RubyModelManager;
+import org.rubypeople.rdt.internal.core.RubyProject;
+import org.rubypeople.rdt.internal.core.hierarchy.TypeHierarchy;
+
+/**
+ * Scope limited to the subtype and supertype hierarchy of a given type.
+ */
+public class HierarchyScope implements IRubySearchScope {
+
+ public IType focusType;
+ private String focusPath;
+ private WorkingCopyOwner owner;
+
+ private ITypeHierarchy hierarchy;
+ private IType[] types;
+ private HashSet resourcePaths;
+ private IPath[] enclosingProjectsAndJars;
+
+ protected IResource[] elements;
+ protected int elementCount;
+
+ public boolean needsRefresh;
+
+ /* (non-Rubydoc)
+ * Adds the given resource to this search scope.
+ */
+ public void add(IResource element) {
+ if (this.elementCount == this.elements.length) {
+ System.arraycopy(
+ this.elements,
+ 0,
+ this.elements = new IResource[this.elementCount * 2],
+ 0,
+ this.elementCount);
+ }
+ elements[elementCount++] = element;
+ }
+
+ /* (non-Rubydoc)
+ * Creates a new hiearchy scope for the given type.
+ */
+ public HierarchyScope(IType type, WorkingCopyOwner owner) throws RubyModelException {
+ this.focusType = type;
+ this.owner = owner;
+
+ this.enclosingProjectsAndJars = this.computeProjectsAndJars(type);
+
+ // resource path
+ ISourceFolderRoot root = (ISourceFolderRoot)type.getSourceFolder().getParent();
+ this.focusPath = type.getPath().toString();
+
+ this.needsRefresh = true;
+
+ //disabled for now as this could be expensive
+ //RubyModelManager.getRubyModelManager().rememberScope(this);
+ }
+ private void buildResourceVector() {
+ HashMap resources = new HashMap();
+ HashMap paths = new HashMap();
+ this.types = this.hierarchy.getAllTypes();
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ for (int i = 0; i < this.types.length; i++) {
+ IType type = this.types[i];
+ IResource resource = type.getResource();
+ if (resource != null && resources.get(resource) == null) {
+ resources.put(resource, resource);
+ add(resource);
+ }
+ ISourceFolderRoot root =
+ (ISourceFolderRoot) type.getSourceFolder().getParent();
+
+ // type is a project
+ paths.put(type.getRubyProject().getProject().getFullPath(), type);
+
+ }
+ this.enclosingProjectsAndJars = new IPath[paths.size()];
+ int i = 0;
+ for (Iterator iter = paths.keySet().iterator(); iter.hasNext();) {
+ this.enclosingProjectsAndJars[i++] = (IPath) iter.next();
+ }
+ }
+ /*
+ * Computes the paths of projects and jars that the hierarchy on the given type could contain.
+ * This is a super set of the project and jar paths once the hierarchy is computed.
+ */
+ private IPath[] computeProjectsAndJars(IType type) throws RubyModelException {
+ HashSet set = new HashSet();
+ ISourceFolderRoot root = (ISourceFolderRoot)type.getSourceFolder().getParent();
+ if (root.isArchive()) {
+ // add the root
+ set.add(root.getPath());
+ // add all projects that reference this archive and their dependents
+ IPath rootPath = root.getPath();
+ IRubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
+ IRubyProject[] projects = model.getRubyProjects();
+ HashSet visited = new HashSet();
+ for (int i = 0; i < projects.length; i++) {
+ RubyProject project = (RubyProject) projects[i];
+ ILoadpathEntry[] classpath = project.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
+ for (int j = 0; j < classpath.length; j++) {
+ if (rootPath.equals(classpath[j].getPath())) {
+ // add the project and its binary pkg fragment roots
+ ISourceFolderRoot[] roots = project.getAllSourceFolderRoots();
+ set.add(project.getPath());
+ // add the dependent projects
+ this.computeDependents(project, set, visited);
+ break;
+ }
+ }
+ }
+ } else {
+ // add all the project's pkg fragment roots
+ IRubyProject project = (IRubyProject)root.getParent();
+ ISourceFolderRoot[] roots = project.getAllSourceFolderRoots();
+ for (int i = 0; i < roots.length; i++) {
+ ISourceFolderRoot pkgFragmentRoot = roots[i];
+ set.add(pkgFragmentRoot.getParent().getPath());
+ }
+ // add the dependent projects
+ this.computeDependents(project, set, new HashSet());
+ }
+ IPath[] result = new IPath[set.size()];
+ set.toArray(result);
+ return result;
+ }
+ private void computeDependents(IRubyProject project, HashSet set, HashSet visited) {
+ if (visited.contains(project)) return;
+ visited.add(project);
+ IProject[] dependents = project.getProject().getReferencingProjects();
+ for (int i = 0; i < dependents.length; i++) {
+ try {
+ IRubyProject dependent = RubyCore.create(dependents[i]);
+ ISourceFolderRoot[] roots = dependent.getSourceFolderRoots();
+ set.add(dependent.getPath());
+ for (int j = 0; j < roots.length; j++) {
+ ISourceFolderRoot pkgFragmentRoot = roots[j];
+ if (pkgFragmentRoot.isArchive()) {
+ set.add(pkgFragmentRoot.getPath());
+ }
+ }
+ this.computeDependents(dependent, set, visited);
+ } catch (RubyModelException e) {
+ // project is not a java project
+ }
+ }
+ }
+ /* (non-Rubydoc)
+ * @see IRubySearchScope#encloses(String)
+ */
+ public boolean encloses(String resourcePath) {
+ if (this.hierarchy == null) {
+ if (resourcePath.equals(this.focusPath)) {
+ return true;
+ } else {
+ if (this.needsRefresh) {
+ try {
+ this.initialize();
+ } catch (RubyModelException e) {
+ return false;
+ }
+ } else {
+ // the scope is used only to find enclosing projects and jars
+ // clients is responsible for filtering out elements not in the hierarchy (see SearchEngine)
+ return true;
+ }
+ }
+ }
+ if (this.needsRefresh) {
+ try {
+ this.refresh();
+ } catch(RubyModelException e) {
+ return false;
+ }
+ }
+
+ for (int i = 0; i < this.elementCount; i++) {
+ if (resourcePath.startsWith(this.elements[i].getFullPath().toString())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ /* (non-Rubydoc)
+ * @see IRubySearchScope#encloses(IRubyElement)
+ */
+ public boolean encloses(IRubyElement element) {
+ if (this.hierarchy == null) {
+ if (this.focusType.equals(element.getAncestor(IRubyElement.TYPE))) {
+ return true;
+ } else {
+ if (this.needsRefresh) {
+ try {
+ this.initialize();
+ } catch (RubyModelException e) {
+ return false;
+ }
+ } else {
+ // the scope is used only to find enclosing projects and jars
+ // clients is responsible for filtering out elements not in the hierarchy (see SearchEngine)
+ return true;
+ }
+ }
+ }
+ if (this.needsRefresh) {
+ try {
+ this.refresh();
+ } catch(RubyModelException e) {
+ return false;
+ }
+ }
+ IType type = null;
+ if (element instanceof IType) {
+ type = (IType) element;
+ } else if (element instanceof IMember) {
+ type = ((IMember) element).getDeclaringType();
+ }
+ if (type != null) {
+ if (this.hierarchy.contains(type)) {
+ return true;
+ } else {
+ // be flexible: look at original element (see bug 14106 Declarations in Hierarchy does not find declarations in hierarchy)
+ IType original;
+ if ((original = (IType)type.getPrimaryElement()) != null) {
+ return this.hierarchy.contains(original);
+ }
+ }
+ }
+ return false;
+ }
+ /* (non-Rubydoc)
+ * @see IRubySearchScope#enclosingProjectsAndJars()
+ * @deprecated
+ */
+ public IPath[] enclosingProjectsAndJars() {
+ if (this.needsRefresh) {
+ try {
+ this.refresh();
+ } catch(RubyModelException e) {
+ return new IPath[0];
+ }
+ }
+ return this.enclosingProjectsAndJars;
+ }
+ protected void initialize() throws RubyModelException {
+ this.resourcePaths = new HashSet();
+ this.elements = new IResource[5];
+ this.elementCount = 0;
+ this.needsRefresh = false;
+ if (this.hierarchy == null) {
+ this.hierarchy = this.focusType.newTypeHierarchy(this.owner, null);
+ } else {
+ this.hierarchy.refresh(null);
+ }
+ this.buildResourceVector();
+ }
+ /*
+ * @see AbstractSearchScope#processDelta(IRubyElementDelta)
+ */
+ public void processDelta(IRubyElementDelta delta) {
+ if (this.needsRefresh) return;
+ this.needsRefresh = this.hierarchy == null ? false : ((TypeHierarchy)this.hierarchy).isAffected(delta);
+ }
+ protected void refresh() throws RubyModelException {
+ if (this.hierarchy != null) {
+ this.initialize();
+ }
+ }
+ public String toString() {
+ return "HierarchyScope on " + ((RubyElement)this.focusType).toStringWithAncestors(); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/HierarchyScope.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-24 17:02:22
|
Revision: 3070
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3070&view=rev
Author: cawilliams
Date: 2007-08-24 10:02:19 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
an initial cut at #4846 - Create a Call Hierarchy View
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java
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/RubyOutlinePage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/SelectionDispatchAction.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_callees.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_callers.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_cancel.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_callees.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_callers.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_cancel.gif
trunk/org.rubypeople.rdt.ui/icons/full/eview16/call_hierarchy.gif
trunk/org.rubypeople.rdt.ui/icons/full/ovr16/maxlevel_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/ovr16/recursive_co.gif
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyVisitor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallLocation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallSearchResultCollector.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeAnalyzerVisitor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeMethodWrapper.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallerMethodWrapper.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodCall.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodReferencesSearchRequestor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodWrapper.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyImageDescriptor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyLabelDecorator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyTransferDropAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyUI.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CancelSearchAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CopyCallHierarchyAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/DeferredMethodWrapper.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/FiltersDialog.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/FocusOnSelectionAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/HistoryAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/HistoryDropDownAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/HistoryListAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/ICallHierarchyViewPart.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/LocationLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/LocationViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/MethodWrapperWorkbenchAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/OpenLocationAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/RefreshAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/SearchScopeAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/SearchScopeActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/SearchScopeProjectAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/SearchScopeWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/SearchScopeWorkspaceAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/SearchUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/SelectWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/ToggleCallModeAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/ToggleOrientationAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/TreeRoot.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/TreeTermination.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/RdtViewerDropAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SelectionTransferDropAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/OpenCallHierarchyAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/OpenTypeHierarchyAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/OpenViewActionGroup.java
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_callees.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_callees.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_callers.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_callers.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_cancel.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/ch_cancel.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_callees.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_callees.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_callers.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_callers.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_cancel.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/ch_cancel.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/eview16/call_hierarchy.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/eview16/call_hierarchy.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/ovr16/maxlevel_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/ovr16/maxlevel_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/ovr16/recursive_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/ovr16/recursive_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-08-24 16:07:58 UTC (rev 3069)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-08-24 17:02:19 UTC (rev 3070)
@@ -8,6 +8,8 @@
hyperlinkProvider=Hyperlink provider
+callHierarchyViewName=Call Hierarchy
+
# Browsing
Browsing.perspectiveName= Ruby Browsing
Browsing.viewCategoryName= Ruby Browsing
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-08-24 16:07:58 UTC (rev 3069)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-08-24 17:02:19 UTC (rev 3070)
@@ -398,6 +398,12 @@
class="org.rubypeople.rdt.internal.ui.typehierarchy.TypeHierarchyViewPart"
id="org.rubypeople.rdt.ui.TypeHierarchy">
</view>
+ <view
+ category="org.rubypeople.rdt.ui.ruby"
+ class="org.rubypeople.rdt.internal.ui.callhierarchy.CallHierarchyViewPart"
+ icon="$nl$/icons/full/eview16/call_hierarchy.gif"
+ id="org.rubypeople.rdt.callhierarchy.view"
+ name="%callHierarchyViewName"/>
</extension>
<extension point="org.eclipse.ui.editors">
<editor
@@ -499,6 +505,10 @@
commandId="org.rubypeople.rdt.ui.edit.text.ruby.open.type.hierarchy"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
+ sequence="CTRL+ALT+H"
+ commandId="org.rubypeople.rdt.ui.edit.text.ruby.open.call.hierarchy"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ <key
sequence="M1+M2+T"
contextId="org.rubypeople.rdt.ui.rubyEditorScope"
commandId="org.rubypeople.rdt.ui.edit.text.ruby.open.type"
@@ -703,6 +713,11 @@
description="%ActionDefinition.openTypeHierarchy.description"
id="org.rubypeople.rdt.ui.edit.text.ruby.open.type.hierarchy"
name="%ActionDefinition.openTypeHierarchy.name"/>
+ <command
+ categoryId="org.eclipse.ui.category.navigate"
+ description="%ActionDefinition.openCallHierarchy.description"
+ id="org.rubypeople.rdt.ui.edit.text.ruby.open.call.hierarchy"
+ name="%ActionDefinition.openCallHierarchy.name"/>
</extension>
<extension
@@ -903,6 +918,13 @@
menubarPath="navigate/open.ext"
id="org.rubypeople.rdt.ui.actions.OpenTypeHierarchy">
</action>
+ <action
+ definitionId="org.rubypeople.rdt.ui.edit.text.ruby.open.call.hierarchy"
+ label="%OpenCallHierarchyAction.label"
+ retarget="true"
+ menubarPath="navigate/open.ext"
+ id="org.rubypeople.rdt.ui.actions.OpenCallHierarchy">
+ </action>
</actionSet>
</extension>
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyMessages.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.corext.callhierarchy;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class CallHierarchyMessages extends NLS {
+
+ private static final String BUNDLE_NAME= "org.rubypeople.rdt.internal.corext.callhierarchy.CallHierarchyMessages";//$NON-NLS-1$
+
+ private CallHierarchyMessages() {
+ // Do not instantiate
+ }
+
+ public static String CallerMethodWrapper_taskname;
+ public static String CalleeMethodWrapper_taskname;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, CallHierarchyMessages.class);
+ }
+}
\ No newline at end of file
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyVisitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyVisitor.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+public abstract class CallHierarchyVisitor {
+ public void preVisit(MethodWrapper methodWrapper) {
+ }
+
+ public void postVisit(MethodWrapper methodWrapper) {
+ }
+
+ public boolean visit(MethodWrapper methodWrapper) {
+ return true;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallHierarchyVisitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallLocation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallLocation.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallLocation.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.rubypeople.rdt.core.IBuffer;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IOpenable;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+public class CallLocation implements IAdaptable {
+ public static final int UNKNOWN_LINE_NUMBER= -1;
+ private IMember fMember;
+ private IMember fCalledMember;
+ private int fStart;
+ private int fEnd;
+
+ private String fCallText;
+ private int fLineNumber;
+
+ public CallLocation(IMember member, IMember calledMember, int start, int end, int lineNumber) {
+ this.fMember = member;
+ this.fCalledMember = calledMember;
+ this.fStart = start;
+ this.fEnd = end;
+ this.fLineNumber= lineNumber;
+ }
+
+ /**
+ * @return IMethod
+ */
+ public IMember getCalledMember() {
+ return fCalledMember;
+ }
+
+ /**
+ *
+ */
+ public int getEnd() {
+ return fEnd;
+ }
+
+ public IMember getMember() {
+ return fMember;
+ }
+
+ /**
+ *
+ */
+ public int getStart() {
+ return fStart;
+ }
+
+ public int getLineNumber() {
+ initCallTextAndLineNumber();
+ return fLineNumber;
+ }
+
+ public String getCallText() {
+ initCallTextAndLineNumber();
+ return fCallText;
+ }
+
+ private void initCallTextAndLineNumber() {
+ if (fCallText != null)
+ return;
+
+ IBuffer buffer= getBufferForMember();
+ if (buffer == null || buffer.getLength() < fEnd) { //binary, without source attachment || buffer contents out of sync (bug 121900)
+ fCallText= ""; //$NON-NLS-1$
+ fLineNumber= UNKNOWN_LINE_NUMBER;
+ return;
+ }
+
+ fCallText= buffer.getText(fStart, (fEnd - fStart));
+
+ if (fLineNumber == UNKNOWN_LINE_NUMBER) {
+ Document document= new Document(buffer.getContents());
+ try {
+ fLineNumber= document.getLineOfOffset(fStart) + 1;
+ } catch (BadLocationException e) {
+ RubyPlugin.log(e);
+ }
+ }
+ }
+
+ /**
+ * Returns the IBuffer for the IMember represented by this CallLocation.
+ *
+ * @return IBuffer for the IMember or null if the member doesn't have a buffer (for
+ * example if it is a binary file without source attachment).
+ */
+ private IBuffer getBufferForMember() {
+ IBuffer buffer = null;
+ try {
+ IOpenable openable = fMember.getOpenable();
+ if (openable != null && fMember.exists()) {
+ buffer = openable.getBuffer();
+ }
+ } catch (RubyModelException e) {
+ RubyPlugin.log(e);
+ }
+ return buffer;
+ }
+
+ public String toString() {
+ return getCallText();
+ }
+
+ public Object getAdapter(Class adapter) {
+ if (IRubyElement.class.isAssignableFrom(adapter)) {
+ return getMember();
+ }
+
+ return null;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallLocation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallSearchResultCollector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallSearchResultCollector.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallSearchResultCollector.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IType;
+
+class CallSearchResultCollector {
+ private Map fCalledMembers;
+
+ public CallSearchResultCollector() {
+ this.fCalledMembers = createCalledMethodsData();
+ }
+
+ public Map getCallers() {
+ return fCalledMembers;
+ }
+
+ protected void addMember(IMember member, IMember calledMember, int start, int end) {
+ addMember(member, calledMember, start, end, CallLocation.UNKNOWN_LINE_NUMBER);
+ }
+
+ protected void addMember(IMember member, IMember calledMember, int start, int end, int lineNumber) {
+ if ((member != null) && (calledMember != null)) {
+ if (!isIgnored(calledMember)) {
+ MethodCall methodCall = (MethodCall) fCalledMembers.get(calledMember.getHandleIdentifier());
+
+ if (methodCall == null) {
+ methodCall = new MethodCall(calledMember);
+ fCalledMembers.put(calledMember.getHandleIdentifier(), methodCall);
+ }
+
+ methodCall.addCallLocation(new CallLocation(member, calledMember, start,
+ end, lineNumber));
+ }
+ }
+ }
+
+ protected Map createCalledMethodsData() {
+ return new HashMap();
+ }
+
+ /**
+ * Method isIgnored.
+ * @param enclosingElement
+ * @return boolean
+ */
+ private boolean isIgnored(IMember enclosingElement) {
+ IType type = getTypeOfElement(enclosingElement);
+ String fullyQualifiedName = "Object";
+ if (type != null) {
+ fullyQualifiedName = type.getFullyQualifiedName();
+ }
+
+ return CallHierarchy.getDefault().isIgnored(fullyQualifiedName);
+ }
+
+ private IType getTypeOfElement(IMember element) {
+ if (element.getElementType() == IRubyElement.TYPE) {
+ return (IType) element;
+ }
+
+ return element.getDeclaringType();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallSearchResultCollector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeAnalyzerVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeAnalyzerVisitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeAnalyzerVisitor.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,119 @@
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jruby.ast.CallNode;
+import org.jruby.ast.FCallNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.VCallNode;
+import org.jruby.evaluator.Instruction;
+import org.jruby.lexer.yacc.IDESourcePosition;
+import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.ISourceRange;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.parser.InOrderVisitor;
+import org.rubypeople.rdt.internal.core.util.ASTUtil;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+class CalleeAnalyzerVisitor extends InOrderVisitor {
+
+ private IMethod fMethod;
+ private CallSearchResultCollector fSearchResults;
+ private IProgressMonitor fProgressMonitor;
+ private int fMethodStartPosition;
+ private int fMethodEndPosition;
+ private Node fCompilationUnit;
+
+ public CalleeAnalyzerVisitor(IMethod method, Node cu, IProgressMonitor progressMonitor) {
+ fSearchResults = new CallSearchResultCollector();
+ this.fMethod = method;
+ this.fCompilationUnit= cu;
+ this.fProgressMonitor = progressMonitor;
+
+ try {
+ ISourceRange sourceRange = method.getSourceRange();
+ this.fMethodStartPosition = sourceRange.getOffset();
+ this.fMethodEndPosition = fMethodStartPosition + sourceRange.getLength();
+ } catch (RubyModelException jme) {
+ RubyPlugin.log(jme);
+ }
+ }
+
+ private void addMethodCall(ISourcePosition pos) {
+ int offset = pos.getStartOffset();
+ int endOffset = pos.getEndOffset();
+ int length = endOffset - offset;
+ try {
+ IRubyElement[] elements = fMethod.getRubyScript().codeSelect(offset, length);
+ if (elements == null) return; // FIXME Only take first, what do we do?
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i] instanceof IMember) {
+ IMember member = (IMember) elements[i];
+ fSearchResults.addMember(fMethod, member, offset, endOffset, pos.getStartLine());
+ }
+ }
+ } catch (RubyModelException e) {
+ RubyPlugin.log(e);
+ }
+ }
+
+ /**
+ * Method getCallees.
+ *
+ * @return CallerElement
+ */
+ public Map getCallees() {
+ return fSearchResults.getCallers();
+ }
+
+ // FIXME When visiting types, check to see if we even need to traverse into the type...
+
+ @Override
+ public Instruction visitVCallNode(VCallNode iVisited) {
+ if (isNodeWithinMethod(iVisited)) {
+ addMethodCall(iVisited.getPosition());
+ }
+ return super.visitVCallNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitFCallNode(FCallNode iVisited) {
+ if (isNodeWithinMethod(iVisited)) {
+ addMethodCall(iVisited.getPosition());// FIXME Only look up the hierarchy for the resolution
+ }
+ return super.visitFCallNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitCallNode(CallNode iVisited) {
+ if (isNodeWithinMethod(iVisited)) {
+ if (iVisited.getName().equals("[]"))return super.visitCallNode(iVisited);
+ String receiver = ASTUtil.stringRepresentation(iVisited.getReceiverNode());
+ ISourcePosition original = iVisited.getPosition();
+ int start = original.getStartOffset() + receiver.length() + 1;
+ ISourcePosition pos = new IDESourcePosition(original.getFile(), original.getStartLine(), original.getEndLine(), start, original.getEndOffset());
+ addMethodCall(pos);
+ }
+ return super.visitCallNode(iVisited);
+ }
+
+ private boolean isNodeWithinMethod(Node node) {
+ int nodeStartPosition = node.getPosition().getStartOffset();
+ int nodeEndPosition = node.getPosition().getEndOffset();
+
+ if (nodeStartPosition < fMethodStartPosition) {
+ return false;
+ }
+
+ if (nodeEndPosition > fMethodEndPosition) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeAnalyzerVisitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeMethodWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeMethodWrapper.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeMethodWrapper.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyElement;
+
+class CalleeMethodWrapper extends MethodWrapper {
+ private Comparator fMethodWrapperComparator = new MethodWrapperComparator();
+
+ private static class MethodWrapperComparator implements Comparator {
+ /* (non-Rubydoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object o1, Object o2) {
+ MethodWrapper m1 = (MethodWrapper) o1;
+ MethodWrapper m2 = (MethodWrapper) o2;
+
+ CallLocation callLocation1 = m1.getMethodCall().getFirstCallLocation();
+ CallLocation callLocation2 = m2.getMethodCall().getFirstCallLocation();
+
+ if ((callLocation1 != null) && (callLocation2 != null)) {
+ if (callLocation1.getStart() == callLocation2.getStart()) {
+ return callLocation1.getEnd() - callLocation2.getEnd();
+ }
+
+ return callLocation1.getStart() - callLocation2.getStart();
+ }
+
+ return 0;
+ }
+ }
+
+ /**
+ * Constructor for CalleeMethodWrapper.
+ */
+ public CalleeMethodWrapper(MethodWrapper parent, MethodCall methodCall) {
+ super(parent, methodCall);
+ }
+
+ /* Returns the calls sorted after the call location
+ * @see org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper#getCalls()
+ */
+ public MethodWrapper[] getCalls(IProgressMonitor progressMonitor) {
+ MethodWrapper[] result = super.getCalls(progressMonitor);
+ Arrays.sort(result, fMethodWrapperComparator);
+
+ return result;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper#getTaskName()
+ */
+ protected String getTaskName() {
+ return CallHierarchyMessages.CalleeMethodWrapper_taskname;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper#createMethodWrapper(org.eclipse.jdt.internal.corext.callhierarchy.MethodCall)
+ */
+ protected MethodWrapper createMethodWrapper(MethodCall methodCall) {
+ return new CalleeMethodWrapper(this, methodCall);
+ }
+
+ /**
+ * Find callees called from the current method.
+ * @see org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper#findChildren(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected Map findChildren(IProgressMonitor progressMonitor) {
+ if (getMember().exists() && getMember().getElementType() == IRubyElement.METHOD) {
+ Node cu= CallHierarchy.getRubyScriptNode(getMember(), true);
+ if (progressMonitor != null) {
+ progressMonitor.worked(5);
+ }
+
+ if (cu != null) {
+ CalleeAnalyzerVisitor visitor = new CalleeAnalyzerVisitor((IMethod) getMember(),
+ cu, progressMonitor);
+
+ cu.accept(visitor);
+ return visitor.getCallees();
+ }
+ }
+ return new HashMap(0);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CalleeMethodWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallerMethodWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallerMethodWrapper.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallerMethodWrapper.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+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.internal.corext.util.SearchUtils;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+class CallerMethodWrapper extends MethodWrapper {
+ public CallerMethodWrapper(MethodWrapper parent, MethodCall methodCall) {
+ super(parent, methodCall);
+ }
+
+ protected IRubySearchScope getSearchScope() {
+ return CallHierarchy.getDefault().getSearchScope();
+ }
+
+ protected String getTaskName() {
+ return CallHierarchyMessages.CallerMethodWrapper_taskname;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper#createMethodWrapper(org.eclipse.jdt.internal.corext.callhierarchy.MethodCall)
+ */
+ protected MethodWrapper createMethodWrapper(MethodCall methodCall) {
+ return new CallerMethodWrapper(this, methodCall);
+ }
+
+ /**
+ * @return The result of the search for children
+ * @see org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper#findChildren(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected Map findChildren(IProgressMonitor progressMonitor) {
+ try {
+ MethodReferencesSearchRequestor searchRequestor= new MethodReferencesSearchRequestor();
+ SearchEngine searchEngine= new SearchEngine();
+
+ IProgressMonitor monitor= new SubProgressMonitor(progressMonitor, 95, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
+ IRubySearchScope defaultSearchScope= getSearchScope();
+ boolean isWorkspaceScope= SearchEngine.createWorkspaceScope().equals(defaultSearchScope);
+
+ for (Iterator iter= getMembers().iterator(); iter.hasNext();) {
+ checkCanceled(progressMonitor);
+
+ IMember member= (IMember) iter.next();
+ SearchPattern pattern= SearchPattern.createPattern(member, IRubySearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
+ IRubySearchScope searchScope= isWorkspaceScope ? getAccurateSearchScope(defaultSearchScope, member) : defaultSearchScope;
+ searchEngine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, searchScope, searchRequestor,
+ monitor);
+ }
+ return searchRequestor.getCallers();
+
+ } catch (CoreException e) {
+ RubyPlugin.log(e);
+ return new HashMap(0);
+ }
+ }
+
+ private IRubySearchScope getAccurateSearchScope(IRubySearchScope defaultSearchScope, IMember member) throws RubyModelException {
+ if (!(member.isType(IRubyElement.METHOD) && (((IMethod)member).isPrivate())))
+ return defaultSearchScope;
+
+ if (member.getRubyScript() != null) {
+ return SearchEngine.createRubySearchScope(new IRubyElement[] { member.getRubyScript() });
+ } else {
+ return defaultSearchScope;
+ }
+ }
+
+ /**
+ * Returns a collection of IMember instances representing what to search for
+ */
+ private Collection getMembers() {
+ Collection result = new ArrayList();
+
+ result.add(getMember());
+
+ return result;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/CallerMethodWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodCall.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodCall.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodCall.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.rubypeople.rdt.core.IMember;
+
+public class MethodCall {
+ private IMember fMember;
+ private List fCallLocations;
+
+ /**
+ * @param enclosingElement
+ */
+ public MethodCall(IMember enclosingElement) {
+ this.fMember = enclosingElement;
+ }
+
+ /**
+ *
+ */
+ public Collection getCallLocations() {
+ return fCallLocations;
+ }
+
+ public CallLocation getFirstCallLocation() {
+ if ((fCallLocations != null) && !fCallLocations.isEmpty()) {
+ return (CallLocation) fCallLocations.get(0);
+ } else {
+ return null;
+ }
+ }
+
+ public boolean hasCallLocations() {
+ return fCallLocations != null && fCallLocations.size() > 0;
+ }
+
+ /**
+ * @return Object
+ */
+ public Object getKey() {
+ return getMember().getHandleIdentifier();
+ }
+
+ /**
+ *
+ */
+ public IMember getMember() {
+ return fMember;
+ }
+
+ /**
+ * @param location
+ */
+ public void addCallLocation(CallLocation location) {
+ if (fCallLocations == null) {
+ fCallLocations = new ArrayList();
+ }
+
+ fCallLocations.add(location);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodCall.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodReferencesSearchRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodReferencesSearchRequestor.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodReferencesSearchRequestor.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import java.util.Map;
+
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.search.SearchMatch;
+import org.rubypeople.rdt.core.search.SearchRequestor;
+
+class MethodReferencesSearchRequestor extends SearchRequestor {
+ private CallSearchResultCollector fSearchResults;
+ private boolean fRequireExactMatch = true;
+
+ MethodReferencesSearchRequestor() {
+ fSearchResults = new CallSearchResultCollector();
+ }
+
+ public Map getCallers() {
+ return fSearchResults.getCallers();
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch)
+ */
+ public void acceptSearchMatch(SearchMatch match) {
+ if (fRequireExactMatch && (match.getAccuracy() != SearchMatch.A_ACCURATE)) {
+ return;
+ }
+
+ if (match.isInsideDocComment()) {
+ return;
+ }
+
+ if (match.getElement() != null && match.getElement() instanceof IMember) {
+ IMember member= (IMember) match.getElement();
+ switch (member.getElementType()) {
+ case IRubyElement.METHOD:
+ case IRubyElement.TYPE:
+ case IRubyElement.FIELD:
+ fSearchResults.addMember(member, member, match.getOffset(), match.getOffset()+match.getLength());
+ break;
+ }
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodReferencesSearchRequestor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodWrapper.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodWrapper.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodWrapper.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,318 @@
+/*******************************************************************************
+ * 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:
+ * Jesper Kamstrup Linnet (ec...@ka...) - initial API and implementation
+ * (report 36180: Callers/Callees view)
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.callhierarchy;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.ui.callhierarchy.MethodWrapperWorkbenchAdapter;
+
+/**
+ * This class represents the general parts of a method call (either to or from a
+ * method).
+ *
+ */
+public abstract class MethodWrapper extends PlatformObject {
+ private Map fElements = null;
+
+ /*
+ * A cache of previously found methods. This cache should be searched
+ * before adding a "new" method object reference to the list of elements.
+ * This way previously found methods won't be searched again.
+ */
+ private Map fMethodCache;
+ private MethodCall fMethodCall;
+ private MethodWrapper fParent;
+ private int fLevel;
+
+ /**
+ * Constructor CallerElement.
+ */
+ public MethodWrapper(MethodWrapper parent, MethodCall methodCall) {
+ Assert.isNotNull(methodCall);
+
+ if (parent == null) {
+ setMethodCache(new HashMap());
+ fLevel = 1;
+ } else {
+ setMethodCache(parent.getMethodCache());
+ fLevel = parent.getLevel() + 1;
+ }
+
+ this.fMethodCall = methodCall;
+ this.fParent = parent;
+ }
+
+ public Object getAdapter(Class adapter) {
+ if (adapter == IRubyElement.class) {
+ return getMember();
+ } else if (adapter == IWorkbenchAdapter.class){
+ return new MethodWrapperWorkbenchAdapter(this);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the child caller elements of this element
+ */
+ public MethodWrapper[] getCalls(IProgressMonitor progressMonitor) {
+ if (fElements == null) {
+ doFindChildren(progressMonitor);
+ }
+
+ MethodWrapper[] result = new MethodWrapper[fElements.size()];
+ int i = 0;
+
+ for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
+ MethodCall methodCall = getMethodCallFromMap(fElements, iter.next());
+ result[i++] = createMethodWrapper(methodCall);
+ }
+
+ return result;
+ }
+
+ public int getLevel() {
+ return fLevel;
+ }
+
+ public IMember getMember() {
+ return getMethodCall().getMember();
+ }
+
+ public MethodCall getMethodCall() {
+ return fMethodCall;
+ }
+
+ public String getName() {
+ if (getMethodCall() != null) {
+ return getMethodCall().getMember().getElementName();
+ } else {
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ public MethodWrapper getParent() {
+ return fParent;
+ }
+
+ public boolean equals(Object oth) {
+ if (this == oth) {
+ return true;
+ }
+
+ if (oth == null) {
+ return false;
+ }
+
+ if (oth instanceof MethodWrapperWorkbenchAdapter) {
+ //Note: A MethodWrapper is equal to a referring MethodWrapperWorkbenchAdapter and vice versa (bug 101677).
+ oth= ((MethodWrapperWorkbenchAdapter) oth).getMethodWrapper();
+ }
+
+ if (oth.getClass() != getClass()) {
+ return false;
+ }
+
+ MethodWrapper other = (MethodWrapper) oth;
+
+ if (this.fParent == null) {
+ if (other.fParent != null) {
+ return false;
+ }
+ } else {
+ if (!this.fParent.equals(other.fParent)) {
+ return false;
+ }
+ }
+
+ if (this.getMethodCall() == null) {
+ if (other.getMethodCall() != null) {
+ return false;
+ }
+ } else {
+ if (!this.getMethodCall().equals(other.getMethodCall())) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ final int PRIME = 1000003;
+ int result = 0;
+
+ if (fParent != null) {
+ result = (PRIME * result) + fParent.hashCode();
+ }
+
+ if (getMethodCall() != null) {
+ result = (PRIME * result) + getMethodCall().getMember().hashCode();
+ }
+
+ return result;
+ }
+
+ private void setMethodCache(Map methodCache) {
+ fMethodCache = methodCache;
+ }
+
+ protected abstract String getTaskName();
+
+ private void addCallToCache(MethodCall methodCall) {
+ Map cachedCalls = lookupMethod(this.getMethodCall());
+ cachedCalls.put(methodCall.getKey(), methodCall);
+ }
+
+ protected abstract MethodWrapper createMethodWrapper(MethodCall methodCall);
+
+ private void doFindChildren(IProgressMonitor progressMonitor) {
+ Map existingResults = lookupMethod(getMethodCall());
+
+ if (existingResults != null) {
+ fElements = new HashMap();
+ fElements.putAll(existingResults);
+ } else {
+ initCalls();
+
+ if (progressMonitor != null) {
+ progressMonitor.beginTask(getTaskName(), 100);
+ }
+
+ try {
+ performSearch(progressMonitor);
+ } finally {
+ if (progressMonitor != null) {
+ progressMonitor.done();
+ }
+ }
+
+ // ModalContext.run(getRunnableWithProgress(), true, getProgressMonitor(),
+ // Display.getCurrent());
+ }
+ }
+
+ /**
+ * Determines if the method represents a recursion call (i.e. whether the
+ * method call is already in the cache.)
+ *
+ * @return True if the call is part of a recursion
+ */
+ public boolean isRecursive() {
+ MethodWrapper current = getParent();
+
+ while (current != null) {
+ if (getMember().getHandleIdentifier().equals(current.getMember()
+ .getHandleIdentifier())) {
+ return true;
+ }
+
+ current = current.getParent();
+ }
+
+ return false;
+ }
+
+ /**
+ * This method finds the children of the current IMethod (either callers or
+ * callees, depending on the concrete subclass.
+ * @return The result of the search for children
+ */
+ protected abstract Map findChildren(IProgressMonitor progressMonitor);
+
+ private Map getMethodCache() {
+ return fMethodCache;
+ }
+
+ private void initCalls() {
+ this.fElements = new HashMap();
+
+ initCacheForMethod();
+ }
+
+ /**
+ * Looks up a previously created search result in the "global" cache.
+ * @return the List of previously found search results
+ */
+ private Map lookupMethod(MethodCall methodCall) {
+ return (Map) getMethodCache().get(methodCall.getKey());
+ }
+
+ private void performSearch(IProgressMonitor progressMonitor) {
+ fElements = findChildren(progressMonitor);
+
+ for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
+ checkCanceled(progressMonitor);
+
+ MethodCall methodCall = getMethodCallFromMap(fElements, iter.next());
+ addCallToCache(methodCall);
+ }
+ }
+
+ private MethodCall getMethodCallFromMap(Map elements, Object key) {
+ return (MethodCall) elements.get(key);
+ }
+
+ private void initCacheForMethod() {
+ Map cachedCalls = new HashMap();
+ getMethodCache().put(this.getMethodCall().getKey(), cachedCalls);
+ }
+
+ /**
+ * Checks with the progress monitor to see whether the creation of the type hierarchy
+ * should be canceled. Should be regularly called
+ * so that the user can cancel.
+ *
+ * @exception OperationCanceledException if cancelling the operation has been requested
+ * @see IProgressMonitor#isCanceled
+ */
+ protected void checkCanceled(IProgressMonitor progressMonitor) {
+ if (progressMonitor != null && progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ }
+
+ /**
+ * Allows a visitor to traverse the call hierarchy. The visiting is stopped when
+ * a recursive node is reached.
+ *
+ * @param visitor
+ */
+ public void accept(CallHierarchyVisitor visitor, IProgressMonitor progressMonitor) {
+ if (getParent() != null && getParent().isRecursive()) {
+ return;
+ }
+ checkCanceled(progressMonitor);
+
+ visitor.preVisit(this);
+ if (visitor.visit(this)) {
+ MethodWrapper[] methodWrappers= getCalls(progressMonitor);
+ for (int i= 0; i < methodWrappers.length; i++) {
+ methodWrappers[i].accept(visitor, progressMonitor);
+ }
+ }
+ visitor.postVisit(this);
+
+ if (progressMonitor != null) {
+ progressMonitor.worked(1);
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/callhierarchy/MethodWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-08-24 16:07:58 UTC (rev 3069)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -193,6 +193,10 @@
public static final ImageDescriptor DESC_ELCL_VIEW_MENU= createManaged(T_ELCL, "view_menu.gif", IMG_ELCL_VIEW_MENU); //$NON-NLS-1$
public static final ImageDescriptor DESC_DLCL_VIEW_MENU= createManaged(T_DLCL, "view_menu.gif", IMG_DLCL_VIEW_MENU); //$NON-NLS-1$
+
+ // Call Hierarchy
+ public static final ImageDescriptor DESC_OVR_RECURSIVE= createUnManaged(T_OVR, "recursive_co.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_OVR_MAX_LEVEL= createUnManaged(T_OVR, "maxlevel_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_MISC_PUBLIC= createManagedFromKey(T_OBJ, IMG_MISC_PUBLIC);
public static final ImageDescriptor DESC_MISC_PROTECTED= createManagedFromKey(T_OBJ, IMG_MISC_PROTECTED);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java 2007-08-24 16:07:58 UTC (rev 3069)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -68,6 +68,19 @@
public static String OpenTypeInHierarchyAction_tooltip;
public static String OpenTypeInHierarchyAction_dialogTitle;
public static String OpenTypeInHierarchyAction_dialogMessage;
+
+ public static String SelectionConverter_codeResolve_failed;
+
+ public static String OpenTypeHierarchyAction_label;
+ public static String OpenTypeHierarchyAction_tooltip;
+ public static String OpenTypeHierarchyAction_description;
+ public static String OpenTypeHierarchyAction_messages_no_ruby_element;
+ public static String OpenTypeHierarchyAction_messages_title;
+ public static String OpenTypeHierarchyAction_dialog_title;
+ public static String OpenTypeHierarchyAction_messages_no_ruby_resources;
+ public static String OpenTypeHierarchyAction_messages_unknown_import_decl;
+ public static String OpenTypeHierarchyAction_messages_no_types;
+ public static String OpenTypeHierarchyAction_messages_no_valid_ruby_element;
static {
NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java 2007-08-24 16:07:58 UTC (rev 3069)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -175,4 +175,14 @@
return runnable.result;
}
+ public static IRubyElement[] codeResolveOrInputForked(RubyEditor editor) throws InvocationTargetException, InterruptedException {
+ IRubyElement input= getInput(editor);
+ ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection();
+ IRubyElement[] result= performForkedCodeResolve(input, selection);
+ if (result.length == 0) {
+ result= new IRubyElement[] {input};
+ }
+ return result;
+ }
+
}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java 2007-08-24 17:02:19 UTC (rev 3070)
@@ -0,0 +1,204 @@
+/*...
[truncated message content] |
|
From: <caw...@us...> - 2007-08-24 16:08:01
|
Revision: 3069
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3069&view=rev
Author: cawilliams
Date: 2007-08-24 09:07:58 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
fix bundle classpath
Modified Paths:
--------------
trunk/org.jruby/META-INF/MANIFEST.MF
Modified: trunk/org.jruby/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.jruby/META-INF/MANIFEST.MF 2007-08-24 14:03:24 UTC (rev 3068)
+++ trunk/org.jruby/META-INF/MANIFEST.MF 2007-08-24 16:07:58 UTC (rev 3069)
@@ -5,8 +5,11 @@
Bundle-Version: 1.0.0.4196p
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime
-Bundle-ClassPath: lib/asm-commons-2.2.3.jar,
- lib/asm-2.2.3.jar,
+Bundle-ClassPath: lib/asm-commons-3.0.jar,
+ lib/asm-3.0.jar,
+ lib/asm-util-3.0.jar,
+ lib/bsf.jar,
+ lib/jline-0.9.91.jar,
lib/backport-util-concurrent.jar,
lib/jruby.jar
Export-Package: edu.emory.mathcs.backport.java.util,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-24 14:03:28
|
Revision: 3068
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3068&view=rev
Author: cawilliams
Date: 2007-08-24 07:03:24 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
rename JDISourceViewer to RubyDebugSourceViewer
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayView.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RubyDebugSourceViewer.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java
Deleted: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java 2007-08-23 20:32:24 UTC (rev 3067)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java 2007-08-24 14:03:24 UTC (rev 3068)
@@ -1,359 +0,0 @@
-/*******************************************************************************
- * 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.debug.ui;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.custom.BidiSegmentEvent;
-import org.eclipse.swt.custom.BidiSegmentListener;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.rubypeople.rdt.internal.debug.ui.display.DisplayViewerConfiguration;
-import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
-
-/**
- * A source viewer configured to display Java source. This
- * viewer obeys the font and color preferences specified in
- * the Java UI plugin.
- */
-public class JDISourceViewer extends SourceViewer implements IPropertyChangeListener {
-
- private Font fFont;
- private Color fBackgroundColor;
- private Color fForegroundColor;
- private IPreferenceStore fStore;
- private DisplayViewerConfiguration fConfiguration;
-
- public JDISourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- super(parent, ruler, styles);
- StyledText text= this.getTextWidget();
- text.addBidiSegmentListener(new BidiSegmentListener() {
- public void lineGetSegments(BidiSegmentEvent event) {
- try {
- event.segments= getBidiLineSegments(event.lineOffset);
- } catch (BadLocationException x) {
- // ignore
- }
- }
- });
- }
-
- /**
- * Updates the viewer's font to match the preferences.
- */
- private void updateViewerFont() {
- IPreferenceStore store= getPreferenceStore();
- if (store != null) {
- FontData data= null;
- if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
- data= PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT);
- } else {
- data= PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT);
- }
- if (data != null) {
- Font font= new Font(getTextWidget().getDisplay(), data);
- applyFont(font);
- if (getFont() != null) {
- getFont().dispose();
- }
- setFont(font);
- return;
- }
- }
- // if all the preferences failed
- applyFont(JFaceResources.getTextFont());
- }
-
- /**
- * Sets the current font.
- *
- * @param font the new font
- */
- private void setFont(Font font) {
- fFont= font;
- }
-
- /**
- * Returns the current font.
- *
- * @return the current font
- */
- private Font getFont() {
- return fFont;
- }
-
- /**
- * Sets the font for the given viewer sustaining selection and scroll position.
- *
- * @param font the font
- */
- private void applyFont(Font font) {
- IDocument doc= getDocument();
- if (doc != null && doc.getLength() > 0) {
- Point selection= getSelectedRange();
- int topIndex= getTopIndex();
-
- StyledText styledText= getTextWidget();
- styledText.setRedraw(false);
-
- styledText.setFont(font);
- setSelectedRange(selection.x , selection.y);
- setTopIndex(topIndex);
-
- styledText.setRedraw(true);
- } else {
- getTextWidget().setFont(font);
- }
- }
-
- /**
- * Updates the given viewer's colors to match the preferences.
- */
- public void updateViewerColors() {
- IPreferenceStore store= getPreferenceStore();
- if (store != null) {
- StyledText styledText= getTextWidget();
- Color color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
- styledText.setForeground(color);
- if (getForegroundColor() != null) {
- getForegroundColor().dispose();
- }
- setForegroundColor(color);
-
- color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
- styledText.setBackground(color);
- if (getBackgroundColor() != null) {
- getBackgroundColor().dispose();
- }
- setBackgroundColor(color);
- }
- }
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns <code>null</code> if there is no such information available.
- */
- private Color createColor(IPreferenceStore store, String key, Display display) {
- RGB rgb= null;
- if (store.contains(key)) {
- if (store.isDefault(key)) {
- rgb= PreferenceConverter.getDefaultColor(store, key);
- } else {
- rgb= PreferenceConverter.getColor(store, key);
- }
- if (rgb != null) {
- return new Color(display, rgb);
- }
- }
- return null;
- }
-
- /**
- * Returns the current background color.
- *
- * @return the current background color
- */
- protected Color getBackgroundColor() {
- return fBackgroundColor;
- }
-
- /**
- * Sets the current background color.
- *
- * @param backgroundColor the new background color
- */
- protected void setBackgroundColor(Color backgroundColor) {
- fBackgroundColor = backgroundColor;
- }
-
- /**
- * Returns the current foreground color.
- *
- * @return the current foreground color
- */
- protected Color getForegroundColor() {
- return fForegroundColor;
- }
-
- /**
- * Sets the current foreground color.
- *
- * @param foregroundColor the new foreground color
- */
- protected void setForegroundColor(Color foregroundColor) {
- fForegroundColor = foregroundColor;
- }
-
- /**
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- IContentAssistant assistant= getContentAssistant();
-// if (assistant instanceof ContentAssistant) {
-// JDIContentAssistPreference.changeConfiguration((ContentAssistant) assistant, event);
-// }
- String property= event.getProperty();
-
- if (JFaceResources.TEXT_FONT.equals(property)) {
- updateViewerFont();
- }
- if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) ||
- AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)) {
- updateViewerColors();
- }
- if (fConfiguration != null) {
- if (fConfiguration.affectsTextPresentation(event)) {
- fConfiguration.handlePropertyChangeEvent(event);
- invalidateTextPresentation();
- }
- }
- }
-
- /**
- * Returns the current content assistant.
- *
- * @return the current content assistant
- */
- public IContentAssistant getContentAssistant() {
- return fContentAssistant;
- }
-
- /**
- * Returns a segmentation of the line of the given document appropriate for bidi rendering.
- * The default implementation returns only the string literals of a Ruby code line as segments.
- *
- * @param document the document
- * @param lineOffset the offset of the line
- * @return the line's bidi segmentation
- * @throws BadLocationException in case lineOffset is not valid in document
- */
- protected int[] getBidiLineSegments(int lineOffset) throws BadLocationException {
- IDocument document= getDocument();
- if (document == null) {
- return null;
- }
- IRegion line= document.getLineInformationOfOffset(lineOffset);
- ITypedRegion[] linePartitioning= document.computePartitioning(lineOffset, line.getLength());
-
- List segmentation= new ArrayList();
- for (int i= 0; i < linePartitioning.length; i++) {
- if (IRubyPartitions.RUBY_STRING.equals(linePartitioning[i].getType()))
- segmentation.add(linePartitioning[i]);
- }
-
-
- if (segmentation.size() == 0)
- return null;
-
- int size= segmentation.size();
- int[] segments= new int[size * 2 + 1];
-
- int j= 0;
- for (int i= 0; i < size; i++) {
- ITypedRegion segment= (ITypedRegion) segmentation.get(i);
-
- if (i == 0)
- segments[j++]= 0;
-
- int offset= segment.getOffset() - lineOffset;
- if (offset > segments[j - 1])
- segments[j++]= offset;
-
- if (offset + segment.getLength() >= line.getLength())
- break;
-
- segments[j++]= offset + segment.getLength();
- }
-
- if (j < segments.length) {
- int[] result= new int[j];
- System.arraycopy(segments, 0, result, 0, j);
- segments= result;
- }
-
- return segments;
- }
-
- /**
- * Disposes the system resources currently in use by this viewer.
- */
- public void dispose() {
- if (getFont() != null) {
- getFont().dispose();
- setFont(null);
- }
- if (getBackgroundColor() != null) {
- getBackgroundColor().dispose();
- setBackgroundColor(null);
- }
- if (getForegroundColor() != null) {
- getForegroundColor().dispose();
- setForegroundColor(null);
- }
- if (fStore != null) {
- fStore.removePropertyChangeListener(this);
- fStore = null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.source.SourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
- */
- public void configure(SourceViewerConfiguration configuration) {
- super.configure(configuration);
- if (fStore != null) {
- fStore.removePropertyChangeListener(this);
- fStore = null;
- }
- if (configuration instanceof DisplayViewerConfiguration) {
- fConfiguration = (DisplayViewerConfiguration) configuration;
- fStore = fConfiguration.getTextPreferenceStore();
- fStore.addPropertyChangeListener(this);
- }
- updateViewerFont();
- updateViewerColors();
- }
-
- /**
- * Returns the preference store used to configure this source viewer or
- * <code>null</code> if none;
- */
- private IPreferenceStore getPreferenceStore() {
- return fStore;
- }
-
-}
Copied: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RubyDebugSourceViewer.java (from rev 3060, trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java)
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RubyDebugSourceViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RubyDebugSourceViewer.java 2007-08-24 14:03:24 UTC (rev 3068)
@@ -0,0 +1,359 @@
+/*******************************************************************************
+ * 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.debug.ui;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.custom.BidiSegmentEvent;
+import org.eclipse.swt.custom.BidiSegmentListener;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.rubypeople.rdt.internal.debug.ui.display.DisplayViewerConfiguration;
+import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
+
+/**
+ * A source viewer configured to display Ruby source. This
+ * viewer obeys the font and color preferences specified in
+ * the Ruby UI plugin.
+ */
+public class RubyDebugSourceViewer extends SourceViewer implements IPropertyChangeListener {
+
+ private Font fFont;
+ private Color fBackgroundColor;
+ private Color fForegroundColor;
+ private IPreferenceStore fStore;
+ private DisplayViewerConfiguration fConfiguration;
+
+ public RubyDebugSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+ super(parent, ruler, styles);
+ StyledText text= this.getTextWidget();
+ text.addBidiSegmentListener(new BidiSegmentListener() {
+ public void lineGetSegments(BidiSegmentEvent event) {
+ try {
+ event.segments= getBidiLineSegments(event.lineOffset);
+ } catch (BadLocationException x) {
+ // ignore
+ }
+ }
+ });
+ }
+
+ /**
+ * Updates the viewer's font to match the preferences.
+ */
+ private void updateViewerFont() {
+ IPreferenceStore store= getPreferenceStore();
+ if (store != null) {
+ FontData data= null;
+ if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
+ data= PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT);
+ } else {
+ data= PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT);
+ }
+ if (data != null) {
+ Font font= new Font(getTextWidget().getDisplay(), data);
+ applyFont(font);
+ if (getFont() != null) {
+ getFont().dispose();
+ }
+ setFont(font);
+ return;
+ }
+ }
+ // if all the preferences failed
+ applyFont(JFaceResources.getTextFont());
+ }
+
+ /**
+ * Sets the current font.
+ *
+ * @param font the new font
+ */
+ private void setFont(Font font) {
+ fFont= font;
+ }
+
+ /**
+ * Returns the current font.
+ *
+ * @return the current font
+ */
+ private Font getFont() {
+ return fFont;
+ }
+
+ /**
+ * Sets the font for the given viewer sustaining selection and scroll position.
+ *
+ * @param font the font
+ */
+ private void applyFont(Font font) {
+ IDocument doc= getDocument();
+ if (doc != null && doc.getLength() > 0) {
+ Point selection= getSelectedRange();
+ int topIndex= getTopIndex();
+
+ StyledText styledText= getTextWidget();
+ styledText.setRedraw(false);
+
+ styledText.setFont(font);
+ setSelectedRange(selection.x , selection.y);
+ setTopIndex(topIndex);
+
+ styledText.setRedraw(true);
+ } else {
+ getTextWidget().setFont(font);
+ }
+ }
+
+ /**
+ * Updates the given viewer's colors to match the preferences.
+ */
+ public void updateViewerColors() {
+ IPreferenceStore store= getPreferenceStore();
+ if (store != null) {
+ StyledText styledText= getTextWidget();
+ Color color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
+ styledText.setForeground(color);
+ if (getForegroundColor() != null) {
+ getForegroundColor().dispose();
+ }
+ setForegroundColor(color);
+
+ color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
+ styledText.setBackground(color);
+ if (getBackgroundColor() != null) {
+ getBackgroundColor().dispose();
+ }
+ setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * Creates a color from the information stored in the given preference store.
+ * Returns <code>null</code> if there is no such information available.
+ */
+ private Color createColor(IPreferenceStore store, String key, Display display) {
+ RGB rgb= null;
+ if (store.contains(key)) {
+ if (store.isDefault(key)) {
+ rgb= PreferenceConverter.getDefaultColor(store, key);
+ } else {
+ rgb= PreferenceConverter.getColor(store, key);
+ }
+ if (rgb != null) {
+ return new Color(display, rgb);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the current background color.
+ *
+ * @return the current background color
+ */
+ protected Color getBackgroundColor() {
+ return fBackgroundColor;
+ }
+
+ /**
+ * Sets the current background color.
+ *
+ * @param backgroundColor the new background color
+ */
+ protected void setBackgroundColor(Color backgroundColor) {
+ fBackgroundColor = backgroundColor;
+ }
+
+ /**
+ * Returns the current foreground color.
+ *
+ * @return the current foreground color
+ */
+ protected Color getForegroundColor() {
+ return fForegroundColor;
+ }
+
+ /**
+ * Sets the current foreground color.
+ *
+ * @param foregroundColor the new foreground color
+ */
+ protected void setForegroundColor(Color foregroundColor) {
+ fForegroundColor = foregroundColor;
+ }
+
+ /**
+ * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ IContentAssistant assistant= getContentAssistant();
+// if (assistant instanceof ContentAssistant) {
+// JDIContentAssistPreference.changeConfiguration((ContentAssistant) assistant, event);
+// }
+ String property= event.getProperty();
+
+ if (JFaceResources.TEXT_FONT.equals(property)) {
+ updateViewerFont();
+ }
+ if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) ||
+ AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)) {
+ updateViewerColors();
+ }
+ if (fConfiguration != null) {
+ if (fConfiguration.affectsTextPresentation(event)) {
+ fConfiguration.handlePropertyChangeEvent(event);
+ invalidateTextPresentation();
+ }
+ }
+ }
+
+ /**
+ * Returns the current content assistant.
+ *
+ * @return the current content assistant
+ */
+ public IContentAssistant getContentAssistant() {
+ return fContentAssistant;
+ }
+
+ /**
+ * Returns a segmentation of the line of the given document appropriate for bidi rendering.
+ * The default implementation returns only the string literals of a Ruby code line as segments.
+ *
+ * @param document the document
+ * @param lineOffset the offset of the line
+ * @return the line's bidi segmentation
+ * @throws BadLocationException in case lineOffset is not valid in document
+ */
+ protected int[] getBidiLineSegments(int lineOffset) throws BadLocationException {
+ IDocument document= getDocument();
+ if (document == null) {
+ return null;
+ }
+ IRegion line= document.getLineInformationOfOffset(lineOffset);
+ ITypedRegion[] linePartitioning= document.computePartitioning(lineOffset, line.getLength());
+
+ List segmentation= new ArrayList();
+ for (int i= 0; i < linePartitioning.length; i++) {
+ if (IRubyPartitions.RUBY_STRING.equals(linePartitioning[i].getType()))
+ segmentation.add(linePartitioning[i]);
+ }
+
+
+ if (segmentation.size() == 0)
+ return null;
+
+ int size= segmentation.size();
+ int[] segments= new int[size * 2 + 1];
+
+ int j= 0;
+ for (int i= 0; i < size; i++) {
+ ITypedRegion segment= (ITypedRegion) segmentation.get(i);
+
+ if (i == 0)
+ segments[j++]= 0;
+
+ int offset= segment.getOffset() - lineOffset;
+ if (offset > segments[j - 1])
+ segments[j++]= offset;
+
+ if (offset + segment.getLength() >= line.getLength())
+ break;
+
+ segments[j++]= offset + segment.getLength();
+ }
+
+ if (j < segments.length) {
+ int[] result= new int[j];
+ System.arraycopy(segments, 0, result, 0, j);
+ segments= result;
+ }
+
+ return segments;
+ }
+
+ /**
+ * Disposes the system resources currently in use by this viewer.
+ */
+ public void dispose() {
+ if (getFont() != null) {
+ getFont().dispose();
+ setFont(null);
+ }
+ if (getBackgroundColor() != null) {
+ getBackgroundColor().dispose();
+ setBackgroundColor(null);
+ }
+ if (getForegroundColor() != null) {
+ getForegroundColor().dispose();
+ setForegroundColor(null);
+ }
+ if (fStore != null) {
+ fStore.removePropertyChangeListener(this);
+ fStore = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
+ */
+ public void configure(SourceViewerConfiguration configuration) {
+ super.configure(configuration);
+ if (fStore != null) {
+ fStore.removePropertyChangeListener(this);
+ fStore = null;
+ }
+ if (configuration instanceof DisplayViewerConfiguration) {
+ fConfiguration = (DisplayViewerConfiguration) configuration;
+ fStore = fConfiguration.getTextPreferenceStore();
+ fStore.addPropertyChangeListener(this);
+ }
+ updateViewerFont();
+ updateViewerColors();
+ }
+
+ /**
+ * Returns the preference store used to configure this source viewer or
+ * <code>null</code> if none;
+ */
+ private IPreferenceStore getPreferenceStore() {
+ return fStore;
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayView.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayView.java 2007-08-23 20:32:24 UTC (rev 3067)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayView.java 2007-08-24 14:03:24 UTC (rev 3068)
@@ -77,7 +77,7 @@
import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
import org.rubypeople.rdt.debug.ui.RdtDebugUiConstants;
-import org.rubypeople.rdt.internal.debug.ui.JDISourceViewer;
+import org.rubypeople.rdt.internal.debug.ui.RubyDebugSourceViewer;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
import org.rubypeople.rdt.ui.text.RubyTextTools;
@@ -136,7 +136,7 @@
protected IDataDisplay fDataDisplay= new DataDisplay();
protected IDocumentListener fDocumentListener= null;
- protected JDISourceViewer fSourceViewer;
+ protected RubyDebugSourceViewer fSourceViewer;
protected IAction fClearDisplayAction;
protected DisplayViewAction fContentAssistAction;
@@ -159,7 +159,7 @@
public void createPartControl(Composite parent) {
int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION;
- fSourceViewer= new JDISourceViewer(parent, null, styles);
+ fSourceViewer= new RubyDebugSourceViewer(parent, null, styles);
fSourceViewer.configure(new DisplayViewerConfiguration());
fSourceViewer.getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
IDocument doc= getRestoredDocument();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 20:33:34
|
Revision: 3067
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3067&view=rev
Author: cawilliams
Date: 2007-08-23 13:32:24 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
Removed Paths:
-------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/cheatsheets/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 20:12:45
|
Revision: 3066
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3066&view=rev
Author: cawilliams
Date: 2007-08-23 13:12:43 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
fix icon to be ruby-like, not Java
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/run_sbook.gif
trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/run_sbook.gif
Modified: trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/run_sbook.gif
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/run_sbook.gif
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 20:01:29
|
Revision: 3065
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3065&view=rev
Author: cawilliams
Date: 2007-08-23 13:01:28 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
modify icons to be ruby-like, make RubyEvaluationResult implement getErrorMessages() and hasErrors() properly. Set exception on result in RubyDebuggerProxy
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/disp_sbook.gif
trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/disp_sbook.gif
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java
Modified: trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/disp_sbook.gif
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/disp_sbook.gif
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java 2007-08-23 20:01:19 UTC (rev 3064)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java 2007-08-23 20:01:28 UTC (rev 3065)
@@ -67,7 +67,6 @@
import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy;
import org.rubypeople.rdt.internal.debug.core.model.IEvaluationResult;
-import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
import org.rubypeople.rdt.internal.debug.core.model.RubyValue;
import org.rubypeople.rdt.internal.debug.core.model.RubyVariable;
@@ -228,20 +227,16 @@
IRubyElement rubyElement= getRubyElement(stackFrame);
if (rubyElement != null) {
IRubyProject project = rubyElement.getRubyProject();
- try {
- Object selection= getSelectedObject();
- if (!(selection instanceof String)) {
- return;
- }
- String expression= (String)selection;
- setEvaluating(true);
- RubyDebuggerProxy proxy = stackFrame.getRubyDebuggerProxy();
- IEvaluationResult result = proxy.evaluate(stackFrame, expression);
- evaluationComplete(result);
+ Object selection= getSelectedObject();
+ if (!(selection instanceof String)) {
return;
- } catch (RubyProcessingException e) {
- throw new InvocationTargetException(e, getExceptionMessage(e));
}
+ String expression= (String)selection;
+ setEvaluating(true);
+ RubyDebuggerProxy proxy = stackFrame.getRubyDebuggerProxy();
+ IEvaluationResult result = proxy.evaluate(stackFrame, expression);
+ evaluationComplete(result);
+ return;
}
throw new InvocationTargetException(null, ActionMessages.Evaluate_error_message_src_context);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 20:01:21
|
Revision: 3064
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3064&view=rev
Author: cawilliams
Date: 2007-08-23 13:01:19 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
modify icons to be ruby-like, make RubyEvaluationResult implement getErrorMessages() and hasErrors() properly. Set exception on result in RubyDebuggerProxy
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-08-23 19:43:29 UTC (rev 3063)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-08-23 20:01:19 UTC (rev 3064)
@@ -5,6 +5,9 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IBreakpoint;
import org.rubypeople.rdt.debug.core.RubyLineBreakpoint;
@@ -243,7 +246,7 @@
}
}
- public IEvaluationResult evaluate(RubyStackFrame frame, String expression) throws RubyProcessingException {
+ public IEvaluationResult evaluate(RubyStackFrame frame, String expression) {
expression = expression.replaceAll("\\r\\n", "\n");
expression = expression.replaceAll("\\n", "; ");
expression = expression.trim();
@@ -255,9 +258,11 @@
result.setValue(variables[0].getValue());
}
} catch (IOException ioex) {
- // TODO Set DebugException
- ioex.printStackTrace();
- throw new RuntimeException(ioex.getMessage());
+ DebugException ex = new DebugException(new Status(IStatus.ERROR, RdtDebugCorePlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, ioex.getMessage(), ioex));
+ result.setException(ex);
+ } catch (RubyProcessingException e) {
+ DebugException ex = new DebugException(new Status(IStatus.ERROR, RdtDebugCorePlugin.PLUGIN_ID, DebugException.TARGET_REQUEST_FAILED, e.getMessage(), e));
+ result.setException(ex);
}
return result;
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java 2007-08-23 19:43:29 UTC (rev 3063)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java 2007-08-23 20:01:19 UTC (rev 3064)
@@ -18,7 +18,7 @@
public String[] getErrorMessages() {
// TODO Auto-generated method stub
- return null;
+ return new String[0];
}
public DebugException getException() {
@@ -46,7 +46,7 @@
}
public boolean hasErrors() {
- return false;
+ return getErrorMessages().length > 0 || getException() != null;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 19:43:30
|
Revision: 3063
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3063&view=rev
Author: cawilliams
Date: 2007-08-23 12:43:29 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
finish up initial version of #4928
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/plugin.properties
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ExecuteAction.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/run_sbook.gif
trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/run_sbook.gif
Added: trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/run_sbook.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/run_sbook.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/run_sbook.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/run_sbook.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.debug.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/plugin.properties 2007-08-23 19:43:20 UTC (rev 3062)
+++ trunk/org.rubypeople.rdt.debug.ui/plugin.properties 2007-08-23 19:43:29 UTC (rev 3063)
@@ -30,4 +30,4 @@
displayViewName=Display
Execute.label=E&xecute
-Execute.tooltip=Evaluate the Selected Text
\ No newline at end of file
+Execute.tooltip=Evaluate the Selected Text
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java 2007-08-23 19:43:20 UTC (rev 3062)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java 2007-08-23 19:43:29 UTC (rev 3063)
@@ -225,9 +225,9 @@
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (stackFrame.isSuspended()) {
- IRubyElement javaElement= getRubyElement(stackFrame);
- if (javaElement != null) {
- IRubyProject project = javaElement.getRubyProject();
+ IRubyElement rubyElement= getRubyElement(stackFrame);
+ if (rubyElement != null) {
+ IRubyProject project = rubyElement.getRubyProject();
try {
Object selection= getSelectedObject();
if (!(selection instanceof String)) {
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ExecuteAction.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ExecuteAction.java 2007-08-23 19:43:20 UTC (rev 3062)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ExecuteAction.java 2007-08-23 19:43:29 UTC (rev 3063)
@@ -11,12 +11,12 @@
package org.rubypeople.rdt.internal.debug.ui.actions;
-import java.text.MessageFormat;
-
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
import org.eclipse.swt.widgets.Display;
import org.rubypeople.rdt.internal.debug.core.model.IEvaluationResult;
+import org.rubypeople.rdt.internal.debug.core.model.RubyValue;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
import org.rubypeople.rdt.internal.debug.ui.display.IDataDisplay;
@@ -38,19 +38,56 @@
}
});
} else {
- IValue value = result.getValue();
- IDataDisplay dataDisplay= getDirectDataDisplay();
- if (dataDisplay != null) {
- try {
- dataDisplay.displayExpressionValue(value.getValueString());
- } catch (DebugException e) {
- RdtDebugUiPlugin.log(e);
- }
+ final Display display = RdtDebugUiPlugin.getStandardDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ if (display.isDisposed()) {
+ return;
+ }
+ IValue value = result.getValue();
+ IDataDisplay dataDisplay= getDirectDataDisplay();
+ if (dataDisplay != null) {
+ try {
+ dataDisplay.displayExpressionValue(valueToCode(value));
+ } catch (DebugException e) {
+ RdtDebugUiPlugin.log(e);
+ }
+ }
+ evaluationCleanup();
+ }
+ });
+ }
+ }
+
+ protected String valueToCode(IValue value) throws DebugException {
+ String string = value.getValueString();
+ if (value instanceof RubyValue) {
+ RubyValue rubyValue = (RubyValue) value;
+ if (value.getReferenceTypeName().equals("Array")) {
+ StringBuffer buffer = new StringBuffer("[");
+ IVariable[] vars = rubyValue.getVariables();
+ for (int i = 0; i < vars.length; i++) {
+ buffer.append(vars[i].getValue().getValueString());
+ if (i < vars.length - 1)
+ buffer.append(", ");
+ }
+ buffer.append("]");
+ string = buffer.toString();
+ } else if (value.getReferenceTypeName().equals("Hash")) {
+ StringBuffer buffer = new StringBuffer("{");
+ IVariable[] vars = rubyValue.getVariables();
+ for (int i = 0; i < vars.length; i++) {
+ buffer.append(vars[i]);
+ if (i < vars.length - 1)
+ buffer.append(", ");
+ }
+ buffer.append("}");
+ string = buffer.toString();
}
- evaluationCleanup();
}
+ return "=> " + string;
}
-
+
/**
* @see org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction#getDataDisplay()
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 19:43:22
|
Revision: 3062
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3062&view=rev
Author: cawilliams
Date: 2007-08-23 12:43:20 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
finish up initial version of #4928
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-08-23 18:40:25 UTC (rev 3061)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-08-23 19:43:20 UTC (rev 3062)
@@ -244,7 +244,9 @@
}
public IEvaluationResult evaluate(RubyStackFrame frame, String expression) throws RubyProcessingException {
- expression = expression.replaceAll("\\n", "\\\\n");
+ expression = expression.replaceAll("\\r\\n", "\n");
+ expression = expression.replaceAll("\\n", "; ");
+ expression = expression.trim();
RubyEvaluationResult result = new RubyEvaluationResult(expression, frame.getThread());
try {
this.println(commandFactory.createInspect(frame, expression));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 18:40:30
|
Revision: 3061
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3061&view=rev
Author: cawilliams
Date: 2007-08-23 11:40:25 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
first stab at implementing #4928 - add support for interacting at breakpoint.
Add Display view which allows users to type in Ruby code and execute/inspect the results
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,48 @@
+/**********************************************************************
+ * 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 - Initial API and implementation
+ **********************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.display;
+
+import org.eclipse.osgi.util.NLS;
+
+public class DisplayMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.rubypeople.rdt.internal.debug.ui.display.DisplayMessages";//$NON-NLS-1$
+
+ public static String ClearDisplay_description;
+ public static String ClearDisplay_label;
+ public static String ClearDisplay_tooltip;
+
+ public static String DisplayView_Co_ntent_Assist_Ctrl_Space_1;
+ public static String DisplayView_Content_Assist_2;
+ public static String DisplayView_Copy_description;
+ public static String DisplayCompletionProcessor_0;
+ public static String DisplayCompletionProcessor_1;
+ public static String DisplayView_Copy_label;
+ public static String DisplayView_Copy_tooltip;
+ public static String DisplayView_Cut_description;
+ public static String DisplayView_Cut_label;
+ public static String DisplayView_Cut_tooltip;
+ public static String DisplayView_Paste_Description;
+ public static String DisplayView_Paste_label;
+ public static String DisplayView_Paste_tooltip;
+ public static String DisplayView_SelectAll_description;
+ public static String DisplayView_SelectAll_label;
+ public static String DisplayView_SelectAll_tooltip;
+
+ public static String find_replace_action_label;
+ public static String find_replace_action_tooltip;
+ public static String find_replace_action_image;
+ public static String find_replace_action_description;
+ public static String JavaInspectExpression_0;
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, DisplayMessages.class);
+ }
+}
\ No newline at end of file
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,37 @@
+###############################################################################
+# 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
+###############################################################################
+
+ClearDisplay_description=Clear the Display
+ClearDisplay_label=Clea&r
+ClearDisplay_tooltip=Clear Display
+
+DisplayView_Co_ntent_Assist_Ctrl_Space_1=Co&ntent Assist
+DisplayView_Content_Assist_2=Content Assist
+DisplayView_Copy_description=Copy
+DisplayCompletionProcessor_0=Unable to resolve selected stack frame
+DisplayCompletionProcessor_1=Unable to resolve enclosing type
+DisplayView_Copy_label=&Copy
+DisplayView_Copy_tooltip=Copy
+DisplayView_Cut_description=Cut
+DisplayView_Cut_label=Cu&t
+DisplayView_Cut_tooltip=Cut
+DisplayView_Paste_Description=Paste
+DisplayView_Paste_label=&Paste
+DisplayView_Paste_tooltip=Paste
+DisplayView_SelectAll_description=Select All
+DisplayView_SelectAll_label=Select &All
+DisplayView_SelectAll_tooltip=Select
+
+find_replace_action_label=&Find/Replace...
+find_replace_action_tooltip=Find/Replace
+find_replace_action_image=
+find_replace_action_description=Find/Replace
+JavaInspectExpression_0=An exception occurred: {0}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.debug.ui.display;
+
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.ui.texteditor.IUpdate;
+
+
+public class DisplayViewAction extends Action implements IUpdate {
+
+ /** The text operation code */
+ private int fOperationCode= -1;
+ /** The text operation target */
+ private ITextOperationTarget fOperationTarget;
+ /** The text operation target provider */
+ private IAdaptable fTargetProvider;
+
+
+ public DisplayViewAction(ITextOperationTarget target, int operationCode) {
+ super();
+ fOperationTarget= target;
+ fOperationCode= operationCode;
+ update();
+ }
+
+ public DisplayViewAction(IAdaptable targetProvider, int operationCode) {
+ super();
+ fTargetProvider= targetProvider;
+ fOperationCode= operationCode;
+ update();
+ }
+
+ /**
+ * The <code>TextOperationAction</code> implementation of this
+ * <code>IAction</code> method runs the operation with the current
+ * operation code.
+ */
+ public void run() {
+ if (fOperationCode != -1 && fOperationTarget != null)
+ fOperationTarget.doOperation(fOperationCode);
+ }
+
+ /**
+ * The <code>TextOperationAction</code> implementation of this
+ * <code>IUpdate</code> method discovers the operation through the current
+ * editor's <code>ITextOperationTarget</code> adapter, and sets the
+ * enabled state accordingly.
+ */
+ public void update() {
+ if (fOperationTarget == null && fTargetProvider != null && fOperationCode != -1){
+ fOperationTarget= (ITextOperationTarget) fTargetProvider.getAdapter(ITextOperationTarget.class);
+ }
+
+ boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
+ setEnabled(isEnabled);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -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.internal.debug.ui.display;
+
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
+import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.text.RubySourceViewerConfiguration;
+
+/**
+ * The source viewer configuration for the Display view
+ */
+public class DisplayViewerConfiguration extends RubySourceViewerConfiguration {
+
+ public DisplayViewerConfiguration() {
+ super(RdtDebugUiPlugin.getDefault().getRubyTextTools().getColorManager(),
+ new ChainedPreferenceStore(new IPreferenceStore[] {
+ PreferenceConstants.getPreferenceStore(),
+ EditorsUI.getPreferenceStore()}),
+ null, null);
+ }
+
+ /**
+ * Returns the preference store this source viewer configuration is associated with.
+ *
+ * @return
+ */
+ public IPreferenceStore getTextPreferenceStore() {
+ return fPreferenceStore;
+ }
+
+ public IContentAssistProcessor getContentAssistantProcessor() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+
+ ContentAssistant assistant = new ContentAssistant();
+ assistant.setContentAssistProcessor(
+ getContentAssistantProcessor(),
+ IDocument.DEFAULT_CONTENT_TYPE);
+
+// JDIContentAssistPreference.configure(assistant, getColorManager());
+
+ assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
+ assistant.setInformationControlCreator(
+ getInformationControlCreator(sourceViewer));
+
+ return assistant;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getDoubleClickStrategy(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
+ */
+ public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
+ ITextDoubleClickStrategy clickStrat = new ITextDoubleClickStrategy() {
+ // Highlight the whole line when double clicked. See Bug#45481
+ public void doubleClicked(ITextViewer viewer) {
+ try {
+ IDocument doc = viewer.getDocument();
+ int caretOffset = viewer.getSelectedRange().x;
+ int lineNum = doc.getLineOfOffset(caretOffset);
+ int start = doc.getLineOffset(lineNum);
+ int length = doc.getLineLength(lineNum);
+ viewer.setSelectedRange(start, length);
+ } catch (BadLocationException e) {
+ RdtDebugUiPlugin.log(e);
+ }
+ }
+ };
+ return clickStrat;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.debug.ui.display;
+
+
+public interface IDataDisplay {
+
+ /**
+ * Clears the content of this data display.
+ */
+ public void clear();
+
+ /**
+ * Displays the expression in the content of this data
+ * display.
+ */
+ public void displayExpression(String expression);
+
+ /**
+ * Displays the expression valur in the content of this data
+ * display.
+ */
+ public void displayExpressionValue(String value);
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * 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.debug.ui.display;
+
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IErrorReportingExpression;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.core.model.IValue;
+import org.rubypeople.rdt.internal.debug.core.model.IEvaluationResult;
+
+/**
+ * An implementation of an expression produced from the
+ * inspect action. An inspect expression removes
+ * itself from the expression manager when its debug
+ * target terminates.
+ */
+public class RubyInspectExpression extends PlatformObject implements IErrorReportingExpression, IDebugEventSetListener {
+
+ /**
+ * The value of this expression
+ */
+ private IValue fValue;
+
+ /**
+ * The code snippet for this expression.
+ */
+ private String fExpression;
+
+ private IEvaluationResult fResult;
+
+ /**
+ * Constructs a new inspect result for the given
+ * expression and resulting value. Starts listening
+ * to debug events such that this element will remove
+ * itself from the expression manager when its debug
+ * target terminates.
+ *
+ * @param expression code snippet
+ * @param value value of the expression
+ */
+ public RubyInspectExpression(String expression, IValue value) {
+ fValue = value;
+ fExpression = expression;
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+
+ /**
+ * Constructs a new inspect result for the given
+ * evaluation result, which provides a snippet, value,
+ * and error messages, if any.
+ *
+ * @param result the evaluation result
+ */
+ public RubyInspectExpression(IEvaluationResult result) {
+ this(result.getSnippet(), result.getValue());
+ fResult= result;
+ }
+
+ /**
+ * @see IExpression#getExpressionText()
+ */
+ public String getExpressionText() {
+ return fExpression;
+ }
+
+ /**
+ * @see IExpression#getValue()
+ */
+ public IValue getValue() {
+ return fValue;
+ }
+
+ /**
+ * @see IDebugElement#getDebugTarget()
+ */
+ public IDebugTarget getDebugTarget() {
+ IValue value= getValue();
+ if (value != null) {
+ return getValue().getDebugTarget();
+ }
+ if (fResult != null) {
+ return fResult.getThread().getDebugTarget();
+ }
+ // An expression should never be created with a null value *and*
+ // a null result.
+ return null;
+ }
+
+ /**
+ * @see IDebugElement#getModelIdentifier()
+ */
+ public String getModelIdentifier() {
+ return getDebugTarget().getModelIdentifier();
+ }
+
+ /**
+ * @see IDebugElement#getLaunch()
+ */
+ public ILaunch getLaunch() {
+ return getDebugTarget().getLaunch();
+ }
+
+ /**
+ * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
+ */
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ switch (event.getKind()) {
+ case DebugEvent.TERMINATE:
+ if (event.getSource().equals(getDebugTarget())) {
+ DebugPlugin.getDefault().getExpressionManager().removeExpression(this);
+ }
+ break;
+ case DebugEvent.SUSPEND:
+ if (event.getDetail() != DebugEvent.EVALUATION_IMPLICIT) {
+ if (event.getSource() instanceof IDebugElement) {
+ IDebugElement source = (IDebugElement) event.getSource();
+ if (source.getDebugTarget().equals(getDebugTarget())) {
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT)});
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * @see IExpression#dispose()
+ */
+ public void dispose() {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+
+ /**
+ * @see org.eclipse.debug.core.model.IErrorReportingExpression#hasErrors()
+ */
+ public boolean hasErrors() {
+ return fResult != null && fResult.hasErrors();
+ }
+
+ /**
+ * @see org.eclipse.debug.core.model.IErrorReportingExpression#getErrorMessages()
+ */
+ public String[] getErrorMessages() {
+ return getErrorMessages(fResult);
+ }
+
+ public static String[] getErrorMessages(IEvaluationResult result) {
+ if (result == null) {
+ return new String[0];
+ }
+ String messages[]= result.getErrorMessages();
+ if (messages.length > 0) {
+ return messages;
+ }
+ DebugException exception= result.getException();
+ if (exception != null ) {
+ return new String[] { exception.getMessage() };
+ }
+ return new String[0];
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 18:18:48
|
Revision: 3060
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3060&view=rev
Author: cawilliams
Date: 2007-08-23 11:18:47 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
first stab at implementing #4928 - add support for interacting at breakpoint.
Add Display view which allows users to type in Ruby code and execute/inspect the results
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/plugin.properties
trunk/org.rubypeople.rdt.debug.ui/plugin.xml
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/debug/ui/RdtDebugUiConstants.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RdtDebugUiPlugin.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/disp_sbook.gif
trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/
trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/disp_sbook.gif
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/EvaluationContextManager.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.properties
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ExecuteAction.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DataDisplay.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayView.java
Added: trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/disp_sbook.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.debug.ui/icons/full/dtool16/disp_sbook.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/disp_sbook.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.debug.ui/icons/full/etool16/disp_sbook.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.debug.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/plugin.properties 2007-08-23 18:18:29 UTC (rev 3059)
+++ trunk/org.rubypeople.rdt.debug.ui/plugin.properties 2007-08-23 18:18:47 UTC (rev 3060)
@@ -27,3 +27,7 @@
modifyCatchpoint.label=Ruby Exception Breakpoint
modifyCatchpoint.tooltip=Define a ruby exception breakpoint
+displayViewName=Display
+
+Execute.label=E&xecute
+Execute.tooltip=Evaluate the Selected Text
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.debug.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/plugin.xml 2007-08-23 18:18:29 UTC (rev 3059)
+++ trunk/org.rubypeople.rdt.debug.ui/plugin.xml 2007-08-23 18:18:47 UTC (rev 3060)
@@ -1,8 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
-
- <extension point="org.eclipse.ui.preferencePages">
+ <extension point="org.eclipse.ui.views">
+ <view
+ name="%displayViewName"
+ icon="$nl$/icons/full/etool16/disp_sbook.gif"
+ category="org.eclipse.debug.ui"
+ class="org.rubypeople.rdt.internal.debug.ui.display.DisplayView"
+ id="org.rubypeople.rdt.debug.ui.DisplayView">
+ </view>
+ </extension>
+ <extension point="org.eclipse.ui.preferencePages">
<page name="%PreferencePage.RubyInterpreter.name"
category="org.rubypeople.rdt.ui.preferences.PreferencePageRubyBase"
class="org.rubypeople.rdt.internal.debug.ui.preferences.RubyInterpreterPreferencePage"
@@ -91,6 +99,33 @@
toolbarPath="rdtExceptions"
tooltip="%modifyCatchpoint.tooltip"/>
</viewContribution>
+ <viewContribution
+ id="org.rubypeople.rdt.debug.ui.DisplayViewActions"
+ targetID="org.rubypeople.rdt.debug.ui.DisplayView">
+ <action
+ toolbarPath="evaluationGroup"
+ id="org.rubypeople.rdt.debug.ui.displayViewToolbar.Execute"
+ hoverIcon="$nl$/icons/full/etool16/run_sbook.gif"
+ class="org.rubypeople.rdt.internal.debug.ui.actions.ExecuteAction"
+ disabledIcon="$nl$/icons/full/dtool16/run_sbook.gif"
+ enablesFor="+"
+ icon="$nl$/icons/full/etool16/run_sbook.gif"
+ helpContextId="execute_action_context"
+ label="%Execute.label"
+ tooltip="%Execute.tooltip">
+ <enablement>
+ <and>
+ <systemProperty
+ name="org.rubypeople.rdt.debug.ui.debuggerActive"
+ value="true">
+ </systemProperty>
+ <objectClass
+ name="org.eclipse.jface.text.ITextSelection">
+ </objectClass>
+ </and>
+ </enablement>
+ </action>
+ </viewContribution>
</extension>
<extension point="org.eclipse.ui.contexts">
<context name="Debugging Ruby" description="Debugging Ruby programs"
@@ -283,4 +318,30 @@
</action>
</actionSet>
</extension>
-</plugin>
\ No newline at end of file
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension targetID="org.eclipse.debug.ui.DebugPerspective">
+ <view
+ id="org.rubypeople.rdt.debug.ui.DisplayView"
+ relationship="stack"
+ relative="org.eclipse.ui.console.ConsoleView"
+ visible="false"/>
+ <viewShortcut id="org.rubypeople.rdt.debug.ui.DisplayView"/>
+ <view
+ id="org.rubypeople.rdt.ui.TypeHierarchy"
+ relationship="stack"
+ relative="org.eclipse.debug.ui.DebugView"
+ visible="false"/>
+ <view
+ id="org.eclipse.search.SearchResultView"
+ relationship="stack"
+ relative="org.eclipse.ui.console.ConsoleView"
+ visible="false"/>
+ <view
+ id="org.rubypeople.rdt.ui.ViewRubyResources"
+ relationship="stack"
+ relative="org.eclipse.debug.ui.DebugView"
+ visible="false"/>
+ </perspectiveExtension>
+ </extension>
+</plugin>
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/debug/ui/RdtDebugUiConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/debug/ui/RdtDebugUiConstants.java 2007-08-23 18:18:29 UTC (rev 3059)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/debug/ui/RdtDebugUiConstants.java 2007-08-23 18:18:47 UTC (rev 3060)
@@ -8,4 +8,14 @@
public static final String SHOW_CONSTANTS_PREFERENCE = RdtDebugUiPlugin.PLUGIN_ID + ".showConstants";
public static final String EVALUATION_EXPRESSIONS_PREFERENCE = RdtDebugUiPlugin.PLUGIN_ID + ".evaluationExpressions";
public static final int INTERNAL_ERROR = 0;
+
+ /**
+ * Identifier for a group of evaluation actions in a menu (value <code>"evaluationGroup"</code>).
+ */
+ public static final String EVALUATION_GROUP= "evaluationGroup"; //$NON-NLS-1$
+
+ /**
+ * Display view identifier (value <code>"org.rubypeople.rdt.debug.ui.DisplayView"</code>).
+ */
+ public static final String ID_DISPLAY_VIEW= RdtDebugUiPlugin.PLUGIN_ID + ".DisplayView"; //$NON-NLS-1$
}
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/EvaluationContextManager.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/EvaluationContextManager.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/EvaluationContextManager.java 2007-08-23 18:18:47 UTC (rev 3060)
@@ -0,0 +1,211 @@
+package org.rubypeople.rdt.internal.debug.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
+import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
+import org.rubypeople.rdt.internal.debug.core.model.RubyThread;
+
+public class EvaluationContextManager implements IDebugContextListener, IWindowListener {
+
+ private static EvaluationContextManager fgManager;
+
+ /**
+ * System property indicating a stack frame is selected in the debug view with an
+ * <code>IJavaStackFrame</code> adapter.
+ */
+ private static final String DEBUGGER_ACTIVE = RdtDebugUiPlugin.getUniqueIdentifier() + ".debuggerActive"; //$NON-NLS-1$
+ /**
+ * System property indicating an element is selected in the debug view that is
+ * an instanceof <code>RubyStackFrame</code> or <code>RubyThread</code>.
+ */
+ private static final String INSTANCE_OF_IRUBY_STACK_FRAME = RdtDebugUiPlugin.getUniqueIdentifier() + ".instanceof.RubyStackFrame"; //$NON-NLS-1$
+
+
+ private Map fContextsByPage = null;
+ private IWorkbenchWindow fActiveWindow;
+
+ private EvaluationContextManager() {
+ DebugContextManager.getDefault().addDebugContextListener(this);
+ }
+
+ public static RubyStackFrame getEvaluationContext(IWorkbenchPart part) {
+ IWorkbenchPage page = part.getSite().getPage();
+ RubyStackFrame frame = getContext(page);
+ if (frame == null) {
+ return getEvaluationContext(page.getWorkbenchWindow());
+ }
+ return frame;
+ }
+
+ public static RubyStackFrame getEvaluationContext(IWorkbenchWindow window) {
+ List alreadyVisited= new ArrayList();
+ if (window == null) {
+ window = fgManager.fActiveWindow;
+ }
+ return getEvaluationContext(window, alreadyVisited);
+ }
+
+ private static RubyStackFrame getEvaluationContext(IWorkbenchWindow window, List alreadyVisited) {
+ IWorkbenchPage activePage = window.getActivePage();
+ RubyStackFrame frame = null;
+ if (activePage != null) {
+ frame = getContext(activePage);
+ }
+ if (frame == null) {
+ IWorkbenchPage[] pages = window.getPages();
+ for (int i = 0; i < pages.length; i++) {
+ if (activePage != pages[i]) {
+ frame = getContext(pages[i]);
+ if (frame != null) {
+ return frame;
+ }
+ }
+ }
+
+ alreadyVisited.add(window);
+
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ if (!alreadyVisited.contains(windows[i])) {
+ frame = getEvaluationContext(windows[i], alreadyVisited);
+ if (frame != null) {
+ return frame;
+ }
+ }
+ }
+ return null;
+ }
+ return frame;
+ }
+
+ private static RubyStackFrame getContext(IWorkbenchPage page) {
+ if (fgManager != null) {
+ if (fgManager.fContextsByPage != null) {
+ return (RubyStackFrame)fgManager.fContextsByPage.get(page);
+ }
+ }
+ return null;
+ }
+
+ public void contextActivated(ISelection selection, IWorkbenchPart part) {
+ if (part != null) {
+ IWorkbenchPage page = part.getSite().getPage();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if (ss.size() == 1) {
+ Object element = ss.getFirstElement();
+ if (element instanceof IAdaptable) {
+ RubyStackFrame frame = (RubyStackFrame)((IAdaptable)element).getAdapter(RubyStackFrame.class);
+ boolean instOf = element instanceof RubyStackFrame || element instanceof RubyThread;
+ if (frame != null) {
+ // do not consider scrapbook frames
+// if (frame.getLaunch().getAttribute(ScrapbookLauncher.SCRAPBOOK_LAUNCH) == null) {
+ setContext(page, frame, instOf);
+ return;
+// }
+ }
+ }
+ }
+ }
+ // no context in the given view
+ removeContext(page);
+ }
+ }
+
+ public void contextChanged(ISelection selection, IWorkbenchPart part) {
+ }
+
+ /**
+ * Sets the evaluation context for the given page, and notes that
+ * a valid execution context exists.
+ *
+ * @param page
+ * @param frame
+ */
+ private void setContext(IWorkbenchPage page, RubyStackFrame frame, boolean instOf) {
+ if (fContextsByPage == null) {
+ fContextsByPage = new HashMap();
+ }
+ fContextsByPage.put(page, frame);
+ System.setProperty(DEBUGGER_ACTIVE, "true"); //$NON-NLS-1$
+ if (instOf) {
+ System.setProperty(INSTANCE_OF_IRUBY_STACK_FRAME, "true"); //$NON-NLS-1$
+ } else {
+ System.setProperty(INSTANCE_OF_IRUBY_STACK_FRAME, "false"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Removes an evaluation context for the given page, and determines if
+ * any valid execution context remain.
+ *
+ * @param page
+ */
+ private void removeContext(IWorkbenchPage page) {
+ if (fContextsByPage != null) {
+ fContextsByPage.remove(page);
+ if (fContextsByPage.isEmpty()) {
+ System.setProperty(DEBUGGER_ACTIVE, "false"); //$NON-NLS-1$
+ System.setProperty(INSTANCE_OF_IRUBY_STACK_FRAME, "false"); //$NON-NLS-1$
+ }
+ }
+ }
+
+ public static void startup() {
+ Runnable r = new Runnable() {
+ public void run() {
+ if (fgManager == null) {
+ fgManager = new EvaluationContextManager();
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ fgManager.windowOpened(windows[i]);
+ }
+ workbench.addWindowListener(fgManager);
+ fgManager.fActiveWindow = workbench.getActiveWorkbenchWindow();
+ }
+ }
+ };
+ RdtDebugUiPlugin.getStandardDisplay().asyncExec(r);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void windowActivated(IWorkbenchWindow window) {
+ fActiveWindow = window;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void windowClosed(IWorkbenchWindow window) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void windowDeactivated(IWorkbenchWindow window) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void windowOpened(IWorkbenchWindow window) {
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/EvaluationContextManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java 2007-08-23 18:18:47 UTC (rev 3060)
@@ -0,0 +1,359 @@
+/*******************************************************************************
+ * 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.debug.ui;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.custom.BidiSegmentEvent;
+import org.eclipse.swt.custom.BidiSegmentListener;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.rubypeople.rdt.internal.debug.ui.display.DisplayViewerConfiguration;
+import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
+
+/**
+ * A source viewer configured to display Java source. This
+ * viewer obeys the font and color preferences specified in
+ * the Java UI plugin.
+ */
+public class JDISourceViewer extends SourceViewer implements IPropertyChangeListener {
+
+ private Font fFont;
+ private Color fBackgroundColor;
+ private Color fForegroundColor;
+ private IPreferenceStore fStore;
+ private DisplayViewerConfiguration fConfiguration;
+
+ public JDISourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+ super(parent, ruler, styles);
+ StyledText text= this.getTextWidget();
+ text.addBidiSegmentListener(new BidiSegmentListener() {
+ public void lineGetSegments(BidiSegmentEvent event) {
+ try {
+ event.segments= getBidiLineSegments(event.lineOffset);
+ } catch (BadLocationException x) {
+ // ignore
+ }
+ }
+ });
+ }
+
+ /**
+ * Updates the viewer's font to match the preferences.
+ */
+ private void updateViewerFont() {
+ IPreferenceStore store= getPreferenceStore();
+ if (store != null) {
+ FontData data= null;
+ if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
+ data= PreferenceConverter.getFontData(store, JFaceResources.TEXT_FONT);
+ } else {
+ data= PreferenceConverter.getDefaultFontData(store, JFaceResources.TEXT_FONT);
+ }
+ if (data != null) {
+ Font font= new Font(getTextWidget().getDisplay(), data);
+ applyFont(font);
+ if (getFont() != null) {
+ getFont().dispose();
+ }
+ setFont(font);
+ return;
+ }
+ }
+ // if all the preferences failed
+ applyFont(JFaceResources.getTextFont());
+ }
+
+ /**
+ * Sets the current font.
+ *
+ * @param font the new font
+ */
+ private void setFont(Font font) {
+ fFont= font;
+ }
+
+ /**
+ * Returns the current font.
+ *
+ * @return the current font
+ */
+ private Font getFont() {
+ return fFont;
+ }
+
+ /**
+ * Sets the font for the given viewer sustaining selection and scroll position.
+ *
+ * @param font the font
+ */
+ private void applyFont(Font font) {
+ IDocument doc= getDocument();
+ if (doc != null && doc.getLength() > 0) {
+ Point selection= getSelectedRange();
+ int topIndex= getTopIndex();
+
+ StyledText styledText= getTextWidget();
+ styledText.setRedraw(false);
+
+ styledText.setFont(font);
+ setSelectedRange(selection.x , selection.y);
+ setTopIndex(topIndex);
+
+ styledText.setRedraw(true);
+ } else {
+ getTextWidget().setFont(font);
+ }
+ }
+
+ /**
+ * Updates the given viewer's colors to match the preferences.
+ */
+ public void updateViewerColors() {
+ IPreferenceStore store= getPreferenceStore();
+ if (store != null) {
+ StyledText styledText= getTextWidget();
+ Color color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
+ styledText.setForeground(color);
+ if (getForegroundColor() != null) {
+ getForegroundColor().dispose();
+ }
+ setForegroundColor(color);
+
+ color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
+ styledText.setBackground(color);
+ if (getBackgroundColor() != null) {
+ getBackgroundColor().dispose();
+ }
+ setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * Creates a color from the information stored in the given preference store.
+ * Returns <code>null</code> if there is no such information available.
+ */
+ private Color createColor(IPreferenceStore store, String key, Display display) {
+ RGB rgb= null;
+ if (store.contains(key)) {
+ if (store.isDefault(key)) {
+ rgb= PreferenceConverter.getDefaultColor(store, key);
+ } else {
+ rgb= PreferenceConverter.getColor(store, key);
+ }
+ if (rgb != null) {
+ return new Color(display, rgb);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the current background color.
+ *
+ * @return the current background color
+ */
+ protected Color getBackgroundColor() {
+ return fBackgroundColor;
+ }
+
+ /**
+ * Sets the current background color.
+ *
+ * @param backgroundColor the new background color
+ */
+ protected void setBackgroundColor(Color backgroundColor) {
+ fBackgroundColor = backgroundColor;
+ }
+
+ /**
+ * Returns the current foreground color.
+ *
+ * @return the current foreground color
+ */
+ protected Color getForegroundColor() {
+ return fForegroundColor;
+ }
+
+ /**
+ * Sets the current foreground color.
+ *
+ * @param foregroundColor the new foreground color
+ */
+ protected void setForegroundColor(Color foregroundColor) {
+ fForegroundColor = foregroundColor;
+ }
+
+ /**
+ * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ IContentAssistant assistant= getContentAssistant();
+// if (assistant instanceof ContentAssistant) {
+// JDIContentAssistPreference.changeConfiguration((ContentAssistant) assistant, event);
+// }
+ String property= event.getProperty();
+
+ if (JFaceResources.TEXT_FONT.equals(property)) {
+ updateViewerFont();
+ }
+ if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) ||
+ AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)) {
+ updateViewerColors();
+ }
+ if (fConfiguration != null) {
+ if (fConfiguration.affectsTextPresentation(event)) {
+ fConfiguration.handlePropertyChangeEvent(event);
+ invalidateTextPresentation();
+ }
+ }
+ }
+
+ /**
+ * Returns the current content assistant.
+ *
+ * @return the current content assistant
+ */
+ public IContentAssistant getContentAssistant() {
+ return fContentAssistant;
+ }
+
+ /**
+ * Returns a segmentation of the line of the given document appropriate for bidi rendering.
+ * The default implementation returns only the string literals of a Ruby code line as segments.
+ *
+ * @param document the document
+ * @param lineOffset the offset of the line
+ * @return the line's bidi segmentation
+ * @throws BadLocationException in case lineOffset is not valid in document
+ */
+ protected int[] getBidiLineSegments(int lineOffset) throws BadLocationException {
+ IDocument document= getDocument();
+ if (document == null) {
+ return null;
+ }
+ IRegion line= document.getLineInformationOfOffset(lineOffset);
+ ITypedRegion[] linePartitioning= document.computePartitioning(lineOffset, line.getLength());
+
+ List segmentation= new ArrayList();
+ for (int i= 0; i < linePartitioning.length; i++) {
+ if (IRubyPartitions.RUBY_STRING.equals(linePartitioning[i].getType()))
+ segmentation.add(linePartitioning[i]);
+ }
+
+
+ if (segmentation.size() == 0)
+ return null;
+
+ int size= segmentation.size();
+ int[] segments= new int[size * 2 + 1];
+
+ int j= 0;
+ for (int i= 0; i < size; i++) {
+ ITypedRegion segment= (ITypedRegion) segmentation.get(i);
+
+ if (i == 0)
+ segments[j++]= 0;
+
+ int offset= segment.getOffset() - lineOffset;
+ if (offset > segments[j - 1])
+ segments[j++]= offset;
+
+ if (offset + segment.getLength() >= line.getLength())
+ break;
+
+ segments[j++]= offset + segment.getLength();
+ }
+
+ if (j < segments.length) {
+ int[] result= new int[j];
+ System.arraycopy(segments, 0, result, 0, j);
+ segments= result;
+ }
+
+ return segments;
+ }
+
+ /**
+ * Disposes the system resources currently in use by this viewer.
+ */
+ public void dispose() {
+ if (getFont() != null) {
+ getFont().dispose();
+ setFont(null);
+ }
+ if (getBackgroundColor() != null) {
+ getBackgroundColor().dispose();
+ setBackgroundColor(null);
+ }
+ if (getForegroundColor() != null) {
+ getForegroundColor().dispose();
+ setForegroundColor(null);
+ }
+ if (fStore != null) {
+ fStore.removePropertyChangeListener(this);
+ fStore = null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
+ */
+ public void configure(SourceViewerConfiguration configuration) {
+ super.configure(configuration);
+ if (fStore != null) {
+ fStore.removePropertyChangeListener(this);
+ fStore = null;
+ }
+ if (configuration instanceof DisplayViewerConfiguration) {
+ fConfiguration = (DisplayViewerConfiguration) configuration;
+ fStore = fConfiguration.getTextPreferenceStore();
+ fStore.addPropertyChangeListener(this);
+ }
+ updateViewerFont();
+ updateViewerColors();
+ }
+
+ /**
+ * Returns the preference store used to configure this source viewer or
+ * <code>null</code> if none;
+ */
+ private IPreferenceStore getPreferenceStore() {
+ return fStore;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/JDISourceViewer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RdtDebugUiPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RdtDebugUiPlugin.java 2007-08-23 18:18:29 UTC (rev 3059)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RdtDebugUiPlugin.java 2007-08-23 18:18:47 UTC (rev 3060)
@@ -6,7 +6,9 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.internal.ui.ImageDescriptorRegistry;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -15,6 +17,8 @@
import org.rubypeople.rdt.debug.ui.RdtDebugUiConstants;
import org.rubypeople.rdt.internal.debug.core.model.RubyVariable;
import org.rubypeople.rdt.internal.debug.ui.evaluation.EvaluationExpressionModel;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.text.RubyTextTools;
public class RdtDebugUiPlugin extends AbstractUIPlugin implements RdtDebugUiConstants {
@@ -24,6 +28,7 @@
private EvaluationExpressionModel evaluationExpressionModel;
private ImageDescriptorRegistry fImageDescriptorRegistry;
+ private RubyTextTools fTextTools;
public RdtDebugUiPlugin() {
super();
@@ -35,7 +40,11 @@
}
public static IWorkbenchPage getActivePage() {
- return RdtDebugUiPlugin.getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchWindow w = getActiveWorkbenchWindow();
+ if (w != null) {
+ return w.getActivePage();
+ }
+ return null;
}
public static RdtDebugUiPlugin getDefault() {
@@ -60,6 +69,7 @@
ActionFilterAdapterFactory actionFilterAdapterFactory= new ActionFilterAdapterFactory();
manager.registerAdapters(actionFilterAdapterFactory, RubyVariable.class);
new CodeReloader();
+ EvaluationContextManager.startup();
}
@Override
@@ -107,4 +117,35 @@
return getDefault().fImageDescriptorRegistry;
}
+ public RubyTextTools getRubyTextTools() {
+ if (fTextTools == null) {
+ fTextTools = new RubyTextTools(PreferenceConstants.getPreferenceStore());
+ }
+ return fTextTools;
+ }
+
+ /**
+ * Returns the active workbench shell or <code>null</code> if none
+ *
+ * @return the active workbench shell or <code>null</code> if none
+ */
+ public static Shell getActiveWorkbenchShell() {
+ IWorkbenchWindow window = getActiveWorkbenchWindow();
+ if (window != null) {
+ return window.getShell();
+ }
+ return null;
+ }
+
+ /**
+ * Utility method with conventions
+ */
+ public static void errorDialog(String message, Throwable t) {
+ log(t);
+ Shell shell = getActiveWorkbenchShell();
+ if (shell != null) {
+ IStatus status= new Status(IStatus.ERROR, getUniqueIdentifier(), RdtDebugUiConstants.INTERNAL_ERROR, "Error logged from RDT Debug UI: ", t); //$NON-NLS-1$
+ ErrorDialog.openError(shell, "Error", message, status);
+ }
+ }
}
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.java 2007-08-23 18:18:47 UTC (rev 3060)
@@ -0,0 +1,26 @@
+package org.rubypeople.rdt.internal.debug.ui.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ActionMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.rubypeople.rdt.internal.debug.ui.actions.ActionMessages";//$NON-NLS-1$
+
+ public static String Evaluate_error_message_direct_exception;
+ public static String Evaluate_error_message_exception_pattern;
+ public static String Evaluate_error_message_src_context;
+ public static String Evaluate_error_message_stack_frame_context;
+ public static String Evaluate_error_message_wrapped_exception;
+ public static String Evaluate_error_problem_append_pattern;
+ public static String Evaluate_error_title_eval_problems;
+ public static String EvaluateAction_Cannot_open_Display_view;
+ public static String EvaluateAction__evaluation_failed__1;
+ public static String EvaluateAction__evaluation_failed__Reason;
+ public static String EvaluateAction_Thread_not_suspended___unable_to_perform_evaluation__1;
+ public static String EvaluateAction_Cannot_perform_nested_evaluations__1;
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.properties (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.properties 2007-08-23 18:18:47 UTC (rev 3060)
@@ -0,0 +1,23 @@
+###############################################################################
+# 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
+###############################################################################
+
+Evaluate_error_message_direct_exception=An exception occurred: {0}
+Evaluate_error_message_exception_pattern={0} - {1}
+Evaluate_error_message_src_context=Unable to evaluate the selected expression:\n\nTo perform an evaluation, an expression must be compiled in the context of a Ruby project's build path. The current execution context is not associated with a Ruby project in the workspace.
+Evaluate_error_message_stack_frame_context=A stack frame must be selected to provide a context for an evaluation.
+Evaluate_error_message_wrapped_exception=An exception occurred: {0}
+Evaluate_error_problem_append_pattern={0}\n{1}
+Evaluate_error_title_eval_problems=Error Evaluating
+EvaluateAction_Cannot_open_Display_view=Cannot open Display View
+EvaluateAction__evaluation_failed__1=(evaluation failed)
+EvaluateAction__evaluation_failed__Reason=Evaluation failed. Reason(s):\n{0}
+EvaluateAction_Thread_not_suspended___unable_to_perform_evaluation__1=Thread not suspended - unable to perform evaluation.
+EvaluateAction_Cannot_perform_nested_evaluations__1=Cannot perform nested evaluations.
\ No newline at end of file
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ActionMessages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java 2007-08-23 18:18:47 UTC (rev 3060)
@@ -0,0 +1,770 @@
+/*******************************************************************************
+ * 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.debug.ui.actions;
+
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.ISourceLocator;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.IDebugView;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.debug.ui.RdtDebugUiConstants;
+import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
+import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy;
+import org.rubypeople.rdt.internal.debug.core.model.IEvaluationResult;
+import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
+import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
+import org.rubypeople.rdt.internal.debug.core.model.RubyValue;
+import org.rubypeople.rdt.internal.debug.core.model.RubyVariable;
+import org.rubypeople.rdt.internal.debug.ui.EvaluationContextManager;
+import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
+import org.rubypeople.rdt.internal.debug.ui.RubySourceLocator.SourceElement;
+import org.rubypeople.rdt.internal.debug.ui.display.IDataDisplay;
+import org.rubypeople.rdt.internal.debug.ui.display.RubyInspectExpression;
+import org.rubypeople.rdt.internal.ui.text.RubyWordFinder;
+
+
+/**
+ * Action to do simple code evaluation. The evaluation
+ * is done in the UI thread and the expression and result are
+ * displayed using the IDataDisplay.
+ */
+public abstract class EvaluateAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate, IEditorActionDelegate, IPartListener, IViewActionDelegate {
+
+ private IAction fAction;
+ private IWorkbenchPart fTargetPart;
+ private IWorkbenchWindow fWindow;
+ private Object fSelection;
+ private IRegion fRegion;
+
+ /**
+ * Is the action waiting for an evaluation.
+ */
+ private boolean fEvaluating;
+
+ /**
+ * The new target part to use with the evaluation completes.
+ */
+ private IWorkbenchPart fNewTargetPart= null;
+
+ /**
+ * Used to resolve editor input for selected stack frame
+ */
+ private IDebugModelPresentation fPresentation;
+
+ public EvaluateAction() {
+ super();
+ }
+
+ /**
+ * Returns the 'object' context for this evaluation,
+ * or <code>null</code> if none. If the evaluation is being performed
+ * in the context of the variables view/inspector. Then
+ * perform the evaluation in the context of the
+ * selected value.
+ *
+ * @return Ruby object or <code>null</code>
+ */
+ protected RubyValue getObjectContext() {
+ IWorkbenchPage page= RdtDebugUiPlugin.getActivePage();
+ if (page != null) {
+ IWorkbenchPart activePart= page.getActivePart();
+ if (activePart != null) {
+ IDebugView a = (IDebugView)activePart.getAdapter(IDebugView.class);
+ if (a != null) {
+ if (a.getViewer() != null) {
+ ISelection s = a.getViewer().getSelection();
+ if (s instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection)s;
+ if (structuredSelection.size() == 1) {
+ Object selection= structuredSelection.getFirstElement();
+ if (selection instanceof RubyVariable) {
+ RubyVariable var = (RubyVariable)selection;
+ // if 'this' is selected, use stack frame context
+// try {
+ if (!var.getName().equals("this")) { //$NON-NLS-1$
+ IValue value= var.getValue();
+ if (value instanceof RubyValue) {
+ return (RubyValue)value;
+ }
+ }
+// } catch (DebugException e) {
+// RdtDebugUiPlugin.log(e);
+// }
+ } else if (selection instanceof RubyInspectExpression) {
+ IValue value= ((RubyInspectExpression)selection).getValue();
+ if (value instanceof RubyValue) {
+ return (RubyValue)value;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Finds the currently selected stack frame in the UI.
+ * Stack frames from a scrapbook launch are ignored.
+ */
+ protected RubyStackFrame getStackFrameContext() {
+ IWorkbenchPart part = getTargetPart();
+ RubyStackFrame frame = null;
+ if (part == null) {
+ frame = EvaluationContextManager.getEvaluationContext(getWindow());
+ } else {
+ frame = EvaluationContextManager.getEvaluationContext(part);
+ }
+ return frame;
+ }
+
+ /**
+ * @see IEvaluationListener#evaluationComplete(IEvaluationResult)
+ */
+ public void evaluationComplete(final IEvaluationResult result) {
+ // if plug-in has shutdown, ignore - see bug# 8693
+ if (RdtDebugUiPlugin.getDefault() == null) {
+ return;
+ }
+
+ final IValue value= result.getValue();
+ if (result.hasErrors() || value != null) {
+ final Display display= RdtDebugUiPlugin.getStandardDisplay();
+ if (display.isDisposed()) {
+ return;
+ }
+ displayResult(result);
+ }
+ }
+
+ protected void evaluationCleanup() {
+ setEvaluating(false);
+ setTargetPart(fNewTargetPart);
+ }
+ /**
+ * Display the given evaluation result.
+ */
+ abstract protected void displayResult(IEvaluationResult result);
+
+ protected void run() {
+ // eval in context of object or stack frame
+ final RubyValue object = getObjectContext();
+ final RubyStackFrame stackFrame= getStackFrameContext();
+ if (stackFrame == null) {
+ reportError(ActionMessages.Evaluate_error_message_stack_frame_context);
+ return;
+ }
+
+ // check for nested evaluation
+ IThread thread = (IThread)stackFrame.getThread();
+// if (thread.isPerformingEvaluation()) {
+// reportError(ActionMessages.EvaluateAction_Cannot_perform_nested_evaluations__1);
+// return;
+// }
+
+ setNewTargetPart(getTargetPart());
+
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ if (stackFrame.isSuspended()) {
+ IRubyElement javaElement= getRubyElement(stackFrame);
+ if (javaElement != null) {
+ IRubyProject project = javaElement.getRubyProject();
+ try {
+ Object selection= getSelectedObject();
+ if (!(selection instanceof String)) {
+ return;
+ }
+ String expression= (String)selection;
+ setEvaluating(true);
+ RubyDebuggerProxy proxy = stackFrame.getRubyDebuggerProxy();
+ IEvaluationResult result = proxy.evaluate(stackFrame, expression);
+ evaluationComplete(result);
+ return;
+ } catch (RubyProcessingException e) {
+ throw new InvocationTargetException(e, getExceptionMessage(e));
+ }
+ }
+ throw new InvocationTargetException(null, ActionMessages.Evaluate_error_message_src_context);
+ }
+ // thread not suspended
+ throw new InvocationTargetException(null, ActionMessages.EvaluateAction_Thread_not_suspended___unable_to_perform_evaluation__1);
+ }
+ };
+
+ IWorkbench workbench = RdtDebugUiPlugin.getDefault().getWorkbench();
+ try {
+ workbench.getProgressService().busyCursorWhile(runnable);
+ } catch (InvocationTargetException e) {
+ evaluationCleanup();
+ String message = e.getMessage();
+ if (message == null) {
+ message = e.getClass().getName();
+ if (e.getCause() != null) {
+ message = e.getCause().getClass().getName();
+ if (e.getCause().getMessage() != null) {
+ message = e.getCause().getMessage();
+ }
+ }
+ }
+ reportError(message);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ protected IRubyElement getRubyElement(IStackFrame stackFrame) {
+
+ // Get the corresponding element.
+ ILaunch launch = stackFrame.getLaunch();
+ if (launch == null) {
+ return null;
+ }
+ ISourceLocator locator= launch.getSourceLocator();
+ if (locator == null)
+ return null;
+
+ Object sourceElement = locator.getSourceElement(stackFrame);
+ if (sourceElement instanceof SourceElement) {
+ SourceElement element = (SourceElement) sourceElement;
+ if (element.isExternal()) {
+ // FIXME We need to track the file to a project that contains it in an external source folder!
+ return null;
+ } else {
+ IRubyProject project = RubyCore.create((element.getWorkspaceFile()).getProject());
+ if (project.exists()) {
+ return project;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Updates the enabled state of the action that this is a
+ * delegate for.
+ */
+ protected void update() {
+ IAction action= getAction();
+ if (action != null) {
+ resolveSelectedObject();
+ }
+ }
+
+ /**
+ * Resolves the selected object in the target part, or <code>null</code>
+ * if there is no selection.
+ */
+ protected void resolveSelectedObject() {
+ Object selectedObject= null;
+ fRegion = null;
+ ISelection selection= getTargetSelection();
+ if (selection instanceof ITextSelection) {
+ ITextSelection ts = (ITextSelection)selection;
+ String text= ts.getText();
+ if (textHasContent(text)) {
+ selectedObject= text;
+ fRegion = new Region(ts.getOffset(), ts.getLength());
+ } else if (getTargetPart() instanceof IEditorPart) {
+ IEditorPart editor= (IEditorPart)getTargetPart();
+ if (editor instanceof ITextEditor) {
+ selectedObject = resolveSelectedObjectUsingToken(selectedObject, ts, editor);
+ }
+ }
+ } else if (selection instanceof IStructuredSelection) {
+ if (!selection.isEmpty()) {
+ if (getTargetPart().getSite().getId().equals(IDebugUIConstants.ID_DEBUG_VIEW)) {
+ //work on the editor selection
+ IEditorPart editor= getTargetPart().getSite().getPage().getActiveEditor();
+ setTargetPart(editor);
+ selection= getTargetSelection();
+ if (selection instanceof ITextSelection) {
+ ITextSelection ts = (ITextSelection)selection;
+ String text= ts.getText();
+ if (textHasContent(text)) {
+ selectedObject= text;
+ } else if (editor instanceof ITextEditor) {
+ selectedObject= resolveSelectedObjectUsingToken(selectedObject, ts, editor);
+ }
+ }
+ } else {
+ IStructuredSelection ss= (IStructuredSelection)selection;
+ Iterator elements = ss.iterator();
+ while (elements.hasNext()) {
+ if (!(elements.next() instanceof RubyVariable)) {
+ setSelectedObject(null);
+ return;
+ }
+ }
+ selectedObject= ss;
+ }
+ }
+ }
+ setSelectedObject(selectedObject);
+ }
+
+ private Object resolveSelectedObjectUsingToken(Object selectedObject, ITextSelection ts, IEditorPart editor) {
+ ITextEditor textEditor= (ITextEditor) editor;
+ IDocument doc= textEditor.getDocumentProvider().getDocument(editor.getEditorInput());
+ fRegion= RubyWordFinder.findWord(doc, ts.getOffset());
+ if (fRegion != null) {
+ try {
+ selectedObject= doc.get(fRegion.getOffset(), fRegion.getLength());
+ } catch (BadLocationException e) {
+ }
+ }
+ return selectedObject;
+ }
+
+ protected ISelection getTargetSelection() {
+ IWorkbenchPart part = getTargetPart();
+ if (part != null) {
+ ISelectionProvider provider = part.getSite().getSelectionProvider();
+ if (provider != null) {
+ return provider.getSelection();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Resolve an editor input from the source element of the stack frame
+ * argument, and return whether it's equal to the editor input for the
+ * editor that owns this action.
+ */
+ protected boolean compareToEditorInput(IStackFrame stackFrame) {
+ ILaunch launch = stackFrame.getLaunch();
+ if (launch == null) {
+ return false;
+ }
+ ISourceLocator locator= launch.getSourceLocator();
+ if (locator == null) {
+ return false;
+ }
+ Object sourceElement = locator.getSourceElement(stackFrame);
+ if (sourceElement == null) {
+ return false;
+ }
+ IEditorInput sfEditorInput= getDebugModelPresentation().getEditorInput(sourceElement);
+ if (getTargetPart() instanceof IEditorPart) {
+ return ((IEditorPart)getTargetPart()).getEditorInput().equals(sfEditorInput);
+ }
+ return false;
+ }
+
+ protected Shell getShell() {
+ if (getTargetPart() != null) {
+ return getTargetPart().getSite().getShell();
+ }
+ return RdtDebugUiPlugin.getActiveWorkbenchShell();
+ }
+
+ protected IDataDisplay getDataDisplay() {
+ IDataDisplay display= getDirectDataDisplay();
+ if (display != null) {
+ return display;
+ }
+ IWorkbenchPage page= RdtDebugUiPlugin.getActivePage();
+ if (page != null) {
+ IWorkbenchPart activePart= page.getActivePart();
+ if (activePart != null) {
+ IViewPart view = page.findView(RdtDebugUiConstants.ID_DISPLAY_VIEW);
+ if (view == null) {
+ try {
+ view= page.showView(RdtDebugUiConstants.ID_DISPLAY_VIEW);
+ } catch (PartInitException e) {
+ RdtDebugUiPlugin.errorDialog(ActionMessages.EvaluateAction_Cannot_open_Display_view, e);
+ } finally {
+ page.activate(activePart);
+ }
+ }
+ if (view != null) {
+ page.bringToTop(view);
+ return (IDataDisplay)view.getAdapter(IDataDisplay.class);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ protected IDataDisplay getDirectDataDisplay() {
+ IWorkbenchPart part= getTargetPart();
+ if (part != null) {
+ IDataDisplay display= (IDataDisplay)part.getAdapter(IDataDisplay.class);
+ if (display != null) {
+ IWorkbenchPage page= RdtDebugUiPlugin.getActivePage();
+ if (page != null) {
+ IWorkbenchPart activePart= page.getActivePart();
+ if (activePart != null) {
+ if (activePart != part) {
+ page.activate(part);
+ }
+ }
+ }
+ return display;
+ }
+ }
+ IWorkbenchPage page= RdtDebugUiPlugin.getActivePage();
+ if (page != null) {
+ IWorkbenchPart activePart= page.getActivePart();
+ if (activePart != null) {
+ IDataDisplay display= (IDataDisplay)activePart.getAdapter(IDataDisplay.class);
+ if (display != null) {
+ return display;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected boolean textHasContent(String text) {
+ if (text != null) {
+ int length= text.length();
+ if (length > 0) {
+ for (int i= 0; i < length; i++) {
+ if (Character.isLetterOrDigit(text.charAt(i))) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Displays a failed evaluation message in the data display.
+ */
+ protected void reportErrors(IEvaluationResult result) {
+ String message= getErrorMessage(result);
+ reportError(message);
+ }
+
+ protected void reportError(String message) {
+ IDataDisplay dataDisplay= getDirectDataDisplay();
+ if (dataDisplay != null) {
+ if (message.length() != 0) {
+ dataDisplay.displayExpressionValue(MessageFormat.format(ActionMessages.EvaluateAction__evaluation_failed__Reason, new String[] {format(message)}));
+ } else {
+ dataDisplay.displayExpressionValue(ActionMessages.EvaluateAction__evaluation_failed__1);
+ }
+ } else {
+ Status status= new Status(IStatus.ERROR, RdtDebugUiPlugin.getUniqueIdentifier(), IStatus.ERROR, message, null);
+ ErrorDialog.openError(getShell(), ActionMessages.Evaluate_error_title_eval_problems, null, status);
+ }
+ }
+
+ private String format(String message) {
+ StringBuffer result= new StringBuffer();
+ int index= 0, pos;
+ while ((pos= message.indexOf('\n', index)) != -1) {
+ result.append("\t\t").append(message.substring(index, index= pos + 1)); //$NON-NLS-1$
+ }
+ if (index < message.length()) {
+ result.append("\t\t").append(message.substring(index)); //$NON-NLS-1$
+ }
+ return result.toString();
+ }
+
+ public static String getExceptionMessage(Throwable exception) {
+ if (exception instanceof CoreException) {
+ CoreException ce = (CoreException)exception;
+ Throwable throwable= ce.getStatus().getException();
+ if (throwable instanceof CoreException) {
+ // Traverse nested CoreExceptions
+ return getExceptionMessage(throwable);
+ }
+ return ce.getStatus().getMessage();
+ }
+ String message= MessageFormat.format(ActionMessages.Evaluate_error_message_direct_exception, new Object[] { exception.getClass() });
+ if (exception.getMessage() != null) {
+ message= MessageFormat.format(ActionMessages.Evaluate_error_message_exception_pattern, new Object[] { message, exception.getMessage() });
+ }
+ return message;
+ }
+
+ protected String getErrorMessage(IEvaluationResult result) {
+ String[] errors= result.getErrorMessages();
+ if (errors.length == 0) {
+ return getExceptionMessage(result.getException());
+ }
+ return getErrorMessage(errors);
+ }
+
+ protected String getErrorMessage(String[] errors) {
+ String message= ""; //$NON-NLS-1$
+ for (int i= 0; i < errors.length; i++) {
+ String msg= errors[i];
+ if (i == 0) {
+ message= msg;
+ } else {
+ message= MessageFormat.format(ActionMessages.Evaluate_error_problem_append_pattern, new Object[] { message, msg });
+ }
+ }
+ return message;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.ui.IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ update();
+ run();
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ setAction(action);
+ }
+
+ /**
+ * @see IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose() {
+ disposeDebugModelPresentation();
+ IWorkbenchWindow win = getWindow();
+ if (win != null) {
+ win.getPartService().removePartListener(this);
+ }
+ }
+
+ /**
+ * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
+ */
+ public void init(IWorkbenchWindow window) {
+ setWindow(window);
+ IWorkbenchPage page= window.getActivePage();
+ if (page != null) {
+ setTargetPart(page.getActivePart());
+ }
+ window.getPartService().addPartListener(this);
+ update();
+ }
+
+ protected IAction getAction() {
+ return fAction;
+ }
+
+ protected void setAction(IAction action) {
+ fAction = action;
+ }
+
+ /**
+ * Returns a debug model presentation (creating one
+ * if necessary).
+ *
+ * @return debug model presentation
+ */
+ protected IDebugModelPresentation getDebugModelPresentation() {
+ if (fPresentation == null) {
+ fPresentation = DebugUITools.newDebugModelPresentation(RdtDebugCorePlugin.getPluginIdentifier());
+ }
+ return fPresentation;
+ }
+
+ /**
+ * Disposes this action's debug model presentation, if
+ * one was created.
+ */
+ protected void disposeDebugModelPresentation() {
+ if (fPresentation != null) {
+ fPresentation.dispose();
+ }
+ }
+
+ /**
+ * @see IEditorActionDelegate#setActiveEditor(IAction, IEditorPart)
+ */
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ setAction(action);
+ setTargetPart(targetEditor);
+ }
+
+ /**
+ * @see IPartListener#partActivated(IWorkbenchPart)
+ */
+ public void partActivated(IWorkbenchPart part) {
+ setTargetPart(part);
+ }
+
+ /**
+ * @see IPartListener#partBroughtToTop(IWorkbenchPart)
+ */
+ public void partBroughtToTop(IWorkbenchPart part) {
+ }
+
+ /**
+ * @see IPartListener#partClosed(IWorkbenchPart)
+ */
+ public void partClosed(IWorkbenchPart part) {
+ if (part == getTargetPart()) {
+ setTargetPart(null);
+ }
+ if (part == getNewTargetPart()) {
+ setNewTargetPart(null);
+ }
+ }
+
+ /**
+ * @see IPartListener#partDeactivated(IWorkbenchPart)
+ */
+ public void partDeactivated(IWorkbenchPart part) {
+ }
+
+ /**
+ * @see IPartListener#partOpened(IWorkbenchPart)
+ */
+ public void partOpened(IWorkbenchPart part) {
+ }
+
+ /**
+ * @see IViewActionDelegate#init(IViewPart)
+ */
+ public void init(IViewPart view) {
+ setTargetPart(view);
+ }
+
+ protected IWorkbenchPart getTargetPart() {
+ return fTargetPart;
+ }
+
+ protected void setTargetPart(IWorkbenchPart part) {
+ if (isEvaluating()) {
+ //do not want to change the target part while evaluating
+ //see bug 8334
+ setNewTargetPart(part);
+ } else {
+ fTargetPart= part;
+ }
+ }
+
+ protected IWorkbenchWindow getWindow() {
+ return fWindow;
+ }
+
+ protected void setWindow(IWorkbenchWindow window) {
+ fWindow = window;
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ setAction(action);
+ setTargetPart(targetPart);
+ update();
+ }
+
+ protected Object getSelectedObject() {
+ return fSelection;
+ }
+
+ protected void setSelectedObject(Object selection) {
+ fSelection = selection;
+ }
+
+ protected IWorkbenchPart getNewTargetPart() {
+ return fNewTargetPart;
+ }
+
+ protected void setNewTargetPart(IWorkbenchPart newTargetPart) {
+ fNewTargetPart = newTargetPart;
+ }
+
+ protected boolean isEvaluating() {
+ return fEvaluating;
+ }
+
+ protected void setEvaluating(boolean evaluating) {
+ fEvaluating = evaluating;
+ }
+
+ /**
+ * Returns the selected text region, or <code>null</code> if none.
+ *
+ * @return
+ */
+ protected IRegion getRegion() {
+ return fRegion;
+ }
+
+ /**
+ * Computes an anchor point for a popup dialog on top of a text viewer.
+ *
+ * @param viewer
+ * @return desired anchor point
+ */
+ public static Point getPopupAnchor(ITextViewer viewer) {
+ StyledText textWidget = viewer.getTextWidget();
+ Point docRange = textWidget.getSelectionRange();
+ int midOffset = docRange.x + (docRange.y / 2);
+ Point point = textWidget.getLocationAtOffset(midOffset);
+ point = textWidget.toDisplay(point);
+
+ GC gc = new GC(textWidget);
+ gc.setFont(textWidget.getFont());
+ int height = gc.getFontMetrics().getHeight();
+ gc.dispose();
+ point.y += height;
+ return point;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/EvaluateAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ExecuteAction.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ExecuteAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/ExecuteAction.java 2007-08-23 18:18:47 UTC (rev 3060)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanyi...
[truncated message content] |
|
From: <caw...@us...> - 2007-08-23 18:18:32
|
Revision: 3059
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3059&view=rev
Author: cawilliams
Date: 2007-08-23 11:18:29 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
first stab at implementing #4928 - add support for interacting at breakpoint.
Add Display view which allows users to type in Ruby code and execute/inspect the results
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RdtDebugCorePlugin.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RdtDebugCorePlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RdtDebugCorePlugin.java 2007-08-23 18:18:22 UTC (rev 3058)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RdtDebugCorePlugin.java 2007-08-23 18:18:29 UTC (rev 3059)
@@ -97,4 +97,8 @@
public static boolean isRubyDebuggerVerbose() {
return isRubyDebuggerVerbose;
}
+
+ public static String getPluginIdentifier() {
+ return PLUGIN_ID;
+ }
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-08-23 18:18:22 UTC (rev 3058)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-08-23 18:18:29 UTC (rev 3059)
@@ -13,8 +13,10 @@
import org.rubypeople.rdt.internal.debug.core.commands.ClassicDebuggerConnection;
import org.rubypeople.rdt.internal.debug.core.commands.GenericCommand;
import org.rubypeople.rdt.internal.debug.core.commands.RubyDebugConnection;
+import org.rubypeople.rdt.internal.debug.core.model.IEvaluationResult;
import org.rubypeople.rdt.internal.debug.core.model.IRubyDebugTarget;
import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
+import org.rubypeople.rdt.internal.debug.core.model.RubyEvaluationResult;
import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
import org.rubypeople.rdt.internal.debug.core.model.RubyThread;
@@ -224,13 +226,15 @@
}
public RubyVariable readInspectExpression(RubyStackFrame frame, String expression) throws RubyProcessingException {
- try {
- expression = expression.replaceAll("\n", "\\\\n");
+ try {
+ expression = expression.replaceAll("\\n", "\\\\n");
+ RubyEvaluationResult result = new RubyEvaluationResult(expression, frame.getThread());
this.println(commandFactory.createInspect(frame, expression));
RubyVariable[] variables = new VariableReader(getMultiReaderStrategy()).readVariables(frame);
if (variables.length == 0) {
return null;
} else {
+ result.setValue(variables[0].getValue());
return variables[0];
}
} catch (IOException ioex) {
@@ -238,6 +242,23 @@
throw new RuntimeException(ioex.getMessage());
}
}
+
+ public IEvaluationResult evaluate(RubyStackFrame frame, String expression) throws RubyProcessingException {
+ expression = expression.replaceAll("\\n", "\\\\n");
+ RubyEvaluationResult result = new RubyEvaluationResult(expression, frame.getThread());
+ try {
+ this.println(commandFactory.createInspect(frame, expression));
+ RubyVariable[] variables = new VariableReader(getMultiReaderStrategy()).readVariables(frame);
+ if (variables.length > 0) {
+ result.setValue(variables[0].getValue());
+ }
+ } catch (IOException ioex) {
+ // TODO Set DebugException
+ ioex.printStackTrace();
+ throw new RuntimeException(ioex.getMessage());
+ }
+ return result;
+ }
public void sendStepOverEnd(RubyStackFrame stackFrame) {
try {
Added: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java 2007-08-23 18:18:29 UTC (rev 3059)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.debug.core.model;
+
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+
+/**
+ * The result of an evaluation. An evaluation result may
+ * contain problems and/or a result value.
+ * <p>
+ * Clients are not intended to implement this interface.
+ * </p>
+ * @see IRubyValue
+ * @since 2.0
+ */
+
+public interface IEvaluationResult {
+
+ /**
+ * Returns the value representing the result of the
+ * evaluation, or <code>null</code> if the
+ * associated evaluation failed. If
+ * the associated evaluation failed, there will
+ * be problems, or an exception in this result.
+ *
+ * @return the resulting value, possibly
+ * <code>null</code>
+ */
+ public IValue getValue();
+
+ /**
+ * Returns whether the evaluation had any problems
+ * or if an exception occurred while performing the
+ * evaluation.
+ *
+ * @return whether there were any problems.
+ * @see #getErrors()
+ * @see #getException()
+ */
+ public boolean hasErrors();
+
+ /**
+ * Returns an array of problem messages. Each message describes a problem that
+ * occurred while compiling the snippet.
+ *
+ * @return compilation error messages, or an empty array if no errors occurred
+ * @since 2.1
+ */
+ public String[] getErrorMessages();
+
+ /**
+ * Returns the snippet that was evaluated.
+ *
+ * @return The string code snippet.
+ */
+ public String getSnippet();
+
+ /**
+ * Returns any exception that occurred while performing the evaluation
+ * or <code>null</code> if an exception did not occur.
+ * The exception will be a debug exception or a debug exception
+ * that wrappers a JDI exception that indicates a problem communicating
+ * with the target or with actually performing some action in the target.
+ *
+ * @return The exception that occurred during the evaluation
+ * @see com.sun.jdi.InvocationException
+ * @see org.eclipse.debug.core.DebugException
+ */
+ public DebugException getException();
+
+ /**
+ * Returns the thread in which the evaluation was performed.
+ *
+ * @return the thread in which the evaluation was performed
+ */
+ public IThread getThread();
+}
Property changes on: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java 2007-08-23 18:18:29 UTC (rev 3059)
@@ -0,0 +1,52 @@
+package org.rubypeople.rdt.internal.debug.core.model;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+
+public class RubyEvaluationResult implements IEvaluationResult {
+
+ private String fSnippet;
+ private IThread fThread;
+ private IValue fValue;
+ private DebugException debugException;
+
+ public RubyEvaluationResult(String expression, IThread thread) {
+ this.fSnippet = expression;
+ this.fThread = thread;
+ }
+
+ public String[] getErrorMessages() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DebugException getException() {
+ return debugException;
+ }
+
+ public void setException(DebugException e) {
+ this.debugException = e;
+ }
+
+ public String getSnippet() {
+ return fSnippet;
+ }
+
+ public IThread getThread() {
+ return fThread;
+ }
+
+ public IValue getValue() {
+ return fValue;
+ }
+
+ public void setValue(IValue value) {
+ this.fValue = value;
+ }
+
+ public boolean hasErrors() {
+ return false;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 18:18:24
|
Revision: 3058
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3058&view=rev
Author: cawilliams
Date: 2007-08-23 11:18:22 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
first stab at implementing #4928 - add support for interacting at breakpoint.
Add Display view which allows users to type in Ruby code and execute/inspect the results
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubyTextTools.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubyTextTools.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubyTextTools.java 2007-08-23 13:58:51 UTC (rev 3057)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubyTextTools.java 2007-08-23 18:18:22 UTC (rev 3058)
@@ -53,6 +53,20 @@
/** The preference change listener */
private PreferenceListener fPreferenceListener = new PreferenceListener();
+ /**
+ * Creates a new Ruby text tools collection.
+ *
+ * @param store the preference store to initialize the text tools. The text tool
+ * instance installs a listener on the passed preference store to adapt itself to
+ * changes in the preference store. In general <code>PreferenceConstants.
+ * getPreferenceStore()</code> should be used to initialize the text tools.
+ * @see org.rubypeople.rdt.ui.PreferenceConstants#getPreferenceStore()
+ * @since 2.0
+ */
+ public RubyTextTools(IPreferenceStore store) {
+ this(store, null, true);
+ }
+
/**
* Creates a new Ruby text tools collection.
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 13:58:55
|
Revision: 3057
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3057&view=rev
Author: cawilliams
Date: 2007-08-23 06:58:51 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
fix build results url to append port 8080 (otherwise teh site is rather broken - images and links)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.build/cruiseControl/config.xml
Modified: trunk/org.rubypeople.rdt.build/cruiseControl/config.xml
===================================================================
--- trunk/org.rubypeople.rdt.build/cruiseControl/config.xml 2007-08-23 13:48:56 UTC (rev 3056)
+++ trunk/org.rubypeople.rdt.build/cruiseControl/config.xml 2007-08-23 13:58:51 UTC (rev 3057)
@@ -61,7 +61,7 @@
<email
mailhost="mail.sf.net"
returnaddress="mba...@us..."
- buildresultsurl="http://rdtcc.pluginbuilder.org/cruisecontrol/buildresults/RDT"
+ buildresultsurl="http://rdtcc.pluginbuilder.org:8080/cruisecontrol/buildresults/RDT"
skipusers="true"
spamwhilebroken="false">
<always address="rub...@li..."/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 13:49:04
|
Revision: 3056
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3056&view=rev
Author: cawilliams
Date: 2007-08-23 06:48:56 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
fix up webpage
Modified Paths:
--------------
trunk/org.rubypeople.rdt.webpage/htdocs/index.php
trunk/org.rubypeople.rdt.webpage/htdocs/welcome.php
Modified: trunk/org.rubypeople.rdt.webpage/htdocs/index.php
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt.webpage/htdocs/welcome.php
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 13:38:23
|
Revision: 3055
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3055&view=rev
Author: cawilliams
Date: 2007-08-23 06:38:21 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
latest JRuby
Modified Paths:
--------------
trunk/org.jruby/META-INF/MANIFEST.MF
Added Paths:
-----------
trunk/org.jruby/lib/jruby.jar
Removed Paths:
-------------
trunk/org.jruby/lib/jruby.jar
Modified: trunk/org.jruby/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.jruby/META-INF/MANIFEST.MF 2007-08-23 13:37:08 UTC (rev 3054)
+++ trunk/org.jruby/META-INF/MANIFEST.MF 2007-08-23 13:38:21 UTC (rev 3055)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: JRuby Plug-in
Bundle-SymbolicName: org.jruby
-Bundle-Version: 1.0.0.4194p
+Bundle-Version: 1.0.0.4196p
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime
Bundle-ClassPath: lib/asm-commons-2.2.3.jar,
Deleted: trunk/org.jruby/lib/jruby.jar
===================================================================
--- trunk/org.jruby/lib/jruby.jar 2007-08-23 13:37:08 UTC (rev 3054)
+++ trunk/org.jruby/lib/jruby.jar 2007-08-23 13:38:21 UTC (rev 3055)
@@ -1,27992 +0,0 @@
-PK
- |
|
From: <caw...@us...> - 2007-08-23 13:37:19
|
Revision: 3054
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3054&view=rev
Author: cawilliams
Date: 2007-08-23 06:37:08 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
latest JRuby
Modified Paths:
--------------
trunk/org.rubypeople.rdt-feature/feature.xml
Modified: trunk/org.rubypeople.rdt-feature/feature.xml
===================================================================
--- trunk/org.rubypeople.rdt-feature/feature.xml 2007-08-23 13:32:53 UTC (rev 3053)
+++ trunk/org.rubypeople.rdt-feature/feature.xml 2007-08-23 13:37:08 UTC (rev 3054)
@@ -117,7 +117,7 @@
id="org.jruby"
download-size="2359"
install-size="2359"
- version="1.0.0.4194p"
+ version="1.0.0.4196p"
unpack="false"/>
<plugin
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-23 13:33:09
|
Revision: 3053
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3053&view=rev
Author: cawilliams
Date: 2007-08-23 06:32:53 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
use latest library JARs
Modified Paths:
--------------
trunk/org.jruby/.classpath
trunk/org.jruby/META-INF/MANIFEST.MF
Added Paths:
-----------
trunk/org.jruby/lib/asm-3.0.jar
trunk/org.jruby/lib/asm-commons-3.0.jar
trunk/org.jruby/lib/asm-util-3.0.jar
trunk/org.jruby/lib/backport-util-concurrent.jar
trunk/org.jruby/lib/bsf.jar
trunk/org.jruby/lib/jline-0.9.91.jar
Removed Paths:
-------------
trunk/org.jruby/lib/asm-2.2.3.jar
trunk/org.jruby/lib/asm-commons-2.2.3.jar
trunk/org.jruby/lib/backport-util-concurrent.jar
Modified: trunk/org.jruby/.classpath
===================================================================
--- trunk/org.jruby/.classpath 2007-08-22 21:47:11 UTC (rev 3052)
+++ trunk/org.jruby/.classpath 2007-08-23 13:32:53 UTC (rev 3053)
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="lib/backport-util-concurrent.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/asm-2.2.3.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/asm-commons-2.2.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jruby.jar" sourcepath="src.zip"/>
+ <classpathentry kind="lib" path="lib/asm-3.0.jar"/>
+ <classpathentry kind="lib" path="lib/backport-util-concurrent.jar"/>
+ <classpathentry kind="lib" path="lib/bsf.jar"/>
+ <classpathentry kind="lib" path="lib/jline-0.9.91.jar"/>
+ <classpathentry kind="lib" path="lib/asm-commons-3.0.jar"/>
+ <classpathentry kind="lib" path="lib/asm-util-3.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
Modified: trunk/org.jruby/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.jruby/META-INF/MANIFEST.MF 2007-08-22 21:47:11 UTC (rev 3052)
+++ trunk/org.jruby/META-INF/MANIFEST.MF 2007-08-23 13:32:53 UTC (rev 3053)
@@ -5,36 +5,64 @@
Bundle-Version: 1.0.0.4194p
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime
-Eclipse-LazyStart: false
Bundle-ClassPath: lib/asm-commons-2.2.3.jar,
lib/asm-2.2.3.jar,
lib/backport-util-concurrent.jar,
lib/jruby.jar
-Export-Package: org.jruby,
+Export-Package: edu.emory.mathcs.backport.java.util,
+ edu.emory.mathcs.backport.java.util.concurrent,
+ edu.emory.mathcs.backport.java.util.concurrent.atomic,
+ edu.emory.mathcs.backport.java.util.concurrent.helpers,
+ edu.emory.mathcs.backport.java.util.concurrent.locks,
+ jregex,
+ jregex.util.io,
+ org.jruby,
+ org.jruby.anno,
org.jruby.ast,
+ org.jruby.ast.executable,
org.jruby.ast.types,
org.jruby.ast.util,
org.jruby.ast.visitor,
org.jruby.ast.visitor.rewriter,
org.jruby.ast.visitor.rewriter.utils,
org.jruby.common,
+ org.jruby.compiler,
+ org.jruby.compiler.impl,
+ org.jruby.compiler.yarv,
+ org.jruby.demo,
org.jruby.environment,
org.jruby.evaluator,
org.jruby.exceptions,
+ org.jruby.ext,
+ org.jruby.ext.socket,
org.jruby.internal.runtime,
org.jruby.internal.runtime.methods,
org.jruby.javasupport,
org.jruby.javasupport.bsf,
+ org.jruby.javasupport.proxy,
+ org.jruby.javasupport.test,
org.jruby.javasupport.util,
org.jruby.lexer.yacc,
org.jruby.libraries,
org.jruby.parser,
+ org.jruby.regexp,
org.jruby.runtime,
org.jruby.runtime.builtin,
org.jruby.runtime.callback,
org.jruby.runtime.load,
org.jruby.runtime.marshal,
+ org.jruby.test,
org.jruby.util,
org.jruby.util.collections,
- org.jruby.yaml
+ org.jruby.util.collections.test,
+ org.jruby.util.string,
+ org.jruby.yaml,
+ org.jvyamlb,
+ org.jvyamlb.events,
+ org.jvyamlb.nodes,
+ org.jvyamlb.tokens,
+ org.jvyamlb.util,
+ org.objectweb.asm,
+ org.objectweb.asm.commons,
+ org.objectweb.asm.signature
Bundle-Vendor: org.jruby
Deleted: trunk/org.jruby/lib/asm-2.2.3.jar
===================================================================
(Binary files differ)
Added: trunk/org.jruby/lib/asm-3.0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/org.jruby/lib/asm-3.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/org.jruby/lib/asm-commons-2.2.3.jar
===================================================================
(Binary files differ)
Added: trunk/org.jruby/lib/asm-commons-3.0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/org.jruby/lib/asm-commons-3.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.jruby/lib/asm-util-3.0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/org.jruby/lib/asm-util-3.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/org.jruby/lib/backport-util-concurrent.jar
===================================================================
(Binary files differ)
Added: trunk/org.jruby/lib/backport-util-concurrent.jar
===================================================================
--- trunk/org.jruby/lib/backport-util-concurrent.jar (rev 0)
+++ trunk/org.jruby/lib/backport-util-concurrent.jar 2007-08-23 13:32:53 UTC (rev 3053)
@@ -0,0 +1,2535 @@
+PK
+ |
|
From: <caw...@us...> - 2007-08-22 21:47:13
|
Revision: 3052
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3052&view=rev
Author: cawilliams
Date: 2007-08-22 14:47:11 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
use new JRuby plugin version number
Modified Paths:
--------------
trunk/org.rubypeople.rdt-feature/feature.xml
Modified: trunk/org.rubypeople.rdt-feature/feature.xml
===================================================================
--- trunk/org.rubypeople.rdt-feature/feature.xml 2007-08-22 21:11:24 UTC (rev 3051)
+++ trunk/org.rubypeople.rdt-feature/feature.xml 2007-08-22 21:47:11 UTC (rev 3052)
@@ -117,7 +117,7 @@
id="org.jruby"
download-size="2359"
install-size="2359"
- version="1.0.0.3967"
+ version="1.0.0.4194p"
unpack="false"/>
<plugin
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 21:11:25
|
Revision: 3051
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3051&view=rev
Author: cawilliams
Date: 2007-08-22 14:11:24 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
update to latest JRuby. Also fix ITypeHierarchy interface to refer to modules and not interfaces
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/parser/TC_RubyParser.java
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/parser/TC_RubyParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/parser/TC_RubyParser.java 2007-08-22 21:11:19 UTC (rev 3050)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/parser/TC_RubyParser.java 2007-08-22 21:11:24 UTC (rev 3051)
@@ -16,7 +16,7 @@
import org.jruby.ast.Node;
import org.jruby.lexer.yacc.LexerSource;
import org.jruby.parser.DefaultRubyParser;
-import org.jruby.parser.RubyParserConfiguration;
+import org.jruby.parser.ParserConfiguration;
import org.jruby.parser.RubyParserResult;
import org.rubypeople.eclipse.shams.resources.ShamFile;
@@ -62,7 +62,7 @@
private static class ShamDefaultRubyParser extends DefaultRubyParser {
private RubyParserResult result;
- public RubyParserResult parse(RubyParserConfiguration config, LexerSource source) {
+ public RubyParserResult parse(ParserConfiguration config, LexerSource source) {
return result;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 21:11:20
|
Revision: 3050
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3050&view=rev
Author: cawilliams
Date: 2007-08-22 14:11:19 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
update to latest JRuby. Also fix ITypeHierarchy interface to refer to modules and not interfaces
Modified Paths:
--------------
trunk/org.rubypeople.rdt.astviewer/src/org/rubypeople/rdt/astviewer/views/ViewContentProvider.java
Modified: trunk/org.rubypeople.rdt.astviewer/src/org/rubypeople/rdt/astviewer/views/ViewContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.astviewer/src/org/rubypeople/rdt/astviewer/views/ViewContentProvider.java 2007-08-22 21:11:14 UTC (rev 3049)
+++ trunk/org.rubypeople.rdt.astviewer/src/org/rubypeople/rdt/astviewer/views/ViewContentProvider.java 2007-08-22 21:11:19 UTC (rev 3050)
@@ -48,7 +48,7 @@
import org.jruby.common.NullWarnings;
import org.jruby.lexer.yacc.LexerSource;
import org.jruby.parser.DefaultRubyParser;
-import org.jruby.parser.RubyParserConfiguration;
+import org.jruby.parser.ParserConfiguration;
import org.jruby.parser.RubyParserPool;
import org.rubypeople.rdt.astviewer.Activator;
import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor;
@@ -120,8 +120,9 @@
public Node getRootNode() {
LexerSource lexerSource;
try {
- lexerSource = new LexerSource(getName(), new InputStreamReader(getContents()), 1, true);
- return parser.parse(new RubyParserConfiguration(false), lexerSource).getAST();
+ ParserConfiguration config = new ParserConfiguration(1, true, false);
+ lexerSource = LexerSource.getSource(getName(), new InputStreamReader(getContents()), null, config);
+ return parser.parse(config, lexerSource).getAST();
} catch (CoreException e) {
return null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-08-22 21:11:15
|
Revision: 3049
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3049&view=rev
Author: cawilliams
Date: 2007-08-22 14:11:14 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
update to latest JRuby. Also fix ITypeHierarchy interface to refer to modules and not interfaces
Modified Paths:
--------------
trunk/org.jruby/META-INF/MANIFEST.MF
trunk/org.jruby/src.zip
Added Paths:
-----------
trunk/org.jruby/lib/jruby.jar
trunk/org.jruby/patches/4194.patch
Removed Paths:
-------------
trunk/org.jruby/lib/jruby.jar
Modified: trunk/org.jruby/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.jruby/META-INF/MANIFEST.MF 2007-08-22 21:05:16 UTC (rev 3048)
+++ trunk/org.jruby/META-INF/MANIFEST.MF 2007-08-22 21:11:14 UTC (rev 3049)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: JRuby Plug-in
Bundle-SymbolicName: org.jruby
-Bundle-Version: 1.0.0.3967
+Bundle-Version: 1.0.0.4194p
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime
Eclipse-LazyStart: false
Deleted: trunk/org.jruby/lib/jruby.jar
===================================================================
(Binary files differ)
Added: trunk/org.jruby/lib/jruby.jar
===================================================================
--- trunk/org.jruby/lib/jruby.jar (rev 0)
+++ trunk/org.jruby/lib/jruby.jar 2007-08-22 21:11:14 UTC (rev 3049)
@@ -0,0 +1,27992 @@
+PK
+ |
|
From: <caw...@us...> - 2007-08-22 21:05:33
|
Revision: 3048
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3048&view=rev
Author: cawilliams
Date: 2007-08-22 14:05:16 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
update to latest JRuby. Also fix ITypeHierarchy interface to refer to modules and not interfaces
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ITypeHierarchy.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/RDocUtil.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/CreateTypeHierarchyOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/ChangeCollector.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/HierarchyBuilder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/RegionBasedTypeHierarchy.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/TypeHierarchy.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyParser.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ITypeHierarchy.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ITypeHierarchy.java 2007-08-22 21:05:06 UTC (rev 3047)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ITypeHierarchy.java 2007-08-22 21:05:16 UTC (rev 3048)
@@ -76,7 +76,7 @@
*
* @return all interfaces in this type hierarchy's graph
*/
-IType[] getAllInterfaces();
+IType[] getAllModules();
/**
* Returns all resolved subtypes (direct and indirect) of the
* given type, in no particular order, limited to the
@@ -118,7 +118,7 @@
* @param type the given type
* @return all resolved superinterfaces (direct and indirect) of the given type, an empty array if none
*/
-IType[] getAllSuperInterfaces(IType type);
+IType[] getAllSuperModules(IType type);
/**
* Returns all resolved supertypes of the
* given type, in bottom-up order. An empty array
@@ -168,7 +168,7 @@
* @return all interfaces resolved to extend the given interface limited to the interfaces in this
* hierarchy's graph, an empty array if none.
*/
-IType[] getExtendingInterfaces(IType type);
+IType[] getExtendingModules(IType type);
/**
* Returns all classes resolved to implement the given interface,
* in no particular order, limited to the classes in this type
@@ -180,7 +180,7 @@
* @return all classes resolved to implement the given interface limited to the classes in this type
* hierarchy's graph, an empty array if none
*/
-IType[] getImplementingClasses(IType type);
+IType[] getIncludingClasses(IType type);
/**
* Returns all classes in the graph which have no resolved superclass,
* in no particular order.
@@ -194,7 +194,7 @@
*
* @return all interfaces in the graph which have no resolved superinterfaces
*/
-IType[] getRootInterfaces();
+IType[] getRootModules();
/**
* Returns the direct resolved subclasses of the given class,
* in no particular order, limited to the classes in this
@@ -245,7 +245,7 @@
* @return the direct resolved interfaces that the given type implements or extends limited to the interfaces in this type
* hierarchy's graph
*/
-IType[] getSuperInterfaces(IType type);
+IType[] getSuperModules(IType type);
/**
* Returns the resolved supertypes of the given type,
* in no particular order, limited to the types in this
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/RDocUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/RDocUtil.java 2007-08-22 21:05:06 UTC (rev 3047)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/util/RDocUtil.java 2007-08-22 21:05:16 UTC (rev 3048)
@@ -11,7 +11,6 @@
import org.eclipse.jface.text.Region;
import org.jruby.Ruby;
import org.jruby.ast.CommentNode;
-import org.jruby.exceptions.RaiseException;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.runtime.builtin.IRubyObject;
import org.rubypeople.rdt.core.IMember;
@@ -128,7 +127,7 @@
Ruby ruby = getJRubyInstance();
try {
ruby.setCurrentDirectory(getRDocScriptPath());
- IRubyObject object = ruby.evalScript(script);
+ IRubyObject object = ruby.evalScriptlet(script);
docs = object.toString();
} catch (Exception e) {
// ignore
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/CreateTypeHierarchyOperation.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/CreateTypeHierarchyOperation.java 2007-08-22 21:05:06 UTC (rev 3047)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/CreateTypeHierarchyOperation.java 2007-08-22 21:05:16 UTC (rev 3048)
@@ -116,7 +116,7 @@
if (elementToProcess != null && !elementToProcess.exists()) {
return new RubyModelStatus(IRubyModelStatusConstants.ELEMENT_DOES_NOT_EXIST, elementToProcess);
}
- IRubyProject project = this.typeHierarchy.javaProject();
+ IRubyProject project = this.typeHierarchy.rubyProject();
if (project != null && !project.exists()) {
return new RubyModelStatus(IRubyModelStatusConstants.ELEMENT_DOES_NOT_EXIST, project);
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/ChangeCollector.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/ChangeCollector.java 2007-08-22 21:05:06 UTC (rev 3047)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/ChangeCollector.java 2007-08-22 21:05:16 UTC (rev 3048)
@@ -403,7 +403,7 @@
}
// check super interfaces
- IType[] existingSuperInterfaces = this.hierarchy.getSuperInterfaces(type);
+ IType[] existingSuperInterfaces = this.hierarchy.getSuperModules(type);
String[] newSuperInterfaces = type.getIncludedModuleNames();
if (existingSuperInterfaces.length != newSuperInterfaces.length) {
return true;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/HierarchyBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/HierarchyBuilder.java 2007-08-22 21:05:06 UTC (rev 3047)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/HierarchyBuilder.java 2007-08-22 21:05:16 UTC (rev 3048)
@@ -46,7 +46,7 @@
public HierarchyBuilder(TypeHierarchy hierarchy) throws RubyModelException {
this.hierarchy = hierarchy;
- RubyProject project = (RubyProject) hierarchy.javaProject();
+ RubyProject project = (RubyProject) hierarchy.rubyProject();
IType focusType = hierarchy.getType();
org.rubypeople.rdt.core.IRubyScript unitToLookInside = focusType == null ? null : focusType.getRubyScript();
@@ -119,7 +119,7 @@
}
// now do the caching
if (typeHandle.isModule()) {
- this.hierarchy.addInterface(typeHandle);
+ this.hierarchy.addModule(typeHandle);
} else {
if (superclassHandle == null) {
this.hierarchy.addRootClass(typeHandle);
@@ -130,7 +130,7 @@
if (superinterfaceHandles == null) {
superinterfaceHandles = TypeHierarchy.NO_TYPE;
}
- this.hierarchy.cacheSuperInterfaces(typeHandle, superinterfaceHandles);
+ this.hierarchy.cacheSuperModules(typeHandle, superinterfaceHandles);
// record flags
this.hierarchy.cacheFlags(typeHandle, /*type.getModifiers()*/ 0 );
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/RegionBasedTypeHierarchy.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/RegionBasedTypeHierarchy.java 2007-08-22 21:05:06 UTC (rev 3047)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/RegionBasedTypeHierarchy.java 2007-08-22 21:05:16 UTC (rev 3048)
@@ -120,12 +120,12 @@
/**
* Returns the java project this hierarchy was created in.
*/
-public IRubyProject javaProject() {
+public IRubyProject rubyProject() {
return this.project;
}
public void pruneDeadBranches() {
pruneDeadBranches(getRootClasses());
- pruneDeadBranches(getRootInterfaces());
+ pruneDeadBranches(getRootModules());
}
/*
* Returns whether all subtypes of the given type have been pruned.
@@ -162,7 +162,7 @@
TypeVector types = (TypeVector)this.typeToSubtypes.get(superclass);
if (types != null) types.remove(type);
}
- IType[] superinterfaces = (IType[])this.typeToSuperInterfaces.remove(type);
+ IType[] superinterfaces = (IType[])this.typeToSuperModules.remove(type);
if (superinterfaces != null) {
for (int i = 0, length = superinterfaces.length; i < length; i++) {
IType superinterface = superinterfaces[i];
@@ -170,7 +170,7 @@
if (types != null) types.remove(type);
}
}
- this.interfaces.remove(type);
+ this.modules.remove(type);
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/TypeHierarchy.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/TypeHierarchy.java 2007-08-22 21:05:06 UTC (rev 3047)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/hierarchy/TypeHierarchy.java 2007-08-22 21:05:16 UTC (rev 3048)
@@ -100,11 +100,11 @@
protected IRubyScript[] workingCopies;
protected Map classToSuperclass;
- protected Map typeToSuperInterfaces;
+ protected Map typeToSuperModules;
protected Map typeToSubtypes;
protected Map typeFlags;
protected TypeVector rootClasses = new TypeVector();
- protected ArrayList interfaces = new ArrayList(10);
+ protected ArrayList modules = new ArrayList(10);
public ArrayList missingTypes = new ArrayList(4);
protected static final IType[] NO_TYPE = new IType[0];
@@ -219,8 +219,8 @@
/**
* Adds the type to the collection of interfaces.
*/
-protected void addInterface(IType type) {
- this.interfaces.add(type);
+protected void addModule(IType type) {
+ this.modules.add(type);
}
/**
* Adds the type to the collection of root classes
@@ -286,15 +286,15 @@
}
}
/**
- * Caches all of the superinterfaces that are specified for the
+ * Caches all of the supermodules that are specified for the
* type.
*/
-protected void cacheSuperInterfaces(IType type, IType[] superinterfaces) {
- this.typeToSuperInterfaces.put(type, superinterfaces);
- for (int i = 0; i < superinterfaces.length; i++) {
- IType superinterface = superinterfaces[i];
- if (superinterface != null) {
- addSubtype(superinterface, type);
+protected void cacheSuperModules(IType type, IType[] supermodules) {
+ this.typeToSuperModules.put(type, supermodules);
+ for (int i = 0; i < supermodules.length; i++) {
+ IType supermodule = supermodules[i];
+ if (supermodule != null) {
+ addSubtype(supermodule, type);
}
}
}
@@ -336,7 +336,7 @@
if (this.rootClasses.contains(type)) return true;
// interfaces
- if (this.interfaces.contains(type)) return true;
+ if (this.modules.contains(type)) return true;
return false;
}
@@ -359,7 +359,7 @@
public boolean exists() {
if (!this.needsRefresh) return true;
- return (this.focusType == null || this.focusType.exists()) && this.javaProject().exists();
+ return (this.focusType == null || this.focusType.exists()) && this.rubyProject().exists();
}
/**
* Notifies listeners that this hierarchy has changed and needs
@@ -412,9 +412,9 @@
/**
* @see ITypeHierarchy
*/
-public IType[] getAllInterfaces() {
- IType[] collection= new IType[this.interfaces.size()];
- this.interfaces.toArray(collection);
+public IType[] getAllModules() {
+ IType[] collection= new IType[this.modules.size()];
+ this.modules.toArray(collection);
return collection;
}
/**
@@ -460,27 +460,27 @@
/**
* @see ITypeHierarchy
*/
-public IType[] getAllSuperInterfaces(IType type) {
+public IType[] getAllSuperModules(IType type) {
ArrayList supers = new ArrayList();
- if (this.typeToSuperInterfaces.get(type) == null) {
+ if (this.typeToSuperModules.get(type) == null) {
return NO_TYPE;
}
- getAllSuperInterfaces0(type, supers);
- IType[] superinterfaces = new IType[supers.size()];
- supers.toArray(superinterfaces);
- return superinterfaces;
+ getAllSuperModules0(type, supers);
+ IType[] supermodules = new IType[supers.size()];
+ supers.toArray(supermodules);
+ return supermodules;
}
-private void getAllSuperInterfaces0(IType type, ArrayList supers) {
- IType[] superinterfaces = (IType[]) this.typeToSuperInterfaces.get(type);
+private void getAllSuperModules0(IType type, ArrayList supers) {
+ IType[] superinterfaces = (IType[]) this.typeToSuperModules.get(type);
if (superinterfaces != null && superinterfaces.length != 0) {
addAllCheckingDuplicates(supers, superinterfaces);
for (int i = 0; i < superinterfaces.length; i++) {
- getAllSuperInterfaces0(superinterfaces[i], supers);
+ getAllSuperModules0(superinterfaces[i], supers);
}
}
IType superclass = (IType) this.classToSuperclass.get(type);
if (superclass != null) {
- getAllSuperInterfaces0(superclass, supers);
+ getAllSuperModules0(superclass, supers);
}
}
/**
@@ -488,7 +488,7 @@
*/
public IType[] getAllSupertypes(IType type) {
ArrayList supers = new ArrayList();
- if (this.typeToSuperInterfaces.get(type) == null) {
+ if (this.typeToSuperModules.get(type) == null) {
return NO_TYPE;
}
getAllSupertypes0(type, supers);
@@ -497,11 +497,11 @@
return supertypes;
}
private void getAllSupertypes0(IType type, ArrayList supers) {
- IType[] superinterfaces = (IType[]) this.typeToSuperInterfaces.get(type);
+ IType[] superinterfaces = (IType[]) this.typeToSuperModules.get(type);
if (superinterfaces != null && superinterfaces.length != 0) {
addAllCheckingDuplicates(supers, superinterfaces);
for (int i = 0; i < superinterfaces.length; i++) {
- getAllSuperInterfaces0(superinterfaces[i], supers);
+ getAllSuperModules0(superinterfaces[i], supers);
}
}
IType superclass = (IType) this.classToSuperclass.get(type);
@@ -516,7 +516,7 @@
public IType[] getAllTypes() {
IType[] classes = getAllClasses();
int classesLength = classes.length;
- IType[] allInterfaces = getAllInterfaces();
+ IType[] allInterfaces = getAllModules();
int interfacesLength = allInterfaces.length;
IType[] all = new IType[classesLength + interfacesLength];
System.arraycopy(classes, 0, all, 0, classesLength);
@@ -538,23 +538,23 @@
/**
* @see ITypeHierarchy
*/
-public IType[] getExtendingInterfaces(IType type) {
- if (!this.isInterface(type)) return NO_TYPE;
- return getExtendingInterfaces0(type);
+public IType[] getExtendingModules(IType type) {
+ if (!this.isModule(type)) return NO_TYPE;
+ return getExtendingModules0(type);
}
/**
- * Assumes that the type is an interface
- * @see #getExtendingInterfaces
+ * Assumes that the type is an module
+ * @see #getExtendingModules
*/
-private IType[] getExtendingInterfaces0(IType extendedInterface) {
- Iterator iter = this.typeToSuperInterfaces.keySet().iterator();
+private IType[] getExtendingModules0(IType extendedInterface) {
+ Iterator iter = this.typeToSuperModules.keySet().iterator();
ArrayList interfaceList = new ArrayList();
while (iter.hasNext()) {
IType type = (IType) iter.next();
- if (!this.isInterface(type)) {
+ if (!this.isModule(type)) {
continue;
}
- IType[] superInterfaces = (IType[]) this.typeToSuperInterfaces.get(type);
+ IType[] superInterfaces = (IType[]) this.typeToSuperModules.get(type);
if (superInterfaces != null) {
for (int i = 0; i < superInterfaces.length; i++) {
IType superInterface = superInterfaces[i];
@@ -571,26 +571,26 @@
/**
* @see ITypeHierarchy
*/
-public IType[] getImplementingClasses(IType type) {
- if (!this.isInterface(type)) {
+public IType[] getIncludingClasses(IType type) {
+ if (!this.isModule(type)) {
return NO_TYPE;
}
- return getImplementingClasses0(type);
+ return getIncludingClasses0(type);
}
/**
* Assumes that the type is an interface
- * @see #getImplementingClasses
+ * @see #getIncludingClasses
*/
-private IType[] getImplementingClasses0(IType interfce) {
+private IType[] getIncludingClasses0(IType interfce) {
- Iterator iter = this.typeToSuperInterfaces.keySet().iterator();
+ Iterator iter = this.typeToSuperModules.keySet().iterator();
ArrayList iMenters = new ArrayList();
while (iter.hasNext()) {
IType type = (IType) iter.next();
- if (this.isInterface(type)) {
+ if (this.isModule(type)) {
continue;
}
- IType[] types = (IType[]) this.typeToSuperInterfaces.get(type);
+ IType[] types = (IType[]) this.typeToSuperModules.get(type);
for (int i = 0; i < types.length; i++) {
IType iFace = types[i];
if (iFace.equals(interfce)) {
@@ -611,12 +611,12 @@
/**
* @see ITypeHierarchy
*/
-public IType[] getRootInterfaces() {
- IType[] allInterfaces = getAllInterfaces();
+public IType[] getRootModules() {
+ IType[] allInterfaces = getAllModules();
IType[] roots = new IType[allInterfaces.length];
int rootNumber = 0;
for (int i = 0; i < allInterfaces.length; i++) {
- IType[] superInterfaces = getSuperInterfaces(allInterfaces[i]);
+ IType[] superInterfaces = getSuperModules(allInterfaces[i]);
if (superInterfaces == null || superInterfaces.length == 0) {
roots[rootNumber++] = allInterfaces[i];
}
@@ -631,7 +631,7 @@
* @see ITypeHierarchy
*/
public IType[] getSubclasses(IType type) {
- if (this.isInterface(type)) {
+ if (this.isModule(type)) {
return NO_TYPE;
}
TypeVector vector = (TypeVector)this.typeToSubtypes.get(type);
@@ -660,7 +660,7 @@
* @see ITypeHierarchy
*/
public IType getSuperclass(IType type) {
- if (this.isInterface(type)) {
+ if (this.isModule(type)) {
return null;
}
return (IType) this.classToSuperclass.get(type);
@@ -668,8 +668,8 @@
/**
* @see ITypeHierarchy
*/
-public IType[] getSuperInterfaces(IType type) {
- IType[] types = (IType[]) this.typeToSuperInterfaces.get(type);
+public IType[] getSuperModules(IType type) {
+ IType[] types = (IType[]) this.typeToSuperModules.get(type);
if (types == null) {
return NO_TYPE;
}
@@ -681,9 +681,9 @@
public IType[] getSupertypes(IType type) {
IType superclass = getSuperclass(type);
if (superclass == null) {
- return getSuperInterfaces(type);
+ return getSuperModules(type);
} else {
- TypeVector superTypes = new TypeVector(getSuperInterfaces(type));
+ TypeVector superTypes = new TypeVector(getSuperModules(type));
superTypes.add(superclass);
return superTypes.elements();
}
@@ -800,11 +800,11 @@
}
int smallSize = (size / 2);
this.classToSuperclass = new HashMap(size);
- this.interfaces = new ArrayList(smallSize);
+ this.modules = new ArrayList(smallSize);
this.missingTypes = new ArrayList(smallSize);
this.rootClasses = new TypeVector();
this.typeToSubtypes = new HashMap(smallSize);
- this.typeToSuperInterfaces = new HashMap(smallSize);
+ this.typeToSuperModules = new HashMap(smallSize);
this.typeFlags = new HashMap(smallSize);
this.projectRegion = new Region();
@@ -854,7 +854,7 @@
switch (delta.getKind()) {
case IRubyElementDelta.ADDED :
case IRubyElementDelta.REMOVED :
- return element.equals(this.javaProject().getRubyModel());
+ return element.equals(this.rubyProject().getRubyModel());
case IRubyElementDelta.CHANGED :
return isAffectedByChildren(delta);
}
@@ -876,7 +876,7 @@
case IRubyElementDelta.ADDED :
try {
// if the added project is on the classpath, then the hierarchy has changed
- ILoadpathEntry[] classpath = ((RubyProject)this.javaProject()).getExpandedLoadpath(true);
+ ILoadpathEntry[] classpath = ((RubyProject)this.rubyProject()).getExpandedLoadpath(true);
for (int i = 0; i < classpath.length; i++) {
if (classpath[i].getEntryKind() == ILoadpathEntry.CPE_PROJECT
&& classpath[i].getPath().equals(element.getPath())) {
@@ -886,7 +886,7 @@
if (this.focusType != null) {
// if the hierarchy's project is on the added project classpath, then the hierarchy has changed
classpath = ((RubyProject)element).getExpandedLoadpath(true);
- IPath hierarchyProject = javaProject().getPath();
+ IPath hierarchyProject = rubyProject().getPath();
for (int i = 0; i < classpath.length; i++) {
if (classpath[i].getEntryKind() == ILoadpathEntry.CPE_PROJECT
&& classpath[i].getPath().equals(hierarchyProject)) {
@@ -1007,18 +1007,13 @@
}
return false;
}
-private boolean isInterface(IType type) {
-// int flags = this.getCachedFlags(type);
-// if (flags == -1) {
- return type.isModule();
-// } else {
-// return Flags.isModule(flags);
-// }
+private boolean isModule(IType type) {
+ return type.isModule();
}
/**
- * Returns the java project this hierarchy was created in.
+ * Returns the ruby project this hierarchy was created in.
*/
-public IRubyProject javaProject() {
+public IRubyProject rubyProject() {
return this.focusType.getRubyProject();
}
protected static byte[] readUntil(InputStream input, byte separator) throws RubyModelException, IOException{
@@ -1112,7 +1107,7 @@
byte info = (byte)input.read();
if((info & INTERFACE) != 0) {
- typeHierarchy.addInterface(element);
+ typeHierarchy.addModule(element);
}
if((info & COMPUTED_FOR) != 0) {
if(!element.equals(type)) {
@@ -1166,7 +1161,7 @@
superInterfaces[interfaceCount++] = types[new Integer(new String(b2)).intValue()];
System.arraycopy(superInterfaces, 0, superInterfaces = new IType[interfaceCount], 0, interfaceCount);
- typeHierarchy.cacheSuperInterfaces(
+ typeHierarchy.cacheSuperModules(
types[subClass],
superInterfaces);
}
@@ -1290,7 +1285,7 @@
hashtable2.put(index, superClass);
}
}
- types = this.typeToSuperInterfaces.keySet().toArray();
+ types = this.typeToSuperModules.keySet().toArray();
for (int i = 0; i < types.length; i++) {
Object t = types[i];
if(hashtable.get(t) == null) {
@@ -1298,7 +1293,7 @@
hashtable.put(t, index);
hashtable2.put(index, t);
}
- Object[] sp = (Object[])this.typeToSuperInterfaces.get(t);
+ Object[] sp = (Object[])this.typeToSuperModules.get(t);
if(sp != null) {
for (int j = 0; j < sp.length; j++) {
Object superInterface = sp[j];
@@ -1349,7 +1344,7 @@
if(this.focusType != null && this.focusType.equals(t)) {
info |= COMPUTED_FOR;
}
- if(this.interfaces.contains(t)) {
+ if(this.modules.contains(t)) {
info |= INTERFACE;
}
if(this.rootClasses.contains(t)) {
@@ -1373,10 +1368,10 @@
output.write(SEPARATOR1);
// save superinterfaces
- types = this.typeToSuperInterfaces.keySet().toArray();
+ types = this.typeToSuperModules.keySet().toArray();
for (int i = 0; i < types.length; i++) {
IRubyElement key = (IRubyElement)types[i];
- IRubyElement[] values = (IRubyElement[])this.typeToSuperInterfaces.get(key);
+ IRubyElement[] values = (IRubyElement[])this.typeToSuperModules.get(key);
if(values.length > 0) {
output.write(((Integer)hashtable.get(key)).toString().getBytes());
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyParser.java 2007-08-22 21:05:06 UTC (rev 3047)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyParser.java 2007-08-22 21:05:16 UTC (rev 3048)
@@ -26,7 +26,7 @@
import org.jruby.lexer.yacc.LexerSource;
import org.jruby.lexer.yacc.SyntaxException;
import org.jruby.parser.DefaultRubyParser;
-import org.jruby.parser.RubyParserConfiguration;
+import org.jruby.parser.ParserConfiguration;
import org.jruby.parser.RubyParserPool;
import org.jruby.parser.RubyParserResult;
import org.rubypeople.rdt.core.RubyCore;
@@ -60,8 +60,9 @@
parser.setWarnings(warnings);
String fileName = "";
if (file != null) fileName = file.getName();
- LexerSource lexerSource = new LexerSource(fileName, content, 0, true);
- result = parser.parse(new RubyParserConfiguration(false), lexerSource);
+ ParserConfiguration config = new ParserConfiguration(0, true, false);
+ LexerSource lexerSource = LexerSource.getSource(fileName, content, null, config);
+ result = parser.parse(config, lexerSource);
} catch (SyntaxException e) {
throw e;
} finally {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|