本文整理汇总了C#中IProgressMonitor.worked方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressMonitor.worked方法的具体用法?C# IProgressMonitor.worked怎么用?C# IProgressMonitor.worked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgressMonitor
的用法示例。
在下文中一共展示了IProgressMonitor.worked方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: compile
public SourceCompilerResults compile(SourceCompilerParameters parameters, IProgressMonitor monitor) {
this.parameters = parameters;
if (parameters.FullBuild) {
return compileCore(monitor);
}
try {
monitor.beginTask("", 5);
var results = compileCore(new SubProgressMonitor(monitor, 2));
if (results.Failed) {
if (results.MissingType == null) {
Environment.trace(this, "Errors: all dependent types rebuild required");
// Try to build with all the dependencies
parameters.ProgressiveBuild = false;
results = compileCore(new SubProgressMonitor(monitor, 3));
} else {
Environment.trace(this, "Missing type '" + results.MissingType + "': full rebuild");
parameters.FullBuild = true;
results = compileCore(new SubProgressMonitor(monitor, 3));
}
} else {
// Check for type structural modifications
var oldDependencyInfo = parameters.DependencyInfo;
var newDependencyInfo = results.DependencyInfo;
var oldTypes = results.CompiledFiles.selectMany(p => oldDependencyInfo.getFileContents(p)).toList();
var newTypes = results.CompiledFiles.selectMany(p => newDependencyInfo.getFileContents(p)).toList();
var typesToRebuild = Query.empty<String>();
foreach (var type in oldTypes.except(newTypes)) {
typesToRebuild = typesToRebuild.concat(oldDependencyInfo.getReferencingTypes(type));
}
foreach (var type in oldTypes.intersect(newTypes)) {
if (!JvmTypeSystemHelper.isStructurallyEqual(JvmTypeSystemHelper.getType(parameters.TypeSystem, type),
JvmTypeSystemHelper.getType(results.TypeSystem, type))) {
Environment.trace(this, "Structurally changed: " + type);
typesToRebuild = typesToRebuild.concat(oldDependencyInfo.getReferencingTypes(type));
}
}
var filesToRebuild = typesToRebuild.selectMany(p => oldDependencyInfo.getTypeLocations(p));
filesToRebuild = filesToRebuild.distinct().except(results.CompiledFiles).toList();
monitor.worked(1);
if (filesToRebuild.any()) {
Environment.trace(this, "Structural changes: referencing types rebuild required (" + filesToRebuild.count() + " files)");
parameters.ProgressiveBuild = false;
results = compileCore(new SubProgressMonitor(monitor, 3));
/* The compilation units are not using the current type system
// If some types have changed, rebuild the referencing types
var oldResult = results;
this.parameters = new SourceCompilerParameters();
foreach (var f in filesToRebuild) {
this.parameters.getFilesToCompile().add(f);
}
this.parameters.AllFiles.addAll(parameters.AllFiles.getAllResources());
this.parameters.DependencyInfo = newDependencyInfo;
this.parameters.ClassPath = parameters.ClassPath;
this.parameters.TypeSystem = results.TypeSystem;
results = compileCore(new SubProgressMonitor(monitor, 2));
foreach (var e in oldResult.CompilationUnits.entrySet()) {
results.CompilationUnits[e.Key] = e.Value;
}
foreach (var e in oldResult.ClassFiles.entrySet()) {
results.ClassFiles[e.Key] = e.Value;
}
results.CompiledFiles.addAll(oldResult.CompiledFiles);
*/
} else {
monitor.worked(2);
}
}
return results;
} finally {
monitor.done();
}
}
示例2: runInUIThread
public override IStatus runInUIThread(IProgressMonitor monitor) {
try {
monitor.beginTask("", 1);
editor.Highlighter.update(text, compilationUnit, typeSystem, annotatedTypeSystem);
monitor.worked(1);
monitor.done();
} catch {
}
return (monitor.isCanceled()) ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
示例3: compileCore
private SourceCompilerResults compileCore(IProgressMonitor monitor) {
var t0 = System.nanoTime();
var results = new SourceCompilerResults();
var hasErrors = false;
var errorManager = new CodeErrorManager();
var allFiles = parameters.AllFiles;
Iterable<IFile> filesToCompile = null;
try {
monitor.beginTask("", 11);
var deletedFiles = parameters.FilesToCompile
.select(p => allFiles.getResource(p))
.where(p => p == null || !p.exists())
.select(p => allFiles.getProjectRelativeName(p)).toSet();
var typesToCopy = Query.empty<TypeInfo>();
// Get the files to compile
if (parameters.FullBuild) {
filesToCompile = allFiles.getAllResources().where(p => p.exists()).toList();
} else {
bool filteringDone = false;
var referencingFiles = parameters.getDependencyInfo().getAllReferencingFiles(parameters.getFilesToCompile());
if (parameters.ProgressiveBuild && deletedFiles.isEmpty()) {
var referencedFiles = parameters.getDependencyInfo().getAllReferencedFiles(parameters.getFilesToCompile());
referencedFiles = referencedFiles.except(parameters.getFilesToCompile());
referencedFiles = referencedFiles.intersect(referencingFiles);
// Progressive build only if referenced and referencing files do not intersect
if (!referencedFiles.any()) {
filesToCompile = parameters.FilesToCompile.select(p => allFiles.getResource(p)).where(p => p.exists()).toList();
filteringDone = true;
}
}
if (!filteringDone) {
// Incremental build with dependencies
filesToCompile = referencingFiles.select(p => allFiles.getResource(p)).where(p => p.exists()).toList();
}
var filesToKeep = allFiles.getAllProjectRelativeNames().except(referencingFiles);
typesToCopy = filesToKeep.selectMany(p => parameters.DependencyInfo.getFileContents(p))
.where(p => p.indexOf('$') == -1).select(p => parameters.TypeSystem.getType(p));
Environment.trace(this, "keeping " + filesToKeep.count() + " files");
Environment.trace(this, "ignoring " +
(allFiles.getAllResources().count() - filesToCompile.count() - filesToKeep.count()) + " files");
}
Environment.trace(this, "compiling " + filesToCompile.count() + " files");
monitor.worked(1);
if (monitor.isCanceled()) {
throw new InterruptedException();
}
var compilationUnits = new HashMap<String, CompilationUnitNode>();
// Parsing
foreach (var file in filesToCompile) {
var text = getText(file);
if (text != null) {
parse(file, text, errorManager, compilationUnits);
}
}
monitor.worked(1);
if (monitor.isCanceled()) {
throw new InterruptedException();
}
// Compiling
var t1 = System.nanoTime();
var typeSystem = new Library(parameters.ClassPath);
JvmTypeSystemHelper.cloneTypes(typesToCopy, typeSystem);
var annotatedTypeSystem = new Library(new[] { Environment.getLibraryPath("stabal.jar") }, typeSystem);
var cparams = new CompilerParameters();
cparams.TypeSystem = typeSystem;
cparams.AnnotatedTypeSystem = annotatedTypeSystem;
cparams.GenerateClassFiles = parameters.GenerateClassFiles;
cparams.ProgressTracker = new CompilationProgressTracker(monitor);
var cunits = compilationUnits.values().toArray(new CompilationUnitNode[compilationUnits.size()]);
var cresults = new StabCompiler().compileFromCompilationUnits(cparams, cunits);
Environment.trace(this, "compilation of " + sizeof(cunits) + " files done in " + ((System.nanoTime() - t1) / 1e6) + "ms");
foreach (var error in cresults.Errors) {
if (error.Level == 0) {
hasErrors = true;
}
results.CodeErrors.add(error);
Environment.trace(this, "error (" + error.Line + ", " + error.Column + ") " + error.Filename + ": " + error.Message);
}
if (!hasErrors) {
var dependencyInfo = new DependencyInfo();
results.DependencyInfo = dependencyInfo;
var allTypes = new HashSet<String>();
//.........这里部分代码省略.........