当前位置: 首页>>代码示例>>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;未经允许,请勿转载。