Skip to content

Commit 8c3716f

Browse files
authored
Merge pull request #277 from codefori/feature/hover_support
Hover support
2 parents 6164c1b + 9198377 commit 8c3716f

25 files changed

+732
-234
lines changed

global.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// https://www.ibm.com/docs/en/i/7.4?topic=views-syscolumns2
12
interface TableColumn {
3+
TABLE_SCHEMA: string,
4+
TABLE_NAME: string,
25
COLUMN_NAME: string,
36
SYSTEM_COLUMN_NAME: string,
47
CONSTRAINT_NAME?: string,
@@ -13,7 +16,9 @@ interface TableColumn {
1316
IS_IDENTITY: "YES" | "NO",
1417
}
1518

19+
// https://www.ibm.com/docs/en/i/7.4?topic=views-sysparms
1620
interface SQLParm {
21+
SPECIFIC_SCHEMA: string,
1722
SPECIFIC_NAME: string,
1823
PARAMETER_NAME: string,
1924
PARAMETER_MODE: "IN" | "OUT" | "INOUT",
@@ -25,6 +30,7 @@ interface SQLParm {
2530
DEFAULT?: string,
2631
LONG_COMMENT?: string,
2732
ORDINAL_POSITION: number,
33+
ROW_TYPE: "P" | "R",
2834
}
2935

3036
interface BasicSQLObject {

package-lock.json

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"chart.js": "^4.4.2",
6666
"csv": "^6.1.3",
6767
"json-to-markdown-table": "^1.0.0",
68-
"lru-cache": "^6.0.0",
6968
"node-fetch": "^3.3.1",
7069
"showdown": "^2.1.0",
7170
"sql-formatter": "^14.0.0"

src/database/callable.ts

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11

22
import vscode from "vscode"
33
import { JobManager } from "../config";
4-
import { QueryOptions } from "../connection/types";
4+
import { QueryOptions } from "@ibm/mapepire-js/dist/src/types";
55
const {instance} = vscode.extensions.getExtension(`halcyontechltd.code-for-ibmi`).exports;
66

77
export type CallableType = "PROCEDURE"|"FUNCTION";
88
export interface CallableRoutine {
9+
schema: string;
10+
name: string;
911
specificNames: string[];
1012
type: string;
1113
}
1214

1315
export interface CallableSignature {
1416
specificName: string;
1517
parms: SQLParm[];
18+
returns: SQLParm[];
1619
}
1720

1821
export default class Callable {
@@ -25,6 +28,8 @@ export default class Callable {
2528
);
2629

2730
let routine: CallableRoutine = {
31+
schema,
32+
name,
2833
specificNames: [],
2934
type: forType
3035
}
@@ -41,7 +46,7 @@ export default class Callable {
4146
const results = await JobManager.runSQL<SQLParm>(
4247
[
4348
`SELECT * FROM QSYS2.SYSPARMS`,
44-
`WHERE SPECIFIC_SCHEMA = ? AND ROW_TYPE = 'P' AND SPECIFIC_NAME in (${specificNames.map(n => `?`).join(`, `)})`,
49+
`WHERE SPECIFIC_SCHEMA = ? AND ROW_TYPE in ('P', 'R') AND SPECIFIC_NAME in (${specificNames.map(n => `?`).join(`, `)})`,
4550
`ORDER BY ORDINAL_POSITION`
4651
].join(` `),
4752
{
@@ -56,49 +61,11 @@ export default class Callable {
5661
const groupedResults: CallableSignature[] = uniqueSpecificNames.map(name => {
5762
return {
5863
specificName: name,
59-
parms: results.filter(row => row.SPECIFIC_NAME === name)
64+
parms: results.filter(row => row.SPECIFIC_NAME === name && row.ROW_TYPE === `P`),
65+
returns: results.filter(row => row.SPECIFIC_NAME === name && row.ROW_TYPE === `R`)
6066
}
6167
});
6268

6369
return groupedResults;
6470
}
65-
66-
/**
67-
* @param schema Not user input
68-
* @param specificName Not user input
69-
* @returns
70-
*/
71-
static getParms(schema: string, specificName: string, resolveName: boolean = false): Promise<SQLParm[]> {
72-
const rowType = `P`; // Parameter
73-
return Callable.getFromSysParms(schema, specificName, rowType, resolveName);
74-
}
75-
76-
static getResultColumns(schema: string, specificName: string, resolveName: boolean = false) {
77-
const rowType = `R`; // Row
78-
return Callable.getFromSysParms(schema, specificName, rowType, resolveName);
79-
}
80-
81-
static getFromSysParms(schema: string, name: string, rowType: "P"|"R", resolveName: boolean = false): Promise<SQLParm[]> {
82-
let parameters = [schema, rowType];
83-
84-
let specificNameClause = undefined;
85-
86-
if (resolveName) {
87-
specificNameClause = `SPECIFIC_NAME = (select specific_name from qsys2.sysroutines where specific_schema = ? and routine_name = ?)`;
88-
parameters.push(schema, name);
89-
} else {
90-
specificNameClause = `SPECIFIC_NAME = ?`;
91-
parameters.push(name);
92-
}
93-
94-
const options : QueryOptions = { parameters };
95-
return JobManager.runSQL<SQLParm>(
96-
[
97-
`SELECT * FROM QSYS2.SYSPARMS`,
98-
`WHERE SPECIFIC_SCHEMA = ? AND ROW_TYPE = ? AND ${specificNameClause}`,
99-
`ORDER BY ORDINAL_POSITION`
100-
].join(` `),
101-
options
102-
);
103-
}
10471
}

src/database/schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getInstance } from "../base";
44
import { JobManager } from "../config";
55

66
export type SQLType = "schemas" | "tables" | "views" | "aliases" | "constraints" | "functions" | "variables" | "indexes" | "procedures" | "sequences" | "packages" | "triggers" | "types" | "logicals";
7-
type PageData = { filter?: string, offset?: number, limit?: number };
7+
export type PageData = { filter?: string, offset?: number, limit?: number };
88

99
const typeMap = {
1010
'tables': [`T`, `P`, `M`],

src/database/table.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export default class Table {
1313
static async getItems(schema: string, name: string): Promise<TableColumn[]> {
1414
const sql = [
1515
`SELECT `,
16+
` column.TABLE_SCHEMA,`,
17+
` column.TABLE_NAME,`,
1618
` column.COLUMN_NAME,`,
1719
` key.CONSTRAINT_NAME,`,
1820
` column.DATA_TYPE, `,

src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getInstance, loadBase } from "./base";
1010
import { JobManager, onConnectOrServerInstall, initConfig } from "./config";
1111
import { queryHistory } from "./views/queryHistoryView";
1212
import { ExampleBrowser } from "./views/examples/exampleBrowser";
13-
import { languageInit } from "./language";
13+
import { languageInit } from "./language/providers";
1414
import { initialiseTestSuite } from "./testing";
1515
import { JobManagerView } from "./views/jobManager/jobManagerView";
1616
import { ServerComponent } from "./connection/serverComponent";
@@ -21,6 +21,7 @@ import { SelfTreeDecorationProvider, selfCodesResultsView } from "./views/jobMan
2121
import Configuration from "./configuration";
2222
import { JDBCOptions } from "@ibm/mapepire-js/dist/src/types";
2323
import { Db2iUriHandler, getStatementUri } from "./uriHandler";
24+
import { DbCache } from "./language/providers/logic/cache";
2425

2526
export interface Db2i {
2627
sqlJobManager: SQLJobManager,
@@ -88,6 +89,7 @@ export function activate(context: vscode.ExtensionContext): Db2i {
8889
const instance = getInstance();
8990

9091
instance.subscribe(context, `connected`, `db2i-connected`, () => {
92+
DbCache.resetCache();
9193
selfCodesView.setRefreshEnabled(false);
9294
selfCodesView.setJobOnly(false);
9395
// Refresh the examples when we have it, so we only display certain examples

src/language/index.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/language/providers/completionItemCache.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)