private void setSourceViewerContents(IJavaElement el) throws JavaModelException { String EMPTY= ""; //$NON-NLS-1$ if (el == null) { fSourceViewer.getDocument().set(EMPTY); return; } ICompilationUnit element= (ICompilationUnit) el.getAncestor(IJavaElement.COMPILATION_UNIT); if (element == null) { fSourceViewer.getDocument().set(EMPTY); return; } String contents= element.getSource(); try { fSourceViewer.setRedraw(false); fSourceViewer.getDocument().set(contents == null ? EMPTY : contents); ISourceRange sr= getNameRange(el); if (sr != null) { fSourceViewer.setSelectedRange(sr.getOffset(), sr.getLength()); } } finally { fSourceViewer.setRedraw(true); } }
private void setSourceViewerContents(IJavaElement el) throws JavaModelException { String EMPTY= ""; //$NON-NLS-1$ if (el == null) { fSourceViewer.getDocument().set(EMPTY); return; } ICompilationUnit element= (ICompilationUnit) el.getAncestor(IJavaElement.COMPILATION_UNIT); if (element == null) { fSourceViewer.getDocument().set(EMPTY); return; } String contents= element.getSource(); try { fSourceViewer.setRedraw(false); fSourceViewer.getDocument().set(contents == null ? EMPTY : contents); ISourceRange sr= getNameRange(el); if (sr != null) { fSourceViewer.setSelectedRange(sr.getOffset(), sr.getLength()); } } finally { fSourceViewer.setRedraw(true); } }
private void setSourceViewerContents(IJavaElement el) throws JavaModelException { String EMPTY= ""; //$NON-NLS-1$ if (el == null) { fSourceViewer.getDocument().set(EMPTY); return; } ICompilationUnit element= (ICompilationUnit) el.getAncestor(IJavaElement.COMPILATION_UNIT); if (element == null) { fSourceViewer.getDocument().set(EMPTY); return; } String contents= element.getSource(); try { fSourceViewer.setRedraw(false); fSourceViewer.getDocument().set(contents == null ? EMPTY : contents); ISourceRange sr= getNameRange(el); if (sr != null) { fSourceViewer.setSelectedRange(sr.getOffset(), sr.getLength()); } } finally { fSourceViewer.setRedraw(true); } }