當前位置: 首頁>>代碼示例>>Java>>正文


Java ICompilationUnit.save方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.ICompilationUnit.save方法的典型用法代碼示例。如果您正苦於以下問題:Java ICompilationUnit.save方法的具體用法?Java ICompilationUnit.save怎麽用?Java ICompilationUnit.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.ICompilationUnit的用法示例。


在下文中一共展示了ICompilationUnit.save方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fix

import org.eclipse.jdt.core.ICompilationUnit; //導入方法依賴的package包/類
private void fix(IMarker marker, IProgressMonitor monitor) {
	MarkerResolutionGenerator.printAttributes (marker);
	try {
		String filepath  = (String) marker.getAttribute(BuildPolicyConfigurationException.JAVAFILENAME);
		int start = (int) marker.getAttribute(IMarker.CHAR_START);
		int end =  (int) marker.getAttribute(IMarker.CHAR_END);
		IFile ifile = (IFile) ResourceManager.toResource(new Path(filepath));
		ICompilationUnit cu = JavaCore.createCompilationUnitFrom(ifile);
		String source = cu.getBuffer().getContents();
		String part1 =  source.substring(0,start);
		String part2 =  source.substring(end);
		source = part1 + "value=\"" + resolutionMarkerDescription.getGenerator() + "\"" + part2;
		final Document document = new Document(source);
		cu.getBuffer().setContents(document.get());
	    cu.save(monitor, false);
	} catch (Exception e) {
		ResourceManager.logException(e);
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:20,代碼來源:InvalidAnnotationPathGeneratorMarkerResolution.java

示例2: updatePathGenerator1

import org.eclipse.jdt.core.ICompilationUnit; //導入方法依賴的package包/類
public static void updatePathGenerator1 (IFile ifile, String oldPathGenerator,String newPathGenerator) throws JavaModelException {
	ICompilationUnit cu = JavaCore.createCompilationUnitFrom(ifile);
	String source = cu.getBuffer().getContents();
	source = source.replace(oldPathGenerator, newPathGenerator);
	final  Document document = new Document(source);
	cu.getBuffer().setContents(document.get());
    cu.save(new NullProgressMonitor(), true);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:9,代碼來源:SourceHelper.java

示例3: createDummyClass

import org.eclipse.jdt.core.ICompilationUnit; //導入方法依賴的package包/類
public static IFile createDummyClass(IJavaProject project) throws CoreException, IOException {
	String clazz = "import org.graphwalker.core.machine.ExecutionContext ; public class Dummy extends org.gw4e.core.machine.ExecutionContext {}";
	IFolder folder = project.getProject().getFolder("src/test/java");
	IPackageFragmentRoot srcFolder = project.getPackageFragmentRoot(folder);
	IPackageFragment pkg = srcFolder.getPackageFragment("");
	ICompilationUnit cu = pkg.createCompilationUnit("Dummy.java", clazz, false, new NullProgressMonitor());
	cu.save(new NullProgressMonitor (), true);

	return (IFile) cu.getResource();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:11,代碼來源:ProjectHelper.java

示例4: createDummyClassWitherror

import org.eclipse.jdt.core.ICompilationUnit; //導入方法依賴的package包/類
public static IFile createDummyClassWitherror(IJavaProject project) throws CoreException, IOException {
	String clazz = "import org.graphwalker.core.machine.ExecutionContext ; public class Dummy1 extends org.gw4e.core.machine.ExecutionContext {}";
	IFolder folder = project.getProject().getFolder("src/test/java");
	IPackageFragmentRoot srcFolder = project.getPackageFragmentRoot(folder);
	IPackageFragment pkg = srcFolder.getPackageFragment("");
	ICompilationUnit cu = pkg.createCompilationUnit("Dummy.java", clazz, false, new NullProgressMonitor());
	cu.save(new NullProgressMonitor (), true);
	return (IFile) cu.getResource();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:10,代碼來源:ProjectHelper.java


注:本文中的org.eclipse.jdt.core.ICompilationUnit.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。