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

Java IJavaRefactorings类代码示例

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

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



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

示例1: test10

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
@Test
public void test10() throws Exception {
  //		printTestDisabledMessage("bug 40628");
  //		if (true)	return;
  ICompilationUnit cuA = createCUfromTestFile(getPackageP(), "A");
  ICompilationUnit cuB = createCUfromTestFile(getPackageP(), "B");

  IType classB = getType(cuB, "B");
  IMethod method = classB.getMethod("method", new String[0]);
  RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_METHOD);
  descriptor.setUpdateReferences(true);
  descriptor.setJavaElement(method);
  descriptor.setNewName("newmethod");

  assertEquals("was supposed to pass", null, performRefactoring(descriptor));
  assertEqualLines(
      "invalid renaming in A", getFileContents(getOutputTestFileName("A")), cuA.getSource());
  assertEqualLines(
      "invalid renaming in B", getFileContents(getOutputTestFileName("B")), cuB.getSource());
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:RenameStaticMethodTest.java


示例2: test11

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
@Test
public void test11() throws Exception {
  //		printTestDisabledMessage("bug 40452");
  //		if (true)	return;
  IPackageFragment packageA =
      getRoot().createPackageFragment("a", false, new NullProgressMonitor());
  IPackageFragment packageB =
      getRoot().createPackageFragment("b", false, new NullProgressMonitor());
  ICompilationUnit cuA = createCUfromTestFile(packageA, "A");
  ICompilationUnit cuB = createCUfromTestFile(packageB, "B");

  IType classA = getType(cuA, "A");
  IMethod method = classA.getMethod("method2", new String[0]);
  RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_METHOD);
  descriptor.setUpdateReferences(true);
  descriptor.setJavaElement(method);
  descriptor.setNewName("fred");

  assertEquals("was supposed to pass", null, performRefactoring(descriptor));
  assertEqualLines(
      "invalid renaming in A", getFileContents(getOutputTestFileName("A")), cuA.getSource());
  assertEqualLines(
      "invalid renaming in B", getFileContents(getOutputTestFileName("B")), cuB.getSource());
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:RenameStaticMethodTest.java


示例3: helper1_0

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
private void helper1_0(
    String fieldName,
    String newFieldName,
    String typeName,
    boolean renameGetter,
    boolean renameSetter)
    throws Exception {
  IType declaringType = getType(createCUfromTestFile(getPackageP(), "A"), typeName);
  IField field = declaringType.getField(fieldName);
  RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_FIELD);
  descriptor.setJavaElement(field);
  descriptor.setNewName(newFieldName);
  descriptor.setUpdateReferences(true);
  descriptor.setRenameGetters(renameGetter);
  descriptor.setRenameSetters(renameSetter);
  RefactoringStatus result = performRefactoring(descriptor);
  assertNotNull("precondition was supposed to fail", result);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RenamePrivateFieldTest.java


示例4: test18

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
@Test
public void test18() throws Exception {
  ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
  ICompilationUnit cuC = createCUfromTestFile(getPackageP(), "C");

  IType classB = getType(cu, "B");
  IMethod method = classB.getMethod("m", new String[] {"I"});

  final RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_METHOD);
  descriptor.setJavaElement(method);
  descriptor.setNewName("kk");
  descriptor.setUpdateReferences(true);
  final RefactoringStatus status = new RefactoringStatus();
  final Refactoring refactoring = descriptor.createRefactoring(status);
  assertNotNull("Refactoring should not be null", refactoring);
  assertTrue("status should be ok", status.isOK());

  assertEquals("was supposed to pass", null, performRefactoring(refactoring));
  assertEqualLines(
      "invalid renaming A", getFileContents(getOutputTestFileName("A")), cu.getSource());
  assertEqualLines(
      "invalid renaming C", getFileContents(getOutputTestFileName("C")), cuC.getSource());
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:RenameVirtualMethodInClassTest.java


示例5: test40

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
@Test
public void test40() throws Exception { // test for bug 68592
  ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
  IType localClass = cu.getType("A").getMethod("doit", new String[0]).getType("LocalClass", 1);
  IMethod method = localClass.getMethod("method", new String[] {"I"});

  final RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_METHOD);
  descriptor.setJavaElement(method);
  descriptor.setNewName("method2");
  descriptor.setUpdateReferences(true);
  final RefactoringStatus status = new RefactoringStatus();
  final Refactoring refactoring = descriptor.createRefactoring(status);
  assertNotNull("Refactoring should not be null", refactoring);
  assertTrue("status should be ok", status.isOK());

  assertEquals("was supposed to pass", null, performRefactoring(refactoring));
  assertEqualLines(
      "invalid renaming A", getFileContents(getOutputTestFileName("A")), cu.getSource());
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:RenameVirtualMethodInClassTest.java


示例6: IntroduceParameterObjectDescriptor

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
/**
 * Creates a new refactoring descriptor.
 *
 * @param project the non-empty name of the project associated with this refactoring, or <code>
 *     null</code> for a workspace refactoring
 * @param description a non-empty human-readable description of the particular refactoring
 *     instance
 * @param comment the human-readable comment of the particular refactoring instance, or <code>null
 *     </code> for no comment
 * @param arguments a map of arguments that will be persisted and describes all settings for this
 *     refactoring
 * @param flags the flags of the refactoring descriptor
 * @throws IllegalArgumentException if the argument map contains invalid keys/values
 */
public IntroduceParameterObjectDescriptor(
    final String project,
    final String description,
    final String comment,
    final Map arguments,
    final int flags)
    throws IllegalArgumentException {
  super(
      IJavaRefactorings.INTRODUCE_PARAMETER_OBJECT,
      project,
      description,
      comment,
      arguments,
      flags);
  initializeFromMap(arguments);
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:IntroduceParameterObjectDescriptor.java


示例7: checkId

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
/**
 * Checks whether the refactoring id is valid.
 *
 * @param id the refactoring id
 * @return the outcome of the validation
 */
private boolean checkId(final String id) {
  Assert.isNotNull(id);
  if (id.equals(IJavaRefactorings.RENAME_COMPILATION_UNIT)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_ENUM_CONSTANT)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_FIELD)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_JAVA_PROJECT)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_LOCAL_VARIABLE)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_METHOD)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_PACKAGE)) return true;
  else if (id.equals(RENAME_RESOURCE)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_SOURCE_FOLDER)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_TYPE)) return true;
  else if (id.equals(IJavaRefactorings.RENAME_TYPE_PARAMETER)) return true;
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:RenameJavaElementDescriptor.java


示例8: ExtractClassDescriptor

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
/**
 * Creates a new refactoring descriptor.
 *
 * @param project the non-empty name of the project associated with this refactoring, or <code>
 *     null</code> for a workspace refactoring
 * @param description a non-empty human-readable description of the particular refactoring
 *     instance
 * @param comment the human-readable comment of the particular refactoring instance, or <code>null
 *     </code> for no comment
 * @param arguments a map of arguments that will be persisted and describes all settings for this
 *     refactoring
 * @param flags the flags of the refactoring descriptor
 * @throws IllegalArgumentException if the argument map contains invalid keys/values
 */
public ExtractClassDescriptor(
    String project, String description, String comment, Map arguments, int flags)
    throws IllegalArgumentException {
  super(IJavaRefactorings.EXTRACT_CLASS, project, description, comment, arguments, flags);
  if (JavaRefactoringDescriptorUtil.getString(arguments, OLD_FIELD_COUNT, true) != null) {
    String[] oldFieldNames =
        JavaRefactoringDescriptorUtil.getStringArray(
            arguments, OLD_FIELD_COUNT, OLD_FIELD_NAME, 0);
    boolean[] createField =
        JavaRefactoringDescriptorUtil.getBooleanArray(
            arguments, CREATE_FIELD_COUNT, CREATE_FIELD, 0);
    fFields = new Field[oldFieldNames.length];
    for (int i = 0; i < oldFieldNames.length; i++) {
      fFields[i] = new Field(oldFieldNames[i]);
      fFields[i].setCreateField(createField[i]);
      if (createField[i])
        fFields[i].setNewFieldName(
            JavaRefactoringDescriptorUtil.getString(
                arguments, JavaRefactoringDescriptorUtil.getAttributeName(NEW_FIELD_NAME, i)));
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:ExtractClassDescriptor.java


示例9: helper1_0

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
private void helper1_0(String methodName, String newMethodName, String[] signatures)
    throws Exception {
  IType classA = getType(createCUfromTestFile(getPackageP(), "A"), "A");
  IMethod method = classA.getMethod(methodName, signatures);
  RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_METHOD);
  descriptor.setJavaElement(method);
  descriptor.setNewName(newMethodName);
  descriptor.setUpdateReferences(true);
  RefactoringStatus result = performRefactoring(descriptor);
  assertNotNull("precondition was supposed to fail", result);
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:RenameStaticMethodTest.java


示例10: helper2_0

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
private void helper2_0(
    String methodName,
    String newMethodName,
    String[] signatures,
    boolean updateReferences,
    boolean createDelegate)
    throws Exception {
  ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
  IType classA = getType(cu, "A");
  IMethod method = classA.getMethod(methodName, signatures);
  RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_METHOD);
  descriptor.setUpdateReferences(updateReferences);
  descriptor.setJavaElement(method);
  descriptor.setNewName(newMethodName);
  descriptor.setKeepOriginal(createDelegate);
  descriptor.setDeprecateDelegate(true);

  assertEquals("was supposed to pass", null, performRefactoring(descriptor));
  assertEqualLines(
      "invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());

  assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
  assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo());
  // assertEquals("1 to undo", 1, Refactoring.getUndoManager().getRefactoringLog().size());

  RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
  assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());

  assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo());
  assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
  // assertEquals("1 to redo", 1, Refactoring.getUndoManager().getRedoStack().size());

  RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
  assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource());
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:RenameStaticMethodTest.java


示例11: MethodRenameChangeBuilder

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
public MethodRenameChangeBuilder(IMethod method, String newName,
    RenameVirtualMethodProcessor processor, IWorkspace workspace) {
  super(RenameJavaElementDescriptor.class, IJavaRefactorings.RENAME_METHOD,
      workspace);

  this.newName = newName;
  this.processor = processor;
  this.method = method;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:10,代码来源:PairedMethodRenameParticipant.java


示例12: testPackageRenameWithResource1

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
@Test
public void testPackageRenameWithResource1() throws Exception {
  IPackageFragment fragment = getRoot().createPackageFragment("org.test", true, null);

  StringBuffer buf = new StringBuffer();
  buf.append("package org.test;\n");
  buf.append("public class MyClass {\n");
  buf.append("	org.test.MyClass me;\n");
  buf.append("}\n");
  fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);

  IFile file = ((IFolder) getRoot().getResource()).getFile("x.properties");
  byte[] content = "This is about 'org.test' and more".getBytes();
  file.create(new ByteArrayInputStream(content), true, null);
  file.refreshLocal(IResource.DEPTH_ONE, null);

  RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_PACKAGE);
  descriptor.setJavaElement(fragment);
  descriptor.setNewName("org.test2");
  descriptor.setUpdateReferences(true);
  descriptor.setUpdateQualifiedNames(true);
  descriptor.setFileNamePatterns("*.properties");
  Refactoring refactoring = createRefactoring(descriptor);
  RefactoringStatus status = performRefactoring(refactoring);
  if (status != null) assertTrue(status.toString(), status.isOK());

  RefactoringProcessor processor = ((RenameRefactoring) refactoring).getProcessor();
  IResourceMapper rm = (IResourceMapper) processor.getAdapter(IResourceMapper.class);
  IJavaElementMapper jm = (IJavaElementMapper) processor.getAdapter(IJavaElementMapper.class);
  checkMappingUnchanged(jm, rm, new Object[] {getRoot().getJavaProject(), getRoot(), file});
  IFile newFile = ((IContainer) getRoot().getResource()).getFile(new Path("x.properties"));
  assertEquals("This is about 'org.test2' and more", getContents(newFile));
  checkMappingChanged(
      jm, rm, new Object[][] {{fragment, getRoot().getPackageFragment("org.test2")}});
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:RenamePackageTest.java


示例13: testPackageRenameWithResource2

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
@Test
public void testPackageRenameWithResource2() throws Exception {
  IPackageFragment fragment = getRoot().createPackageFragment("org.test", true, null);

  StringBuffer buf = new StringBuffer();
  buf.append("package org.test;\n");
  buf.append("public class MyClass {\n");
  buf.append("}\n");
  fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);

  IFile file = ((IFolder) fragment.getResource()).getFile("x.properties");
  byte[] content = "This is about 'org.test' and more".getBytes();
  file.create(new ByteArrayInputStream(content), true, null);
  file.refreshLocal(IResource.DEPTH_ONE, null);

  RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_PACKAGE);
  descriptor.setJavaElement(fragment);
  descriptor.setNewName("org.test2");
  descriptor.setUpdateReferences(true);
  descriptor.setUpdateHierarchy(true);
  descriptor.setUpdateQualifiedNames(true);
  descriptor.setFileNamePatterns("*.properties");
  Refactoring refactoring = createRefactoring(descriptor);
  RefactoringStatus status = performRefactoring(refactoring);
  if (status != null) assertTrue(status.toString(), status.isOK());

  RefactoringProcessor processor = ((RenameRefactoring) refactoring).getProcessor();
  IResourceMapper rm = (IResourceMapper) processor.getAdapter(IResourceMapper.class);
  IJavaElementMapper jm = (IJavaElementMapper) processor.getAdapter(IJavaElementMapper.class);
  checkMappingUnchanged(jm, rm, new Object[] {getRoot().getJavaProject(), getRoot()});
  IPackageFragment newFragment = getRoot().getPackageFragment("org.test2");
  IFile newFile = ((IContainer) newFragment.getResource()).getFile(new Path("x.properties"));
  assertEquals("This is about 'org.test2' and more", getContents(newFile));
  checkMappingChanged(jm, rm, new Object[][] {{file, newFile}});
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:RenamePackageTest.java


示例14: helper1_0

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
private void helper1_0(String fieldName, String newFieldName) throws Exception {
  IType classA = getType(createCUfromTestFile(getPackageP(), "A"), "A");
  IField field = classA.getField(fieldName);
  RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_FIELD);
  descriptor.setJavaElement(field);
  descriptor.setUpdateReferences(true);
  descriptor.setNewName(newFieldName);
  RefactoringStatus result = performRefactoring(descriptor);
  assertNotNull("precondition was supposed to fail", result);
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:RenameNonPrivateFieldTest.java


示例15: initialize

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
private RefactoringStatus initialize(JavaRefactoringArguments arguments) {
  final String clone = arguments.getAttribute(ATTRIBUTE_CLONE);
  if (clone != null) {
    fAssumeCloneReturnsSameType = Boolean.valueOf(clone).booleanValue();
  } else
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            ATTRIBUTE_CLONE));
  final String leave = arguments.getAttribute(ATTRIBUTE_LEAVE);
  if (leave != null) {
    fLeaveUnconstrainedRaw = Boolean.valueOf(leave).booleanValue();
  } else
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            ATTRIBUTE_LEAVE));
  int count = 1;
  final List<IJavaElement> elements = new ArrayList<IJavaElement>();
  String handle = null;
  String attribute = JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count;
  final RefactoringStatus status = new RefactoringStatus();
  while ((handle = arguments.getAttribute(attribute)) != null) {
    final IJavaElement element =
        JavaRefactoringDescriptorUtil.handleToElement(arguments.getProject(), handle, false);
    if (element == null || !element.exists())
      return JavaRefactoringDescriptorUtil.createInputFatalStatus(
          element, getName(), IJavaRefactorings.INFER_TYPE_ARGUMENTS);
    else elements.add(element);
    count++;
    attribute = JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count;
  }
  fElements = elements.toArray(new IJavaElement[elements.size()]);
  if (elements.isEmpty())
    return JavaRefactoringDescriptorUtil.createInputFatalStatus(
        null, getName(), IJavaRefactorings.INFER_TYPE_ARGUMENTS);
  if (!status.isOK()) return status;
  return new RefactoringStatus();
}
 
开发者ID:eclipse,项目名称:che,代码行数:40,代码来源:InferTypeArgumentsRefactoring.java


示例16: createRefactoringDescriptor

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
private RenameJavaElementDescriptor createRefactoringDescriptor() {
  String project = null;
  IJavaProject javaProject = fCu.getJavaProject();
  if (javaProject != null) project = javaProject.getElementName();
  final String header =
      Messages.format(
          RefactoringCoreMessages.RenameLocalVariableProcessor_descriptor_description,
          new String[] {
            BasicElementLabels.getJavaElementName(fCurrentName),
            JavaElementLabels.getElementLabel(
                fLocalVariable.getParent(), JavaElementLabels.ALL_FULLY_QUALIFIED),
            BasicElementLabels.getJavaElementName(fNewName)
          });
  final String description =
      Messages.format(
          RefactoringCoreMessages.RenameLocalVariableProcessor_descriptor_description_short,
          BasicElementLabels.getJavaElementName(fCurrentName));
  final String comment = new JDTRefactoringDescriptorComment(project, this, header).asString();
  final RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_LOCAL_VARIABLE);
  descriptor.setProject(project);
  descriptor.setDescription(description);
  descriptor.setComment(comment);
  descriptor.setFlags(RefactoringDescriptor.NONE);
  descriptor.setJavaElement(fLocalVariable);
  descriptor.setNewName(getNewElementName());
  descriptor.setUpdateReferences(fUpdateReferences);
  return descriptor;
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:RenameLocalVariableProcessor.java


示例17: initialize

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
private RefactoringStatus initialize(JavaRefactoringArguments extended) {
  final String handle = extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
  if (handle == null) {
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT));
  }

  final IJavaElement element =
      JavaRefactoringDescriptorUtil.handleToElement(extended.getProject(), handle, false);
  if (element == null
      || !element.exists()
      || element.getElementType() != IJavaElement.COMPILATION_UNIT)
    return JavaRefactoringDescriptorUtil.createInputFatalStatus(
        element, getProcessorName(), IJavaRefactorings.RENAME_COMPILATION_UNIT);

  final String name = extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME);
  if (name == null || name.length() == 0)
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));

  fCu = (ICompilationUnit) element;
  try {
    computeRenameTypeRefactoring();
    setNewElementName(name);
  } catch (CoreException exception) {
    JavaPlugin.log(exception);
    return JavaRefactoringDescriptorUtil.createInputFatalStatus(
        element, getProcessorName(), IJavaRefactorings.RENAME_COMPILATION_UNIT);
  }
  return new RefactoringStatus();
}
 
开发者ID:eclipse,项目名称:che,代码行数:36,代码来源:RenameCompilationUnitProcessor.java


示例18: createRefactoringDescriptor

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
private RenameJavaElementDescriptor createRefactoringDescriptor() {
  String project = null;
  IJavaProject javaProject = fPackage.getJavaProject();
  if (javaProject != null) project = javaProject.getElementName();
  final int flags =
      JavaRefactoringDescriptor.JAR_MIGRATION
          | JavaRefactoringDescriptor.JAR_REFACTORING
          | RefactoringDescriptor.STRUCTURAL_CHANGE
          | RefactoringDescriptor.MULTI_CHANGE;
  final String description =
      Messages.format(
          RefactoringCoreMessages.RenamePackageProcessor_descriptor_description_short,
          getElementLabel(fPackage));
  final String header =
      Messages.format(
          RefactoringCoreMessages.RenamePackageProcessor_descriptor_description,
          new String[] {getElementLabel(fPackage), getNewElementName()});
  final JDTRefactoringDescriptorComment comment =
      new JDTRefactoringDescriptorComment(project, this, header);
  if (fRenameSubpackages)
    comment.addSetting(RefactoringCoreMessages.RenamePackageProcessor_rename_subpackages);
  final RenameJavaElementDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
          IJavaRefactorings.RENAME_PACKAGE);
  descriptor.setProject(project);
  descriptor.setDescription(description);
  descriptor.setComment(comment.asString());
  descriptor.setFlags(flags);
  descriptor.setJavaElement(fPackage);
  descriptor.setNewName(getNewElementName());
  descriptor.setUpdateReferences(fUpdateReferences);
  descriptor.setUpdateTextualOccurrences(fUpdateTextualMatches);
  descriptor.setUpdateQualifiedNames(fUpdateQualifiedNames);
  if (fUpdateQualifiedNames && fFilePatterns != null && !"".equals(fFilePatterns)) // $NON-NLS-1$
  descriptor.setFileNamePatterns(fFilePatterns);
  descriptor.setUpdateHierarchy(fRenameSubpackages);
  return descriptor;
}
 
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:RenamePackageProcessor.java


示例19: perform

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的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


示例20: ExtractSuperclassDescriptor

import org.eclipse.jdt.core.refactoring.IJavaRefactorings; //导入依赖的package包/类
/** Creates a new refactoring descriptor. */
public ExtractSuperclassDescriptor() {
  super(IJavaRefactorings.EXTRACT_SUPERCLASS);
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:ExtractSuperclassDescriptor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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