use of org.eclipse.n4js.postprocessing.ASTFlowInfo in project n4js by eclipse.
the class N4JSProjectBuilder method newBuildRequest.
@Override
protected XBuildRequest newBuildRequest(IBuildRequestFactory buildRequestFactory, Set<URI> changedFiles, Set<URI> deletedFiles, List<Delta> externalDeltas, CancelIndicator cancelIndicator) {
XBuildRequest request = super.newBuildRequest(buildRequestFactory, changedFiles, deletedFiles, externalDeltas, cancelIndicator);
ProjectDescription pd = getProjectConfig().getProjectDescription();
if (N4JSLanguageUtils.isDtsGenerationActive(pd)) {
request.addAfterBuildRequestListener(new DtsAfterBuildListener(getProjectConfig()));
}
request.addAfterBuildFileListener((uri) -> {
Resource resource = getResource(uri);
if (resource instanceof N4JSResource) {
N4JSResource n4jsResource = (N4JSResource) resource;
ASTFlowInfo flowInfo = n4jsResource.getASTMetaInfoCache().getFlowInfo();
// release memory
flowInfo.reset();
n4jsResource.unloadAST();
}
});
return request;
}
use of org.eclipse.n4js.postprocessing.ASTFlowInfo in project n4js by eclipse.
the class N4JSFlowgraphValidator method checkFlowGraphs.
/**
* Triggers all flow graph related validations
*/
@Check
public void checkFlowGraphs(Script script) {
N4JSResource resource = (N4JSResource) script.eResource();
ASTFlowInfo flowInfo = resource.getASTMetaInfoCache().getFlowInfo();
if (!flowInfo.canPerformBackwardAnalysis()) {
return;
}
flowInfo.performBackwardAnalysis(this::checkCancelled);
FlowValidator[] fValidators = { new DeadCodeValidator(flowInfo.deadCodeAnalyser, keywordProvider), new UsedBeforeDeclaredValidator(flowInfo.usedBeforeDeclaredAnalyser), new NullUndefinedValidator(flowInfo.nullDereferenceAnalyser, workspaceAccess, findReferenceHelper), new MissingReturnOrThrowValidator(flowInfo.missingReturnOrThrowAnalyser) };
String uriString = script.eResource().getURI().toString();
try (Measurement m1 = N4JSDataCollectors.dcFlowGraphs.getMeasurement("flowGraphs_" + uriString);
Measurement m2 = N4JSDataCollectors.dcFlowGraphPostprocessing.getMeasurement("createGraph_" + uriString)) {
for (FlowValidator fValidator : fValidators) {
fValidator.checkResults(this);
}
}
// note that releasing memory is done in AfterBuildFileListener added in N4JSProjectBuilder#newBuildRequest
}
Aggregations