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

Show SQL cursors in outline view #216

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

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
Contributor

@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
Contributor

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

vscode-rpgle barry$ npm run test

> [email protected] 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
Contributor

@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
Contributor

@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!

@@ -42,6 +42,10 @@ export default class Cache {

/** @type {IncludeStatement[]} */
this.includes = cache.includes || [];

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

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
Contributor

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
Contributor

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
Contributor

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
Contributor

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
Contributor

@sebCIL Review incoming today. Thank you!

Copy link
Contributor

@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!

@@ -120,6 +127,7 @@ export default class Cache {
...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
Contributor

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.

@@ -93,7 +99,8 @@ export default class Cache {
this.structs.filter(d => d.position.path === fsPath).pop(),
this.variables.filter(d => d.position.path === fsPath).pop(),
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
Contributor

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

@@ -79,6 +84,7 @@ export default class Cache {
...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
Contributor

Choose a reason for hiding this comment

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

cursor -> cursors.

@@ -58,7 +62,8 @@ export default class Cache {
files: [...this.files, ...second.files],
structs: [...this.structs, ...second.structs],
constants: [...this.constants, ...second.constants],
indicators: [...this.indicators, ...second.indicators]
indicators: [...this.indicators, ...second.indicators],
cursor: [...this.cursor, ...second.cursor]
Copy link
Contributor

Choose a reason for hiding this comment

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

cursor -> cursors

@@ -136,7 +144,7 @@ export default class Cache {
}

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
Contributor

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
Contributor

@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.

None yet

3 participants