Examples of SourceRange


Examples of org.aspectj.org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer.SourceRange

          pos= endPos;
          break;
        }
        case RewriteEvent.REPLACED: {
          ASTNode superClass= (ASTNode) superClassEvent.getOriginalValue();
          SourceRange range= getExtendedRange(superClass);
          int offset= range.getStartPosition();
          int length= range.getLength();
          doTextRemoveAndVisit(offset, length, superClass, getEditGroup(superClassEvent));
          doTextInsert(offset, (ASTNode) superClassEvent.getNewValue(), 0, false, getEditGroup(superClassEvent));
          pos= offset + length;
          break;
        }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer.SourceRange

      ArrayType replacingType= (ArrayType) typeEvent.getNewValue();
      editGroup= getEditGroup(typeEvent);
      Type newType= replacingType.getElementType();
      Type oldType= getElementType(arrayType);
      if (!newType.equals(oldType)) {
        SourceRange range= getExtendedRange(oldType);
        int offset= range.getStartPosition();
        int length= range.getLength();
        doTextRemove(offset, length, editGroup);
        doTextInsert(offset, newType, 0, false, editGroup);
      }
      nNewBrackets= replacingType.getDimensions(); // is replaced type
    }
    voidVisit(arrayType);
   

    try {
      int offset= getScanner().getTokenStartOffset(ITerminalSymbols.TokenNameLBRACKET, arrayType.getStartPosition());
      // dimension node with expressions
      RewriteEvent dimEvent= getEvent(node, ArrayCreation.DIMENSIONS_PROPERTY);
      boolean hasDimensionChanges= (dimEvent != null && dimEvent.getChangeKind() != RewriteEvent.UNCHANGED);
      if (hasDimensionChanges) {
        RewriteEvent[] events= dimEvent.getChildren();
        // offset on first opening brace
        for (int i= 0; i < events.length; i++) {
          RewriteEvent event= events[i];
          int changeKind= event.getChangeKind();
          if (changeKind == RewriteEvent.INSERTED) { // insert new dimension
            editGroup= getEditGroup(event);
            doTextInsert(offset, "[", editGroup); //$NON-NLS-1$
            doTextInsert(offset, (ASTNode) event.getNewValue(), 0, false, editGroup);
            doTextInsert(offset, "]", editGroup); //$NON-NLS-1$
            nNewBrackets--;
          } else {
            ASTNode elem= (ASTNode) event.getOriginalValue();
            int elemEnd= elem.getStartPosition() + elem.getLength();
            int endPos= getScanner().getTokenEndOffset(ITerminalSymbols.TokenNameRBRACKET, elemEnd);
            if (changeKind == RewriteEvent.REMOVED) {
              editGroup= getEditGroup(event);
              doTextRemoveAndVisit(offset, endPos - offset, elem, editGroup);
            } else if (changeKind == RewriteEvent.REPLACED) {
              editGroup= getEditGroup(event);
              SourceRange range= getExtendedRange(elem);
              int elemOffset= range.getStartPosition();
              int elemLength= range.getLength();
              doTextRemoveAndVisit(elemOffset, elemLength, elem, editGroup);
              doTextInsert(elemOffset, (ASTNode) event.getNewValue(), 0, false, editGroup);
              nNewBrackets--;
            } else {
              voidVisit(elem);
View Full Code Here

Examples of org.eclipse.dltk.core.SourceRange

 
  public static ISourceRange createFrom(ASTNode node)
  {
    Assert.isNotNull(node);
   
    return new SourceRange(node.getStart(), node.getLength());
  }
View Full Code Here

Examples of org.eclipse.dltk.core.SourceRange

    fGenerateDoc = true;
    fReturnMultipleVariables = false;
    fMethodName = "extracted"; //$NON-NLS-1$
    fSelectionStart = selectionStart;
    fSelectionLength = selectionLength;
    fSelectedSourceRange = new SourceRange(selectionStart, selectionLength);
    fReplaceDuplicates = false;
    fAddTypeHint = true;
  }
View Full Code Here

Examples of org.eclipse.dltk.core.SourceRange

    } catch(Exception e) {
      throw new RefactoringStatusException(RefactoringMessages.ExtractMethodInputPage_errorCouldNotRetrieveCoveringMethodDeclaration);
    }
   
    // compute source ranges before and after the selected code
    fPreSelectedSourceRange = new SourceRange(fSelectedMethodSourceRange.getOffset(), fSelectionStart - fSelectedMethodSourceRange.getOffset());
    fPostSelectedSourceRange = new SourceRange(fSelectionStart + fSelectionLength, fSelectedMethodSourceRange.getOffset() + fSelectedMethodSourceRange.getLength() - fSelectionStart + fSelectionLength);
   
    // find all variables used in the selected method
    LocalVariableFinder finder = new LocalVariableFinder();
    finder.setRange(fSelectedMethodSourceRange);
    fProgram.accept(finder);
View Full Code Here

Examples of org.eclipse.dltk.internal.core.SourceRange

      return;
    }

    IDLTKSearchScope scope = SearchEngine.createSearchScope(module.getScriptProject());
    SourceType type = (SourceType) element;
    SourceRange range = getReplacementRange(context);
    String prefix = context.getPrefix();

    IType[] projectTypes = PhpModelAccess.getDefault().findTypes(type.getElementName(), MatchRule.EXACT, 0, 0, scope, null);

    if (projectTypes.length != 1) {
View Full Code Here

Examples of org.eclipse.jdt.core.SourceRange

      }
    } else {
      this.types[this.typeDepth] = getType(new String(typeInfo.name));
    }
    this.typeNameRanges[this.typeDepth] =
      new SourceRange(typeInfo.nameSourceStart, typeInfo.nameSourceEnd - typeInfo.nameSourceStart + 1);
    this.typeDeclarationStarts[this.typeDepth] = typeInfo.declarationStart;

    IType currentType = this.types[this.typeDepth];

    // type parameters
    if (typeInfo.typeParameters != null) {
      for (int i = 0, length = typeInfo.typeParameters.length; i < length; i++) {
        TypeParameterInfo typeParameterInfo = typeInfo.typeParameters[i];
        ITypeParameter typeParameter = currentType.getTypeParameter(new String(typeParameterInfo.name));
        setSourceRange(
          typeParameter,
          new SourceRange(
            typeParameterInfo.declarationStart,
            typeParameterInfo.declarationEnd - typeParameterInfo.declarationStart + 1),
          new SourceRange(
            typeParameterInfo.nameSourceStart,
            typeParameterInfo.nameSourceEnd - typeParameterInfo.nameSourceStart + 1));
      }
    }
View Full Code Here

Examples of org.eclipse.jdt.core.SourceRange

   */
  public void enterField(FieldInfo fieldInfo) {
    if (this.typeDepth >= 0) {
      this.memberDeclarationStart[this.typeDepth] = fieldInfo.declarationStart;
      this.memberNameRange[this.typeDepth] =
        new SourceRange(fieldInfo.nameSourceStart, fieldInfo.nameSourceEnd - fieldInfo.nameSourceStart + 1);
      String fieldName = new String(fieldInfo.name);
      this.memberName[this.typeDepth] = fieldName;

      // categories
      IType currentType = this.types[this.typeDepth];
View Full Code Here

Examples of org.eclipse.jdt.core.SourceRange

  }
  private void enterAbstractMethod(MethodInfo methodInfo) {
    if (this.typeDepth >= 0) {
      this.memberName[this.typeDepth] = new String(methodInfo.name);
      this.memberNameRange[this.typeDepth] =
        new SourceRange(methodInfo.nameSourceStart, methodInfo.nameSourceEnd - methodInfo.nameSourceStart + 1);
      this.memberDeclarationStart[this.typeDepth] = methodInfo.declarationStart;
      IType currentType = this.types[this.typeDepth];
      int currenTypeModifiers = this.typeModifiers[this.typeDepth];
      char[][] parameterTypes = methodInfo.parameterTypes;
      if (methodInfo.isConstructor && currentType.getDeclaringType() != null && !Flags.isStatic(currenTypeModifiers)) {
        IType declaringType = currentType.getDeclaringType();
        String declaringTypeName = declaringType.getElementName();
        if (declaringTypeName.length() == 0) {
          IClassFile classFile = declaringType.getClassFile();
          int length = parameterTypes != null ? parameterTypes.length : 0;
          char[][] newParameterTypes = new char[length+1][];
          declaringTypeName = classFile.getElementName();
          declaringTypeName = declaringTypeName.substring(0, declaringTypeName.indexOf('.'));
          newParameterTypes[0] = declaringTypeName.toCharArray();
          if (length != 0) {
            System.arraycopy(parameterTypes, 0, newParameterTypes, 1, length);
          }
          this.methodParameterTypes[this.typeDepth] = newParameterTypes;
        } else {
          int length = parameterTypes != null ? parameterTypes.length : 0;
          char[][] newParameterTypes = new char[length+1][];
          newParameterTypes[0] = declaringTypeName.toCharArray();
          if (length != 0) {
            System.arraycopy(parameterTypes, 0, newParameterTypes, 1, length);
          }
          this.methodParameterTypes[this.typeDepth] = newParameterTypes;
        }
      } else {
        this.methodParameterTypes[this.typeDepth] = parameterTypes;
      }
      this.methodParameterNames[this.typeDepth] = methodInfo.parameterNames;

      IMethod method = currentType.getMethod(
          this.memberName[this.typeDepth],
          convertTypeNamesToSigs(this.methodParameterTypes[this.typeDepth]));

      // type parameters
      if (methodInfo.typeParameters != null) {
        for (int i = 0, length = methodInfo.typeParameters.length; i < length; i++) {
          TypeParameterInfo typeParameterInfo = methodInfo.typeParameters[i];
          ITypeParameter typeParameter = method.getTypeParameter(new String(typeParameterInfo.name));
          setSourceRange(
            typeParameter,
            new SourceRange(
              typeParameterInfo.declarationStart,
              typeParameterInfo.declarationEnd - typeParameterInfo.declarationStart + 1),
            new SourceRange(
              typeParameterInfo.nameSourceStart,
              typeParameterInfo.nameSourceEnd - typeParameterInfo.nameSourceStart + 1));
        }
      }
      // parameters infos
      if (methodInfo.parameterInfos != null) {
        for (int i = 0, length = methodInfo.parameterInfos.length; i < length; i++) {
          ParameterInfo parameterInfo = methodInfo.parameterInfos[i];
          LocalVariableElementKey key = new LocalVariableElementKey(method, new String(parameterInfo.name));
          SourceRange[] allRanges = new SourceRange[] {
            new SourceRange(
              parameterInfo.declarationStart,
              parameterInfo.declarationEnd - parameterInfo.declarationStart + 1),
            new SourceRange(
              parameterInfo.nameSourceStart,
              parameterInfo.nameSourceEnd - parameterInfo.nameSourceStart + 1)
          };
          this.parametersRanges.put(
            key,
View Full Code Here

Examples of org.eclipse.jdt.core.SourceRange

  public void exitType(int declarationEnd) {
    if (this.typeDepth >= 0) {
      IType currentType = this.types[this.typeDepth];
      setSourceRange(
        currentType,
        new SourceRange(
          this.typeDeclarationStarts[this.typeDepth],
          declarationEnd - this.typeDeclarationStarts[this.typeDepth] + 1),
        this.typeNameRanges[this.typeDepth]);
      this.typeDepth--;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.