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

Wrong indent for annotation in otherwise empty sections #31

Closed
m-kessler opened this issue Feb 12, 2024 · 2 comments · Fixed by #33
Closed

Wrong indent for annotation in otherwise empty sections #31

m-kessler opened this issue Feb 12, 2024 · 2 comments · Fixed by #33
Assignees
Labels
bug Something isn't working
Milestone

Comments

@m-kessler
Copy link
Contributor

m-kessler commented Feb 12, 2024

With mofmt 0.4.1 annotations of local class definitions in empty sections (equation, algorithm, protected) are indented one level too much:

Exemplary input:

model M
protected
  model X
  equation
    annotation (revisionId = "c04e23a0d");
  end X;
end M;

Output:

model M

protected

  model X

  equation
      annotation (revisionId = "c04e23a0d");

  end X;

end M;
@ErykMroczek ErykMroczek added the bug Something isn't working label Feb 12, 2024
@ErykMroczek ErykMroczek added this to the 1.0.0 milestone Feb 12, 2024
@ErykMroczek ErykMroczek self-assigned this Feb 12, 2024
@ErykMroczek
Copy link
Owner

Does it happen only in cases like that, ie. after equation, protected etc. keywords, without any elements/equations?

@ErykMroczek ErykMroczek modified the milestones: 1.0.0, 0.4.2 Feb 12, 2024
@m-kessler
Copy link
Contributor Author

Yes, that seems to be the problem. It has nothing to do with nested classes, the problem also occurs for this code:

function indent
  input String u;
  output String y = "    " + u;
algorithm
  annotation (Inline = true);
end indent;

@m-kessler m-kessler changed the title Wrong indent for annotation of nested classes Wrong indent for annotation in otherwise empty sections Feb 13, 2024
ErykMroczek added a commit that referenced this issue Feb 13, 2024
Fixes #31

The issue was caused by wrong heuristic used to differentiate between external function all annotation and "class" annotation inside the *composition* production.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants