當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。