ForNeVeR / ForNeVeR/haskeletor

Inspections use outdated file text?

Open
#101 0 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Scala
Stars
6
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Consider this file:
```haskell
module Layout.Grid
( Occupancy
, roomCells
, pipeCells
, roomsOverlap
, addCells
, occupancyOf
, roomOfEnd
) where

import Data.List (find)
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)

import Types.LL

-- | How many things (room or pipe cells) occupy each grid cell.
type Occupancy = Map Point Int

-- | All cells of a room's rectangle, borders included.
roomCells :: Room -> [Point]
roomCells room =
[ Point (tx + dx) (ty + dy)
| dx <- [0 .. width room - 1]
, dy <- [0 .. height room - 1]
]
where
Point tx ty = topleft room

allPipeCells :: Pipe -> [Point]
allPipeCells p = startPoint p : middlePoints p ++ [endPoint p]

-- | Do two rooms share at least one cell (borders included)?
roomsOverlap :: Room -> Room -> Bool
roomsOverlap a b =
ax < bx + width b && bx < ax + width a &&
ay < by + height b && by < ay + height a
where
Point ax ay = topleft a
Point bx by = topleft b

-- | Increment occupancy for each of the given cells.
addCells :: [Point] -> Occupancy -> Occupancy
addCells cs occ = foldr (\c -> Map.insertWith (+) c 1) occ cs

-- | Build an occupancy map from placed rooms and routed pipes.
occupancyOf :: [Room] -> [Pipe] -> Occupancy
occupancyOf rs ps =
addCells (concatMap pipeCells ps) (addCells (concatMap roomCells rs) Map.empty)

-- | Which room a pipe end touches, by stepping one cell in @dir@ from @p@
-- and checking which room contains that cell (ports the old @layOut@ rule).
roomOfEnd :: [Room] -> Point -> Direction -> Maybe Room
roomOfEnd rs p dir = find (\r -> roomContains r (step dir p)) rs
```

I was in the middle of rename from `pipeCells` to `allPipeCells`.

So, I select `p`, and type `allO` (a typo!), getting this:
```haskell
module Layout.Grid
( Occupancy
, roomCells
, pipeCells
```

Perhaps the fact that there's completion happening during typing is important.

Anyway, typing `allO` and then `Shift+←` and `P` leads to correct code that's highlighted as incorrect:
Image

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the completion and rename sequence in the Layout.Grid example: type allO, then Shift+Left and P. Trace the IntelliJ plugin's handling of completion during typing and subsequent edits; done means the resulting valid Haskell code is no longer highlighted as incorrect.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, scala
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.