当前位置: 首页>>代码示例>>Java>>正文


Java ICompilationUnit.isWorkingCopy方法代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:20,代码来源:DocumentLifeCycleHandler.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:33,代码来源:WorkspaceEventsHandler.java

示例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();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:SharedASTProvider.java


注:本文中的org.eclipse.jdt.core.ICompilationUnit.isWorkingCopy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。