Skip to content

Commit

Permalink
Revert changes that broke debugger in 2.8.3 (#171)
Browse files Browse the repository at this point in the history
* Revert "Add ESLint and fix problems"

This reverts commit 0f9d15f.

* Remove noise from sample test

* Use typescript~4.7.4

TypeScript does not use semantic versioning. See microsoft/TypeScript#14116

* Install ESLint and add warning notifications

* Fixup some ESLint warnings

* Lint all src files

* Fixup codeUtil.ts

* Ensure no warnings when committing

* Change script  to  for clarity

* Fixup codeUtil.ts

* Fixup fileManager and runnerService

```
$ npx tsc --noEmit --project tsconfig.json src/common/fileManager.ts
error TS5042: Option 'project' cannot be mixed with source files on a command line.
```

oh well

* Fixup global.ts

* Fixup debugDispatcher

Without changing `lint-staged`:

```
✖ tsc --noEmit --target 'es2016':
src/debugger/debugDispatcher.ts(2,45): error TS2792: Cannot find module '@vscode/debugadapter'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
```

not easy to find details here, just going to `tsc` the whole project since it's still pretty speedy.

* Update Contributing.md

* Fixup debugServer

* Fixup debugSession

* Fixup breakpointHandler and variableHandler

* Fixup model

* Fixup parser.ts

* Fixup ahkHoverProvider

* Fixup some providers

* Fixup formattingProvider

Keep known issue #40 to minimize merge conflicts with #163

* Fixup signatureProvider

* Use Prettier 2.6.1

Matches https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode used in changelog, see also https://prettier.io/docs/en/install.html#:~:text=Even%20a%20patch%20release%20of%20Prettier%20can%20result%20in%20slightly%20different%20formatting "Even a patch release of Prettier can result in slightly different formatting"

* Misc fixups

* Update enum member names to match convention

* Fixup Continue enum names
  • Loading branch information
mark-wiemer authored Jul 18, 2022
1 parent 8ce8989 commit bfc5cd7
Show file tree
Hide file tree
Showing 15 changed files with 249 additions and 249 deletions.
13 changes: 8 additions & 5 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ All checks are found in [📄 `package.json`](https://github.com/mark-wiemer/vsc

- Validate: Make sure everything is working correctly
- Lint
- Quality: [ESLint](https://eslint.org/)
- Format: [Prettier](https://prettier.io/)
- Package: [`sort-package-json`](https://www.npmjs.com/package/sort-package-json)
- TSC: [TypeScript compiler](https://code.visualstudio.com/docs/typescript/typescript-compiling) checks for compile-time issues
- ESLint: [ESLint](https://eslint.org/) checks code quality
- Format: [Prettier](https://prettier.io/) checks code formatting
- PackageJSON: [`sort-package-json`](https://www.npmjs.com/package/sort-package-json) checks `package.json` property order
- Test
- Pretest (compile): [TypeScript compiler](https://code.visualstudio.com/docs/typescript/typescript-compiling)
- Automated tests: [Mocha](https://mochajs.org/)
- Pretest (compile)
- TS: [TypeScript compiler](https://code.visualstudio.com/docs/typescript/typescript-compiling) ["upserts"](https://www.wordnik.com/words/upsert) `.js` files that are executed
- Grammar: [js-yaml](https://www.npmjs.com/package/js-yaml) converts [language syntax](https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#:~:text=USING%20YAML%20TO%20WRITE%20A%20GRAMMAR) from YAML to JSON
- Automated tests: [Mocha](https://mochajs.org/) checks functionality

## Syntax / code color contributions

Expand Down
404 changes: 202 additions & 202 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@
"compile": "npm run compile_ts && npm run compile_grammar",
"compile_grammar": "js-yaml syntaxes/ahk.tmLanguage.yaml > syntaxes/ahk.tmLanguage.json",
"compile_ts": "tsc -p ./",
"eslint": "npm run eslint_inner -- src && echo ✅ No ESLint problems",
"eslint_fix": "npm run eslint_inner -- --fix src",
"eslint_inner": "eslint --ext ts --max-warnings=0",
"format": "npm run format_inner -- --check .",
"format_fix": "npm run format_inner -- --write .",
"format_inner": "prettier",
"lint": "npm run quality && npm run format && npm run packagejson",
"lint": "npm run tsc && npm run eslint && npm run format && npm run packagejson",
"packagejson": "sort-package-json --check",
"packagejson_fix": "sort-package-json",
"prepare": "husky install",
"quality": "npm run quality_inner -- src && echo ✅ No problems",
"quality_fix": "npm run quality_inner -- --fix src",
"quality_inner": "eslint --ext ts --max-warnings=0",
"pretest": "npm run compile",
"test": "npm run test_unit && npm run test_grammar_inner",
"test_grammar": "npm run compile_grammar && npm run test_grammar_inner",
"test_grammar_inner": "vscode-tmgrammar-snap src/test/suite/grammar/samples/*.ahk",
"test_unit": "node ./out/test/runTest.js",
"tsc": "tsc --noEmit --skipLibCheck && echo ✅ No TSC problems",
"validate": "npm run lint && npm run test",
"vscode:prepublish": "npm run compile",
"watch": "tsc -watch -p ./"
Expand Down Expand Up @@ -276,9 +277,9 @@
],
"lint-staged": {
"*": "prettier --check",
"src/*": [
"npm run quality_inner",
"tsc --noEmit"
"src/**": [
"npm run eslint_inner",
"npm run tsc"
],
"package.json": "npm run packagejson"
},
Expand All @@ -303,7 +304,7 @@
"js-yaml": "^4.1.0",
"lint-staged": "^13.0.3",
"mocha": "^10.0.0",
"prettier": "^2.6.1",
"prettier": "2.6.1",
"sort-package-json": "^1.57.0",
"source-map-support": "^0.5.19",
"typescript": "~4.7.4",
Expand Down
7 changes: 3 additions & 4 deletions src/debugger/debugDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,9 @@ export class DebugDispatcher extends EventEmitter {
if (parentFullName) {
const isIndex: boolean =
fullname.includes('[') && fullname.includes(']');
fullname =
isIndex === true
? `${parentFullName}${fullname}`
: `${parentFullName}.${fullname}`;
fullname = isIndex
? `${parentFullName}${fullname}`
: `${parentFullName}.${fullname}`;
}

const response: DbgpResponse = await this.sendComand(
Expand Down
6 changes: 3 additions & 3 deletions src/debugger/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { Continue } from './struct/command';
import { VscodeScope } from './struct/scope';

/**
* This interface describes the mock-debug specific launch attr
* This interface describes the mock-debug specific launch attributes
* (which are not part of the Debug Adapter Protocol).
* The schema for these attr lives in the package.json of the mock-debug extension.
* The interface should always match the package.json.
* The schema for these attributes lives in the package.json of the mock-debug extension.
* The interface should always match the one in package.json.
*/
export interface LaunchRequestArguments
extends DebugProtocol.LaunchRequestArguments {
Expand Down
6 changes: 3 additions & 3 deletions src/debugger/struct/command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum Continue {
break = 'break',
run = 'run',
stepOver = 'stepOver',
stepOut = 'stepOut',
stepInto = 'stepInto',
stepOver = 'step_over',
stepOut = 'step_out',
stepInto = 'step_into',
}
4 changes: 1 addition & 3 deletions src/debugger/struct/dbgpResponse.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Property names may come from AHK itself
// let's not change names until we are more confident
/* eslint-disable @typescript-eslint/naming-convention */
export interface DbgpResponse {
attr: {
/** only one stack */
stack: any;
command: string;
context: string;
// eslint-disable-next-line @typescript-eslint/naming-convention
transaction_id: string;
success: '0' | '1';
/** Breakpoint id */
Expand Down
2 changes: 1 addition & 1 deletion src/parser/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class Method {
if (paramsMatch) {
this.params = paramsMatch[1]
.split(',')
.filter((param) => param.trim() !== '')
.filter((param) => param.trim())
.map((param) => {
const paramMatch = param.match(/[^:=* \t]+/);
return paramMatch?.[0] ?? param;
Expand Down
8 changes: 4 additions & 4 deletions src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Parser {
document: vscode.TextDocument,
usingCache = false,
): Promise<Script> {
if (usingCache && !!this.documentCache.get(document.uri.path)) {
if (usingCache && this.documentCache.get(document.uri.path)) {
return this.documentCache.get(document.uri.path);
}

Expand Down Expand Up @@ -98,12 +98,12 @@ export class Parser {
if (block) {
blocks.push(block);
}
if (lineText.indexOf('{') !== -1) {
if (lineText.includes('{')) {
deep++;
}
if (lineText.indexOf('}') !== -1) {
if (lineText.includes('}')) {
deep--;
if (!!currentMethod) {
if (currentMethod) {
currentMethod.endLine = line;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ahkHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class AhkHoverProvider implements HoverProvider {
token: CancellationToken,
) {
const context = this.buildContext(document, position);
if (context === undefined) {
if (!context) {
return null;
}

Expand Down
3 changes: 2 additions & 1 deletion src/providers/ahkRenameProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from 'vscode';
import { Parser } from '../parser/parser';
import { Out } from '../common/out';

export class AhkRenameProvider implements vscode.RenameProvider {
async provideRenameEdits(
Expand Down Expand Up @@ -51,7 +52,7 @@ export class AhkRenameProvider implements vscode.RenameProvider {
const word = document.getText(wordRange);

const method = await Parser.getMethodByName(document, word);
if (!!method) {
if (method) {
return wordRange;
}
throw new Error('You cannot rename this element.');
Expand Down
1 change: 0 additions & 1 deletion src/providers/defProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export class DefProvider implements vscode.DefinitionProvider {
}
for (const param of method.params) {
if (param === word) {
// TODO cannot find param character
return new vscode.Location(
document.uri,
new vscode.Position(
Expand Down
14 changes: 8 additions & 6 deletions src/providers/formattingProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class FormatProvider implements vscode.DocumentFormattingEditProvider {
}

// Check close braces
if (!!purifiedLine.match(/}/)) {
if (purifiedLine.includes('}')) {
let temp = purifiedLine.match(/}/).length;
const t2 = purifiedLine.match(/{[^{}]*}/);
if (t2) {
Expand All @@ -146,7 +146,7 @@ export class FormatProvider implements vscode.DocumentFormattingEditProvider {
}

// One command code and open braces
if (!!oneCommandCode && !!purifiedLine.match(/{/)) {
if (oneCommandCode && purifiedLine.includes('{')) {
let temp = purifiedLine.match(/{/).length;
const t2 = purifiedLine.match(/{[^{}]*}/);
if (t2) {
Expand Down Expand Up @@ -193,7 +193,7 @@ export class FormatProvider implements vscode.DocumentFormattingEditProvider {
}

// Check open braces
if (!!purifiedLine.match(/{/)) {
if (purifiedLine.includes('{')) {
let temp = purifiedLine.match(/{/).length;
const t2 = purifiedLine.match(/{[^{}]*}/);
if (t2) {
Expand All @@ -220,9 +220,11 @@ export class FormatProvider implements vscode.DocumentFormattingEditProvider {
for (const oneCommand of FormatProvider.oneCommandList) {
let temp: RegExpExecArray;
if (
!!(temp = new RegExp(
'\\b' + oneCommand + '\\b(.*)',
).exec(purifiedLine)) &&
// if the regex matches the purified line
(temp = new RegExp('\\b' + oneCommand + '\\b(.*)').exec(
purifiedLine,
)) &&
// and the captured group includes a slash
!temp[1].includes('/')
) {
oneCommandCode = true;
Expand Down
2 changes: 1 addition & 1 deletion src/service/runnerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class RunnerService {
? vscode.Uri.file(script)
: vscode.window.activeTextEditor.document.uri;
script = script ? script : await this.getPathByActive();
const debugPlusExists = !!vscode.extensions.getExtension(
const debugPlusExists = vscode.extensions.getExtension(
'zero-plusplus.vscode-autohotkey-debug',
);
vscode.debug.startDebugging(vscode.workspace.getWorkspaceFolder(cwd), {
Expand Down
9 changes: 3 additions & 6 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ import * as assert from 'assert';

// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as vscode from 'vscode';
// import * as myExtension from '../../extension';

suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');

suite('Extension', () => {
test('Sample test', () => {
assert.strictEqual([1, 2, 3].indexOf(5), -1);
assert.strictEqual([1, 2, 3].indexOf(0), -1);
assert.strictEqual(1 + 1, 2);
});
});

0 comments on commit bfc5cd7

Please sign in to comment.