@@ -12,7 +12,7 @@ use crate::core::odoo::SyncOdoo;
12
12
use crate :: threads:: SessionInfo ;
13
13
use crate :: S ;
14
14
15
- use super :: file_mgr:: FileMgr ;
15
+ use super :: file_mgr:: { add_diagnostic , FileMgr , NoqaInfo } ;
16
16
use super :: python_validator:: PythonValidator ;
17
17
use super :: symbols:: function_symbol:: { Argument , ArgumentType , FunctionSymbol } ;
18
18
use super :: symbols:: symbol:: Symbol ;
@@ -757,7 +757,7 @@ impl Evaluation {
757
757
}
758
758
let class_sym_weak_eval = class_sym_weak_eval. as_weak ( ) ;
759
759
if class_sym_weak_eval. instance . unwrap_or ( false ) {
760
- diagnostics . push ( Diagnostic :: new (
760
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
761
761
Range :: new ( Position :: new ( expr. arguments . args [ 0 ] . range ( ) . start ( ) . to_u32 ( ) , 0 ) ,
762
762
Position :: new ( expr. arguments . args [ 0 ] . range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
763
763
Some ( DiagnosticSeverity :: ERROR ) ,
@@ -767,7 +767,7 @@ impl Evaluation {
767
767
None ,
768
768
None
769
769
)
770
- ) ;
770
+ , & session . current_noqa ) ;
771
771
None
772
772
} else {
773
773
let mut is_instance = None ;
@@ -793,7 +793,7 @@ impl Evaluation {
793
793
} else {
794
794
match parent. borrow ( ) . get_in_parents ( & vec ! [ SymType :: CLASS ] , true ) {
795
795
None => {
796
- diagnostics . push ( Diagnostic :: new (
796
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
797
797
Range :: new ( Position :: new ( expr. range ( ) . start ( ) . to_u32 ( ) , 0 ) ,
798
798
Position :: new ( expr. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
799
799
Some ( DiagnosticSeverity :: ERROR ) ,
@@ -803,7 +803,7 @@ impl Evaluation {
803
803
None ,
804
804
None
805
805
)
806
- ) ;
806
+ , & session . current_noqa ) ;
807
807
None
808
808
} ,
809
809
Some ( parent_class) => Some ( ( parent_class. clone ( ) , Some ( true ) ) )
@@ -929,7 +929,8 @@ impl Evaluation {
929
929
expr,
930
930
call_parent. clone ( ) ,
931
931
module. clone ( ) ,
932
- on_instance) ) ;
932
+ on_instance,
933
+ ) ) ;
933
934
}
934
935
context. as_mut ( ) . unwrap ( ) . insert ( S ! ( "base_call" ) , ContextValue :: SYMBOL ( call_parent) ) ;
935
936
for eval in base_sym. borrow ( ) . evaluations ( ) . unwrap ( ) . iter ( ) {
@@ -1213,15 +1214,15 @@ impl Evaluation {
1213
1214
}
1214
1215
}
1215
1216
if !pos_arg {
1216
- diagnostics . push ( Diagnostic :: new (
1217
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
1217
1218
Range :: new ( Position :: new ( exprCall. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( exprCall. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1218
1219
Some ( DiagnosticSeverity :: ERROR ) ,
1219
1220
Some ( NumberOrString :: String ( S ! ( "OLS30315" ) ) ) ,
1220
1221
Some ( EXTENSION_NAME . to_string ( ) ) ,
1221
1222
format ! ( "{} takes 0 positional arguments, but at least 1 is given" , function. name) ,
1222
1223
None ,
1223
1224
None ,
1224
- ) ) ;
1225
+ ) , & session . current_noqa ) ;
1225
1226
return diagnostics;
1226
1227
}
1227
1228
arg_index += 1 ;
@@ -1234,15 +1235,15 @@ impl Evaluation {
1234
1235
//match arg with argument from function
1235
1236
let function_arg = function. args . get ( min ( arg_index, vararg_index) as usize ) ;
1236
1237
if function_arg. is_none ( ) || function_arg. unwrap ( ) . arg_type == ArgumentType :: KWORD_ONLY || function_arg. unwrap ( ) . arg_type == ArgumentType :: KWARG {
1237
- diagnostics . push ( Diagnostic :: new (
1238
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
1238
1239
Range :: new ( Position :: new ( exprCall. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( exprCall. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1239
1240
Some ( DiagnosticSeverity :: ERROR ) ,
1240
1241
Some ( NumberOrString :: String ( S ! ( "OLS30315" ) ) ) ,
1241
1242
Some ( EXTENSION_NAME . to_string ( ) ) ,
1242
1243
format ! ( "{} takes {} positional arguments, but at least {} is given" , function. name, number_pos_arg, arg_index + 1 ) ,
1243
1244
None ,
1244
1245
None ,
1245
- ) ) ;
1246
+ ) , & session . current_noqa ) ;
1246
1247
return diagnostics;
1247
1248
}
1248
1249
if function_arg. unwrap ( ) . arg_type != ArgumentType :: VARARG {
@@ -1268,31 +1269,31 @@ impl Evaluation {
1268
1269
}
1269
1270
}
1270
1271
if !found_one && kwarg_index == i32:: MAX {
1271
- diagnostics . push ( Diagnostic :: new (
1272
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
1272
1273
Range :: new ( Position :: new ( exprCall. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( exprCall. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1273
1274
Some ( DiagnosticSeverity :: ERROR ) ,
1274
1275
Some ( NumberOrString :: String ( S ! ( "OLS30316" ) ) ) ,
1275
1276
Some ( EXTENSION_NAME . to_string ( ) ) ,
1276
1277
format ! ( "{} got an unexpected keyword argument '{}'" , function. name, arg_identifier. id) ,
1277
1278
None ,
1278
1279
None ,
1279
- ) )
1280
+ ) , & session . current_noqa )
1280
1281
}
1281
1282
} else {
1282
1283
// if arg is None, it means that it is a **arg
1283
1284
found_pos_arg_with_kw = number_pos_arg;
1284
1285
}
1285
1286
}
1286
1287
if found_pos_arg_with_kw + 1 < number_pos_arg {
1287
- diagnostics . push ( Diagnostic :: new (
1288
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
1288
1289
Range :: new ( Position :: new ( exprCall. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( exprCall. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1289
1290
Some ( DiagnosticSeverity :: ERROR ) ,
1290
1291
Some ( NumberOrString :: String ( S ! ( "OLS30315" ) ) ) ,
1291
1292
Some ( EXTENSION_NAME . to_string ( ) ) ,
1292
1293
format ! ( "{} takes {} positional arguments, but only {} is given" , function. name, number_pos_arg, arg_index) ,
1293
1294
None ,
1294
1295
None ,
1295
- ) ) ;
1296
+ ) , & session . current_noqa ) ;
1296
1297
return diagnostics;
1297
1298
}
1298
1299
diagnostics
@@ -1312,31 +1313,31 @@ impl Evaluation {
1312
1313
Expr :: Tuple ( t) => {
1313
1314
need_tuple = max ( need_tuple - 1 , 0 ) ;
1314
1315
if t. elts . len ( ) != 3 {
1315
- diagnostics . push ( Diagnostic :: new (
1316
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
1316
1317
Range :: new ( Position :: new ( t. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( t. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1317
1318
Some ( DiagnosticSeverity :: ERROR ) ,
1318
1319
Some ( NumberOrString :: String ( S ! ( "OLS30314" ) ) ) ,
1319
1320
Some ( EXTENSION_NAME . to_string ( ) ) ,
1320
1321
format ! ( "Domain tuple should have 3 elements" ) ,
1321
1322
None ,
1322
1323
None ,
1323
- ) ) ;
1324
+ ) , & session . current_noqa ) ;
1324
1325
} else {
1325
1326
Evaluation :: validate_tuple_search_domain ( session, on_object. clone ( ) , from_module. clone ( ) , & t. elts [ 0 ] , & t. elts [ 1 ] , & t. elts [ 2 ] , & mut diagnostics) ;
1326
1327
}
1327
1328
} ,
1328
1329
Expr :: List ( l) => {
1329
1330
need_tuple = max ( need_tuple - 1 , 0 ) ;
1330
1331
if l. elts . len ( ) != 3 {
1331
- diagnostics . push ( Diagnostic :: new (
1332
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
1332
1333
Range :: new ( Position :: new ( l. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( l. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1333
1334
Some ( DiagnosticSeverity :: ERROR ) ,
1334
1335
Some ( NumberOrString :: String ( S ! ( "OLS30314" ) ) ) ,
1335
1336
Some ( EXTENSION_NAME . to_string ( ) ) ,
1336
1337
format ! ( "Domain tuple should have 3 elements" ) ,
1337
1338
None ,
1338
1339
None ,
1339
- ) ) ;
1340
+ ) , & session . current_noqa ) ;
1340
1341
} else {
1341
1342
Evaluation :: validate_tuple_search_domain ( session, on_object. clone ( ) , from_module. clone ( ) , & l. elts [ 0 ] , & l. elts [ 1 ] , & l. elts [ 2 ] , & mut diagnostics) ;
1342
1343
}
@@ -1356,15 +1357,15 @@ impl Evaluation {
1356
1357
}
1357
1358
}
1358
1359
_ => {
1359
- diagnostics . push ( Diagnostic :: new (
1360
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
1360
1361
Range :: new ( Position :: new ( s. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( s. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1361
1362
Some ( DiagnosticSeverity :: ERROR ) ,
1362
1363
Some ( NumberOrString :: String ( S ! ( "OLS30317" ) ) ) ,
1363
1364
Some ( EXTENSION_NAME . to_string ( ) ) ,
1364
1365
format ! ( "A String value in tuple should contains '&', '|' or '!'" ) ,
1365
1366
None ,
1366
1367
None ,
1367
- ) ) ;
1368
+ ) , & session . current_noqa ) ;
1368
1369
}
1369
1370
}
1370
1371
} ,
@@ -1373,15 +1374,15 @@ impl Evaluation {
1373
1374
}
1374
1375
}
1375
1376
if need_tuple > 0 {
1376
- diagnostics . push ( Diagnostic :: new (
1377
+ add_diagnostic ( & mut diagnostics , Diagnostic :: new (
1377
1378
Range :: new ( Position :: new ( value. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( value. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1378
1379
Some ( DiagnosticSeverity :: ERROR ) ,
1379
1380
Some ( NumberOrString :: String ( S ! ( "OLS30319" ) ) ) ,
1380
1381
Some ( EXTENSION_NAME . to_string ( ) ) ,
1381
1382
format ! ( "Missing tuple after a search domain operator" ) ,
1382
1383
None ,
1383
1384
None ,
1384
- ) ) ;
1385
+ ) , & session . current_noqa ) ;
1385
1386
}
1386
1387
diagnostics
1387
1388
}
@@ -1398,21 +1399,21 @@ impl Evaluation {
1398
1399
' split_name: for name in split_expr {
1399
1400
if date_mode {
1400
1401
if ![ "year_number" , "quarter_number" , "month_number" , "iso_week_number" , "day_of_week" , "day_of_month" , "day_of_year" , "hour_number" , "minute_number" , "second_number" ] . contains ( & name) {
1401
- diagnostics . push ( Diagnostic :: new (
1402
+ add_diagnostic ( diagnostics , Diagnostic :: new (
1402
1403
Range :: new ( Position :: new ( s. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( s. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1403
1404
Some ( DiagnosticSeverity :: ERROR ) ,
1404
1405
Some ( NumberOrString :: String ( S ! ( "OLS30321" ) ) ) ,
1405
1406
Some ( EXTENSION_NAME . to_string ( ) ) ,
1406
1407
format ! ( "Invalid search domain field: Unknown granularity for date field. Use either \" year_number\" , \" quarter_number\" , \" month_number\" , \" iso_week_number\" , \" day_of_week\" , \" day_of_month\" , \" day_of_year\" , \" hour_number\" , \" minute_number\" or \" second_number\" " ) ,
1407
1408
None ,
1408
1409
None ,
1409
- ) ) ;
1410
+ ) , & session . current_noqa ) ;
1410
1411
}
1411
1412
date_mode = false ;
1412
1413
continue ;
1413
1414
}
1414
1415
if obj. is_none ( ) {
1415
- diagnostics . push ( Diagnostic :: new (
1416
+ add_diagnostic ( diagnostics , Diagnostic :: new (
1416
1417
Range :: new ( Position :: new ( s. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( s. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1417
1418
Some ( DiagnosticSeverity :: ERROR ) ,
1418
1419
Some ( NumberOrString :: String ( S ! ( "OLS30322" ) ) ) ,
@@ -1422,7 +1423,7 @@ In a search domain, when using a dot separator, it should be used either on a Da
1422
1423
If you used a relational field and get this error, check that the comodel of this field is valid." ) ,
1423
1424
None ,
1424
1425
None ,
1425
- ) ) ;
1426
+ ) , & session . current_noqa ) ;
1426
1427
break ;
1427
1428
}
1428
1429
if let Some ( object) = & obj {
@@ -1434,15 +1435,15 @@ If you used a relational field and get this error, check that the comodel of thi
1434
1435
false ,
1435
1436
false ) ;
1436
1437
if symbols. is_empty ( ) {
1437
- diagnostics . push ( Diagnostic :: new (
1438
+ add_diagnostic ( diagnostics , Diagnostic :: new (
1438
1439
Range :: new ( Position :: new ( s. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( s. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1439
1440
Some ( DiagnosticSeverity :: ERROR ) ,
1440
1441
Some ( NumberOrString :: String ( S ! ( "OLS30320" ) ) ) ,
1441
1442
Some ( EXTENSION_NAME . to_string ( ) ) ,
1442
1443
format ! ( "Invalid search domain field: {} is not a member of {}" , name, object. borrow( ) . name( ) ) ,
1443
1444
None ,
1444
1445
None ,
1445
- ) ) ;
1446
+ ) , & session . current_noqa ) ;
1446
1447
break ;
1447
1448
}
1448
1449
obj = None ;
@@ -1478,15 +1479,15 @@ If you used a relational field and get this error, check that the comodel of thi
1478
1479
"=" | "!=" | ">" | ">=" | "<" | "<=" | "=?" | "=like" | "like" | "not like" | "ilike" |
1479
1480
"not ilike" | "=ilike" | "in" | "not in" | "child_of" | "parent_of" | "any" | "not any" => { } ,
1480
1481
_ => {
1481
- diagnostics . push ( Diagnostic :: new (
1482
+ add_diagnostic ( diagnostics , Diagnostic :: new (
1482
1483
Range :: new ( Position :: new ( s. range ( ) . start ( ) . to_u32 ( ) , 0 ) , Position :: new ( s. range ( ) . end ( ) . to_u32 ( ) , 0 ) ) ,
1483
1484
Some ( DiagnosticSeverity :: ERROR ) ,
1484
1485
Some ( NumberOrString :: String ( S ! ( "OLS30318" ) ) ) ,
1485
1486
Some ( EXTENSION_NAME . to_string ( ) ) ,
1486
1487
format ! ( "Invalid comparison operator" ) ,
1487
1488
None ,
1488
1489
None ,
1489
- ) ) ;
1490
+ ) , & session . current_noqa ) ;
1490
1491
}
1491
1492
}
1492
1493
} ,
0 commit comments