use of net.vtst.ow.closure.compiler.compile.CompilableJSUnit in project ow by vtst.
the class ClosureContentAssistIncovationContext method computeCompilerRun.
private void computeCompilerRun() {
IFile file = OwJsClosurePlugin.getDefault().getEditorRegistry().getFile(getDocument());
if (file != null) {
CompilableJSUnit unit = ResourceProperties.getJSUnitOrNullIfCoreException(file);
if (unit != null) {
run = unit.getLastAvailableCompilerRun();
if (run != null) {
run.fastCompile();
node = run.getNode(unit, getPrefixOffset());
}
}
}
}
use of net.vtst.ow.closure.compiler.compile.CompilableJSUnit in project ow by vtst.
the class ClosureTextHover method getHoverHTML.
/* (non-Javadoc)
* @see net.vtst.ow.eclipse.js.closure.editor.hover.AbstractTextHover#getHoverHTML(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
*/
@Override
protected String getHoverHTML(ITextViewer viewer, IRegion region) {
CompilableJSUnit unit = getJSUnit();
if (unit == null)
return null;
CompilerRun run = getCompilerRun(unit);
if (run == null)
return null;
Node node = run.getNode(unit, region.getOffset());
if (node == null)
return null;
JSElementInfo info = getElementInfo(run, node);
if (info == null)
return null;
return info.getHTMLStringForHover();
}
use of net.vtst.ow.closure.compiler.compile.CompilableJSUnit in project ow by vtst.
the class ClosureBuilder method compileJavaScriptFile.
/**
* Compile a JavaScript file.
*/
private void compileJavaScriptFile(IFile file, CompilerOptions options, boolean fileIsOpen, boolean stripIncludedFiles, boolean doNotKeepCompilationResultsOfClosedFilesInMemory, boolean force) throws CoreException {
OwJsDev.log("Compiling %s", file.getFullPath().toOSString());
CompilableJSUnit unit = ResourceProperties.getJSUnit(file);
if (unit == null)
return;
ErrorManager errorManager = new ErrorManagerForFileBuild(unit, file);
boolean keepCompilationResultsInMemory = !doNotKeepCompilationResultsOfClosedFilesInMemory || fileIsOpen;
boolean force2 = force || editorRegistry.isNewlyOpenedFile(file);
CompilerRun run = unit.fullCompile(options, errorManager, keepCompilationResultsInMemory, stripIncludedFiles, force2);
run.setErrorManager(new NullErrorManager());
}
use of net.vtst.ow.closure.compiler.compile.CompilableJSUnit in project ow by vtst.
the class ClosureBuilder method fullBuild.
// **************************************************************************
// Full build
/**
* Perform a full build of a project.
* @param monitor The project monitor. This methods reports two units of work.
* @param project The project to build.
* @throws CoreException, OperationCanceledException
*/
private void fullBuild(IProgressMonitor monitor, IProject project) throws CoreException {
monitor.subTask(messages.format("build_prepare"));
boolean forgetIfCanceled = true;
Compiler compiler = CompilerUtils.makeCompiler(new ErrorManagerForProjectBuild(project));
compiler.initOptions(CompilerUtils.makeOptionsForParsingAndErrorReporting());
try {
File pathOfClosureBase = ClosureCompiler.getPathOfClosureBase(project);
if (pathOfClosureBase == null) {
monitor.worked(1);
return;
}
// Create or get the project
JSProject jsProject = ResourceProperties.getOrCreateJSProject(project);
boolean jsProjectUpdated = updateJSProjectIfNeeded(monitor, compiler, project, jsProject);
// Set the compilation units
Set<IFile> files = ClosureCompiler.getJavaScriptFilesOfProject(project);
ResourceProperties.setJavaScriptFiles(project, files);
List<CompilableJSUnit> units = new ArrayList<CompilableJSUnit>(files.size());
for (IFile file : files) {
Utils.checkCancel(monitor);
CompilableJSUnit unit = ResourceProperties.getJSUnit(file);
if (unit == null) {
unit = new CompilableJSUnit(jsProject, file.getLocation().toFile(), pathOfClosureBase, new CompilationUnitProviderFromEclipseIFile(file));
ResourceProperties.setJSUnit(file, unit);
} else {
if (jsProjectUpdated)
unit.clear();
}
units.add(unit);
}
try {
jsProject.setUnits(compiler, units);
monitor.worked(1);
forgetIfCanceled = false;
compileJavaScriptFiles(monitor, project, files, false);
} catch (CircularDependencyException e) {
CompilerUtils.reportError(compiler, JSError.make(CIRCULAR_DEPENDENCY_ERROR, e.getMessage()));
forgetLastBuiltState();
}
} catch (OperationCanceledException e) {
if (forgetIfCanceled)
forgetLastBuiltState();
throw e;
} finally {
compiler.getErrorManager().generateReport();
}
}
Aggregations