@@ -25,12 +25,9 @@ import { Readable } from 'stream';
25
25
import * as nls from 'vscode-nls' ;
26
26
import { CppBuildTaskProvider } from './cppBuildTaskProvider' ;
27
27
import { UpdateInsidersAccess } from '../main' ;
28
- import { PlatformInformation } from '../platform' ;
29
- import * as semver from 'semver' ;
30
28
31
29
nls . config ( { messageFormat : nls . MessageFormat . bundle , bundleFormat : nls . BundleFormat . standalone } ) ( ) ;
32
30
const localize : nls . LocalizeFunc = nls . loadMessageBundle ( ) ;
33
- export const cppBuildTaskProvider : CppBuildTaskProvider = new CppBuildTaskProvider ( ) ;
34
31
export const CppSourceStr : string = "C/C++" ;
35
32
export const configPrefix : string = "C/C++: " ;
36
33
@@ -41,7 +38,6 @@ let ui: UI;
41
38
const disposables : vscode . Disposable [ ] = [ ] ;
42
39
let languageConfigurations : vscode . Disposable [ ] = [ ] ;
43
40
let intervalTimer : NodeJS . Timer ;
44
- let taskProvider : vscode . Disposable ;
45
41
let codeActionProvider : vscode . Disposable ;
46
42
export const intelliSenseDisabledError : string = "Do not activate the extension when IntelliSense is disabled." ;
47
43
@@ -157,129 +153,20 @@ function sendActivationTelemetry(): void {
157
153
telemetry . logLanguageServerEvent ( "Activate" , activateEvent ) ;
158
154
}
159
155
160
- async function checkVsixCompatibility ( ) : Promise < void > {
161
- const ignoreMismatchedCompatibleVsix : PersistentState < boolean > = new PersistentState < boolean > ( "CPP." + util . packageJson . version + ".ignoreMismatchedCompatibleVsix" , false ) ;
162
- let resetIgnoreMismatchedCompatibleVsix : boolean = true ;
163
-
164
- // Check to ensure the correct platform-specific VSIX was installed.
165
- const vsixManifestPath : string = path . join ( util . extensionPath , ".vsixmanifest" ) ;
166
- // Skip the check if the file does not exist, such as when debugging cpptools.
167
- if ( await util . checkFileExists ( vsixManifestPath ) ) {
168
- const content : string = await util . readFileText ( vsixManifestPath ) ;
169
- const matches : RegExpMatchArray | null = content . match ( / T a r g e t P l a t f o r m = " (?< platform > [ ^ " ] * ) " / ) ;
170
- if ( matches && matches . length > 0 && matches . groups ) {
171
- const vsixTargetPlatform : string = matches . groups [ 'platform' ] ;
172
- const platformInfo : PlatformInformation = await PlatformInformation . GetPlatformInformation ( ) ;
173
- let isPlatformCompatible : boolean = true ;
174
- let isPlatformMatching : boolean = true ;
175
- switch ( vsixTargetPlatform ) {
176
- case "win32-x64" :
177
- isPlatformMatching = platformInfo . platform === "win32" && platformInfo . architecture === "x64" ;
178
- // x64 binaries can also be run on arm64 Windows 11.
179
- isPlatformCompatible = platformInfo . platform === "win32" && ( platformInfo . architecture === "x64" || ( platformInfo . architecture === "arm64" && semver . gte ( os . release ( ) , "10.0.22000" ) ) ) ;
180
- break ;
181
- case "win32-ia32" :
182
- isPlatformMatching = platformInfo . platform === "win32" && platformInfo . architecture === "x86" ;
183
- // x86 binaries can also be run on x64 and arm64 Windows.
184
- isPlatformCompatible = platformInfo . platform === "win32" && ( platformInfo . architecture === "x86" || platformInfo . architecture === "x64" || platformInfo . architecture === "arm64" ) ;
185
- break ;
186
- case "win32-arm64" :
187
- isPlatformMatching = platformInfo . platform === "win32" && platformInfo . architecture === "arm64" ;
188
- isPlatformCompatible = isPlatformMatching ;
189
- break ;
190
- case "linux-x64" :
191
- isPlatformMatching = platformInfo . platform === "linux" && platformInfo . architecture === "x64" && platformInfo . distribution ?. name !== "alpine" ;
192
- isPlatformCompatible = isPlatformMatching ;
193
- break ;
194
- case "linux-arm64" :
195
- isPlatformMatching = platformInfo . platform === "linux" && platformInfo . architecture === "arm64" && platformInfo . distribution ?. name !== "alpine" ;
196
- isPlatformCompatible = isPlatformMatching ;
197
- break ;
198
- case "linux-armhf" :
199
- isPlatformMatching = platformInfo . platform === "linux" && platformInfo . architecture === "arm" && platformInfo . distribution ?. name !== "alpine" ;
200
- // armhf binaries can also be run on aarch64 linux.
201
- isPlatformCompatible = platformInfo . platform === "linux" && ( platformInfo . architecture === "arm" || platformInfo . architecture === "arm64" ) && platformInfo . distribution ?. name !== "alpine" ;
202
- break ;
203
- case "alpine-x64" :
204
- isPlatformMatching = platformInfo . platform === "linux" && platformInfo . architecture === "x64" && platformInfo . distribution ?. name === "alpine" ;
205
- isPlatformCompatible = isPlatformMatching ;
206
- break ;
207
- case "alpine-arm64" :
208
- isPlatformMatching = platformInfo . platform === "linux" && platformInfo . architecture === "arm64" && platformInfo . distribution ?. name === "alpine" ;
209
- isPlatformCompatible = isPlatformMatching ;
210
- break ;
211
- case "darwin-x64" :
212
- isPlatformMatching = platformInfo . platform === "darwin" && platformInfo . architecture === "x64" ;
213
- isPlatformCompatible = isPlatformMatching ;
214
- break ;
215
- case "darwin-arm64" :
216
- isPlatformMatching = platformInfo . platform === "darwin" && platformInfo . architecture === "arm64" ;
217
- // x64 binaries can also be run on arm64 macOS.
218
- isPlatformCompatible = platformInfo . platform === "darwin" && ( platformInfo . architecture === "x64" || platformInfo . architecture === "arm64" ) ;
219
- break ;
220
- default :
221
- console . log ( "Unrecognized TargetPlatform in .vsixmanifest" ) ;
222
- break ;
223
- }
224
- const moreInfoButton : string = localize ( "more.info.button" , "More Info" ) ;
225
- const ignoreButton : string = localize ( "ignore.button" , "Ignore" ) ;
226
- let promise : Thenable < string | undefined > | undefined ;
227
- if ( ! isPlatformCompatible ) {
228
- promise = vscode . window . showErrorMessage ( localize ( "vsix.platform.incompatible" , "The C/C++ extension installed does not match your system." , vsixTargetPlatform ) , moreInfoButton ) ;
229
- } else if ( ! isPlatformMatching ) {
230
- if ( ! ignoreMismatchedCompatibleVsix . Value ) {
231
- resetIgnoreMismatchedCompatibleVsix = false ;
232
- promise = vscode . window . showWarningMessage ( localize ( "vsix.platform.mismatching" , "The C/C++ extension installed is compatible with but does not match your system." , vsixTargetPlatform ) , moreInfoButton , ignoreButton ) ;
233
- }
234
- }
235
- if ( promise ) {
236
- promise . then ( async ( value ) => {
237
- if ( value === moreInfoButton ) {
238
- await vscode . commands . executeCommand ( "markdown.showPreview" , vscode . Uri . file ( util . getLocalizedHtmlPath ( "Reinstalling the Extension.md" ) ) ) ;
239
- } else if ( value === ignoreButton ) {
240
- ignoreMismatchedCompatibleVsix . Value = true ;
241
- }
242
- } ) ;
243
- }
244
- } else {
245
- console . log ( "Unable to find TargetPlatform in .vsixmanifest" ) ;
246
- }
247
- }
248
- if ( resetIgnoreMismatchedCompatibleVsix ) {
249
- ignoreMismatchedCompatibleVsix . Value = false ;
250
- }
251
- }
252
-
253
156
/**
254
157
* activate: set up the extension for language services
255
158
*/
256
159
export async function activate ( ) : Promise < void > {
257
160
258
- await checkVsixCompatibility ( ) ;
259
-
260
- if ( vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length > 0 ) {
261
- for ( let i : number = 0 ; i < vscode . workspace . workspaceFolders . length ; ++ i ) {
262
- const config : string = path . join ( vscode . workspace . workspaceFolders [ i ] . uri . fsPath , ".vscode/c_cpp_properties.json" ) ;
263
- if ( await util . checkFileExists ( config ) ) {
264
- const doc : vscode . TextDocument = await vscode . workspace . openTextDocument ( config ) ;
265
- vscode . languages . setTextDocumentLanguage ( doc , "jsonc" ) ;
266
- }
267
- }
268
- }
269
-
270
- if ( new CppSettings ( ( vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length > 0 ) ? vscode . workspace . workspaceFolders [ 0 ] ?. uri : undefined ) . intelliSenseEngine === "Disabled" ) {
271
- throw new Error ( intelliSenseDisabledError ) ;
272
- } else {
273
- console . log ( "activating extension" ) ;
274
- sendActivationTelemetry ( ) ;
275
- const checkForConflictingExtensions : PersistentState < boolean > = new PersistentState < boolean > ( "CPP." + util . packageJson . version + ".checkForConflictingExtensions" , true ) ;
276
- if ( checkForConflictingExtensions . Value ) {
277
- checkForConflictingExtensions . Value = false ;
278
- const clangCommandAdapterActive : boolean = vscode . extensions . all . some ( ( extension : vscode . Extension < any > , index : number , array : Readonly < vscode . Extension < any > [ ] > ) : boolean =>
279
- extension . isActive && extension . id === "mitaki28.vscode-clang" ) ;
280
- if ( clangCommandAdapterActive ) {
281
- telemetry . logLanguageServerEvent ( "conflictingExtension" ) ;
282
- }
161
+ console . log ( "activating extension" ) ;
162
+ sendActivationTelemetry ( ) ;
163
+ const checkForConflictingExtensions : PersistentState < boolean > = new PersistentState < boolean > ( "CPP." + util . packageJson . version + ".checkForConflictingExtensions" , true ) ;
164
+ if ( checkForConflictingExtensions . Value ) {
165
+ checkForConflictingExtensions . Value = false ;
166
+ const clangCommandAdapterActive : boolean = vscode . extensions . all . some ( ( extension : vscode . Extension < any > , index : number , array : Readonly < vscode . Extension < any > [ ] > ) : boolean =>
167
+ extension . isActive && extension . id === "mitaki28.vscode-clang" ) ;
168
+ if ( clangCommandAdapterActive ) {
169
+ telemetry . logLanguageServerEvent ( "conflictingExtension" ) ;
283
170
}
284
171
}
285
172
@@ -311,21 +198,14 @@ export async function activate(): Promise<void> {
311
198
312
199
registerCommands ( ) ;
313
200
314
- taskProvider = vscode . tasks . registerTaskProvider ( CppBuildTaskProvider . CppBuildScriptType , cppBuildTaskProvider ) ;
315
-
316
201
vscode . tasks . onDidStartTask ( event => {
317
202
getActiveClient ( ) . PauseCodeAnalysis ( ) ;
318
- if ( event . execution . task . definition . type === CppBuildTaskProvider . CppBuildScriptType
319
- || event . execution . task . name . startsWith ( configPrefix ) ) {
320
- telemetry . logLanguageServerEvent ( 'buildTaskStarted' ) ;
321
- }
322
203
} ) ;
323
204
324
205
vscode . tasks . onDidEndTask ( event => {
325
206
getActiveClient ( ) . ResumeCodeAnalysis ( ) ;
326
207
if ( event . execution . task . definition . type === CppBuildTaskProvider . CppBuildScriptType
327
208
|| event . execution . task . name . startsWith ( configPrefix ) ) {
328
- telemetry . logLanguageServerEvent ( 'buildTaskFinished' ) ;
329
209
if ( event . execution . task . scope !== vscode . TaskScope . Global && event . execution . task . scope !== vscode . TaskScope . Workspace ) {
330
210
const folder : vscode . WorkspaceFolder | undefined = event . execution . task . scope ;
331
211
if ( folder ) {
@@ -1032,9 +912,6 @@ export function deactivate(): Thenable<void> {
1032
912
disposables . forEach ( d => d . dispose ( ) ) ;
1033
913
languageConfigurations . forEach ( d => d . dispose ( ) ) ;
1034
914
ui . dispose ( ) ;
1035
- if ( taskProvider ) {
1036
- taskProvider . dispose ( ) ;
1037
- }
1038
915
if ( codeActionProvider ) {
1039
916
codeActionProvider . dispose ( ) ;
1040
917
}
0 commit comments