Skip to content

Conversation

@sebCIL
Copy link
Contributor

@sebCIL sebCIL commented Mar 6, 2023

Changes

Show SQL cursors in outline view.
image

I'm not sure about the icon.

Checklist

  • have tested my change
  • updated relevant documentation
  • Remove any/all console.logs I added
  • eslint is not complaining
  • have added myself to the contributors' list in the README
  • for feature PRs: PR only includes one feature enhancement.

@worksofliam worksofliam self-assigned this Mar 6, 2023
@sebCIL
Copy link
Contributor Author

sebCIL commented Mar 6, 2023

Sorry, after more tests, I have some bug with fixed format.

@sebCIL sebCIL changed the title Show SQL cursors in outline view [WIP] Show SQL cursors in outline view Mar 6, 2023
@worksofliam
Copy link
Member

@sebCIL please also write some test cases for this feature.

Thanks!

@sebCIL sebCIL changed the title [WIP] Show SQL cursors in outline view Show SQL cursors in outline view Mar 8, 2023
@sebCIL
Copy link
Contributor Author

sebCIL commented Mar 8, 2023

@sebCIL please also write some test cases for this feature.

Thanks!

Done.

@worksofliam
Copy link
Member

@sebCIL When running these tests, I am getting an error from a test:

vscode-rpgle barry$ npm run test

> vscode-rpgle@0.17.6 test
> tsx tests

Running 157 tests:
/Users/barry/Repos/vscode-rpgle/tests/suite/linter.js:2429
  assert.strictEqual(errors.length, 1);
         ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

3 !== 1

    at null.exports.linter34 (/Users/barry/Repos/vscode-rpgle/tests/suite/linter.js:2429:10)
    at null.run (/Users/barry/Repos/vscode-rpgle/tests/index.js:17:5) {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: 3,
  expected: 1,
  operator: 'strictEqual'
}

@sebCIL
Copy link
Contributor Author

sebCIL commented Mar 20, 2023

Ok, I fixed it.

@worksofliam
Copy link
Member

@chrjorgensen @sebjulliand Any chance I can get your opinion on this PR? Do you think showing the cursors is standard and would be useful to the user?

@chrjorgensen
Copy link
Contributor

@worksofliam I have not seen cursors in an outline view before - it's not in RDi.
But to me it would be a nice addition - helping in locating the definition of a SQL cursor.

Copy link
Member

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

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

Overall a good implementation, but the EXEC handling logic needs formatting.

Also, I don't think we should be appending the CURSOR keyword on the definition. I think instead we should use a different SymbolKind to indicate the difference.

See my review notes - thanks!

this.includes = cache.includes || [];

/** @type {Declaration[]} */
this.cursor = cache.cursor || [];
Copy link
Member

Choose a reason for hiding this comment

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

Please use a plural here. cursor to be cursors to follow the rest of the properties in this class.

indexCursorName = indexCursor-1;
}
if (currentCursor === undefined
&& indexDeclare >=0
Copy link
Member

Choose a reason for hiding this comment

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

Indentation here is incorrect. eslint should be able to fix this up automatically for you. (or Format Document in VS Code)

path: file,
line: statementStartingLine
};
currentCursor.keywords.push(`CURSOR`);
Copy link
Member

Choose a reason for hiding this comment

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

Cursor keyword should not be used here. See final review notes.

indexCursorName = indexCursor-1;
}
if (currentCursor === undefined
&& indexDeclare >=0
Copy link
Member

Choose a reason for hiding this comment

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

Indentation also incorrect here.

.map(def => DocumentSymbol.create(
def.name,
def.keywords.join(` `).trim(),
SymbolKind.Constant,
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect symbol kind. I think Operator or Interface

@sebCIL sebCIL requested a review from worksofliam May 18, 2023 13:27
@worksofliam
Copy link
Member

@sebCIL Review incoming today. Thank you!

Copy link
Member

@worksofliam worksofliam left a comment

Choose a reason for hiding this comment

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

Looks like there are some invalid references which causes the tests to fail. Check out my comments and request my review again when it's ready.

Thanks!

p.s. I am waiting for this PR to be merged before merging a rather large cleanup PR. Thank you!

...this.subroutines.filter(def => def.name.toUpperCase() === name),
...this.variables.filter(def => def.name.toUpperCase() === name),
...this.indicators.filter(def => def.name.toUpperCase() === name),
...this.cursor.filter(def => def.name.toUpperCase() === name),
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you've updated the cursors property but missed renaming it elsewhere.

this.constants.filter(d => d.position.path === fsPath).pop(),
this.files.filter(d => d.position.path === fsPath).pop()
this.files.filter(d => d.position.path === fsPath).pop(),
this.cursor.filter(d => d.position.path === fsPath).pop()
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect reference here also. cursor -> cursors

...this.subroutines.map(def => def.name),
...this.variables.map(def => def.name),
...this.structs.map(def => def.name),
...this.cursor.map(def => def.name),
Copy link
Member

Choose a reason for hiding this comment

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

cursor -> cursors.

constants: [...this.constants, ...second.constants],
indicators: [...this.indicators, ...second.indicators]
indicators: [...this.indicators, ...second.indicators],
cursor: [...this.cursor, ...second.cursor]
Copy link
Member

Choose a reason for hiding this comment

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

cursor -> cursors


clearReferences() {
[...this.parameters, ...this.constants, ...this.files, ...this.procedures, ...this.subroutines, ...this.variables, ...this.structs].forEach(def => {
[...this.parameters, ...this.constants, ...this.files, ...this.procedures, ...this.subroutines, ...this.variables, ...this.structs, ...this.cursor].forEach(def => {
Copy link
Member

Choose a reason for hiding this comment

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

cursor -> cursors

@sebCIL
Copy link
Contributor Author

sebCIL commented May 21, 2023

Sorry, I didn't test my test !

@sebCIL sebCIL requested a review from worksofliam May 21, 2023 08:50
@worksofliam
Copy link
Member

@sebCIL There is another big PR I am needing to merge ASAP. I suspect it will have a large impact on this PR. Just thought I'd give you a heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants