Context

public class Context

Contains AST nodes created from Coco files. A context is the main container for AST nodes created from Coco models.

Fields

client

protected final APIClient client

objectId

protected long objectId

Constructors

Context

protected Context(APIClient client, long objectId)

Internal constructor

Context

protected Context(APIClient client)

Methods

finalize

protected void finalize()

generate

public boolean generate(io.cocotec.coco.platform.coco.CodeGenerationLanguage language, String outputDirectory)

Generates code from all modules that are currently loaded.

Returns:true on error. Diagnostics will have been created on failure.

generateArchitectureDiagram

public io.cocotec.coco.platform.coco.ArchitectureDiagram generateArchitectureDiagram(io.cocotec.coco.platform.coco.Node node, String font, boolean componentNames, boolean componentTypes, boolean portNames, boolean portTypes, boolean hidePorts, int depth)

Generates an SVG diagram of a component, recursively showing subcomponents.

generateArchitectureDiagramAsync

public void generateArchitectureDiagramAsync(io.cocotec.coco.platform.coco.ArchitectureDiagramHandle listener, io.cocotec.coco.platform.coco.Node node, String font, boolean componentNames, boolean componentTypes, boolean portNames, boolean portTypes, boolean hidePorts, int depth)

Generates an SVG diagram of a component, recursively showing subcomponents, without blocking. Both the listener and the canceller must be kept alive until the listener receives a value. Upon cancellation, the listener will still receive a value.

generateComponentSummary

public io.cocotec.coco.platform.coco.StateMachineSummary generateComponentSummary(io.cocotec.coco.platform.coco.Node node)

Returns a summary of the state machine at the supplied port or component

generateStateDiagramGraph

public io.cocotec.coco.platform.coco.StateDiagram generateStateDiagramGraph(io.cocotec.coco.platform.coco.Node node, boolean collapseEdges, boolean hideTransitionLabels)

Generate dot graph(s) of any state machines found under the specified node. Returns an empty string if no state machines are found.

getObjectId

public long getObjectId()

Internal method

getOrCreate

public static Context getOrCreate(APIClient client, long objectId)

Internal method

graphvizFonts

public java.util.ArrayList<String> graphvizFonts()

Returns a list of sans-serif fonts for which Graphviz has hard-coded font metrics, with the nicest fonts listed first.

importedModules

public java.util.ArrayList<io.cocotec.coco.platform.coco.Node> importedModules(io.cocotec.coco.platform.coco.Node module)

For a module, returns the list of non-stdlib modules that this module directly imports. This does not include transitive dependencies.

injectStylesIntoStateDiagramSvg

public String injectStylesIntoStateDiagramSvg(String diagramSvg)

Inject Coco CSS styling into the given state machine diagram generated by generate_state_diagram_graph() and rendered by ‘dot’ into an SVG graphics. The CSS styling text will be injected along with an enclosing style element directly after the first svg element opening. Returns a copy of the given SVG with the CSS injected or the empty string if the injecting failed.

loadedModules

public java.util.ArrayList<io.cocotec.coco.platform.coco.Node> loadedModules()

Returns all modules that have been loaded into this context.

maxArchitectureDiagramDepth

public int maxArchitectureDiagramDepth(io.cocotec.coco.platform.coco.Node node)

Calculates how deep a diagram will be if -1 is passed as the depth parameter to generateArchitectureDiagram.

nodePosition

public io.cocotec.coco.platform.coco.SourceRange nodePosition(io.cocotec.coco.platform.coco.Node node)

Returns the given node’s position in the Coco file.

recommendedArchitectureDiagramDepth

public int recommendedArchitectureDiagramDepth(io.cocotec.coco.platform.coco.Node node)

Recommends a depth limit for a component to avoid the diagram being overwhelming. This can be useful to avoid slow render times for very large diagrams. For flat architectures, it errs on the side of caution and recommends showing too little detail instead of too much.