本文整理汇总了Java中org.eclipse.jdt.core.ICompilationUnit.exists方法的典型用法代码示例。如果您正苦于以下问题:Java ICompilationUnit.exists方法的具体用法?Java ICompilationUnit.exists怎么用?Java ICompilationUnit.exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.ICompilationUnit
的用法示例。
在下文中一共展示了ICompilationUnit.exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findClassesWithAnnotation
import org.eclipse.jdt.core.ICompilationUnit; //导入方法依赖的package包/类
/**
* @param projectName
* @return
* @throws JavaModelException
*/
private static List<IType> findClassesWithAnnotation(String projectName, Class annotationClass, String attributName,
boolean valued) throws JavaModelException {
List<IType> classList = new ArrayList<IType>();
IProject project = ResourceManager.getProject(projectName);
IJavaProject javaProject = JavaCore.create(project);
IPackageFragment[] packages = javaProject.getPackageFragments();
for (IPackageFragment packageFragment : packages) {
for (final ICompilationUnit compilationUnit : packageFragment.getCompilationUnits()) {
if (compilationUnit.exists()) {
IType type = getClassesWithAnnotation(compilationUnit, annotationClass, attributName, valued);
if (type != null)
classList.add(type);
}
}
}
return classList;
}
示例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);
}
}