Search in sources :

Example 6 with ISourceRange

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);
}
Also used : IBuffer(org.eclipse.jdt.core.IBuffer) ISourceRange(org.eclipse.jdt.core.ISourceRange)

Example 7 with ISourceRange

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;
}
Also used : OpenDeclarationDescriptor(org.eclipse.che.ide.ext.java.shared.OpenDeclarationDescriptor) ISourceReference(org.eclipse.jdt.core.ISourceReference) ISourceRange(org.eclipse.jdt.core.ISourceRange)

Example 8 with ISourceRange

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;
}
Also used : OpenDeclarationDescriptor(org.eclipse.che.ide.ext.java.shared.OpenDeclarationDescriptor) ISourceReference(org.eclipse.jdt.core.ISourceReference) ISourceRange(org.eclipse.jdt.core.ISourceRange)

Example 9 with ISourceRange

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());
}
Also used : InfixExpression(org.eclipse.jdt.core.dom.InfixExpression) Expression(org.eclipse.jdt.core.dom.Expression) ParenthesizedExpression(org.eclipse.jdt.core.dom.ParenthesizedExpression) ISourceRange(org.eclipse.jdt.core.ISourceRange) SourceRange(org.eclipse.jdt.core.SourceRange)

Example 10 with ISourceRange

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;
}
Also used : RefactoringASTParser(org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser) ASTNode(org.eclipse.jdt.core.dom.ASTNode) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ISourceRange(org.eclipse.jdt.core.ISourceRange)

Aggregations

ISourceRange (org.eclipse.jdt.core.ISourceRange)53 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)18 IJavaElement (org.eclipse.jdt.core.IJavaElement)14 JavaModelException (org.eclipse.jdt.core.JavaModelException)13 ASTNode (org.eclipse.jdt.core.dom.ASTNode)12 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)10 ISourceReference (org.eclipse.jdt.core.ISourceReference)9 IType (org.eclipse.jdt.core.IType)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)6 SourceRange (org.eclipse.jdt.core.SourceRange)6 IBuffer (org.eclipse.jdt.core.IBuffer)5 IMethod (org.eclipse.jdt.core.IMethod)5 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)5 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)5 ArrayList (java.util.ArrayList)4 IField (org.eclipse.jdt.core.IField)4 IMember (org.eclipse.jdt.core.IMember)4 CoreException (org.eclipse.core.runtime.CoreException)3 IClassFile (org.eclipse.jdt.core.IClassFile)3