Package org.eclipse.jdt.core.dom.rewrite

Examples of org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition


  {
    ChildListPropertyDescriptor descriptor = getPropDescriptor(node);
    ListRewrite rewriter = rewrite.getListRewrite(node, descriptor);
    rewriter.insertFirst(stub, null);

    ITrackedNodePosition position = rewrite.track(stub);

    rewrite.rewriteAST(recoveredDocument, fJavaProject.getOptions(true)).apply(recoveredDocument);

    String generatedCode = recoveredDocument.get(position.getStartPosition(), position.getLength());

    int generatedIndent = IndentManipulation.measureIndentUnits(
        getIndentAt(recoveredDocument, position.getStartPosition(), settings), settings.tabWidth,
        settings.indentWidth);

    String indent = getIndentAt(document, getReplacementOffset(), settings);
    String methodDeclarationText = IndentManipulation.changeIndent(generatedCode, generatedIndent,
        settings.tabWidth, settings.indentWidth, indent,
View Full Code Here


    SimpleName typeName = ast.newSimpleName(className);
    SimpleType type = ast.newSimpleType(typeName);
    TypeLiteral typeLiteral = ast.newTypeLiteral();
    typeLiteral.setType(type);
    final ITrackedNodePosition newValuePosition = rewrite.track(typeLiteral);

    rewrite.replace(oldLiteral, typeLiteral, null);

    if (packageFragment != null) {
      ImportRewrite importRewrite = createImportRewrite(ASTResolving.findParentCompilationUnit(oldLiteral));
      importRewrite.addImport(packageFragment.getElementName() + "." + className);
    }

    setTrackPosition(new ITrackedNodePosition() {

      public int getStartPosition() {
        return newValuePosition.getStartPosition() + newValuePosition.getLength();
      }

      public int getLength() {
        return 0;
      }
View Full Code Here

      rewrite.remove(annot, null);

      callASTRewriteCorrectionProposal(getDisplayString(), cu, rewrite, 6, getImage(), document);

      ITextViewer viewer = getViewer(JavaPlugin.getActivePage().getActiveEditor());
      ITrackedNodePosition trackPos = rewrite.track(decl);
      if (trackPos != null && viewer != null) {
        viewer.setSelectedRange(trackPos.getStartPosition(), 0);
      }
    }
  }
View Full Code Here

    SingleMemberAnnotation annotation = ast.newSingleMemberAnnotation();
    annotation.setTypeName(ast.newSimpleName("Qualifier"));
    StringLiteral literal = ast.newStringLiteral();
    // literal.setLiteralValue(qualifier);
    annotation.setValue(literal);
    ITrackedNodePosition position = astRewrite.track(literal);
    addLinkedPosition(new StringLiteralTrackedPosition(position), true, "Qualifier");

    ChildListPropertyDescriptor property;

    if (decl instanceof FieldDeclaration) {
View Full Code Here

      return rewrite;
    }

    StringLiteral newValue = ast.newStringLiteral();
    newValue.setLiteralValue(packageName);
    ITrackedNodePosition newValuePosition = rewrite.track(newValue);

    rewrite.replace(oldLiteral, newValue, null);
    setTrackPosition(new StringLiteralTrackedPosition(newValuePosition, newValuePosition.getStartPosition() + 1
        + packageName.length(), 0, true));

    return rewrite;
  }
View Full Code Here

      SingleMemberAnnotation annotation = ast.newSingleMemberAnnotation();
      annotation.setTypeName(ast.newSimpleName("PathVariable"));
      StringLiteral pathVariableName = ast.newStringLiteral();
      pathVariableName.setLiteralValue(variableName);
      ITrackedNodePosition trackPathVariable = rewrite.track(pathVariableName);
      addLinkedPosition(new StringLiteralTrackedPosition(trackPathVariable), true, "PathVariable");
      annotation.setValue(pathVariableName);
      isLinked = true;

      ChildListPropertyDescriptor property;

      property = SingleVariableDeclaration.MODIFIERS2_PROPERTY;

      rewrite.getListRewrite(param, property).insertLast(annotation, null);
    }

    StringLiteral newTemplate = ast.newStringLiteral();
    newTemplate.setLiteralValue(newTemplateString);
    ITrackedNodePosition trackTemplateVariable = rewrite.track(newTemplate);
    rewrite.replace(oldTemplate, newTemplate, null);

    if (isLinked) {
      addLinkedPosition(
          new StringLiteralTrackedPosition(trackTemplateVariable, cursorOffset, variableName.length(), false),
View Full Code Here

    if (!ProposalCalculatorUtil.containsImport(getCompilationUnit(), importName)) {
      ImportRewrite importRewrite = createImportRewrite(astRoot);
      importRewrite.addImport(importName);
    }

    addLinkedPosition(new ITrackedNodePosition() {

      public int getStartPosition() {
        return variable.getOffset();
      }
View Full Code Here

    pathVariableName.setLiteralValue(variable.getVariableName());
    annotation.setValue(pathVariableName);

    astRewrite.getListRewrite(param, SingleVariableDeclaration.MODIFIERS2_PROPERTY).insertFirst(annotation, null);

    final ITrackedNodePosition literalPosition = astRewrite.track(variable.getNode());
    addLinkedPosition(new ITrackedNodePosition() {

      public int getStartPosition() {
        return literalPosition.getStartPosition() + variable.getOffsetFromNode();
      }

      public int getLength() {
        return variable.getVariableName().length();
      }
View Full Code Here

    NormalAnnotation annotation = astRewrite.getAST().newNormalAnnotation();

    annotation.setTypeName(astRewrite.getAST().newSimpleName("RequestMapping"));
    astRewrite.getListRewrite(decl, TypeDeclaration.MODIFIERS2_PROPERTY).insertFirst(annotation, null);

    ITrackedNodePosition tracker = astRewrite.track(annotation.getTypeName());
    edit.addChild(astRewrite.rewriteAST());

    edit.apply(document);

    setReplacementOffset(tracker.getStartPosition() + annotation.getTypeName().getFullyQualifiedName().length() + 1);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.rewrite.ITrackedNodePosition

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.