I propose refactoring to “the tuple of five” to make it consistent with the other builders.

Also the outline builder should then have a (source) option to get the non-analyzed AST and get the analyzed AST otherwise.

I guess these changes can be implemented backwards compatible by first trying with the tuple of five, and if that fails try the non-analyzed AST.

(Related issue: https://yellowgrass.org/issue/Spoofax/754 on different outline types)

Workaround for analyzed AST outline (almost)

To get an analyzed AST outline in the mean time:

outline2 = simple-label-outline(to-outline-label)

outline: ast -> <outline2> analyzed-ast
	with
		index-setup(|<language>, <project-path>);
		task-setup(|<project-path>)
	with
		path := <origin-relative-path>;
		(analyzed-ast, _, _, _) := <analysis-single-default-interface>(ast, path, <project-path>)

however <project-path> is broken from the context of the outline view: it returns the empty string. So <origin-relative-path> returns the complete instead of relative path. (<project-path> works fine in the rest of the project.)

Submitted by Daco Harkes on 25 March 2014 at 16:17

On 25 March 2014 at 16:17 Daco Harkes tagged @oskarvanrest

On 16 May 2014 at 19:38 Oskar van Rest commented:

The outliner now supports the five tuple as well as selection-based outlining. There is no support yet for an outline based on the analyzed AST, so I’m leaving this issue open.

There are now two new outline options available: (source) and (onselection).
The (source) option currently has no effect, but this will change once there is support for an outline based on the analyzed AST.
The (onselection) makes the outline update every time the selection changes and provides you with the selection AST.
For example, if you have outline view: editor-outline (source) in your YourLang-Views.esv, then the editor-outline below will be invoked every time a new AST is generated. Furthermore, the node and ast variables will both hold the source AST.

editor-outline:
	(node, position, ast, path, project-path) -> outline
	where
		outline := <simple-label-outline(to-outline-label)> ast

If you have outline view: editor-outline (source) (onselection) in your YourLang-Views.esv, then the editor-outline below will be invoked every time the user changes the text selection in the editor. Furthermore, the node and ast variables will hold the selection AST and the source AST respectively.

editor-outline:
	(node, position, ast, path, project-path) -> outline
	where
		outline := <simple-label-outline(to-outline-label)> node

On 11 June 2014 at 12:45 Daco Harkes commented:

Thanks!

Looking forward to the analysed one.

Log in to post comments