Skip to content

Commit

Permalink
Merge branch 'codefori:main' into fix/299-extname-not-qualified-by-de…
Browse files Browse the repository at this point in the history
…fault
  • Loading branch information
Wright4i authored Mar 6, 2024
2 parents 4cf73e1 + 7d51b7b commit 5221e1a
Show file tree
Hide file tree
Showing 24 changed files with 4,259 additions and 3,118 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,4 @@ jobs:
# Create and publish build to OpenVSX
- name: Publish to Open VSX
run: npx ovsx publish -p ${{ secrets.OPENVSX_TOKEN }}

# Create linter only build
- name: Create linter only build (Merlin)
run: npm run package:linter
- name: Upload build
uses: actions/upload-artifact@v2
with:
name: vscode-rpgle-linter-only
path: ./*.vsix

2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on: pull_request

jobs:
release:
name: Validation
name: Create PR build
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'build')
steps:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
pull_request:
paths:
- 'language/**'

jobs:
release:
name: Test runner
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- run: npm install
- run: node ./node_modules/eslint/bin/eslint src/** --no-error-on-unmatched-pattern
- run: npm run test
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"type": "npm",
"script": "compile:tests"
},
"args": [],
"args": ["sqlRunner1"],
"env": {
"INCLUDE_DIR": "${workspaceFolder}"
}
Expand Down
5 changes: 5 additions & 0 deletions extension/server/src/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Declaration from '../../../language/models/declaration';
import { getPrettyType } from '../../../language/models/fixed';

export function isInMerlin(): boolean {
const { MACHINE_EXEC_PORT } = process.env;
return MACHINE_EXEC_PORT !== undefined;
}

export function parseMemberUri(path: string): {asp?: string, library?: string, file?: string, name: string} {
const parts = path.split(`/`).map(s => s.split(`,`)).flat().filter(s => s.length >= 1);
return {
Expand Down
10 changes: 6 additions & 4 deletions extension/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { getPrettyType } from '../../../language/models/fixed';
import * as Project from './providers/project';
import workspaceSymbolProvider from './providers/project/workspaceSymbol';
import implementationProvider from './providers/implementation';
import { dspffdToRecordFormats, parseMemberUri } from './data';
import { dspffdToRecordFormats, isInMerlin, parseMemberUri } from './data';
import path = require('path');
import { existsSync } from 'fs';
import { renamePrepareProvider, renameRequestProvider } from './providers/rename';
Expand All @@ -35,9 +35,11 @@ let hasConfigurationCapability = false;
let hasWorkspaceFolderCapability = false;
let hasDiagnosticRelatedInformationCapability = false;

const languageToolsEnabled = process.env.LANGUAGE_TOOLS_ENABLED;
const linterEnabled = process.env.LINTER_ENABLED;
const formatterEnabled = process.env.FORMATTER_ENABLED;
const outsideMerlin = !isInMerlin();

const languageToolsEnabled = outsideMerlin;
const linterEnabled = true;
const formatterEnabled = outsideMerlin;

let projectEnabled = false;

Expand Down
7 changes: 0 additions & 7 deletions extension/server/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,4 @@ module.exports = withDefaults({
filename: `server.js`,
path: path.join(__dirname, `..`, `..`, `out`)
},
plugins: [
new webpack.DefinePlugin({
'process.env.LANGUAGE_TOOLS_ENABLED': process.env.LANGUAGE_TOOLS_ENABLED || `true`,
'process.env.LINTER_ENABLED': process.env.LINTER_ENABLED || `true`,
'process.env.FORMATTER_ENABLED': process.env.FORMATTER_ENABLED || `true`,
}),
],
});
2 changes: 1 addition & 1 deletion language/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ export default class Linter {

if (rules.SQLRunner) {
// For running SQL statements
const validStatements = [`declare`, `with`, `select`].includes(statement[2].value.toLowerCase());
const validStatements = [`declare`, `with`, `select`, `merge`, `update`].includes(statement.find((t, i) => i >= 2 && t.type !== `newline`)?.value.toLowerCase());
if (validStatements) {
errors.push({
type: `SQLRunner`,
Expand Down
48 changes: 29 additions & 19 deletions language/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ export default class Parser {
// select * into :x from xx.xx
// call xx.xx()
const preFileWords = [`INTO`, `FROM`, `UPDATE`, `CALL`, `JOIN`];
const ignoredWords = [`FINAL`, `SET`];

const cleanupObjectRef = (content = ``) => {
const result = {
Expand All @@ -860,38 +861,47 @@ export default class Parser {
}

// End bracket for sub-statements
if (result.name.endsWith(`)`)) {
if (result.name.endsWith(`)`) || result.name.endsWith(`,`)) {
result.name = result.name.substring(0, result.name.length - 1);
}

return result;
}

parts.forEach((part, index) => {
let isContinued = false;
for (let index = 0; index < parts.length; index++) {
const part = parts[index];
let inBlock = preFileWords.includes(part);

if (
preFileWords.includes(part) && // If this is true, usually means next word is the object
(inBlock || isContinued) && // If this is true, usually means next word is the object
(part === `INTO` ? parts[index-1] === `INSERT` : true) // INTO is special, as it can be used in both SELECT and INSERT
) {
if (index >= 0 && (index+1) < parts.length) {
if (index >= 0 && (index+1) < parts.length && !ignoredWords.includes(parts[index+1])) {
const possibleFileName = partsLower[index+1];
isContinued = (possibleFileName.endsWith(`,`) || (parts[index+2] === `,`));

const qualifiedObjectPath = cleanupObjectRef(possibleFileName);

const currentSqlItem = new Declaration(`file`);
currentSqlItem.name = qualifiedObjectPath.name;
currentSqlItem.keywords = [];
currentSqlItem.description = qualifiedObjectPath.schema || ``;

currentSqlItem.position = {
path: file,
line: statementStartingLine
};

scope.sqlReferences.push(currentSqlItem);

if (qualifiedObjectPath.name && !qualifiedObjectPath.name.startsWith(`:`)) {
const currentSqlItem = new Declaration(`file`);
currentSqlItem.name = qualifiedObjectPath.name;

if (currentSqlItem.name)

currentSqlItem.keywords = [];
currentSqlItem.description = qualifiedObjectPath.schema || ``;

currentSqlItem.position = {
path: file,
line: statementStartingLine
};

scope.sqlReferences.push(currentSqlItem);
}
}
}

resetDefinition = true;
});
};
}
break;

Expand Down
Loading

0 comments on commit 5221e1a

Please sign in to comment.