Package org.eclim.plugin.core.command.refactoring

Examples of org.eclim.plugin.core.command.refactoring.RefactorException


    int flags = RenameSupport.UPDATE_REFERENCES;

    ICompilationUnit src = JavaUtils.getCompilationUnit(project, file);
    IJavaElement[] elements = src.codeSelect(offset, length);
    if(elements == null || elements.length == 0){
      throw new RefactorException();
    }

    IJavaElement element = elements[0];

    // check for element outside any user project
    if (element instanceof IMember){
      ICompilationUnit cu = ((IMember)element).getCompilationUnit();
      if (cu == null){
        throw new RefactorException(Services.getMessage(
              "rename.element.unable", element.getElementName()));
      }
    }

    JavaRenameProcessor processor = getProcessor(element, name, flags);
View Full Code Here


    ICompilationUnit src = JavaUtils.getCompilationUnit(project, file);
    IPackageFragmentRoot root = JavaModelUtil.getPackageFragmentRoot(src);
    IPackageFragment pack = root.getPackageFragment(packName);
    ICompilationUnit dest = pack.getCompilationUnit(src.getElementName());
    if (dest.exists()){
      throw new RefactorException(Services.getMessage(
            "move.element.exists",
            pack.getElementName(),
            src.getElementName()));
    }

    if(!pack.exists()){
      pack = root.createPackageFragment(packName, true, null);
    }

    IMovePolicy policy = ReorgPolicyFactory.createMovePolicy(
        new IResource[0],
        new IJavaElement[]{src});

    JavaMoveProcessor processor = new JavaMoveProcessor(policy);
    IReorgDestination destination =
      ReorgDestinationFactory.createDestination(pack);
    RefactoringStatus status = processor.setDestination(destination);
    if (status.hasError()){
      throw new RefactorException(status);
    }

    Shell shell = EclimPlugin.getShell();
    processor.setCreateTargetQueries(new CreateTargetQueries(shell));
    processor.setReorgQueries(new ReorgQueries(shell));
View Full Code Here

TOP

Related Classes of org.eclim.plugin.core.command.refactoring.RefactorException

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.