本文整理汇总了Java中org.eclipse.jdt.internal.corext.ValidateEditException类的典型用法代码示例。如果您正苦于以下问题:Java ValidateEditException类的具体用法?Java ValidateEditException怎么用?Java ValidateEditException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidateEditException类属于org.eclipse.jdt.internal.corext包,在下文中一共展示了ValidateEditException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyEdit
import org.eclipse.jdt.internal.corext.ValidateEditException; //导入依赖的package包/类
/**
* Applies an text edit to a compilation unit. Filed bug 117694 against jdt.core.
*
* @param cu the compilation unit to apply the edit to
* @param edit the edit to apply
* @param save is set, save the CU after the edit has been applied
* @param monitor the progress monitor to use
* @throws CoreException Thrown when the access to the CU failed
* @throws ValidateEditException if validate edit fails
*/
public static void applyEdit(
ICompilationUnit cu, TextEdit edit, boolean save, IProgressMonitor monitor)
throws CoreException, ValidateEditException {
IFile file = (IFile) cu.getResource();
if (!save || !file.exists()) {
cu.applyTextEdit(edit, monitor);
} else {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(CorextMessages.JavaModelUtil_applyedit_operation, 2);
try {
// IStatus status= Resources.makeCommittable(file, null);
// if (!status.isOK()) {
// throw new ValidateEditException(status);
// }
cu.applyTextEdit(edit, new SubProgressMonitor(monitor, 1));
cu.save(new SubProgressMonitor(monitor, 1), true);
} finally {
monitor.done();
}
}
}
示例2: applyEdit
import org.eclipse.jdt.internal.corext.ValidateEditException; //导入依赖的package包/类
private static void applyEdit(ICompilationUnit cu, TextEdit edit, boolean save, IProgressMonitor monitor)
throws CoreException, ValidateEditException {
IFile file = (IFile) cu.getResource();
if (!save || !file.exists()) {
cu.applyTextEdit(edit, monitor);
} else {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(CorextMessages.JavaModelUtil_applyedit_operation, 2);
try {
IStatus status = Resources.makeCommittable(file, null);
if (!status.isOK()) {
throw new ValidateEditException(status);
}
cu.applyTextEdit(edit, SubMonitor.convert(monitor, 1));
cu.save(SubMonitor.convert(monitor, 1), true);
} finally {
monitor.done();
}
}
}
示例3: applyEdit
import org.eclipse.jdt.internal.corext.ValidateEditException; //导入依赖的package包/类
/**
* Applies an text edit to a compilation unit. Filed bug 117694 against jdt.core.
* @param cu the compilation unit to apply the edit to
* @param edit the edit to apply
* @param save is set, save the CU after the edit has been applied
* @param monitor the progress monitor to use
* @throws CoreException Thrown when the access to the CU failed
* @throws ValidateEditException if validate edit fails
*/
public static void applyEdit(ICompilationUnit cu, TextEdit edit, boolean save, IProgressMonitor monitor) throws CoreException, ValidateEditException {
IFile file= (IFile) cu.getResource();
if (!save || !file.exists()) {
cu.applyTextEdit(edit, monitor);
} else {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
monitor.beginTask(CorextMessages.JavaModelUtil_applyedit_operation, 2);
try {
IStatus status= Resources.makeCommittable(file, null);
if (!status.isOK()) {
throw new ValidateEditException(status);
}
cu.applyTextEdit(edit, new SubProgressMonitor(monitor, 1));
cu.save(new SubProgressMonitor(monitor, 1), true);
} finally {
monitor.done();
}
}
}