use of org.eclipse.jdt.core.ISourceRange in project che by eclipse.
the class JavadocContentAccess2 method getHTMLContentFromSource.
private static String getHTMLContentFromSource(IMember member, String urlPrefix) throws JavaModelException {
IBuffer buf = member.getOpenable().getBuffer();
if (buf == null) {
// no source attachment found
return null;
}
ISourceRange javadocRange = member.getJavadocRange();
if (javadocRange == null) {
if (canInheritJavadoc(member)) {
// Try to use the inheritDoc algorithm.
//$NON-NLS-1$
String inheritedJavadoc = javadoc2HTML(member, "/***/", urlPrefix);
if (inheritedJavadoc != null && inheritedJavadoc.length() > 0) {
return inheritedJavadoc;
}
}
// getJavaFxPropertyDoc(member);
return null;
}
String rawJavadoc = buf.getText(javadocRange.getOffset(), javadocRange.getLength());
return javadoc2HTML(member, rawJavadoc, urlPrefix);
}
use of org.eclipse.jdt.core.ISourceRange in project che by eclipse.
the class JavaNavigation method compilationUnitNavigation.
private OpenDeclarationDescriptor compilationUnitNavigation(ICompilationUnit unit, IJavaElement element) throws JavaModelException {
OpenDeclarationDescriptor dto = DtoFactory.getInstance().createDto(OpenDeclarationDescriptor.class);
String absolutePath = unit.getPath().toOSString();
dto.setPath(absolutePath);
dto.setBinary(false);
if (element instanceof ISourceReference) {
ISourceRange nameRange = ((ISourceReference) element).getNameRange();
dto.setOffset(nameRange.getOffset());
dto.setLength(nameRange.getLength());
}
return dto;
}
use of org.eclipse.jdt.core.ISourceRange in project che by eclipse.
the class JavaNavigation method classFileNavigation.
private OpenDeclarationDescriptor classFileNavigation(IClassFile classFile, IJavaElement element) throws JavaModelException {
OpenDeclarationDescriptor dto = DtoFactory.getInstance().createDto(OpenDeclarationDescriptor.class);
dto.setPath(classFile.getType().getFullyQualifiedName());
dto.setLibId(classFile.getAncestor(IPackageFragmentRoot.PACKAGE_FRAGMENT_ROOT).hashCode());
dto.setBinary(true);
if (classFile.getSourceRange() != null) {
if (element instanceof ISourceReference) {
ISourceRange nameRange = ((ISourceReference) element).getNameRange();
dto.setOffset(nameRange.getOffset());
dto.setLength(nameRange.getLength());
}
}
return dto;
}
use of org.eclipse.jdt.core.ISourceRange in project che by eclipse.
the class AssociativeInfixExpressionFragment method getRangeOfOperands.
private static ISourceRange getRangeOfOperands(List<Expression> operands) {
Expression first = operands.get(0);
Expression last = operands.get(operands.size() - 1);
return new SourceRange(first.getStartPosition(), last.getStartPosition() + last.getLength() - first.getStartPosition());
}
use of org.eclipse.jdt.core.ISourceRange in project che by eclipse.
the class SelfEncapsulateFieldRefactoring method checkInitialConditions.
//----activation checking ----------------------------------------------------------
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
if (fVisibility < 0)
fVisibility = (fField.getFlags() & (Flags.AccPublic | Flags.AccProtected | Flags.AccPrivate));
RefactoringStatus result = new RefactoringStatus();
result.merge(Checks.checkAvailability(fField));
if (result.hasFatalError())
return result;
fRoot = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(fField.getCompilationUnit(), true, pm);
ISourceRange sourceRange = fField.getNameRange();
ASTNode node = NodeFinder.perform(fRoot, sourceRange.getOffset(), sourceRange.getLength());
if (node == null) {
return mappingErrorFound(result, node);
}
fFieldDeclaration = (VariableDeclarationFragment) ASTNodes.getParent(node, VariableDeclarationFragment.class);
if (fFieldDeclaration == null) {
return mappingErrorFound(result, node);
}
if (fFieldDeclaration.resolveBinding() == null) {
if (!processCompilerError(result, node))
result.addFatalError(RefactoringCoreMessages.SelfEncapsulateField_type_not_resolveable);
return result;
}
computeUsedNames();
return result;
}
Aggregations