@@ -151,7 +151,12 @@ function updateProgressIndicator(): void {
151151 } else {
152152 cppcheckProgressIndicator . hide ( ) ;
153153 severityOption . show ( ) ;
154- fullAnalysisStatusBarItem . show ( ) ;
154+ // If a project file exists, show full analysis status bar item
155+ if ( projectFileStore . getUri ( ) ) {
156+ fullAnalysisStatusBarItem . show ( ) ;
157+ } else {
158+ fullAnalysisStatusBarItem . hide ( ) ;
159+ }
155160 }
156161}
157162
@@ -532,7 +537,10 @@ export async function activate(context: vscode.ExtensionContext) {
532537 fullAnalysisStatusBarItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left , 8 ) ;
533538 fullAnalysisStatusBarItem . command = "cppcheck-official.runFullAnalysis" ;
534539 fullAnalysisStatusBarItem . text = `$(play) Full Analysis` ;
535- fullAnalysisStatusBarItem . show ( ) ;
540+ // If a project file exists, show full analysis status bar item
541+ if ( projectFileStore . getUri ( ) ) {
542+ fullAnalysisStatusBarItem . show ( ) ;
543+ }
536544 context . subscriptions . push ( fullAnalysisStatusBarItem ) ;
537545
538546 function clearDiagnosticForDoc ( doc : vscode . TextDocument ) : void {
@@ -760,7 +768,7 @@ async function runCppcheckOnFileXML(
760768 return ;
761769 }
762770
763- const errors = result . results ?. errors ?. [ 0 ] ?. error || [ ] ;
771+ const errors = result ? .results ?. errors ?. [ 0 ] ?. error || [ ] ;
764772 const diagnostics : Record < string , vscode . Diagnostic [ ] > = { } ;
765773 for ( const e of errors ) {
766774 const isCriticalError = criticalWarningTypes . includes ( e . $ . id ) ;
@@ -817,7 +825,6 @@ async function runCppcheckOnFileXML(
817825
818826 // Parse Related Information
819827 const relatedInfos : vscode . DiagnosticRelatedInformation [ ] = await extractRelatedInformation ( locations ) ;
820-
821828 if ( relatedInfos . length > 0 ) {
822829 diagnostic . relatedInformation = relatedInfos ;
823830 }
@@ -871,7 +878,7 @@ async function runFullAnalysis(
871878 threadsOption : string ,
872879) : Promise < void > {
873880 if ( ! processedArgs . includes ( "--project=" ) ) {
874- throw new Error ( "full analysis called without specified project file!" ) ;
881+ throw new Error ( "Full analysis called without specified project file!" ) ;
875882 }
876883
877884 checksRunning = true ;
@@ -940,7 +947,7 @@ async function runFullAnalysis(
940947 return ;
941948 }
942949
943- const errors = result . results ?. errors ?. [ 0 ] ?. error || [ ] ;
950+ const errors = result ? .results ?. errors ?. [ 0 ] ?. error || [ ] ;
944951 const diagnostics : Record < string , vscode . Diagnostic [ ] > = { } ;
945952 for ( const e of errors ) {
946953 const isCriticalError = criticalWarningTypes . includes ( e . $ . id ) ;
0 commit comments