|
From: <caw...@us...> - 2007-05-31 13:41:25
|
Revision: 2569
http://svn.sourceforge.net/rubyeclipse/?rev=2569&view=rev
Author: cawilliams
Date: 2007-05-31 06:41:24 -0700 (Thu, 31 May 2007)
Log Message:
-----------
be more careful to avoid ClassCastExceptions
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java 2007-05-31 13:38:43 UTC (rev 2568)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java 2007-05-31 13:41:24 UTC (rev 2569)
@@ -9,6 +9,7 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPartitioningException;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension3;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
@@ -47,12 +48,15 @@
}
}
try {
- IDocumentExtension3 extension = (IDocumentExtension3)textViewer.getDocument();
+ IDocument doc = textViewer.getDocument();
String contentType = null;
- try {
- contentType = extension.getContentType(IRubyPartitions.RUBY_PARTITIONING, hoverRegion.getOffset(), false);
- } catch (BadPartitioningException e) {
- // ignore
+ if (doc instanceof IDocumentExtension3) {
+ IDocumentExtension3 extension = (IDocumentExtension3) doc;
+ try {
+ contentType = extension.getContentType(IRubyPartitions.RUBY_PARTITIONING, hoverRegion.getOffset(), false);
+ } catch (BadPartitioningException e) {
+ // ignore
+ }
}
if (contentType != null && (contentType.equals(IRubyPartitions.RUBY_MULTI_LINE_COMMENT) || contentType.equals(IRubyPartitions.RUBY_SINGLE_LINE_COMMENT))) {
return null;
@@ -68,6 +72,7 @@
private String getRIResult(String symbol) {
+ if (symbol == null || symbol.trim().length() == 0) return null;
File ri = RubyRuntime.getRI();
if (ri == null || !ri.exists() || !ri.isFile()) return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|