Page MenuHomePhabricator

[clangd] Add highlighting for macro expansions.
ClosedPublic

Authored by jvikstrom on Aug 30 2019, 2:50 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

jvikstrom created this revision.Aug 30 2019, 2:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2019, 2:50 AM
jvikstrom updated this revision to Diff 218061.Aug 30 2019, 3:17 AM

Removed SourceManager field from HighlightingTokenCollector.

ilya-biryukov added inline comments.Aug 30 2019, 3:23 AM
clang-tools-extra/clangd/SemanticHighlighting.cpp
35 ↗(On Diff #218061)

NIT: uncapitalize and use 'macro expansions' instead of `Macro Expansions'

469 ↗(On Diff #218061)

Is there a place on the internet with conventional textmate scope names?
Or do we come up with these on our own?

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
394 ↗(On Diff #218061)

Similar to how we highlight everything else, we should also highlight macro declarations and usages (i.e. expansions in the same way).
Could we add the corresponding highlightings?

#define $Macro[[DEF_CLASS]](T) class T T{}
$Macro[[DEF_CLASS]](A);
hokein added inline comments.Aug 30 2019, 4:29 AM
clang-tools-extra/clangd/SemanticHighlighting.cpp
469 ↗(On Diff #218061)

This is not standard TX scope names, we only have guidelines. In general, we use the names using in vscode as references (you could see the TM name via vscode's "Insepct TM Scopes" functionality)

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
394 ↗(On Diff #218061)

+1, I think we could name the HighlightingKind as Macro instead of MacroExpansion (even through we don't highlighting the macro def yet).

jvikstrom updated this revision to Diff 218087.Aug 30 2019, 6:48 AM
jvikstrom marked 3 inline comments as done.

Address comments.

jvikstrom added inline comments.Aug 30 2019, 6:54 AM
clang-tools-extra/clangd/SemanticHighlighting.cpp
469 ↗(On Diff #218061)

This is from the vscode c++ extension. (we mostly use the same scopes as in that extension, but in a few cases we have our own scopes as there aren't any in vscode)

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
394 ↗(On Diff #218061)

We don't seem to collect information about where macro declarations are in the code in ParsedAST.
Added a fixme to add it.

jvikstrom updated this revision to Diff 218089.Aug 30 2019, 6:57 AM

Renamed MacroExpansion to Macro.

jvikstrom marked an inline comment as done.Aug 30 2019, 6:57 AM
hokein accepted this revision.Aug 30 2019, 7:25 AM

LGTM from my side.

clang-tools-extra/clangd/SemanticHighlighting.cpp
471 ↗(On Diff #218089)

I'd drop the expansion, just use entity.name.function.preprocessor.cpp.

This revision is now accepted and ready to land.Aug 30 2019, 7:25 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2019, 8:46 AM