Search in sources :

Example 1 with CompilerRun

use of net.vtst.ow.closure.compiler.compile.CompilerRun in project ow by vtst.

the class ClosureCompletionProposalCollector method getProposals.

/**
   * Get all the completion proposals which are valid in the given context.
   * @return  The list of the completion proposals.
   */
public List<ClosureCompletionProposal> getProposals() {
    CompilerRun run = context.getCompilerRun();
    List<String> qualifiedName = context.getPrefixAsQualifiedName();
    if (qualifiedName.isEmpty()) {
        try {
            return getProposalsFromScope();
        } catch (RuntimeException e) {
            return Collections.emptyList();
        }
    } else {
        Scope scope = run.getScope(context.getNode());
        if (scope == null)
            return Collections.emptyList();
        JSType type = CompilerRun.getTypeOfQualifiedName(scope, qualifiedName);
        if (type == null)
            return Collections.emptyList();
        else
            return getProposalsFromType(type);
    }
}
Also used : JSType(com.google.javascript.rhino.jstype.JSType) Scope(com.google.javascript.jscomp.Scope) CompilerRun(net.vtst.ow.closure.compiler.compile.CompilerRun)

Example 2 with CompilerRun

use of net.vtst.ow.closure.compiler.compile.CompilerRun 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();
}
Also used : Node(com.google.javascript.rhino.Node) JSElementInfo(net.vtst.ow.eclipse.js.closure.editor.JSElementInfo) CompilerRun(net.vtst.ow.closure.compiler.compile.CompilerRun) CompilableJSUnit(net.vtst.ow.closure.compiler.compile.CompilableJSUnit)

Example 3 with CompilerRun

use of net.vtst.ow.closure.compiler.compile.CompilerRun 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());
}
Also used : ErrorManager(com.google.javascript.jscomp.ErrorManager) NullErrorManager(net.vtst.ow.closure.compiler.util.NullErrorManager) CompilerRun(net.vtst.ow.closure.compiler.compile.CompilerRun) CompilableJSUnit(net.vtst.ow.closure.compiler.compile.CompilableJSUnit) NullErrorManager(net.vtst.ow.closure.compiler.util.NullErrorManager)

Aggregations

CompilerRun (net.vtst.ow.closure.compiler.compile.CompilerRun)3 CompilableJSUnit (net.vtst.ow.closure.compiler.compile.CompilableJSUnit)2 ErrorManager (com.google.javascript.jscomp.ErrorManager)1 Scope (com.google.javascript.jscomp.Scope)1 Node (com.google.javascript.rhino.Node)1 JSType (com.google.javascript.rhino.jstype.JSType)1 NullErrorManager (net.vtst.ow.closure.compiler.util.NullErrorManager)1 JSElementInfo (net.vtst.ow.eclipse.js.closure.editor.JSElementInfo)1