diff --git a/ahk2 b/ahk2 index f75b53eb..d5a3f83e 160000 --- a/ahk2 +++ b/ahk2 @@ -1 +1 @@ -Subproject commit f75b53eb8b7b14e8bfd4a6ad299dd19caa8526c1 +Subproject commit d5a3f83e88d624eb2cd0ec06cc99b36e8855cd8a diff --git a/changelog.md b/changelog.md index 2231efdf..acfdb7e6 100644 --- a/changelog.md +++ b/changelog.md @@ -3,10 +3,12 @@ ## 6.3.0 - unreleased 🕳️ - Add exclude setting ([#488](https://github.com/mark-wiemer-org/ahkpp/issues/488)) + - Excluded files are not included in IntelliSense completion suggestions, even when they're added via `#include` - Changed `v2.exclude` setting to `exclude` - One setting works for both v1 and v2 + - Changes to this setting take effect immediately, no need to restart your IDE (different than thqby's extension) - v2 will exclude excluded files from suggestions even if they're opened in the IDE (different than thqby's extension) - - v1 no longer automatically ignores files with `out`, `target`, and `node_modules` in their name + - v1 no longer automatically ignores files with `out`, `target`, or `node_modules` in their name - Fixup output channel names: "AHK++ (v1)" and "AHK++ (v2)" instead of "AHK" and "AHK++" respectively - Fix duplicate output channels diff --git a/e2e/main.ahk1 b/e2e/main.ahk1 new file mode 100644 index 00000000..773b0592 --- /dev/null +++ b/e2e/main.ahk1 @@ -0,0 +1,5 @@ +#NoEnv +#SingleInstance, Force +SendMode, Input +SetBatchLines, -1 +SetWorkingDir, %A_ScriptDir% diff --git a/e2e/main.ahk b/e2e/main.ahk2 similarity index 54% rename from e2e/main.ahk rename to e2e/main.ahk2 index 83791603..12f90e0d 100644 --- a/e2e/main.ahk +++ b/e2e/main.ahk2 @@ -1,5 +1,5 @@ #Requires AutoHotkey v2.0 ; Exclude pattern: excluded.ahk -;* Should not suggest "my excluded func" in completion +;* Should not suggest "MyExcludedFunc" in completion MyExclu \ No newline at end of file diff --git a/package.json b/package.json index 548f7820..e13932f3 100644 --- a/package.json +++ b/package.json @@ -48,9 +48,9 @@ ], "scripts": { "prebuild": "npm run clean:dist", - "build": "node src/build.mjs --mode=production && cd ahk2 && npm run build", - "build:ahk1": "node src/build.mjs --mode=production", - "build:dev": "node src/build.mjs && cd ahk2 && npm run build", + "build": "npm run compile:grammar && node src/build.mjs --mode=production && cd ahk2 && npm run build", + "build:ahk1": "npm run compile:grammar && node src/build.mjs --mode=production", + "build:dev": "npm run compile:grammar && node src/build.mjs && cd ahk2 && npm run build", "clean": "npm run clean:dist && npm run clean:language && npm run clean:out", "clean:dist": "del-cli dist", "clean:language": "del-cli \"language/*.tmLanguage.json\"", @@ -72,7 +72,7 @@ "sort-package-json:fix": "sort-package-json", "test": "npm run test:grammar && npm run test:unit && npm run test:e2e", "test:ci": "npm run test:grammar && npm run test:e2e:ci", - "pretest:e2e": "npm run vscode:prepublish && npm run compile:ts", + "pretest:e2e": "npm run build && npm run compile:ts", "test:e2e": "vscode-test", "test:e2e:ci": "npm run test:e2e -- -i --fgrep @ignoreCI", "pretest:grammar": "npm run compile:grammar", @@ -83,7 +83,7 @@ "validate:ci": "npm run lint && npm run test:ci && npm run package", "validate:deep": "cd ahk2 && npm run validate && cd .. && npm run validate", "validate:fix": "npm run lint:fix && npm run test && npm run package", - "vscode:prepublish": "npm run compile:grammar && npm run build && echo Packaging..." + "vscode:prepublish": "npm run build && echo Packaging..." }, "contributes": { "breakpoints": [ diff --git a/package.nls.json b/package.nls.json index 5d05a0c1..eb910c98 100644 --- a/package.nls.json +++ b/package.nls.json @@ -22,7 +22,7 @@ "ahk++.config.v2.diagnostics.classNonDynamicMemberCheck": "Check whether non-dynamic members of a class exist", "ahk++.config.v2.diagnostics.paramsCheck": "Check that the function call has the correct number of arguments", "ahk++.config.v2.file.interpreterPath": "Path to the `AutoHotkey.exe` executable file for AHK v2.", - "ahk++.config.exclude": "[Glob patterns]() for excluding files and folders. Applies even when files are opened. Changes take effect after restart.", + "ahk++.config.exclude": "[Glob patterns]() for excluding files and folders from completion suggestions. Applies even when files are opened.", "ahk++.config.v2.file.maxScanDepth": "Depth of folders to scan for IntelliSense. Negative values mean infinite depth.", "ahk++.config.v2.librarySuggestions": "Which libraries to suggest functions from, if any. In case of issues, restart your IDE.", "ahk++.config.v2.symbolFoldingFromOpenBrace": "Fold parameter lists separately from definitions.", diff --git a/src/common/global.ts b/src/common/global.ts index 061a7f6b..0214a777 100644 --- a/src/common/global.ts +++ b/src/common/global.ts @@ -41,6 +41,8 @@ export enum ConfigKey { compileIcon = 'compiler.compileIcon', compilerPath = 'compiler.compilerPath', exclude = 'exclude', + general = 'general', + generalV2 = 'v2.general', helpPathV1 = 'v1.file.helpPath', helpPathV2 = 'v2.file.helpPath', indentCodeAfterIfDirective = 'v1.formatter.indentCodeAfterIfDirective', @@ -61,3 +63,13 @@ export enum LanguageId { ahk1 = 'ahk', ahk2 = 'ahk2', } + +/** Defined in package.json */ +export type ShowOutput = 'always' | 'never'; + +export enum LibIncludeType { + Disabled = 'Off', + Local = 'Local', + UserAndStandard = 'User and Standard', + All = 'All', +} diff --git a/src/extension.ts b/src/extension.ts index 2bc2e9b3..6468df83 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; import { ProviderResult } from 'vscode'; -import { Parser } from './parser/parser'; +import { clearCache, Parser } from './parser/parser'; import { RunnerService } from './service/runnerService'; import { DebugSession } from './debugger/debugSession'; import { DefProvider } from './providers/defProvider'; @@ -10,7 +10,7 @@ import { SymbolProvider } from './providers/symbolProvider'; import { FileManager } from './common/fileManager'; import { AhkHoverProvider } from './providers/ahkHoverProvider'; import { RefProvider } from './providers/refProvider'; -import { Global } from './common/global'; +import { ConfigKey, configPrefix, Global } from './common/global'; import { AhkRenameProvider } from './providers/ahkRenameProvider'; import { SignatureProvider } from './providers/signatureProvider'; import { CompletionProvider } from './providers/completionProvider'; @@ -84,6 +84,16 @@ export function activate(context: vscode.ExtensionContext) { ), ); + vscode.workspace.onDidChangeConfiguration(async (e) => { + if (!e.affectsConfiguration(`${configPrefix}.${ConfigKey.exclude}`)) + return; + + clearCache(); + await Parser.buildByPath( + vscode.workspace.workspaceFolders?.[0].uri.fsPath, + ); + }); + activateV2(context); } diff --git a/src/parser/parser.ts b/src/parser/parser.ts index 6c75255a..25654d63 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -5,6 +5,15 @@ import { Script, Method, Ref, Label, Block, Variable } from './model'; import { pathsToBuild } from './parser.utils'; import { Out } from '../common/out'; +const startBlockComment = / *\/\*/; +const endBlockComment = / *\*\//; +const documentCache = new Map(); + +export const clearCache = () => { + Out.debug('Clearing cache'); + documentCache.clear(); +}; + export interface BuildScriptOptions { /** Defaults to false. If true, short-circuits when document is in cache. */ usingCache?: boolean; @@ -14,10 +23,8 @@ export interface BuildScriptOptions { /** Parses v1 files */ export class Parser { - private static documentCache = new Map(); - /** - * load method list by path + * Load method list by path * @param buildPath */ public static async buildByPath(buildPath: string) { @@ -46,8 +53,8 @@ export class Parser { document: vscode.TextDocument, options: BuildScriptOptions = {}, ): Promise