Java Code Examples for org.eclipse.xtext.util.internal.Stopwatches.StoppedTask#stop()
The following examples show how to use
org.eclipse.xtext.util.internal.Stopwatches.StoppedTask#stop() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public IResolvedTypes reentrantResolve(CancelIndicator monitor) { if (resolving) { throw new UnsupportedOperationException("TODO: import a functional handle on the type resolution that delegates to the best available (current, but evolving) result"); } StoppedTask task = Stopwatches.forTask("DefaultReentrantTypeResolver.resolve"); try { task.start(); resolving = true; return resolve(monitor); } catch(Throwable e) { clear(); if (operationCanceledManager.isOperationCanceledException(e)) { operationCanceledManager.propagateAsErrorIfCancelException(e); } Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } finally { resolving = false; task.stop(); } }
Example 2
Source File: ResourceValidatorImpl.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public List<Issue> validate(Resource resource, final CheckMode mode, CancelIndicator mon) throws OperationCanceledError { StoppedTask task = Stopwatches.forTask("ResourceValidatorImpl.validation"); try { task.start(); final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon; resolveProxies(resource, monitor); operationCanceledManager.checkCanceled(monitor); final List<Issue> result = Lists.newArrayListWithExpectedSize(resource.getErrors().size() + resource.getWarnings().size()); try { IAcceptor<Issue> acceptor = createAcceptor(result); if (mode.shouldCheck(CheckType.FAST)) { collectResourceDiagnostics(resource, monitor, acceptor); } operationCanceledManager.checkCanceled(monitor); boolean syntaxDiagFail = !result.isEmpty(); logCheckStatus(resource, syntaxDiagFail, "Syntax"); validate(resource, mode, monitor, acceptor); operationCanceledManager.checkCanceled(monitor); } catch (RuntimeException e) { operationCanceledManager.propagateAsErrorIfCancelException(e); log.error(e.getMessage(), e); } return result; } finally { task.stop(); } }
Example 3
Source File: AbstractParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public final IParseResult parse(Reader reader) { StoppedTask task = Stopwatches.forTask("AbstractParser.parse"); try { task.start(); return doParse(reader); } finally { task.stop(); } }
Example 4
Source File: DebugSourceInstallingCompilationParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public void buildFinished(IJavaProject project) { StoppedTask task = Stopwatches.forTask("DebugSourceInstallingCompilationParticipant.install"); try { task.start(); super.buildFinished(project); if (files == null) return; for (BuildContext ctx : files) { try { IFile generatedJavaFile = ctx.getFile(); // This may fail if there is no trace file. IEclipseTrace traceToSource = traceInformation.getTraceToSource(generatedJavaFile); if (traceToSource == null) { continue; } AbstractTraceRegion rootTraceRegion = findRootTraceRegion(traceToSource); if (rootTraceRegion == null) continue; SourceRelativeURI dslSourceFile = rootTraceRegion.getAssociatedSrcRelativePath(); // OutputConfigurations are only available for folders targeted by Xtext's code generation. OutputConfiguration outputConfiguration = findOutputConfiguration(dslSourceFile, generatedJavaFile); if (outputConfiguration == null) continue; IJavaElement element = JavaCore.create(generatedJavaFile); if (element == null) continue; deleteTaskMarkers(generatedJavaFile); markerReflector.reflectErrorMarkerInSource(generatedJavaFile, traceToSource); ITraceToBytecodeInstaller installer = getInstaller(outputConfiguration); installer.setTrace(generatedJavaFile.getName(), rootTraceRegion); for (IFile javaClassFile : findGeneratedJavaClassFiles(element)) { InputStream contents = javaClassFile.getContents(); try { byte[] byteCode = installer.installTrace(ByteStreams.toByteArray(contents)); if (byteCode != null) { javaClassFile.setContents(new ByteArrayInputStream(byteCode), 0, null); } else { // we need to touch the class file to do a respin of the build // otherwise a needsRebuild request is ignored since no IResourceDelta is available javaClassFile.touch(null); } } finally { contents.close(); } } } catch (Exception e) { String msg = "Could not process %s to install source information: %s"; log.error(String.format(msg, ctx.getFile().getFullPath().toString(), e.getMessage()), e); } } } finally { files = null; task.stop(); } }
Example 5
Source File: BuilderParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public void build(final IBuildContext context, IProgressMonitor monitor) throws CoreException { if (!isEnabled(context)) { return; } final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context); if (deltas.isEmpty()) { return; } StoppedTask task = Stopwatches.forTask("org.eclipse.xtext.builder.BuilderParticipant.build(IBuildContext, IProgressMonitor)"); try { task.start(); // monitor handling if (monitor.isCanceled()) throw new OperationCanceledException(); SubMonitor subMonitor = SubMonitor.convert(monitor, context.getBuildType() == BuildType.RECOVERY ? 5 : 3); EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get(); IProject builtProject = context.getBuiltProject(); access.setProject(builtProject); Map<String, OutputConfiguration> outputConfigurations = getOutputConfigurations(context); refreshOutputFolders(context, outputConfigurations, subMonitor.split(1)); if (subMonitor.isCanceled()) { throw new OperationCanceledException(); } access.setOutputConfigurations(outputConfigurations); if (context.getBuildType() == BuildType.CLEAN || context.getBuildType() == BuildType.RECOVERY) { SubMonitor cleanMonitor = SubMonitor.convert(subMonitor.newChild(2), outputConfigurations.size()); for (OutputConfiguration config : outputConfigurations.values()) { cleanOutput(context, config, access, cleanMonitor.newChild(1)); } if (context.getBuildType() == BuildType.CLEAN) return; } Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = getGeneratorMarkers(builtProject, outputConfigurations.values()); if (subMonitor.isCanceled()) { throw new OperationCanceledException(); } doBuild(deltas, outputConfigurations, generatorMarkers, context, access, subMonitor.newChild(2)); } finally { outputConfigurationCache.clear(); task.stop(); } }