Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 216195 Details for
Bug 380520
[hovering] NPE in JavaSourceHover.getBracketHoverInfo
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix
eclipse.jdt.ui.patch (text/plain), 3.63 KB, created by
Dani Megert
on 2012-05-24 10:10:58 EDT
(
hide
)
Description:
Fix
Filename:
MIME Type:
Creator:
Dani Megert
Created:
2012-05-24 10:10:58 EDT
Size:
3.63 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaSourceHover.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaSourceHover.java >index 8529a98..e5a2f76 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaSourceHover.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaSourceHover.java >@@ -13,6 +13,7 @@ > import java.io.IOException; > > import org.eclipse.swt.SWT; >+import org.eclipse.swt.SWTException; > import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >@@ -26,7 +27,6 @@ > import org.eclipse.jface.text.IInformationControlCreator; > import org.eclipse.jface.text.IRegion; > import org.eclipse.jface.text.ITextViewer; >-import org.eclipse.jface.text.source.ISourceViewer; > > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.part.IWorkbenchPartOrientation; >@@ -118,24 +118,26 @@ > return null; > } > >- private String getBracketHoverInfo(ITextViewer textViewer, IRegion region, ITypeRoot editorInput) { >+ private String getBracketHoverInfo(final ITextViewer textViewer, IRegion region, ITypeRoot editorInput) { > IEditorPart editor= getEditor(); > if (!(editor instanceof JavaEditor)) > return null; > > int offset= region.getOffset(); > IDocument document= textViewer.getDocument(); >+ if (document == null) >+ return null; > try { > char c= document.getChar(offset); > if (c != '}') > return null; > JavaPairMatcher matcher= ((JavaEditor) editor).getBracketMatcher(); >+ if (matcher == null) >+ return null; > IRegion match= matcher.match(document, offset); > if (match == null) > return null; > >- int sourceOffset; >- int sourceLength; > String delim= StubUtility.getLineDelimiterUsed(editorInput); > > CompilationUnit ast= SharedASTProvider.getAST(editorInput, SharedASTProvider.WAIT_NO, null); >@@ -167,26 +169,34 @@ > } > > int line1= document.getLineOfOffset(nodeStart); >- sourceOffset= document.getLineOffset(line1); >+ int sourceOffset= document.getLineOffset(line1); > int line2= document.getLineOfOffset(nodeStart + nodeLength); > int hoveredLine= document.getLineOfOffset(offset); > if (line2 > hoveredLine) > line2= hoveredLine; > > //check if line1 is visible >- JavaEditor javaEditor= (JavaEditor) editor; >- final ISourceViewer viewer= javaEditor.getViewer(); > final int[] topIndex= new int[1]; >- StyledText textWidget= viewer.getTextWidget(); >- if (textWidget != null) { >- Display display= textWidget.getDisplay(); >- display.syncExec(new Runnable() { >- public void run() { >- topIndex[0]= viewer.getTopIndex(); >- } >- }); >+ StyledText textWidget= textViewer.getTextWidget(); >+ if (textWidget == null) >+ return null; >+ >+ Display display; >+ try { >+ display= textWidget.getDisplay(); >+ } catch (SWTException ex) { >+ if (ex.code == SWT.ERROR_WIDGET_DISPOSED) >+ return null; >+ else >+ throw ex; > } >- >+ >+ display.syncExec(new Runnable() { >+ public void run() { >+ topIndex[0]= textViewer.getTopIndex(); >+ } >+ }); >+ > int topLine= topIndex[0]; > int noOfSourceLines; > IRegion endLine; >@@ -208,10 +218,10 @@ > endLine= document.getLineInformation(line2); > fUpwardShiftInLines= line2 - line1; > } >- sourceLength= (endLine.getOffset() + endLine.getLength()) - sourceOffset; > if (fUpwardShiftInLines == 0) > return null; > >+ int sourceLength= (endLine.getOffset() + endLine.getLength()) - sourceOffset; > String source= document.get(sourceOffset, sourceLength); > String[] sourceLines= getTrimmedSource(source, editorInput); > if (sourceLines == null)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 380520
:
216189
| 216195