@@ -85,27 +85,33 @@ applyHint file mpos = do
85
85
opts = case mpos of
86
86
Nothing -> optsf
87
87
Just (r,c) -> optsf ++ " --pos " ++ show r ++ " ," ++ show c
88
- -- let hlintOpts = [file, "--quiet", "--refactor", "--refactor-options=" ++ opts ]
89
- let hlintOpts = [file, " --quiet" ]
88
+ let hlintOpts = [file, " --quiet" , " --refactor" , " --refactor-options=" ++ opts ]
89
+ -- let hlintOpts = [file, "--quiet" ]
90
90
logm $ " applyHint=" ++ show hlintOpts
91
- res <- catchException $ hlint hlintOpts
91
+ res <- catchException $ runHlint file hlintOpts
92
92
logm $ " applyHint:res=" ++ show res
93
93
-- res <- hlint hlintOpts
94
94
case res of
95
95
Left x -> return $ Left (show x)
96
96
Right x -> do
97
- let commands = makeApplyRefact x
97
+ let commands = makeApplyRefactFromIdeas x
98
98
logm $ " applyHint:commands=" ++ show commands
99
99
appliedFile <- applyRefactorings mpos commands file
100
100
diff <- makeDiffResult file (T. pack appliedFile)
101
101
logm $ " applyHint:diff=" ++ show diff
102
102
return $ Right diff
103
103
104
+ runHlint :: FilePath -> [String ] -> IO [Idea ]
105
+ runHlint fileName args = do
106
+ (flags, classify, hint) <- argsSettings args
107
+ Right m <- parseModuleEx flags fileName Nothing
108
+ return $ applyHints classify hint [m]
109
+
104
110
-- ---------------------------------------------------------------------
105
111
106
- makeApplyRefact :: [Suggestion ] -> [(String , [Refactoring R. SrcSpan ])]
107
- makeApplyRefact suggestions =
108
- map (\ ( Suggestion i) -> (show i, ideaRefactoring i)) suggestions
112
+ makeApplyRefactFromIdeas :: [Idea ] -> [(String , [Refactoring R. SrcSpan ])]
113
+ makeApplyRefactFromIdeas ideas =
114
+ map (\ i -> (show i, ideaRefactoring i)) ideas
109
115
110
116
-- ---------------------------------------------------------------------
111
117
0 commit comments