Package Torello.Browser.JsonAST
Class AST_BUILD
- java.lang.Object
-
- Torello.Browser.JsonAST.AST_BUILD
-
public class AST_BUILD extends java.lang.Object
The contents of theJsonAST-Package are, in general, provided strictly for informational & reference purposes. If further research & investigation of Google's CDP API are necessary, one may deserialize theBrowser-APIand / or theJavaScript-APIfrom the Java-HTML'.jar'file, and review the AST's programmatically. The AST Node Java-Classes have been meticulously documented exactly for that purpose.
Generally, though, there really is very little need to review, understand, or programmatically analyze the CDP API. And the contents of this entire package, again, are largely here for reference only.
This particular class falls under the Package "Sub-Category" of"Data Serializers". These classes actually just store some (extremely uninteresting) data which is eventually utilized by the Code Generator to convert the two AST's from Java Memory into actual, reified Java POJO's / Classes.
It might be somewhat important to recognize that though the Java-HTML Library makes theJsonASTPackage source files public in the documentation files for this library, the CDP API Code Generator is not in the public docs, nor are its included in the'.jar'file, either. Generally, what there is to know, is that if you think this JsonAST stuff is actually kind of boring, and not that useful as a reference tool, wait until you get a load of what "Code Generator" code actually looks like. Keeping your eyes open is quite difficult!AST Build Driver.
This top-level builder orchestrates the end-to-end pipeline for transforming the Chrome DevTools Protocol (CDP) schema JSON files into the Java-HTML abstract syntax tree (AST) representation and derived outputs.
The build process follows a compiler-style sequence of phases:- Constructors: Parse raw JSON into untyped AST node tuples with no side effects.
- LinkTypes: Wire parents, resolve
ref4references, and set cross-links. - SimplifyTypes: Normalize and simplify types (collapse aliases, lift unions, etc.).
- ToHTML: Emit human-readable documentation pages for both
browser_protocol.jsonandjs_protocol.json. - ToString: Provide summaries suitable for debugging, logs, and diffs.
All semantic violations are reported viaJsonExceptionwith contextual notes. This avoids uncheckedClassCastExceptionand ensures validation through explicitJsonValue.ValueTypegates.
This class is intended for use by build tools and advanced users who need to regenerate the API documentation or validate schema changes. It is not part of the runtime API.
Hi-Lited Source-Code:- View Here: Torello/Browser/JsonAST/AST_BUILD.java
- Open New Browser-Tab: Torello/Browser/JsonAST/AST_BUILD.java
File Size: 7,012 Bytes Line Count: 166 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctionalAnnotation may also be called 'The Spaghetti Report'.Static-Functionalclasses are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@StatelessAnnotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 3 Method(s), 3 declared static
- 1 Field(s), 1 declared static, 1 declared final
-
-
Method Summary
Generate Complete AST Trees, by parsing Source JSON Files Modifier and Type Method Description static voidgenerate(String htmlFileOutputDir, String dataFileOutputDir, String jsonFileSourceDir)Executes the full JSON→AST build pipeline for the Chrome DevTools Protocol schema.static voidmain(String[] args)Command line variant of the generate method which uses the Java-HTML Default File & Directory Names.
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.io.IOException
Command line variant of the generate method which uses the Java-HTML Default File & Directory Names.- Throws:
java.io.IOException- Code:
- Exact Method Body:
generate( "Torello" + FS + "Browser" + FS + "doc-files" + FS + "protocol_as_html" + FS, "Torello" + FS + "Browser" + FS + "JsonAST" + FS + "data-files" + FS, "Torello" + FS + "Browser" + FS + "doc-files" + FS + "protocol_as_json" + FS );
-
generate
public static void generate(java.lang.String htmlFileOutputDir, java.lang.String dataFileOutputDir, java.lang.String jsonFileSourceDir) throws java.io.IOException
Executes the full JSON→AST build pipeline for the Chrome DevTools Protocol schema.
This method reads the canonical CDP specification files (browser_protocol.jsonandjs_protocol.json) from the givendataFileDir, parses them intoAPIinstances, runs the linker and simplification phases, and finally writes the generated HTML documentation into the providedhtmlFileOutputDir.- Parameters:
htmlFileOutputDir- Directory where the generated HTML protocol documentation will be written.dataFileOutputDir- Target location for writing two '.dat' filesjsonFileSourceDir- Directory containing the JSON schema input files:browser_protocol.jsonandjs_protocol.json.- Throws:
java.io.IOException- if the schema files cannot be read or the HTML output cannot be written.- Code:
- Exact Method Body:
final StorageWriter sw = new StorageWriter(); // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** printPhaseToTerminal(sw, "Parsign Raw JSON Files "); // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** final String browserAPI_Filename = jsonFileSourceDir + "browser_protocol.json"; final String jsAPI_Filename = jsonFileSourceDir + "js_protocol.json"; final API browser = new API(sw, browserAPI_Filename, "BrowserAPI"); final API js = new API(sw, jsAPI_Filename, "JavaScriptAPI"); // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** printPhaseToTerminal(sw, "Running the Linker"); // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Linker.run(sw, browser, js); // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** printPhaseToTerminal(sw, "Writing Data Files"); // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** // // return new Ret2<>(browserData, jsData); // Don't confuse which one is which. Save these to explicitly named variables final Ret2<InfoData, InfoData> extraData = ExtraData.run(sw, browser, js); final InfoData browserData = extraData.a; final InfoData jsData = extraData.b; // Container Data-Class "SERIALIZED_AST" just keeps these four types together final String fName = dataFileOutputDir + SERIALIZED_AST.FILE_NAME_JAR; final SERIALIZED_AST dat = new SERIALIZED_AST(browser, js, browserData, jsData); try { sw.println("Writing File: " + BYELLOW + fName + RESET); FileRW.writeObjectToFileNOCNFE(dat, fName, true); } catch (IOException ioe) { sw.println(EXCC.toString(ioe) + "\nExiting..."); System.exit(0); } // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** printPhaseToTerminal(sw, "Writing HTML Files"); // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** WriteBothHTMLFiles.write(htmlFileOutputDir, browser, js); sw.println();
-
-