Package org.eclipse.ltk.core.refactoring

Examples of org.eclipse.ltk.core.refactoring.RefactoringStatus


        return "Bndtools Package Rename Participant";
    }

    @Override
    public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException {
        return new RefactoringStatus();
    }
View Full Code Here


    @Override
    public RefactoringStatus isValid(IProgressMonitor progress) throws CoreException,
        OperationCanceledException
    {
        // TODO check project is synchronized
        return new RefactoringStatus();
    }
View Full Code Here

    @Override
    public RefactoringStatus checkConditions(IProgressMonitor monitor,
        CheckConditionsContext ctx) throws OperationCanceledException
    {
        RefactoringStatus status = null;
        if (getArguments().getUpdateReferences())
        {
            try
            {
                ISigilProjectModel sourceProject = SigilCore.create(compilationUnit.getJavaProject().getProject());
                RefactorUtil.touch(ctx, sourceProject);
                IPackageFragment packageFragment = (IPackageFragment) compilationUnit.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
                final String packageName = packageFragment.getElementName();
                IPackageExport oldExport = ModelHelper.findExport(sourceProject,
                    packageName);

                if (oldExport != null) {
                    status = RefactoringStatus.createWarningStatus("Moving a class from an exported package effects client bundles");
                   
                    IPackageFragment dest = (IPackageFragment) getArguments().getDestination();
                    ISigilProjectModel destProject = SigilCore.create(dest.getJavaProject().getProject());

                    if (!destProject.equals(sourceProject)) {
                        status.addWarning("Moving an exported class to another bundle effects client bundles that use Require-Bundle");
                    }
                   
                    IPackageExport newExport = ModelHelper.findExport(destProject,
                        dest.getElementName());
                   
                    if ( newExport == null ) {
                        newExport = RefactorUtil.createNewExport(status, changes, destProject, dest.getElementName());
                    }
                   
                    if ( packageFragment.getCompilationUnits().length == 1 ) {
                        status.addInfo("Last exported class removed from " + packageName);
                        changes.add( new ExportPackageChange(sourceProject, oldExport, null));
                    }
                }
            }
            catch (CoreException e)
View Full Code Here

    @Override
    public RefactoringStatus checkConditions(IProgressMonitor monitor,
        CheckConditionsContext ctx) throws OperationCanceledException
    {
        RefactoringStatus status = null;
        if (getArguments().getUpdateReferences())
        {
            IPackageFragment pf = (IPackageFragment) compilationUnit.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
            String oldName = qualifiedName(pf, compilationUnit.getElementName());
            try
View Full Code Here

    @Override
    public RefactoringStatus checkConditions(IProgressMonitor monitor,
        CheckConditionsContext ctx) throws OperationCanceledException
    {
        RefactoringStatus status = null;
        if (getArguments().getUpdateReferences())
        {
            IPackageFragment pf = (IPackageFragment) compilationUnit.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
            String oldName = qualifiedName(pf, compilationUnit.getElementName());
            try
View Full Code Here

    @Override
    public RefactoringStatus checkConditions(IProgressMonitor monitor,
        CheckConditionsContext ctx) throws OperationCanceledException
    {
        RefactoringStatus status = null;
        if (getArguments().getUpdateReferences())
        {
            try
            {
                ISigilProjectModel sigil = SigilCore.create(packageFragment.getJavaProject().getProject());
View Full Code Here

            {
                ISigilProjectModel sourceProject = SigilCore.create(packageFragment.getJavaProject().getProject());
                IPackageFragmentRoot dest = (IPackageFragmentRoot) getArguments().getDestination();
                ISigilProjectModel destProject = SigilCore.create(dest.getJavaProject().getProject());

                RefactoringStatus status = new RefactoringStatus();
                if (!sourceProject.equals(destProject))
                {
                    RefactorUtil.touch(context, sourceProject);
                    RefactorUtil.touch(context, destProject);

                    final String packageName = packageFragment.getElementName();
                    IPackageExport oldExport = ModelHelper.findExport(sourceProject,
                        packageName);

                    if (oldExport != null)
                    {
                        IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
                            IPackageExport.class);

                        newExport.setPackageName(oldExport.getPackageName());
                        newExport.setVersion(oldExport.getRawVersion());

                        changes.add(new ExportPackageChange(destProject, null, newExport));
                        changes.add(new ExportPackageChange(sourceProject, oldExport,
                            null));

                        status.addWarning("Package " + packageName + " is exported from "
                            + sourceProject.getSymbolicName()
                            + ", this may effect client bundles that use require bundle");
                    }
                    else
                    {
                        SubMonitor sub = SubMonitor.convert(monitor);
                       
                        sub.beginTask("Resolving package users", 200);
                       
                        Set<String> users = JavaHelper.findLocalPackageUsers(
                            sourceProject, packageName, sub.newChild(100));
                        Set<String> dependencies = JavaHelper.findLocalPackageDependencies(
                            sourceProject, packageName, sub.newChild(100));

                        if (users.size() > 0 && dependencies.size() > 0)
                        {
                            status.addWarning("Package " + packageName
                                + " is coupled to " + users + " and " + dependencies
                                + " this may cause a cyclical dependency");
                        }

                        if (users.size() > 0)
                        { // attempt to move an API package
                            IPackageExport newExport = RefactorUtil.createNewExport(status, changes,
                                destProject, packageName);
                            RefactorUtil.createNewImport(status, changes, sourceProject, newExport);
                        }

                        if (dependencies.size() > 0)
                        { // moved an impl package
                            for (String dep : dependencies)
                            {
                                IPackageExport newExport = RefactorUtil.createNewExport(status, changes,
                                    sourceProject, dep);
                                RefactorUtil.createNewImport(status, changes, destProject, newExport);
                            }
                        }
                    }
                }
                return status;
            }
            catch (CoreException e)
            {
                SigilCore.warn("Failed to create move refactor conditions", e);
                throw new OperationCanceledException(e.getMessage());
            }
        }
        else
        {
            return new RefactoringStatus();
        }
    }
View Full Code Here

    @Override
    public RefactoringStatus isValid(IProgressMonitor progress) throws CoreException,
        OperationCanceledException
    {
        // TODO check project is synchronized
        return new RefactoringStatus();
    }
View Full Code Here

    @Override
    public RefactoringStatus checkConditions(IProgressMonitor pm,
        CheckConditionsContext context) throws OperationCanceledException
    {
        RefactoringStatus status = new RefactoringStatus();

        if (getArguments().getUpdateReferences())
        {
            try
            {
View Full Code Here

    return "Japid Template Naming Participation";
  }
 
  @Override
  public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
    return new RefactoringStatus();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.ltk.core.refactoring.RefactoringStatus

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.