Examples of ISourceRange


Examples of org.eclipse.dltk.core.ISourceRange

  protected RefactoringStatus renameDeclaration(IProgressMonitor pm) throws CoreException {
    return renameDeclaration(pm, modelElement, cu);
  }

  protected RefactoringStatus renameDeclaration(IProgressMonitor pm, IModelElement modelElement, ISourceModule sourceModule) throws CoreException {
    ISourceRange sourceRange = null;
    if (modelElement instanceof IMember) {
      sourceRange = ((IMember) modelElement).getNameRange();
    }
    if (sourceRange != null) {
      addTextEdit(changeManager.get(sourceModule), getProcessorName(), new ReplaceEdit(sourceRange.getOffset(), modelElement.getElementName().length(), getNewElementName()));
    }

    return new RefactoringStatus();
  }
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceRange

  @Override
  protected RefactoringStatus updateReferences(IProgressMonitor pm) throws CoreException {
    ModuleDeclaration moduleDeclaration = SourceParserUtil.getModuleDeclaration(cu);
    if (moduleDeclaration != null) {
      IModelElement enclosingElement = modelElement.getParent();
      final ISourceRange declarationSourceRange = ((IField) modelElement).getNameRange();
      if (enclosingElement != null && declarationSourceRange != null) {
        ISourceRange enclosingElementSourceRange = null;

        if (enclosingElement.getElementType() == IModelElement.METHOD) {
          enclosingElementSourceRange = ((IMethod) enclosingElement).getSourceRange();
        } else if (enclosingElement.getElementType() == IModelElement.SOURCE_MODULE) {
          enclosingElementSourceRange = ((ISourceModule) enclosingElement).getSourceRange();
        }

        if (enclosingElementSourceRange != null) {
          final int enclosingElementSourceStart = enclosingElementSourceRange.getOffset();
          final int enclosingElementSourceEnd = enclosingElementSourceRange.getOffset() + enclosingElementSourceRange.getLength();

          try {
            moduleDeclaration.traverse(new PHPASTVisitor() {
              @Override
              public boolean visit(ArrayVariableReference s) throws Exception {
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceRange

   3. the variable is local (local scope or a parameter for the covering method)
   *
   */
  private void computeRequiredArgumentsForExtractedMethod() {

    ISourceRange selectedRange = getSelectedRange();
    ISourceRange preSelectedRange = getPreSelectedRange();
   
    // Since we're iterating over fMethodVariables (this is gathered by LocalVariableFinder
    // those variables are already local (so 3. is fulfilled)
    // covers 3.
    for(Variable possibleParameter : fMethodVariables)
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceRange

   * which is not the same code! So we have to return $object even though $object is an object.
   *
   */
  private void computeMethodReturnValues() {

    ISourceRange preSelectedRange = getPreSelectedRange();
    ISourceRange postSelectionRange = getPostSelectedRange();
    ISourceRange selectedRange = getSelectedRange();
   
    // again, 3. is fulfilled, since fMethodVariables only contains local variables
    for(Variable var : fMethodVariables)
    {
      // covers 5.
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceRange

   * of $obj at the end of the extracted method, since it's reference was changed.
   *  
   */
  private boolean isUsedAsObject(Variable var) {
   
    ISourceRange preSelectedRange = getPreSelectedRange();
    ISourceRange selectedRange = getSelectedRange();
   
    Variable lastObjectAssignment = null;
   
    // first we collect all assignments to var before the selected code.
    // and we take the last one of it, and hope that the last assignment is an object assignment
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceRange

   
    Program program = parser.createAST(new NullProgressMonitor());     
//    program.recordModifications();   
//    AST ast = program.getAST();   

    ISourceRange range = type.getSourceRange();   
    ASTNode node = program.getElementAt(range.getOffset());

    if (!(node instanceof ClassDeclaration)) {
      return ;       
    }
   
    char indentChar = FormatterUtils
        .getFormatterCommonPrferences().getIndentationChar(document);
    String indent = String.valueOf(indentChar);
   
    ClassDeclaration clazz = (ClassDeclaration) node;
    Block body = clazz.getBody();
    List<Statement> bodyStatements = body.statements();
       

    int end = bodyStatements.get(bodyStatements.size()-1).getEnd();
   
    if (insertFirst) {
      end = bodyStatements.get(0).getStart() - 1;
    } else if (insertAfter != null) {
     
      boolean found = false;
     
      for (IMethod method : type.getMethods()) {       
        if (method == insertAfter) {
          ISourceRange r = method.getSourceRange();
          end = r.getOffset() + r.getLength();
          found = true;
        }
      }
     
      if (!found) {       
        for (IField field : type.getFields()) {
          ISourceRange r = field.getSourceRange();
          end = r.getOffset() + r.getLength() + 1;
        }
      }
    }
   
    lineDelim = TextUtilities.getDefaultLineDelimiter(document);
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceRange

                final int kind = element.getElementType();
                if (kind == IModelElement.TYPE || kind == IModelElement.METHOD) {

                  final ISourceReference reference = (ISourceReference) element;
                  final ISourceRange range = reference.getSourceRange();

                  if (range != null) {
                    viewer.setSelectedRange(range.getOffset(), range.getLength());
                    viewer.doOperation(ISourceViewer.FORMAT);
                  }
                }
              }
            } catch (ModelException exception) {
View Full Code Here

Examples of org.eclipse.dltk.core.ISourceRange

  protected String getHeaderComment(IMember member) {
    if (member instanceof IField) {
      return null;
    }
    try {
      ISourceRange range = member.getSourceRange();
      if (range == null)
        return null;

      IBuffer buf = null;

      ISourceModule compilationUnit = member.getSourceModule();
      if (!compilationUnit.isConsistent()) {
        return null;
      }

      buf = compilationUnit.getBuffer();

      final int start = range.getOffset();

      String contents = buf.getContents();

      String result = "";
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

      lineDelimiter = StubUtility.getLineDelimiterUsed(aspect);

      // Write crosscut and format it
      IField field = fCrosscutPage.writeCrosscut(aspect, fCrosscutTypeDialogField.getSelectionIndex(), imports,
          new SubProgressMonitor(monitor, 2), lineDelimiter);
      ISourceRange range = field.getSourceRange();
      IBuffer buf = cu.getBuffer();
      String originalContent = buf.getText(range.getOffset(), range.getLength());
      String formattedContent = CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARATIONS, originalContent, 1, null,
          lineDelimiter, field.getJavaProject());
      buf.replace(range.getOffset(), range.getLength(), formattedContent);
      if (!cu.isWorkingCopy())
        buf.save(null, false);

      imports.create(needsSave, new SubProgressMonitor(monitor, 1));
      removeUnusedImports(cu, needsSave);
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

                resetHighlightRange();
            }
            return;
        }
        try {
            ISourceRange range = null;
            int offset;
            int length;
            if (isDecompiled() && isSupportedMember(reference)) {

                // document lines count starts with 1 and not with 0
                int decompLine = -1
                    + getSourceMapper().getDecompiledLine(
                        (IMember) reference, getClassFile());
                if(decompLine < 0){
                    return;
                }
                IRegion region = ((BytecodeDocumentProvider) getDocumentProvider())
                    .getDecompiledLineInfo(getEditorInput(), decompLine);
                if (region == null) {
                    return;
                }
                offset = region.getOffset();
                length = region.getLength();
            } else if (!isDecompiled()) {
                range = reference.getSourceRange();
                if (range == null) {
                    return;
                }
                offset = range.getOffset();
                length = range.getLength();
            } else {
                return;
            }

            if (offset > -1 && length > 0) {
                setHighlightRange(offset, length, moveCursor);
            }

            if ((reference instanceof IMember) && !isDecompiled()) {
                IMember member = (IMember) reference;
                range = member.getNameRange();
                if (range != null) {
                    offset = range.getOffset();
                    length = range.getLength();
                }
            }
            if (moveCursor && offset > -1 && length > 0) {
                ISourceViewer sourceViewer = getSourceViewer();
                if (sourceViewer != null) {
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.