Skip to content

Commit 5be134e

Browse files
authored
Revert "Reuse the prism result again" (#3826)
Revert "Reuse the prism result again (#3729)" This reverts commit 8cbd8f8.
1 parent 1debe52 commit 5be134e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/ruby_lsp/requests/support/rubocop_runner.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ class ConfigurationError < StandardError; end
6161
"RuboCop::Formatter::BaseFormatter", # Suppress any output by using the base formatter
6262
] #: Array[String]
6363

64-
# Functionality was introduced in 1.75.0 but had issues with autocorrect
65-
REUSE_PRISM_RESULT = begin
66-
gem("rubocop", ">= 1.80.1")
67-
true
68-
rescue LoadError
69-
false
70-
end #: bool
71-
7264
#: Array[::RuboCop::Cop::Offense]
7365
attr_reader :offenses
7466

@@ -89,7 +81,7 @@ def initialize(*args)
8981
@offenses = [] #: Array[::RuboCop::Cop::Offense]
9082
@errors = [] #: Array[String]
9183
@warnings = [] #: Array[String]
92-
@prism_result = nil #: Prism::ParseLexResult?
84+
# @prism_result = nil #: Prism::ParseLexResult?
9385

9486
args += DEFAULT_ARGS
9587
rubocop_options = ::RuboCop::Options.new.parse(args).first
@@ -109,7 +101,11 @@ def run(path, contents, prism_result)
109101
@warnings = []
110102
@offenses = []
111103
@options[:stdin] = contents
112-
@prism_result = prism_result if REUSE_PRISM_RESULT
104+
105+
# Setting the Prism result before running the RuboCop runner makes it reuse the existing AST and avoids
106+
# double-parsing. Unfortunately, this leads to a bunch of cops failing to execute properly under LSP mode.
107+
# Uncomment this once reusing the Prism result is more stable
108+
# @prism_result = prism_result
113109

114110
super([path])
115111

0 commit comments

Comments
 (0)