Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.ISourceRange


  }

  private IRegion computeHeaderComment(FoldingStructureComputationContext ctx)
      throws JavaModelException {
    // search at most up to the first type
    ISourceRange range = ctx.getFirstType().getSourceRange();
    if (range == null)
      return null;
    int start = 0;
    int end = range.getOffset();

    /* code adapted from CommentFormattingStrategy:
     * scan the header content up to the first type. Once a comment is
     * found, accumulate any additional comments up to the stop condition.
     * The stop condition is reaching a package declaration, import container,
View Full Code Here


      IJavaElement selectedElement = SelectionConverter.getElementAtOffset(root, selectedText);
      if(!(selectedElement instanceof IMethod)) {
        return null;
      }
      IMethod method= (IMethod) selectedElement;
      ISourceRange nameRange = method.getNameRange();
      if(nameRange.getOffset() <= selectedText.getOffset() && selectedText.getOffset() + selectedText.getLength() <= nameRange.getOffset() + nameRange.getLength()) {
        return method;
      }
    } catch (JavaModelException jme) {
      ;
    }
View Full Code Here

      // other
      // // cases
      // if (ProposalCalculatorUtil.hasAnnotationInParameters(method,
      // "Qualifier")) {

      ISourceRange methodSourceRange = method.getSourceRange();
      assistContext = new AssistContext(javaContext.getCompilationUnit(), sourceViewer,
          methodSourceRange.getOffset(), methodSourceRange.getLength());
      node = assistContext.getCoveringNode();
      if (node instanceof MethodDeclaration) {
        MethodDeclaration methodDecl = (MethodDeclaration) node;
        @SuppressWarnings("unchecked")
        List<SingleVariableDeclaration> parameters = methodDecl.parameters();
View Full Code Here

      if (locationInfo == null) {
        return Collections.emptyList();
      }

      ISourceRange fieldSourceRange = field.getSourceRange();
      assistContext = new AssistContext(javaContext.getCompilationUnit(), sourceViewer,
          fieldSourceRange.getOffset(), fieldSourceRange.getLength());
      node = assistContext.getCoveringNode();
      if (node instanceof FieldDeclaration) {
        // int invocationOffset = javaContext.getInvocationOffset();
        FieldDeclaration fieldDecl = (FieldDeclaration) node;
        // Set<Annotation> annotations =
View Full Code Here

        if (javaElement instanceof IMember) {
          List<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();

          IMember member = (IMember) javaElement;
          ICompilationUnit compilationUnit = member.getCompilationUnit();
          ISourceRange sourceRange = member.getSourceRange();
          AssistContext assistContext = new AssistContext(compilationUnit, null, sourceRange.getOffset(),
              sourceRange.getLength());
          ASTNode node = assistContext.getCoveringNode();

          if (node instanceof MethodDeclaration) {
            MethodDeclaration decl = (MethodDeclaration) node;
            // SimpleName name = decl.getName();
View Full Code Here

    return filePattern;
  }

  private String getAnnotationText(IAnnotation annotation, ITextViewer viewer, int invocationOffset) {
    ISourceRange nameRange;
    ISourceRange sourceRange;
    try {
      nameRange = annotation.getNameRange();
      sourceRange = annotation.getSourceRange();
    }
    catch (JavaModelException e) {
      return "";
    }

    int endPoint = sourceRange.getOffset() + sourceRange.getLength();
    // Want to get AT LEAST to the invocation point
    if (invocationOffset > endPoint) {
      endPoint = invocationOffset;
    }
    String text;
View Full Code Here

    if (element.getElementType() == IJavaElement.IMPORT_DECLARATION) {

      IImportDeclaration declaration = (IImportDeclaration) element;
      IImportContainer container = (IImportContainer) declaration
          .getParent();
      ISourceRange srcRange = null;
      try {
        srcRange = container.getSourceRange();
      }
      catch (JavaModelException e) {
      }

      if (srcRange != null && srcRange.getOffset() == caret)
        return container;
    }

    return (ISourceReference) element;
  }
View Full Code Here

  private int getLastImportEndPosition() {
    try {
      IImportDeclaration[] imports = cu.getImports();
      int lastPos = -1;
      for (IImportDeclaration currImport : imports) {
        ISourceRange sourceRange = currImport.getSourceRange();
        if (sourceRange != null) {
          int currPos = sourceRange.getOffset() + sourceRange.getLength();
          if (currPos > lastPos) {
            lastPos = currPos;
          }
        }
      }
View Full Code Here

              Class<?> propertyReturnType = propertyMethod.getReturnType();
              String propertySimpleType = propertyReturnType.getSimpleName();
              String paramSimpleType = Signature.getSignatureSimpleName(paramTypeSignature);
              if (propertySimpleType != null && !(propertySimpleType.equals(paramSimpleType))) {
                element.setElementSourceLocation(new JavaModelSourceLocation(params[0]));
                ISourceRange paramSourceRange = params[0].getSourceRange();
                ValidationProblemAttribute start = new ValidationProblemAttribute(
                    IMarker.CHAR_START,  paramSourceRange.getOffset());
                ValidationProblemAttribute end = new ValidationProblemAttribute(
                    IMarker.CHAR_END, paramSourceRange.getOffset() + paramSourceRange.getLength());
                ValidationProblemAttribute problemId = new ValidationProblemAttribute(IMarker.PROBLEM, PROBLEM_ID);
                ValidationProblemAttribute propertyType = new ValidationProblemAttribute(PROPERTY_TYPE_ATTR, propertyReturnType.getSimpleName());
                ValidationProblemAttribute propertyTypePackage = new ValidationProblemAttribute(PROPERTY_TYPE_PACKAGE_ATTR, propertyReturnType.getPackage().getName());
                context.warning(element, "SpringDataProbleMarker",
                    "Parameter type (" + paramSimpleType + ") does not match domain class property definition (" + propertySimpleType + ").",
View Full Code Here

  private static BodyDeclaration getBodyDeclaration(IJavaElement element) {
    try {
      if (element instanceof IMember) {
        IMember member = (IMember) element;
        ICompilationUnit compilationUnit = member.getCompilationUnit();
        ISourceRange sourceRange = member.getSourceRange();
        AssistContext assistContext = new AssistContext(compilationUnit, null, sourceRange.getOffset(),
            sourceRange.getLength());
        ASTNode node = assistContext.getCoveringNode();
        if (node instanceof BodyDeclaration) {
          return (BodyDeclaration) node;
        }
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.ISourceRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.