Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.ISourceRange


        /* The member's name range may not be correct. However,
         * reconciling would trigger another element delta which would
         * lead to reentrant situations. Therefore, we optimistically
         * assume that the name range is correct, but double check the
         * received lines below. */
        ISourceRange nameRange = fMember.getNameRange();
        if (nameRange != null)
          nameStart = nameRange.getOffset();

      } catch (JavaModelException e) {
        // ignore and use default
      }

View Full Code Here


      if (!fMember.exists())
        return 0;

      try {
        ISourceRange sourceRange = fMember.getSourceRange();
        IMethod foldedMethod = lambdaMethod;

        if (foldedMethod != null && !foldedMethod.exists()) {
          foldedMethod = findLambdaMethodIn(fMember);
          if (foldedMethod != null) {
View Full Code Here

        if (buf == null) {
          // no source attachment found. This method maybe the one. Stop.
          return InheritDocVisitor.STOP_BRANCH;
        }

        ISourceRange javadocRange= member.getJavadocRange();
        if (javadocRange == null)
          return InheritDocVisitor.CONTINUE;  // this method doesn't have javadoc, continue to look.
        String rawJavadoc= buf.getText(javadocRange.getOffset(), javadocRange.getLength());
        if (rawJavadoc != null) {
          return overridden;
        }
        return InheritDocVisitor.CONTINUE;
      }
View Full Code Here

   * @return the regions to be folded
   */
  protected final IRegion[] computeProjectionRanges(ISourceReference reference,
          FoldingStructureComputationContext ctx) {
    try {
      ISourceRange range = reference.getSourceRange();
      if (!SourceRange.isAvailable(range))
        return new IRegion[0];

      String contents = reference.getSource();
      if (contents == null)
        return new IRegion[0];

      List<IRegion> regions = new ArrayList<IRegion>();
      if (!ctx.hasFirstType() && reference instanceof IType) {
        ctx.setFirstType((IType) reference);
        IRegion headerComment = computeHeaderComment(ctx);
        if (headerComment != null) {
          regions.add(headerComment);
          ctx.setHasHeaderComment();
        }
      }

      final int shift = range.getOffset();
      IScanner scanner = ctx.getScanner();
      scanner.resetTo(shift, shift + range.getLength());

      int start = shift;
      while (true) {

        int token = scanner.getNextToken();
        start = scanner.getCurrentTokenStartPosition();

        switch (token) {
        case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
        case ITerminalSymbols.TokenNameCOMMENT_BLOCK: {
          int end = scanner.getCurrentTokenEndPosition() + 1;
          regions.add(new Region(start, end - start));
          continue;
        }
        case ITerminalSymbols.TokenNameCOMMENT_LINE:
          continue;
        }

        break;
      }

      regions.add(new Region(start, shift + range.getLength() - start));

      return regions.toArray(new IRegion[regions.size()]);
    } catch (JavaModelException e) {} catch (InvalidInputException e) {}

    return new IRegion[0];
View Full Code Here

  }

  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

        return null;

      int nameStart = computeCaptionOffset(document) + offset;

      try {
        ISourceRange sourceRange = fMember.getSourceRange();
        IMethod foldedMethod = lambdaMethod;

        if (foldedMethod != null && !foldedMethod.exists()) {
          foldedMethod = findLambdaMethodIn(fMember);
          if (foldedMethod != null) {
View Full Code Here

        /* The member's name range may not be correct. However,
         * reconciling would trigger another element delta which would
         * lead to reentrant situations. Therefore, we optimistically
         * assume that the name range is correct, but double check the
         * received lines below. */
        ISourceRange nameRange = fMember.getNameRange();
        if (nameRange != null)
          nameStart = nameRange.getOffset();

      }
      catch (JavaModelException e) {
        // ignore and use default
      }
View Full Code Here

      if (!fMember.exists())
        return 0;

      try {
        ISourceRange sourceRange = fMember.getSourceRange();
        IMethod foldedMethod = lambdaMethod;

        if (foldedMethod != null && !foldedMethod.exists()) {
          foldedMethod = findLambdaMethodIn(fMember);
          if (foldedMethod != null) {
View Full Code Here

  }

  private IRegion computeImportProjectionRanges(IImportContainer element,
      FoldingStructureComputationContext ctx) {
    try {
      ISourceRange range = element.getSourceRange();
      String contents = null;
      if (SourceRange.isAvailable(range) && (contents = element.getSource()) != null) {
        Region importRegion = new Region(range.getOffset(), range.getLength());
        return importRegion;
        /*return alignRegion(importRegion, ctx);*/
      }
    }
    catch (Exception e) {
View Full Code Here

   * @return the regions to be folded
   */
  protected final IRegion[] computeProjectionRanges(ISourceReference reference,
      FoldingStructureComputationContext ctx) {
    try {
      ISourceRange range = reference.getSourceRange();
      if (!SourceRange.isAvailable(range))
        return new IRegion[0];

      String contents = reference.getSource();
      if (contents == null)
        return new IRegion[0];

      List<IRegion> regions = new ArrayList<IRegion>();
      if (!ctx.hasFirstType() && reference instanceof IType) {
        ctx.setFirstType((IType) reference);
        IRegion headerComment = computeHeaderComment(ctx);
        if (headerComment != null) {
          regions.add(headerComment);
          ctx.setHasHeaderComment();
        }
      }

      final int shift = range.getOffset();
      IScanner scanner = ctx.getScanner();
      scanner.resetTo(shift, shift + range.getLength());

      int start = shift;
      while (true) {

        int token = scanner.getNextToken();
        start = scanner.getCurrentTokenStartPosition();

        switch (token) {
        case ITerminalSymbols.TokenNameCOMMENT_JAVADOC:
        case ITerminalSymbols.TokenNameCOMMENT_BLOCK: {
          int end = scanner.getCurrentTokenEndPosition() + 1;
          regions.add(new Region(start, end - start));
          continue;
        }
        case ITerminalSymbols.TokenNameCOMMENT_LINE:
          continue;
        }

        break;
      }

      regions.add(new Region(start, shift + range.getLength() - start));

      return regions.toArray(new IRegion[regions.size()]);
    }
    catch (JavaModelException e) {
    }
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.