/** * Returns the trimmed source lines. * * @param source the source string, could be <code>null</code> * @param javaElement the java element * @return the trimmed source lines or <code>null</code> */ private String[] getTrimmedSource(String source, IJavaElement javaElement) { if (source == null) return null; source= removeLeadingComments(source); String[] sourceLines= Strings.convertIntoLines(source); Strings.trimIndentation(sourceLines, javaElement.getJavaProject()); return sourceLines; }
/** * Returns the trimmed source lines. * * @param source the source string, could be <code>null</code> * @param javaElement the java element * @return the trimmed source lines or <code>null</code> */ private String[] getTrimmedSource(String source, IJavaElement javaElement) { if (source == null) return null; source= removeLeadingComments(source); String[] sourceLines= Strings.convertIntoLines(source); Strings.trimIndentation(sourceLines, javaElement.getJavaProject()); return sourceLines; }
protected String getHoverInfo(IJavaElement[] result) { int nResults= result.length; if (nResults > 1) return null; IJavaElement curr= result[0]; if ((curr instanceof IMember || curr instanceof ILocalVariable || curr instanceof ITypeParameter) && curr instanceof ISourceReference) { try { String source= ((ISourceReference) curr).getSource(); if (source == null) return null; source= removeLeadingComments(source); String delim= StubUtility.getLineDelimiterUsed(result[0]); String[] sourceLines= Strings.convertIntoLines(source); String firstLine= sourceLines[0]; if (!Character.isWhitespace(firstLine.charAt(0))) sourceLines[0]= ""; //$NON-NLS-1$ Strings.trimIndentation(sourceLines, curr.getJavaProject()); if (!Character.isWhitespace(firstLine.charAt(0))) sourceLines[0]= firstLine; source= Strings.concatenate(sourceLines, delim); return source; } catch (JavaModelException ex) { } } return null; }