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


Java CompilationUnitChange.setSaveMode方法代码示例

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


在下文中一共展示了CompilationUnitChange.setSaveMode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cloneCompilationUnitChangeWithDifferentCu

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
/**
 * Destructively clones a {@link CompilationUnitChange} where the cloned
 * change will have a different compilation unit. This does not update text
 * regions or anything more than setting the change properties and moving text
 * edits from the old to new change.
 * 
 * @param originalChange the original change, this change's internal state
 *          will likely become invalid (its text edits will be moved to the
 *          new change)
 * @param cu the compilation unit to be used for the new
 *          {@link CompilationUnitChange}
 * @return the cloned {@link CompilationUnitChange}
 */
public static CompilationUnitChange cloneCompilationUnitChangeWithDifferentCu(
    TextFileChange originalChange, ICompilationUnit cu) {
  CompilationUnitChange newChange = new CompilationUnitChange(
      originalChange.getName(), cu);

  newChange.setEdit(originalChange.getEdit());
  newChange.setEnabledShallow(originalChange.isEnabled());
  newChange.setKeepPreviewEdits(originalChange.getKeepPreviewEdits());
  newChange.setSaveMode(originalChange.getSaveMode());
  newChange.setTextType(originalChange.getTextType());

  // Copy the changes over
  TextEditUtilities.moveTextEditGroupsIntoChange(
      originalChange.getChangeGroups(), newChange);

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

示例2: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
	final String NN = ""; //$NON-NLS-1$
	if (pm == null) {
		pm = new NullProgressMonitor();
	}
	pm.beginTask(NN, 2);
	try {
		final CompilationUnitChange result = new CompilationUnitChange(getName(), fCUnit);
		if (fLeaveDirty) {
			result.setSaveMode(TextFileChange.LEAVE_DIRTY);
		}
		MultiTextEdit root = new MultiTextEdit();
		result.setEdit(root);
		fRewriter = ASTRewrite.create(fAnalyzer.getEnclosingBodyDeclaration().getAST());
		fRewriter.setTargetSourceRangeComputer(new SelectionAwareSourceRangeComputer(fAnalyzer.getSelectedNodes(), fCUnit.getBuffer(), fSelection.getOffset(), fSelection.getLength()));
		fImportRewrite = StubUtility.createImportRewrite(fRootNode, true);

		fLinkedProposalModel = new LinkedProposalModel();

		fScope = CodeScopeBuilder.perform(fAnalyzer.getEnclosingBodyDeclaration(), fSelection).findScope(fSelection.getOffset(), fSelection.getLength());
		fScope.setCursor(fSelection.getOffset());

		fSelectedNodes = fAnalyzer.getSelectedNodes();

		createTryCatchStatement(fCUnit.getBuffer(), fCUnit.findRecommendedLineSeparator());

		if (fImportRewrite.hasRecordedChanges()) {
			TextEdit edit = fImportRewrite.rewriteImports(null);
			root.addChild(edit);
			result.addTextEditGroup(new TextEditGroup(NN, new TextEdit[] { edit }));
		}
		TextEdit change = fRewriter.rewriteAST();
		root.addChild(change);
		result.addTextEditGroup(new TextEditGroup(NN, new TextEdit[] { change }));
		return result;
	} finally {
		pm.done();
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:41,代码来源:SurroundWithTryCatchRefactoring.java

示例3: createTextChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
protected TextChange createTextChange() throws CoreException {
	CompilationUnitChange createChange = fFix.createChange(null);
	createChange.setSaveMode(TextFileChange.LEAVE_DIRTY);

	//			if (fFix instanceof ILinkedFix) {
	//				setLinkedProposalModel(((ILinkedFix) fFix).getLinkedPositions());
	//			}

	return createChange;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:FixCorrectionProposal.java

示例4: createCompilationUnitChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
protected static CompilationUnitChange createCompilationUnitChange(
    CompilationUnitRewrite rewrite) throws CoreException {
  CompilationUnitChange change = rewrite.createChange(true);
  if (change != null) change.setSaveMode(TextFileChange.KEEP_SAVE_STATE);

  return change;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:ReorgPolicyFactory.java

示例5: createTextChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
protected TextChange createTextChange() throws CoreException {
  CompilationUnitChange createChange = fFix.createChange(null);
  createChange.setSaveMode(TextFileChange.LEAVE_DIRTY);

  //		if (fFix instanceof ILinkedFix) {
  //			setLinkedProposalModel(((ILinkedFix)fFix).getLinkedPositions());
  //		}

  return createChange;
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:FixCorrectionProposal.java

示例6: run

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
public void run(IProgressMonitor monitor) throws CoreException {
  ICompilationUnit icu = clientBundle.getCompilationUnit();
  CompilationUnit cu = JavaASTUtils.parseCompilationUnit(icu);
  ImportRewrite importRewrite = StubUtility.createImportRewrite(cu, true);

  // Find the target type declaration
  TypeDeclaration typeDecl = JavaASTUtils.findTypeDeclaration(cu,
      clientBundle.getFullyQualifiedName());
  if (typeDecl == null) {
    throw new CoreException(
        StatusUtilities.newErrorStatus("Missing ClientBundle type "
            + clientBundle.getFullyQualifiedName(), GWTPlugin.PLUGIN_ID));
  }

  // We need to rewrite the AST of the ClientBundle type declaration
  ASTRewrite astRewrite = ASTRewrite.create(cu.getAST());
  ChildListPropertyDescriptor property = ASTNodes.getBodyDeclarationsProperty(typeDecl);
  ListRewrite listRewriter = astRewrite.getListRewrite(typeDecl, property);

  // Add the new resource methods
  boolean addComments = StubUtility.doAddComments(icu.getJavaProject());
  for (ClientBundleResource resource : resources) {
    listRewriter.insertLast(resource.createMethodDeclaration(clientBundle,
        astRewrite, importRewrite, addComments), null);
  }

  // Create the edit to add the methods and update the imports
  TextEdit rootEdit = new MultiTextEdit();
  rootEdit.addChild(astRewrite.rewriteAST());
  rootEdit.addChild(importRewrite.rewriteImports(null));

  // Apply the change to the compilation unit
  CompilationUnitChange cuChange = new CompilationUnitChange(
      "Update ClientBundle", icu);
  cuChange.setSaveMode(TextFileChange.KEEP_SAVE_STATE);
  cuChange.setEdit(rootEdit);
  cuChange.perform(new NullProgressMonitor());
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:39,代码来源:AddResourcesToClientBundleAction.java

示例7: createCompilationUnitChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
protected static CompilationUnitChange createCompilationUnitChange(CompilationUnitRewrite rewrite) throws CoreException {
	CompilationUnitChange change= rewrite.createChange(true);
	if (change != null)
		change.setSaveMode(TextFileChange.KEEP_SAVE_STATE);

	return change;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:ReorgPolicyFactory.java

示例8: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
	final String NN= ""; //$NON-NLS-1$
	if (pm == null) pm= new NullProgressMonitor();
	pm.beginTask(NN, 2);
	try {
		final CompilationUnitChange result= new CompilationUnitChange(getName(), fCUnit);
		if (fLeaveDirty)
			result.setSaveMode(TextFileChange.LEAVE_DIRTY);
		MultiTextEdit root= new MultiTextEdit();
		result.setEdit(root);
		fRewriter= ASTRewrite.create(fAnalyzer.getEnclosingBodyDeclaration().getAST());
		fRewriter.setTargetSourceRangeComputer(new SelectionAwareSourceRangeComputer(
			fAnalyzer.getSelectedNodes(), fCUnit.getBuffer(), fSelection.getOffset(), fSelection.getLength()));
		fImportRewrite= StubUtility.createImportRewrite(fRootNode, true);

		fLinkedProposalModel= new LinkedProposalModel();

		fScope= CodeScopeBuilder.perform(fAnalyzer.getEnclosingBodyDeclaration(), fSelection).
			findScope(fSelection.getOffset(), fSelection.getLength());
		fScope.setCursor(fSelection.getOffset());

		fSelectedNodes= fAnalyzer.getSelectedNodes();

		createTryCatchStatement(fCUnit.getBuffer(), fCUnit.findRecommendedLineSeparator());

		if (fImportRewrite.hasRecordedChanges()) {
			TextEdit edit= fImportRewrite.rewriteImports(null);
			root.addChild(edit);
			result.addTextEditGroup(new TextEditGroup(NN, new TextEdit[] {edit} ));
		}
		TextEdit change= fRewriter.rewriteAST();
		root.addChild(change);
		result.addTextEditGroup(new TextEditGroup(NN, new TextEdit[] {change} ));
		return result;
	} finally {
		pm.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:40,代码来源:SurroundWithTryCatchRefactoring.java

示例9: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
	ASTParser p= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
	p.setSource(getDestinationCu());
	CompilationUnit cuNode= (CompilationUnit) p.createAST(pm);
	ASTRewrite rewrite= ASTRewrite.create(cuNode.getAST());
	TypedSource source= null;
	for (int i= fSources.length - 1; i >= 0; i--) {
		source= fSources[i];
		final ASTNode destination= getDestinationNodeForSourceElement(fDestination, source.getType(), cuNode);
		if (destination != null) {
			if (destination instanceof CompilationUnit)
				insertToCu(rewrite, createNewNodeToInsertToCu(source, rewrite), (CompilationUnit) destination);
			else if (destination instanceof AbstractTypeDeclaration)
				insertToType(rewrite, createNewNodeToInsertToType(source, rewrite), (AbstractTypeDeclaration) destination);
		}
	}
	final CompilationUnitChange result= new CompilationUnitChange(ReorgMessages.PasteAction_change_name, getDestinationCu());
	try {
		ITextFileBuffer buffer= RefactoringFileBuffers.acquire(getDestinationCu());
		TextEdit rootEdit= rewrite.rewriteAST(buffer.getDocument(), fDestination.getJavaProject().getOptions(true));
		if (getDestinationCu().isWorkingCopy())
			result.setSaveMode(TextFileChange.LEAVE_DIRTY);
		TextChangeCompatibility.addTextEdit(result, ReorgMessages.PasteAction_edit_name, rootEdit);
	} finally {
		RefactoringFileBuffers.release(getDestinationCu());
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:PasteAction.java

示例10: createTextChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
protected TextChange createTextChange() throws CoreException {
	CompilationUnitChange createChange= fFix.createChange(null);
	createChange.setSaveMode(TextFileChange.LEAVE_DIRTY);

	if (fFix instanceof ILinkedFix) {
		setLinkedProposalModel(((ILinkedFix) fFix).getLinkedPositions());
	}

	return createChange;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:FixCorrectionProposal.java

示例11: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
  final String NN = ""; // $NON-NLS-1$
  if (pm == null) pm = new NullProgressMonitor();
  pm.beginTask(NN, 2);
  try {
    final CompilationUnitChange result = new CompilationUnitChange(getName(), fCUnit);
    if (fLeaveDirty) result.setSaveMode(TextFileChange.LEAVE_DIRTY);
    MultiTextEdit root = new MultiTextEdit();
    result.setEdit(root);
    fRewriter = ASTRewrite.create(fAnalyzer.getEnclosingBodyDeclaration().getAST());
    fRewriter.setTargetSourceRangeComputer(
        new SelectionAwareSourceRangeComputer(
            fAnalyzer.getSelectedNodes(),
            fCUnit.getBuffer(),
            fSelection.getOffset(),
            fSelection.getLength()));
    fImportRewrite = StubUtility.createImportRewrite(fRootNode, true);

    fLinkedProposalModel = new LinkedProposalModel();

    fScope =
        CodeScopeBuilder.perform(fAnalyzer.getEnclosingBodyDeclaration(), fSelection)
            .findScope(fSelection.getOffset(), fSelection.getLength());
    fScope.setCursor(fSelection.getOffset());

    fSelectedNodes = fAnalyzer.getSelectedNodes();

    createTryCatchStatement(fCUnit.getBuffer(), fCUnit.findRecommendedLineSeparator());

    if (fImportRewrite.hasRecordedChanges()) {
      TextEdit edit = fImportRewrite.rewriteImports(null);
      root.addChild(edit);
      result.addTextEditGroup(new TextEditGroup(NN, new TextEdit[] {edit}));
    }
    TextEdit change = fRewriter.rewriteAST();
    root.addChild(change);
    result.addTextEditGroup(new TextEditGroup(NN, new TextEdit[] {change}));
    return result;
  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:44,代码来源:SurroundWithTryCatchRefactoring.java


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