当前位置: 首页>>代码示例>>Java>>正文


Java InlineMethodDescriptor类代码示例

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


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

示例1: createInlineMethodDescriptor

import org.eclipse.jdt.core.refactoring.descriptors.InlineMethodDescriptor; //导入依赖的package包/类
public static InlineMethodDescriptor createInlineMethodDescriptor() {
  return new InlineMethodDescriptor();
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:RefactoringSignatureDescriptorFactory.java

示例2: createRefactoring

import org.eclipse.jdt.core.refactoring.descriptors.InlineMethodDescriptor; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
	int selectionStart= -1;
	int selectionLength= -1;
	ICompilationUnit unit= null;
	CompilationUnit node= null;
	if (descriptor instanceof InlineMethodDescriptor) {
		InlineMethodDescriptor extended= (InlineMethodDescriptor) descriptor;
		Map<String, String> arguments= retrieveArgumentMap(extended);
		final String selection= arguments.get(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION);
		if (selection != null) {
			int offset= -1;
			int length= -1;
			final StringTokenizer tokenizer= new StringTokenizer(selection);
			if (tokenizer.hasMoreTokens())
				offset= Integer.valueOf(tokenizer.nextToken()).intValue();
			if (tokenizer.hasMoreTokens())
				length= Integer.valueOf(tokenizer.nextToken()).intValue();
			if (offset >= 0 && length >= 0) {
				selectionStart= offset;
				selectionLength= length;
			} else
				throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(RefactoringCoreMessages.InitializableRefactoring_illegal_argument, new Object[] { selection, JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION}), null));
		}
		final String handle= arguments.get(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
		if (handle != null) {
			final IJavaElement element= JavaRefactoringDescriptorUtil.handleToElement(descriptor.getProject(), handle, false);
			if (element == null || !element.exists())
				throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(RefactoringCoreMessages.InitializableRefactoring_inputs_do_not_exist, new String[] { RefactoringCoreMessages.InlineMethodRefactoring_name, IJavaRefactorings.INLINE_METHOD}), null));
			else {
				if (element instanceof ICompilationUnit) {
					unit= (ICompilationUnit) element;
					if (selection == null)
						throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION), null));
				} else if (element instanceof IMethod) {
					final IMethod method= (IMethod) element;
					try {
						final ISourceRange range= method.getNameRange();
						if (range != null) {
							selectionStart= range.getOffset();
							selectionLength= range.getLength();
						} else
							throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(RefactoringCoreMessages.InitializableRefactoring_illegal_argument, new Object[] { handle, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT}), null));
					} catch (JavaModelException exception) {
						throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(RefactoringCoreMessages.InitializableRefactoring_inputs_do_not_exist, new String[] { RefactoringCoreMessages.InlineMethodRefactoring_name, IJavaRefactorings.INLINE_METHOD}), exception));
					}
					unit= method.getCompilationUnit();
				} else
					throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(RefactoringCoreMessages.InitializableRefactoring_illegal_argument, new Object[] { handle, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT}), null));
				final ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
				parser.setResolveBindings(true);
				parser.setSource(unit);
				node= (CompilationUnit) parser.createAST(null);
			}
		} else
			throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT), null));
	} else
		throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments, null));
	return InlineMethodRefactoring.create(unit, node, selectionStart, selectionLength);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:64,代码来源:InlineMethodRefactoringContribution.java


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