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

2695 implement output type tree in getdatalayout lsp request #2697

Open
wants to merge 20 commits into
base: 2699-new-command-insert-variable-display
Choose a base branch
from

Conversation

efr15
Copy link
Contributor

@efr15 efr15 commented Jan 10, 2025

Fixes #2695

There is a functional changes in GetDataLayoutRequest with CSV output type.
The declaration may now contain additional information for a REDEFINES: PICTURE, USAGE or GROUP.

@efr15 efr15 requested a review from fm-117 January 10, 2025 09:19
@efr15 efr15 self-assigned this Jan 10, 2025
@efr15 efr15 linked an issue Jan 10, 2025 that may be closed by this pull request
@trafico-bot trafico-bot bot added the 🔍 Ready for Review Pull Request is not reviewed yet label Jan 10, 2025
TypeCobol/Compiler/Nodes/Data.cs Outdated Show resolved Hide resolved
TypeCobol.LanguageServer/Processor/DataLayoutProcessor.cs Outdated Show resolved Hide resolved
TypeCobol.LanguageServer/Processor/DataLayoutProcessor.cs Outdated Show resolved Hide resolved
TypeCobol.LanguageServer/Processor/DataLayoutProcessor.cs Outdated Show resolved Hide resolved
@@ -0,0 +1,120 @@
{"line":1,"character":12}
---------------------------------------------------------------------------------
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON produced are huge. Maybe we should contract node data into a single value or an array ?

      "logicalLevel": 1,
      "line": 0,
      "physicalLevel": 0,
      "name": "working-storage",
      "occursDimension": 0,
      "start": 0,
      "length": 0,
      "index": 0,
      "flags": 0,

would become

      [1, 0, 0, "working-storage", 0, 0, 0, 0, 0]

Much less readable I agree but also much shorter !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, to be done at the end

TypeCobol.LanguageServer/Processor/DataLayoutProcessor.cs Outdated Show resolved Hide resolved
@trafico-bot trafico-bot bot added ⚠️ Changes requested Pull Request needs changes before it can be reviewed again and removed 🔍 Ready for Review Pull Request is not reviewed yet labels Jan 10, 2025
@fm-117 fm-117 self-requested a review January 13, 2025 08:38
@trafico-bot trafico-bot bot added the 🔍 Ready for Review Pull Request is not reviewed yet label Jan 20, 2025
@trafico-bot trafico-bot bot removed the 🔍 Ready for Review Pull Request is not reviewed yet label Jan 24, 2025
@trafico-bot trafico-bot bot added the 🔍 Ready for Review Pull Request is not reviewed yet label Jan 30, 2025
@efr15 efr15 changed the base branch from develop to 2699-new-command-insert-variable-display January 30, 2025 09:12
@trafico-bot trafico-bot bot removed the ⚠️ Changes requested Pull Request needs changes before it can be reviewed again label Jan 30, 2025
@efr15 efr15 requested a review from fm-117 January 30, 2025 12:44
@trafico-bot trafico-bot bot added the ⚠️ Changes requested Pull Request needs changes before it can be reviewed again label Jan 30, 2025
@trafico-bot trafico-bot bot removed the 🔍 Ready for Review Pull Request is not reviewed yet label Jan 30, 2025
@trafico-bot trafico-bot bot added the 🔍 Ready for Review Pull Request is not reviewed yet label Jan 31, 2025
@efr15 efr15 requested a review from fm-117 February 4, 2025 11:00
"start": 1,
"length": 4,
"index": 3,
"flags": 2,
Copy link
Contributor

@fm-117 fm-117 Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Displayable ? Nothing looks displayable to me in the whole group except var-displayable

@@ -20,6 +19,7 @@ public class DataLayoutProcessor
private const string DIMENSION_ITEM = "1";
private const string GROUP = "GROUP";
private const string FILLER = "FILLER";
private const int MAX_INDEX_CAPACITY = 65535; // Max capacity of an index declared as PIC 9(4) COMP-5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this into IndexGenerator as this is where we decide to use PIC 9(4) COMP-5 ? Use internal const modifier.

@@ -238,14 +239,42 @@ internal static DataLayoutNode From(DataDefinition dataDefinition, DataLayoutNod

bool IsDisplayable()
{
// FILLER with a National or NationalEdited picture are not displayable
if (name == FILLER && (dataDefinition.SemanticData?.Type).IsNationalOrNationalEdited())
// OCCURS that can not be looped by an index defined as PIC 9(4) COMP-5 (see InsertVariableDisplay command) are not displayable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment to point to IndexGenerator

return false;
}

if (!dataDefinition.IsFiller())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot use IsFiller here. The definition of a FILLER in the context of InsertVariableDisplay is unfortunately different than the one in our private copy comparison tool.
For InsertVariableDisplay a 'FILLER' is simply an anonymous variable, so we just have to test string.IsNullOrEmpty(dataDefinition.Name) here.

Comment on lines +266 to +275
// FILLER with no named ascendant are not displayable
var ascendantNode = dataDefinition.Parent;
while (ascendantNode is DataDefinition ascendantDataDefinition)
{
if (!ascendantDataDefinition.CodeElement.IsFiller())
{
return true;
}
ascendantNode = ascendantNode.Parent;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the ExceedsMaxIndexCapacity, you can apply the same mechanism to compute whether the data is adressable or not without having to crawl up the parents. Something like isNotAdressable = parent.IsNotAdressable && string.IsNullOrEmpty(dataDefinition.Name)

@trafico-bot trafico-bot bot removed the 🔍 Ready for Review Pull Request is not reviewed yet label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ Changes requested Pull Request needs changes before it can be reviewed again
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement output type Tree in GetDataLayout LSP request
2 participants