jeff-hykin / better-cpp-syntax Goto Github PK
View Code? Open in Web Editor NEW๐พ The source of VS Code's C++ syntax highlighting
License: GNU General Public License v3.0
๐พ The source of VS Code's C++ syntax highlighting
License: GNU General Public License v3.0
generate_c.rb
is not able to generate syntaxes/c.tmLanguage.json
as It appears to be a stub and c_grammar
is not a Grammar
object. Additionally generate_c.rb
is missing several referenced variables:
function_definition_pattern
probably_a_parameter_2_groups
operator_overload_4_groups
variable_name_without_bounds
non_primitive_types
primitive_types
This issue precludes fixing issues in the C grammar.
Sadly this is just outside of the capabilities of TextMate grammars (as noted on the original issue)
From @Yanpas on February 15, 2019 14:11
Steps to Reproduce:
bool aaaa(const char */* comment */) { return true; }
No matter if you have any c/c++ extensions installed
Does this issue occur when all extensions are disabled?: Yes/No
Copied from original issue: microsoft/vscode#68784
Example code:
class foo : bar {};
class foo : public bar {};
One line 1 bar
has the scope meta.class-struct-block.cpp source.cpp
.
One line 2 bar
has the scope entity.name.type.inherited.cpp meta.class-struct-block.cpp source.cpp
.
The scope for bar
on each line should be identical.
This is not a regression, and the issue existed prior to #49.
If a template has two 2 <
(including the one after template
than most syntax highlighting is disabled for the rest of the file.
The rest of the file has the TM scope of template.definition
. It looks like the issue first appeared in 1.4.0 ( 1.3.3 does not exhibit this issue).
For debugging
namespace test {
template <class T>
struct test {
template <class U = std::vector<int>>
bool operator()(U k) {}
};
struct test2 {
bool operator()() = delete;
};
} // namespace test
// no syntax highlighting
class test2 {};
Example code:
namespace {
using A = decltype(5);
decltype(5) B = A();
}
This effects decltype
, static_assert
, template deduction guides (migh not be incorrect however), some macros.
This is because the namespace pattern includes :constructors
before $base
.
Removing :constructors
seems to have almost no negative side effects. (One exception is test::test(){}
is not tagged as a constructor, it is also not tagged outside of a namespace currently as well, so a better solution should be found). I cannot think of why constructors should be treated differently inside/outside a namespace.
atom/language-c#230
atom/language-c#73
This is going to take awhile, but it shouldn't be to complicated. The work for iostream has already been started.
Originally From atom/language-c#127
and microsoft/vscode-cpptools#2498
Describe the bug
To Reproduce
int main()
{
int* i = new int;
delete i;
}
Expected behavior
'new' and 'delete' should be colorized.
Additional context
May be true for other keywords as well.
atom/language-c#269
atom/language-c#290
atom/language-c#280
Almost all of these involve code that is highlighted differently because of preprocessor statements.
Most of them are impossible because the TextMate parser needs to find the end of something, but the preprocessor makes it possible for there to be two ends, and TextMate can't handle conditional endings.
However, one improvement that probably can be made, is that the macros should not include any of the TextMate range patterns. This is because if they do, they can screw up the entire rest of the file.
Example code
int main() {
if constexpr(std::is_signed_v<char>>) { // no syntax highlighting
}
}
The entirety of constexpr(std::is_signed_v<char>>) { // no syntax highlighting
has the scope of meta.function-call
.
Additionally, the developer tools console has the error [2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing
.
Neither the begin
or end
of the range pattern for "c_function_call"
consume any characters. Per microsoft/vscode-textmate#12 VSCode has limited support for zero width range matches.
The grammar causes visual studio code to have a type error in the form of [renderer1] [error] Cannot create property 'id' on string 't': TypeError: Cannot create property 'id' on string 't'
git-bisect
has determined that the offending commit is 216543b. The issue is found in VSCode 1.32 and insiders as well as the standalone https://github.com/Microsoft/vscode-textmate/ package. The type error seems to have little if any impact on the actual application of scopes, It does however seem to occasionally cause the theme to not be applied.
example:
namespace test {
class test {
test(){};
};
} // namespace test
From #45
Effects: C
The code fragment struct f foo
has incorrect highlighting. f
has the scope source.c
when it should have entity.name.type.c source.c
struct f foo;
int func() {
struct f foo;
}
const char * a = "foo ??/" ??/??/";
#pragma once
#include <type_traits>
#define IsPointDef(...) \
template<> \
struct IsPoint<__VA_ARGS__> \
{\
static const bool isPoint = true;\
}
#define ArrayBasedPointDef(T) \
IsPointDef(T); \
template<> \
struct IsArrayBasedPoint<T>:public std::true_type \
{};
#define XYBasedPointDef(T) \
IsPointDef(T); \
template<> \
struct IsXYBasedPoint<T>:public std::true_type \
{};
#define TypeTAndUIsPoint \
template<typename T, typename U, class = typename std::enable_if<IsPoint<T>::isPoint>::type, class = typename std::enable_if<IsPoint<U>::isPoint>::type>
namespace Navigation
{
namespace Utils
{
template<typename T>
struct IsPoint
{
static const bool isPoint = false;
};
template<typename T>
struct IsArrayBasedPoint
{
static const bool value = false;
};
template<typename T>
struct IsXYBasedPoint
{
static const bool value = false;
};
}
}
This is probably going to take awhile, but it needs to be done in order to prevent introducing new bugs when fixing old ones.
Normally unit tests are not so bad when written beforehand, but when there's already ~3000 lines of untested code its a bit more difficult.
struct foo {
int (*bar)();
};
union baz {
int (*quz)();
};
int (*bar) is tagged as a constructor
atom/language-c#236
For example:
std::string string1{"test"};
vector <int> v_name (3);
v_name is highlighted as function
From: #45
Effects: C, C++
In the declaration enum bar b;
, bar
has incorrect highlighting. bar
has the scope of source.{c,cpp}
, it should have the scope entity.name.type.{c,cpp} source.{c,cpp}
Example:
enum bar b;
int foo() {
enum bar b;
}
This issue is fixed for C++, but it hasn't been ported to C yet
atom/language-c#222
atom/language-c#70
atom/language-c#81
atom/language-c#169
class ClassA {
};
class ClassE final : public ClassA {
};
namespace foo {
class ClassF {
};
class ClassG {
};
}
class ClassH : public foo::ClassF, public foo::ClassG {
};
/**/ #define a cout << "this works :/\n";
Describe the bug
To Reproduce
class B
{};
class A :
public B
{};
Expected behavior
The 'public' keyword should be colorized regardless if there is a linebreak or not.
Additional context
This issue exists with default VS code highlighting as well.
Describe the bug
To Reproduce
class C
{
public :
};
Expected behavior
The keyword shall be colored regardless of space between the keyword and colon.
Additional context
This issue exists with default VS code highlighting as well. I'm not sure if it's syntactically correct, but it compiles on GCC/clang.
Currently there is no special coloring for these keywords: https://en.cppreference.com/w/cpp/language/operator_alternative
and, and_eq, bitand, bitor, compl etc.
Similar to #37 after a C++ attribute [[fallthrough]]
,[[nodiscard]]
, etc. Syntax highlighting breaks until {
.
Example
switch(test) {
case 1:
break;
case 2: [[fallthrough]];
case 3: break; // no syntax highlighting
}
void func1();
[[noreturn]] void func2(/*syntax highlighting*/); // no syntax highlighting
struct st { // syntax highlighting works now
};
void func3();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.