Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.ISourceRange


 
  private String computeSource() {
    StringBuffer result = new StringBuffer();
    try {
      ISourceReference ref = (ISourceReference) owner;
      ISourceRange range = ref.getSourceRange();
      int sourceOffset = range.getOffset();
      int sourceLen = range.getLength();
      int offset = position.getOffset();
      int len = position.getLength();

      offset -= sourceOffset;
      if (offset < 0) {
View Full Code Here


    if (!strategy.shouldScan(elem)) {
      regionSet = strategy.result(); // call immediately...
    }
    else {
      ISourceReference reference = (ISourceReference) elem;
      ISourceRange range = reference.getSourceRange();

      // All other element types require some parsing...
      String contents = reference.getSource();

      if (contents == null) return null;

      IScanner scanner = ToolFactory.createScanner(true, false, false, false);
      scanner.setSource(contents.toCharArray());

      int shift = range.getOffset();
      int start = shift;

      while (true) {
        int token = scanner.getNextToken();
View Full Code Here

    Annotation[] astAnnotations = new Annotation[length];
    if (length > 0) {
      char[] cuSource = getSource();
      int recordedAnnotations = 0;
      for (int i = 0; i < length; i++) {
        ISourceRange positions = annotations[i].getSourceRange();
        int start = positions.getOffset();
        int end = start + positions.getLength();
        char[] annotationSource = CharOperation.subarray(cuSource, start, end);
        if (annotationSource != null) {
            Expression expression = parseMemberValue(annotationSource);
            /*
             * expression can be null or not an annotation if the source has changed between
View Full Code Here

       
        this.parser = ASTParser.newParser(AST.JLS3);
        parser.setResolveBindings(true);
        parser.setSource(compilationUnit);

        ISourceRange sourceRange;
        try {
            sourceRange = method.getSourceRange();

            this.parsedCompilationUnit = (CompilationUnit) parser.createAST(null);
           
View Full Code Here

    if (!strategy.shouldScan(elem)) {
      regionSet = strategy.result(); // call immediately...
    }
    else {
      ISourceReference reference = (ISourceReference) elem;
      ISourceRange range = reference.getSourceRange();

      // All other element types require some parsing...
      String contents = reference.getSource();

      if (contents == null) return null;

      IScanner scanner = ToolFactory.createScanner(true, false, false, false);
      scanner.setSource(contents.toCharArray());

      int shift = range.getOffset();
      int start = shift;

      while (true) {
        int token = scanner.getNextToken();
View Full Code Here

   * (non-Javadoc)
   *
   * @see com.cb.eclipse.folding.calculation.CalculationStrategy#shouldScan(org.eclipse.jdt.core.IJavaElement)
   */
  public boolean shouldScan(IJavaElement elem) throws JavaModelException {
    ISourceRange range = getNaturalRange(elem);

    if (FoldingPlugin.getBoolean(PreferenceKeys.FOLD_IMPORTS)) {
      boolean doCollapse = FoldingPlugin.getBoolean(PreferenceKeys.COLLAPSE_IMPORTS);
      // get a region for the entire range of the IJavaElement
      addRegion(new EnhancedPosition(range.getOffset(), range.getLength(), new JavaPositionMetadata(false, false, doCollapse, false, null)));
    }
    // don't scan.
    return false;
  }
View Full Code Here

 
  private String computeSource() {
    StringBuffer result = new StringBuffer();
    try {
      ISourceReference ref = (ISourceReference) owner;
      ISourceRange range = ref.getSourceRange();
      int sourceOffset = range.getOffset();
      int sourceLen = range.getLength();
      int offset = position.getOffset();
      int len = position.getLength();

      offset -= sourceOffset;
      if (offset < 0) {
View Full Code Here

   * TODO investigate using shouldScan and sourceRef.getContents()...
   *
   * @see com.cb.eclipse.folding.calculation.CalculationStrategy#shouldScan(org.eclipse.jdt.core.IJavaElement)
   */
  public void postScan(int position, IJavaElement elem) throws JavaModelException {
    ISourceRange range = getNaturalRange(elem);
    IType type = (IType) elem;

    boolean collapse;
    boolean fold;
   
    boolean negateLine = FoldingPlugin.getBoolean(PreferenceKeys.LAST_LINE_TYPES);
    if (type.getDeclaringType() != null) { // inner class
      collapse = FoldingPlugin.getBoolean(PreferenceKeys.COLLAPSE_INNER_TYPES);
      fold = FoldingPlugin.getBoolean(PreferenceKeys.FOLD_INNER_TYPES);
    }
    else { // top level type
      collapse = FoldingPlugin.getBoolean(PreferenceKeys.COLLAPSE_TOP_TYPES);
      fold = FoldingPlugin.getBoolean(PreferenceKeys.FOLD_TOP_TYPES);
    }

    if (fold) {
     
      addRegion(new EnhancedPosition(position, range.getOffset() + (range.getLength() - position), new JavaPositionMetadata(false, negateLine, collapse, false, null)));
    }

  }
View Full Code Here

 
  public boolean isSentinel(String sentinel, int start, int end, IJavaElement owner) throws JavaModelException {
    ISourceReference reference = (ISourceReference) owner;
   
    String contents = reference.getSource();
    ISourceRange range = (ISourceRange)reference.getSourceRange();
   
   
    int correctedStart = start - range.getOffset();
    // Math.min should be redundant (no JavaElement should contain half of a comment)
    int correctedEnd = Math.min( (end - range.getOffset()) , range.getLength());
   
    //System.out.println("Checking for sentinel: " + contents.substring(correctedStart, correctedEnd));
    boolean keepScanning = true;
    int shift = correctedStart+2; // +2 refers to the // characters which we know we can remove
   
View Full Code Here

   * @return The position.
   */
  public static Position getPosition(IType type, ISourceReference reference)
    throws Exception
  {
    ISourceRange range = reference.getSourceRange();
    return Position.fromOffset(
        type.getResource().getLocation().toOSString(), null,
        range.getOffset(), range.getLength());
  }
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.