-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to select between multiple fixits (#24744)
Follow on to #24663 This PR allows rules to define multiple fixits for a single rule, allowing rule writers to give multiple ways to resolve an issue For example: ![Screenshot 2024-04-02 at 9 07 53 AM](https://github.com/chapel-lang/chapel/assets/15747900/3661b0a4-8689-40a3-86a7-c8fb34c2e381) This PR changes how Fixit works. A Fixit is made of multiple Edits (to support Fixits editing multiple places at once) and rules can define multiple Fixits. This PR uses that functionally to add a Fixits for `chplcheck.ignore`. For example, on `UnusedLoopIndex` warnings, users can either remove the index or add `chplcheck.ignore`, this PR provides both options. This PR also adds a `--interactive` command line flag to let non-lsp users select between multiple fixits. [Reviewed by @DanilaFe]
- Loading branch information
Showing
22 changed files
with
374 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,4 @@ module MethodsAfterFields { | |
return field1; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module MethodsAfterFields { | ||
record emptyRecord { } | ||
|
||
@chplcheck.ignore("MethodsAfterFields") | ||
record methodField { | ||
proc method1() { | ||
return 12; | ||
} | ||
var field1: int; | ||
} | ||
|
||
@chplcheck.ignore("MethodsAfterFields") | ||
record fieldMethodField { | ||
var field1: int; | ||
proc method1() { | ||
return field1; | ||
} | ||
var field2: int; | ||
} | ||
|
||
record fieldFieldMethod { | ||
var field1: int; | ||
const field2: real; | ||
|
||
proc method1() { | ||
return field1; | ||
} | ||
} | ||
|
||
class EmptyClass { | ||
} | ||
|
||
@chplcheck.ignore("MethodsAfterFields") | ||
class MethodField { | ||
proc method1() { | ||
return 12; | ||
} | ||
var field1: int; | ||
} | ||
|
||
@chplcheck.ignore("MethodsAfterFields") | ||
class FieldMethodField { | ||
var field1: int; | ||
proc method1() { | ||
return field1; | ||
} | ||
var field2: int; | ||
} | ||
|
||
class FieldFieldMethod { | ||
var field1: int; | ||
const field2: real; | ||
|
||
proc method1() { | ||
return field1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
MisleadingIndentation.chpl:4: node violates rule MisleadingIndentation | ||
[Success matching fixit for MisleadingIndentation] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Indentation { | ||
@chplcheck.ignore("MisleadingIndentation") | ||
for i in 1..10 do | ||
writeln(i); | ||
writeln("second thing"); | ||
|
||
@chplcheck.ignore("MisleadingIndentation") | ||
for i in 1..10 do | ||
writeln(i); | ||
writeln("second thing"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--using-attribute-toolname chplcheck --stop-after-pass=parseAndConvertUast |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
$CHPL_HOME/tools/chplcheck/chplcheck --enable-rule ConsecutiveDecls \ | ||
--enable-rule BoolLitInCondStatement \ | ||
--enable-rule UseExplicitModules \ | ||
--enable-rule UnusedFormal \ | ||
--enable-rule CamelOrPascalCaseVariables \ | ||
--enable-rule NestedCoforalls \ | ||
--internal-prefix "myprefix_" --internal-prefix "_" \ | ||
--skip-unstable \ | ||
--fixit --fixit-suffix .fixed --interactive \ | ||
$1.chpl <$1.input >/dev/null | ||
|
||
# move the fixed file to the output | ||
mv $1.chpl.fixed $2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
source $CHPL_HOME/util/config/run-in-venv-common.bash | ||
|
||
if python3 -c "import chapel" 2> /dev/null; then | ||
echo "False" | ||
else | ||
echo "True" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module errorHandling { | ||
for i in 1..10 {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module errorHandling { | ||
for 1..10 {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
am | ||
|
||
4 | ||
-1 | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module M { | ||
|
||
for {1..10} {} | ||
|
||
for i in 1..10 {} | ||
|
||
record R { | ||
proc foo() {} | ||
var x: int; | ||
} | ||
|
||
proc foo(a: int) {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module M { | ||
|
||
for 1..10 {} | ||
|
||
@chplcheck.ignore("UnusedLoopIndex") | ||
for i in 1..10 {} | ||
|
||
@chplcheck.ignore("MethodsAfterFields") | ||
record R { | ||
proc foo() {} | ||
var x: int; | ||
} | ||
|
||
proc foo(a: int) {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1 | ||
2 | ||
1 | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.