|
From: <caw...@us...> - 2007-08-15 15:49:39
|
Revision: 2981
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=2981&view=rev
Author: cawilliams
Date: 2007-08-15 08:49:37 -0700 (Wed, 15 Aug 2007)
Log Message:
-----------
be extra paranoid, and capture all exceptions in suggestMethod
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-08-15 15:48:24 UTC (rev 2980)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-08-15 15:49:37 UTC (rev 2981)
@@ -451,56 +451,61 @@
}
private CompletionProposal suggestMethod(IMethod method, String typeName, int confidence) {
- int start = fContext.getReplaceStart();
- String name = method.getElementName();
- int flags = Flags.AccDefault;
- if (method.isSingleton()) {
- flags |= Flags.AccStatic;
- if (method.isConstructor())
- name = CONSTRUCTOR_INVOKE_NAME;
- else {
- if (name.startsWith(typeName)) {
- name = name.substring(typeName.length() + 1);
+ try {
+ int start = fContext.getReplaceStart();
+ String name = method.getElementName();
+ int flags = Flags.AccDefault;
+ if (method.isSingleton()) {
+ flags |= Flags.AccStatic;
+ if (method.isConstructor())
+ name = CONSTRUCTOR_INVOKE_NAME;
+ else {
+ if (name.startsWith(typeName)) {
+ name = name.substring(typeName.length() + 1);
+ }
}
+ } else {
+ // Don't show instance methods if the thing we're working on is a class' name!
+ // FIXME We do want to show if it is a constant, but not a class name
+ if (fContext.fullPrefixIsConstant()) return null;
}
- } else {
- // Don't show instance methods if the thing we're working on is a class' name!
- // FIXME We do want to show if it is a constant, but not a class name
- if (fContext.fullPrefixIsConstant()) return null;
- }
- if (!fContext.prefixStartsWith(name))
- return null;
-
- try {
- switch (method.getVisibility()) {
- case IMethod.PRIVATE:
- flags |= Flags.AccPrivate;
- if (fOriginalType != null && !fOriginalType.getElementName().equals(typeName)) return null; // FIXME We should do a comparison of types, not names
- if (fContext.hasReceiver()) return null; // can't invoke a private method on a receiver
- break;
- case IMethod.PUBLIC:
- flags |= Flags.AccPublic; // FIXME Check if receiver is of same class as method's declaring type, if not, skip this method. (so we can invoke with no receiver inside same class, with explicit self as receiver, or with receiver who has same class).
- break;
- case IMethod.PROTECTED:
- flags |= Flags.AccProtected;
- break;
- default:
- break;
+ if (!fContext.prefixStartsWith(name))
+ return null;
+
+ try {
+ switch (method.getVisibility()) {
+ case IMethod.PRIVATE:
+ flags |= Flags.AccPrivate;
+ if (fOriginalType != null && !fOriginalType.getElementName().equals(typeName)) return null; // FIXME We should do a comparison of types, not names
+ if (fContext.hasReceiver()) return null; // can't invoke a private method on a receiver
+ break;
+ case IMethod.PUBLIC:
+ flags |= Flags.AccPublic; // FIXME Check if receiver is of same class as method's declaring type, if not, skip this method. (so we can invoke with no receiver inside same class, with explicit self as receiver, or with receiver who has same class).
+ break;
+ case IMethod.PROTECTED:
+ flags |= Flags.AccProtected;
+ break;
+ default:
+ break;
+ }
+ } catch (RubyModelException e) {
+ RubyCore.log(e);
+ flags |= Flags.AccPublic;
}
- } catch (RubyModelException e) {
+ CompletionProposal proposal = createProposal(start, CompletionProposal.METHOD_REF, name, confidence, method);
+ proposal.setReplaceRange(start, start + name.length());
+ proposal.setFlags(flags);
+ proposal.setName(name);
+ IType declaringType = method.getDeclaringType();
+ String declaringName = typeName;
+ if (declaringType != null)
+ declaringName = declaringType.getFullyQualifiedName();
+ proposal.setDeclaringType(declaringName);
+ return proposal;
+ } catch (RuntimeException e) {
RubyCore.log(e);
- flags |= Flags.AccPublic;
+ return null;
}
- CompletionProposal proposal = createProposal(start, CompletionProposal.METHOD_REF, name, confidence, method);
- proposal.setReplaceRange(start, start + name.length());
- proposal.setFlags(flags);
- proposal.setName(name);
- IType declaringType = method.getDeclaringType();
- String declaringName = typeName;
- if (declaringType != null)
- declaringName = declaringType.getFullyQualifiedName();
- proposal.setDeclaringType(declaringName);
- return proposal;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|