本文整理汇总了Java中org.eclipse.jdt.core.ICompilationUnit.isWorkingCopy方法的典型用法代码示例。如果您正苦于以下问题:Java ICompilationUnit.isWorkingCopy方法的具体用法?Java ICompilationUnit.isWorkingCopy怎么用?Java ICompilationUnit.isWorkingCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.ICompilationUnit
的用法示例。
在下文中一共展示了ICompilationUnit.isWorkingCopy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleSaved
import org.eclipse.jdt.core.ICompilationUnit; //导入方法依赖的package包/类
public void handleSaved(DidSaveTextDocumentParams params) {
String uri = params.getTextDocument().getUri();
ICompilationUnit unit = JDTUtils.resolveCompilationUnit(uri);
if (unit == null) {
JavaLanguageServerPlugin.logError(uri + " does not resolve to a ICompilationUnit");
return;
}
// see https://github.com/redhat-developer/vscode-java/issues/274
unit = checkPackageDeclaration(uri, unit);
if (unit.isWorkingCopy()) {
try {
projectsManager.fileChanged(uri, CHANGE_TYPE.CHANGED);
unit.discardWorkingCopy();
unit.becomeWorkingCopy(new NullProgressMonitor());
} catch (JavaModelException e) {
JavaLanguageServerPlugin.logException("Error while handling document save", e);
}
}
}
示例2: didChangeWatchedFiles
import org.eclipse.jdt.core.ICompilationUnit; //导入方法依赖的package包/类
void didChangeWatchedFiles(DidChangeWatchedFilesParams param){
List<FileEvent> changes = param.getChanges();
for (FileEvent fileEvent : changes) {
CHANGE_TYPE changeType = toChangeType(fileEvent.getType());
if(changeType==CHANGE_TYPE.DELETED){
cleanUpDiagnostics(fileEvent.getUri());
}
ICompilationUnit unit = JDTUtils.resolveCompilationUnit(fileEvent.getUri());
if (unit != null && changeType == CHANGE_TYPE.CREATED && !unit.exists()) {
final ICompilationUnit[] units = new ICompilationUnit[1];
units[0] = unit;
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
units[0] = createCompilationUnit(units[0]);
}
}, new NullProgressMonitor());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
unit = units[0];
}
if (unit != null && unit.isWorkingCopy()) {
continue;
}
if(changeType == CHANGE_TYPE.DELETED || changeType == CHANGE_TYPE.CHANGED){
SharedASTProvider.getInstance().invalidate(unit);
}
pm.fileChanged(fileEvent.getUri(), changeType);
}
}
示例3: shouldCache
import org.eclipse.jdt.core.ICompilationUnit; //导入方法依赖的package包/类
/**
* Only cache ASTs for compilation units in working copy mode (open in a
* buffer)
*/
private boolean shouldCache(ITypeRoot input) {
if (input.getElementType() != IJavaElement.COMPILATION_UNIT) {
return false;
}
ICompilationUnit cu = (ICompilationUnit) input;
return cu.getOwner() == null && cu.isWorkingCopy();
}