Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outline does not capture steps within macro definitions #6

Closed
thays42 opened this issue May 25, 2022 · 4 comments · Fixed by #555
Closed

Outline does not capture steps within macro definitions #6

thays42 opened this issue May 25, 2022 · 4 comments · Fixed by #555
Assignees
Labels
feature request New feature or request

Comments

@thays42
Copy link

thays42 commented May 25, 2022

Any steps written within a macro definition do not appear in the Outline. Since macros are a way to group and reuse steps, it would be nice if the outline could show steps and macros within a macro definition.

To replicate, place the following code in a new SAS script:

data work.class;
    set sashelp.class;
run;

proc sort data=work.class;
    by age;
run;

%macro foo();
    data work.class;
        set sashelp.class;
    run;
    
    proc sort data=work.class;
        by age;
    run;
%mend;

The Outline looks like this:

image

It would be great if it could look something like this (mocked up in paint):

image

I am using v0.0.4 of the extension.

@cjdinger
Copy link
Member

@thays42 I'll let the development team respond officially, but this can get tricky/impossible quickly. SAS macro language can generate any text in nearly any way and only the SAS macro processor can really reveal that structure -- at run time when all other conditions are evaluated.

For example, imagine:

%let step=proc means data=cars sum means;

%macro foo;
&step.
%mend;

What would you expect to see? Or imagine macro code that generates different steps of SAS code depending on some condition?

@thays42
Copy link
Author

thays42 commented May 25, 2022

I agree that flexibility of the SAS macro language creates a lot of edge cases. This is something I have been thinking about myself when considering SAS language support for VS Code.

I would expect the Outline to point to SAS statements that start steps. I would not expect the Outline to try to do any macro processing so that the Outline works with the code as it appears in the source file. In your example, I would expect the Outline to show a single %MACRO (ideally, it'd show %MACRO - FOO, but that's a separate issue).

There are definitely edge cases and there always will be because the macro language is so flexible. Perhaps you can establish and document a set of rules that yield a better outline than the current version offers so users know how the outline works. Perhaps there could be a setting like Outline Behavior that can be set to "Top Level" (current behavior) or "Nested" (proposed behavior).

@2TomLi 2TomLi added the feature request New feature or request label Nov 30, 2022
@2TomLi 2TomLi changed the title Outline does not capture steps within macro definitions [Feature] Outline does not capture steps within macro definitions Dec 16, 2022
@2TomLi 2TomLi changed the title [Feature] Outline does not capture steps within macro definitions Outline does not capture steps within macro definitions Dec 19, 2022
@ShuguangSun
Copy link
Contributor

I think we provide something like lsp server. Maybe we could outline based that.
Or simply as @thays42 suggested. No matter what, it is fine to treat the "proc means..." in the example above as string and no need outline or folding.

Leave decision on the code style to the user or their team.

@ShuguangSun
Copy link
Contributor

ShuguangSun commented Sep 12, 2023

Or make /*region*/ and /*endregion*/ work in macro definition.

@scnwwu scnwwu linked a pull request Oct 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants