• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RefactoringContribution类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.ltk.core.refactoring.RefactoringContribution的典型用法代码示例。如果您正苦于以下问题:Java RefactoringContribution类的具体用法?Java RefactoringContribution怎么用?Java RefactoringContribution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RefactoringContribution类属于org.eclipse.ltk.core.refactoring包,在下文中一共展示了RefactoringContribution类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createRefactoring

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
/** {@inheritDoc} */
public Refactoring createRefactoring(final RefactoringStatus status) throws CoreException {
  Refactoring refactoring = null;
  final String id = getID();
  final RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(id);
  if (contribution != null) {
    if (contribution instanceof JavaRefactoringContribution) {
      JavaRefactoringContribution javaContribution = (JavaRefactoringContribution) contribution;
      refactoring = javaContribution.createRefactoring(this, status);
    } else
      JavaPlugin.log(
          new Status(
              IStatus.ERROR,
              JavaPlugin.getPluginId(),
              0,
              MessageFormat.format(
                  DescriptorMessages.JavaRefactoringDescriptor_no_resulting_descriptor,
                  new Object[] {id}),
              null));
  }
  return refactoring;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:JavaRefactoringDescriptor.java


示例2: createDescriptor

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
/**
 * Creates a new refactoring descriptor for the specified input data.
 *
 * @param id the unique id of the refactoring
 * @param project the project name, or <code>null</code>
 * @param description a description
 * @param comment the comment, or <code>null</code>
 * @param arguments the argument map
 * @param flags the flags
 * @return the refactoring descriptor
 * @throws IllegalArgumentException if the argument map contains invalid keys/values
 */
public RefactoringDescriptor createDescriptor(
    final String id,
    final String project,
    final String description,
    final String comment,
    final Map arguments,
    final int flags)
    throws IllegalArgumentException {
  Assert.isNotNull(id);
  Assert.isNotNull(description);
  Assert.isNotNull(arguments);
  Assert.isLegal(flags >= RefactoringDescriptor.NONE);
  final RefactoringContribution contribution = getRefactoringContribution(id);
  if (contribution != null)
    return contribution.createDescriptor(id, project, description, comment, arguments, flags);
  return new DefaultRefactoringDescriptor(id, project, description, comment, arguments, flags);
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:RefactoringContributionManager.java


示例3: createDescriptor

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
/**
 * Creates a {@link RefactoringDescriptor} from a
 * {@link RefactoringContribution} of the given ID.
 * 
 * @return a non-null {@link RefactoringDescriptor}
 * @throws RefactoringException if there was a problem creating the descriptor
 */
public static RefactoringDescriptor createDescriptor(String contributionId)
    throws RefactoringException {
  RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(contributionId);
  if (contribution == null) {
    throw new RefactoringException(
        String.format("The refactoring contribution (%s) is not available.",
            contributionId));
  }

  RefactoringDescriptor refactoringDescriptor = contribution.createDescriptor();
  if (refactoringDescriptor == null) {
    throw new RefactoringException(
        String.format(
            "A descriptor could not be created from the refactoring contribution (%s).",
            contribution.getClass().getSimpleName()));
  }

  return refactoringDescriptor;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:27,代码来源:RefactoringUtilities.java


示例4: getRefactoringDescriptor

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
private IntroduceParameterDescriptor getRefactoringDescriptor() {
	ChangeMethodSignatureDescriptor extended= (ChangeMethodSignatureDescriptor) fChangeSignatureProcessor.createDescriptor();
	RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(IJavaRefactorings.CHANGE_METHOD_SIGNATURE);

	Map<String, String> argumentsMap= contribution.retrieveArgumentMap(extended);

	final Map<String, String> arguments= new HashMap<String, String>();
	arguments.put(ATTRIBUTE_ARGUMENT, fParameter.getNewName());
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$
	arguments.putAll(argumentsMap);
	String signature= fChangeSignatureProcessor.getMethodName();
	try {
		signature= fChangeSignatureProcessor.getOldMethodSignature();
	} catch (JavaModelException exception) {
		JavaPlugin.log(exception);
	}
	final String description= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fChangeSignatureProcessor.getMethod().getElementName()));
	final String header= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fParameter.getNewName()), signature, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression))});
	final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(extended.getProject(), this, header);
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_original_pattern, JavaElementLabels.getTextLabel(fChangeSignatureProcessor.getMethod(),
			JavaElementLabels.ALL_FULLY_QUALIFIED)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_expression_pattern, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression))));
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_parameter_pattern, BasicElementLabels.getJavaElementName(getAddedParameterInfo().getNewName())));
	return RefactoringSignatureDescriptorFactory.createIntroduceParameterDescriptor(extended.getProject(), description, comment.asString(), arguments, extended.getFlags());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:IntroduceParameterRefactoring.java


示例5: renameVariable

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
public static void renameVariable(String task, IJavaElement element, String new_name) {
    RefactoringStatus status = new RefactoringStatus();

    RefactoringContribution contrib = RefactoringCore
            .getRefactoringContribution(IJavaRefactorings.RENAME_LOCAL_VARIABLE);
    RenameJavaElementDescriptor rnDesc = (RenameJavaElementDescriptor) contrib.createDescriptor();
    rnDesc.setFlags(JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING);
    rnDesc.setProject(element.getJavaProject().getProject().getName());
    rnDesc.setUpdateReferences(true);
    rnDesc.setJavaElement(element);
    rnDesc.setNewName(new_name);

    Refactoring ref;
    try {
        ref = rnDesc.createRefactoring(status);
        ref.checkInitialConditions(NULL_MON);
        ref.checkFinalConditions(NULL_MON);

        Change change = ref.createChange(NULL_MON);
        change.perform(NULL_MON);
    } catch (CoreException e) {
        e.printStackTrace();
    }

}
 
开发者ID:Flamefire,项目名称:ImportSmaliVarNames,代码行数:26,代码来源:RefactoringHelper.java


示例6: executionNotification

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
@Override
public void executionNotification(RefactoringExecutionEvent event) {
	refactoringName = getRefactoringID(event);
	int refactoringEventType = event.getEventType();
	RefactoringDescriptor refactoringDescriptor = getRefactoringDescriptorFromEvent(event);
	RefactoringContribution refactoringContribution = RefactoringCore.getRefactoringContribution(refactoringName);
	Map argumentMap = refactoringContribution.retrieveArgumentMap(refactoringDescriptor);
	
	if (refactoringEventType == RefactoringExecutionEvent.ABOUT_TO_PERFORM || refactoringEventType == RefactoringExecutionEvent.ABOUT_TO_REDO) {
		isRefactoringInProgress = true;
		clientRecorder.recordRefactoring(refactoringName, argumentMap);
	}
	
	if (refactoringEventType == RefactoringExecutionEvent.ABOUT_TO_UNDO) {
		isRefactoringInProgress = true;
		clientRecorder.recordRefactoringUndo(refactoringName, argumentMap);
	}
	
	if (refactoringEventType == RefactoringExecutionEvent.PERFORMED || refactoringEventType == RefactoringExecutionEvent.REDONE || refactoringEventType == RefactoringExecutionEvent.UNDONE) {
		isRefactoringInProgress = false;
		clientRecorder.recordRefactoringEnd(refactoringName, argumentMap);
		refactoringName = "";
	}
}
 
开发者ID:ChangeOrientedProgrammingEnvironment,项目名称:eclipseRecorder,代码行数:25,代码来源:RefactoringExecutionListener.java


示例7: getArgumentMap

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
/**
 * Returns the argument map of the specified descriptor.
 *
 * @param descriptor the refactoring descriptor
 * @return the argument map, or <code>null</code>
 */
public static Map getArgumentMap(final RefactoringDescriptor descriptor) {
  Map arguments = null;
  final RefactoringContribution contribution =
      RefactoringContributionManager.getInstance().getRefactoringContribution(descriptor.getID());
  if (contribution != null) arguments = contribution.retrieveArgumentMap(descriptor);
  else if (descriptor instanceof DefaultRefactoringDescriptor)
    arguments = ((DefaultRefactoringDescriptor) descriptor).getArguments();
  return arguments;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:RefactoringHistoryManager.java


示例8: perform

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
@Override
public Change perform(IProgressMonitor pm) throws CoreException {

	RefactoringContribution refactoringContribution = RefactoringCore
			.getRefactoringContribution(IJavaRefactorings.MOVE);
	RefactoringDescriptor desc = refactoringContribution.createDescriptor();
	MoveDescriptor moveDes = (MoveDescriptor) desc;
	moveDes.setComment("Moving " + originalFile);
	moveDes.setDescription("Moving " + originalFile);
	IFolder dest = computeCompilationUnitDestination();
	moveDes.setDestination(JavaCore.create(dest));
	moveDes.setProject(originalFile.getProject().getName());
 
	moveDes.setMoveResources(new IFile[0], new IFolder[0],
			new ICompilationUnit[] { JavaCore.createCompilationUnitFrom(originalFile) });
	moveDes.setUpdateReferences(true);

	RefactoringStatus status = new RefactoringStatus();

	RefactoringContext context = moveDes.createRefactoringContext(status);
	PerformRefactoringOperation op = new PerformRefactoringOperation(context,
			CheckConditionsOperation.ALL_CONDITIONS);
	Job job = new WorkspaceJob("GW4E Moving Job") {
		@Override
		public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
			Display.getDefault().syncExec(() -> {
				try {
					
					op.run(monitor);
				} catch (Exception e) {
					ResourceManager.logException(e);
				}
			});
			return Status.OK_STATUS;
		}
	};
	job.setRule(originalFile.getProject()); // lock so that we serialize the
											// refactoring of the "test
											// interface" AND the "test
											// implementation"
	job.setUser(true);
	job.schedule();

	return op.getUndoChange();
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:46,代码来源:MoveCompilationUnitChange.java


示例9: populateCache

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
/**
 * Populates the refactoring contribution cache if necessary.
 *
 * @since 3.3
 */
private void populateCache() {
  if (fContributionCache == null || fIdCache == null) {
    fContributionCache = new HashMap(32);
    fIdCache = new HashMap(32);
    Map<String, String> contributions = CheRefactoringContributions.getRefactoringContributions();
    contributions.forEach(
        (id, clazz) -> {
          try {
            final Object implementation =
                CheRefactoringContributions.createExecutableExtension(clazz);
            if (implementation instanceof RefactoringContribution) {
              if (fContributionCache.get(id) != null)
                RefactoringCorePlugin.logErrorMessage(
                    Messages.format(
                        RefactoringCoreMessages.RefactoringCorePlugin_duplicate_warning,
                        new String[] {id, clazz}));
              fContributionCache.put(id, implementation);
              fIdCache.put(implementation, id);
            } else
              RefactoringCorePlugin.logErrorMessage(
                  Messages.format(
                      RefactoringCoreMessages.RefactoringCorePlugin_creation_error,
                      new String[] {id, clazz}));
          } catch (CoreException exception) {
            RefactoringCorePlugin.log(exception);
          }
        });
    //			final IConfigurationElement[] elements=
    // Platform.getExtensionRegistry().getConfigurationElementsFor(RefactoringCore.ID_PLUGIN,
    // REFACTORING_CONTRIBUTIONS_EXTENSION_POINT);
    //			for (int index= 0; index < elements.length; index++) {
    //				final IConfigurationElement element= elements[index];
    //				final String attributeId= element.getAttribute(ATTRIBUTE_ID);
    //				final String point= RefactoringCore.ID_PLUGIN + "." +
    // REFACTORING_CONTRIBUTIONS_EXTENSION_POINT; //$NON-NLS-1$
    //				if (attributeId != null && !"".equals(attributeId)) { //$NON-NLS-1$
    //					final String className= element.getAttribute(ATTRIBUTE_CLASS);
    //					if (className != null && !"".equals(className)) { //$NON-NLS-1$
    //						try {
    //							final Object implementation= element.createExecutableExtension(ATTRIBUTE_CLASS);
    //							if (implementation instanceof RefactoringContribution) {
    //								if (fContributionCache.get(attributeId) != null)
    //									RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages
    // .RefactoringCorePlugin_duplicate_warning, new String[] { attributeId, point}));
    //								fContributionCache.put(attributeId, implementation);
    //								fIdCache.put(implementation, attributeId);
    //							} else
    //
    //	RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages.RefactoringCorePlugin_creation_error, new String[] { point, attributeId}));
    //						} catch (CoreException exception) {
    //							RefactoringCorePlugin.log(exception);
    //						}
    //					} else
    //
    //	RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages.RefactoringCorePlugin_missing_class_attribute, new String[] { point, attributeId, ATTRIBUTE_CLASS}));
    //				} else
    //
    //	RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages.RefactoringCorePlugin_missing_attribute, new String[] { point, ATTRIBUTE_ID}));
    //			}
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:67,代码来源:RefactoringContributionManager.java


示例10: createRefactoringContext

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected RefactoringContext createRefactoringContext(RefactoringDescriptor descriptor, RefactoringStatus status, IProgressMonitor monitor) throws CoreException {
	Assert.isNotNull(descriptor);

	createNecessarySourceCode(monitor);

	if (descriptor instanceof JavaRefactoringDescriptor) {
		JavaRefactoringDescriptor javaDescriptor= (JavaRefactoringDescriptor) descriptor;
		RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID());

		Map<String, String> map= contribution.retrieveArgumentMap(descriptor);
		if (fJavaProject == null) {
			status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
			return null;
		}

		String name= fJavaProject.getElementName();

		String handle= map.get(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
		if (handle != null && handle.length() > 0)
			map.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, getTransformedHandle(name, handle));

		int count= 1;
		String attribute= JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count;
		while ((handle= map.get(attribute)) != null) {
			if (handle.length() > 0)
				map.put(attribute, getTransformedHandle(name, handle));
			count++;
			attribute= JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count;
		}

		// create adapted descriptor
		try {
			descriptor= contribution.createDescriptor(descriptor.getID(), name, descriptor.getDescription(), descriptor.getComment(), map, descriptor.getFlags());
		} catch (IllegalArgumentException e) {
			status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
			return null;
		}
	}
	return descriptor.createRefactoringContext(status);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:45,代码来源:BinaryRefactoringHistoryWizard.java


示例11: getRefactoringContribution

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
/**
 * Returns the refactoring contribution for the refactoring with the specified id.
 *
 * @param id the unique id of the refactoring
 * @return the refactoring contribution, or <code>null</code> if no refactoring contribution has
 *     been registered with the specified id
 */
public RefactoringContribution getRefactoringContribution(final String id) {
  Assert.isNotNull(id);
  Assert.isTrue(!"".equals(id)); // $NON-NLS-1$
  populateCache();
  return (RefactoringContribution) fContributionCache.get(id);
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:RefactoringContributionManager.java


示例12: getRefactoringId

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入依赖的package包/类
/**
 * Returns the refactoring id for the specified refactoring contribution.
 *
 * @param contribution the refactoring contribution
 * @return the corresonding refactoring id
 * @since 3.3
 */
public String getRefactoringId(final RefactoringContribution contribution) {
  Assert.isNotNull(contribution);
  populateCache();
  return (String) fIdCache.get(contribution);
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:RefactoringContributionManager.java



注:本文中的org.eclipse.ltk.core.refactoring.RefactoringContribution类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GeneralItemAnimator类代码示例发布时间:2022-05-21
下一篇:
Java TIntObjectHashMap类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap