@@ -63,46 +63,52 @@ export default {
63
63
scope : 'file' ,
64
64
lintOnFly : false ,
65
65
grammarScopes : [ 'source.c' , 'source.cpp' , 'source.objc' , 'source.objcpp' ] ,
66
- lint : ( activeEditor ) => {
66
+ lint : ( editor ) => {
67
67
if ( helpers === null ) {
68
68
helpers = require ( 'atom-linter' ) ;
69
69
}
70
70
if ( clangFlags === null ) {
71
71
clangFlags = require ( 'clang-flags' ) ;
72
72
}
73
73
74
- const filePath = activeEditor . getPath ( ) ;
74
+ const filePath = editor . getPath ( ) ;
75
+
75
76
const args = [
76
77
'-fsyntax-only' ,
77
78
'-fno-caret-diagnostics' ,
78
79
'-fno-diagnostics-fixit-info' ,
79
80
'-fdiagnostics-print-source-range-info' ,
80
81
'-fexceptions' ,
82
+ `-ferror-limit=${ this . clangErrorLimit } ` ,
81
83
] ;
82
84
83
- const grammar = activeEditor . getGrammar ( ) . name ;
85
+ const grammar = editor . getGrammar ( ) . name ;
84
86
85
- if ( / ^ C \+ \+ / . test ( grammar ) ) {
86
- args . push ( '-xc++' ) ;
87
- args . push ( ...this . clangDefaultCppFlags . split ( / \s + / ) ) ;
88
- }
89
- if ( grammar === 'Objective-C++' ) {
90
- args . push ( '-xobjective-c++' ) ;
91
- args . push ( ...this . clangDefaultObjCppFlags . split ( / \s + / ) ) ;
92
- }
93
- if ( grammar === 'C' ) {
94
- args . push ( '-xc' ) ;
95
- args . push ( ...this . clangDefaultCFlags . split ( / \s + / ) ) ;
96
- }
97
- if ( grammar === 'Objective-C' ) {
98
- args . push ( '-xobjective-c' ) ;
99
- args . push ( ...this . clangDefaultObjCFlags . split ( / \s + / ) ) ;
87
+ switch ( grammar ) {
88
+ case 'Objective-C++' :
89
+ args . push ( '-xobjective-c++' ) ;
90
+ args . push ( ...this . clangDefaultObjCppFlags . split ( / \s + / ) ) ;
91
+ break ;
92
+ case 'C' :
93
+ args . push ( '-xc' ) ;
94
+ args . push ( ...this . clangDefaultCFlags . split ( / \s + / ) ) ;
95
+ break ;
96
+ case 'Objective-C' :
97
+ args . push ( '-xobjective-c' ) ;
98
+ args . push ( ...this . clangDefaultObjCFlags . split ( / \s + / ) ) ;
99
+ break ;
100
+ default :
101
+ case 'C++' :
102
+ case 'C++14' :
103
+ args . push ( '-xc++' ) ;
104
+ args . push ( ...this . clangDefaultCppFlags . split ( / \s + / ) ) ;
105
+ break ;
100
106
}
101
107
102
- args . push ( `-ferror-limit=${ this . clangErrorLimit } ` ) ;
103
108
if ( this . clangSuppressWarnings ) {
104
109
args . push ( '-w' ) ;
105
110
}
111
+
106
112
if ( atom . inDevMode ( ) ) {
107
113
args . push ( '--verbose' ) ;
108
114
}
@@ -122,6 +128,7 @@ export default {
122
128
console . log ( error ) ;
123
129
}
124
130
}
131
+
125
132
args . push ( filePath ) ;
126
133
127
134
const execOpts = {
0 commit comments