linkedin / css-blocks

High performance, maintainable stylesheets.
http://css-blocks.com/
BSD 2-Clause "Simplified" License
6.33k stars 152 forks source link

feat: WIP for find all references. #387

Open chriseppstein opened 4 years ago

chriseppstein commented 4 years ago

In ElementAnalyzer, I think we can get rid of the distinction of analyze and analyzeForRewrite and just make everything use analyzeForRewrite (which we would then rename to analyze). There's very little benefit to this, it's really just a microoptimization to store less data in situation where we don't need it, but it's adding a lot of unnecessary code complexity.

Then we need to augment how much information we store about where the styles are in the template. The current source locations that we capture aren't specific enough for vscode. For this, we need to augment ElementAnalysis in @css-blocks/core so that for every static and dynamic style we capture there's an associated node location. For instance I suspect we'll need to change

interface TrueCondition<Container extends BlockClass | number = BlockClass> {
  whenTrue: Array<Container>;
}

to be

interface StyleAndLocation<Style> {
  style: Style;
  location: SourceLocation;
}
interface TrueCondition<Container extends BlockClass | number = BlockClass> {
  whenTrue: Array<StyleAndLocation<Container>>;
}