Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cpp support #84

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/symbols-list-regex.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ module.exports =
todo: /#[ ]*todo\:[ ]*(.+?)[ ]*(?:\r\n|\n)/gmi
fixme: /#[ ]*fixme\:[ ]*(.+?)[ ]*(?:\r\n|\n)/gmi
hack: /#[ ]*hack\:[ ]*(.+?)[ ]*(?:\r\n|\n)/gmi
cpp:
regex:
class: /^[^\S\n]*class[\W]+(\w+)[\s{]/gmi
struct: /^[^\S\n]*struct[\W]+(\w+)[\s{]/gmi
enum: /^[^\S\n]*enum[\W]+(\w+)[\s{]/gmi
union: /^[^\S\n]*union[\W]+(\w+)[\s{]/gmi
function: /^[^\S\n]*(?:(?:\w+::)*\w+\s+)+(\w+)\s*\([^)]*\)\s*(?::{1}|[^;])[^{;]*[\s{]/gmi
method: /^[^\S\n]*(?:(?:\w+::)*\w+\s+)+(\w+::\w+)\s*\([^)]*\)\s*(?::{1}|[^;])[^{;]*[\s{]/gmi
todo: /\/\/[ ]*todo\:[ ]*(.+?)[ ]*(?:\r\n|\n)/gmi
fixme: /\/\/[ ]*fixme\:[ ]*(.+?)[ ]*(?:\r\n|\n)/gmi
hack: /\/\/[ ]*hack\:[ ]*(.+?)[ ]*(?:\r\n|\n)/gmi
ruby:
regex:
attr: /^[ ]*(?:attr_reader|attr_writer|attr_accessor)[ ]+([^ \n\r]+)/gmi
Expand Down
18 changes: 18 additions & 0 deletions styles/symbols-list.less
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@
.symbols-list .list-item-class::before,
.symbols-list .list-item-class_named_expression::before,
.symbols-list .list-item-class_expression::before{ content: "C"; color: #FFF;}
.symbols-list .list-item-struct,
.symbols-list .list-item-struct_named_expression,
.symbols-list .list-item-struct_expression{ background: #ee8a1e }
.symbols-list .list-item-struct::before,
.symbols-list .list-item-struct_named_expression::before,
.symbols-list .list-item-struct_expression::before{ content: "S"; color: #FFF;}
.symbols-list .list-item-enum,
.symbols-list .list-item-enum_named_expression,
.symbols-list .list-item-enum_expression{ background: #ee8a1e }
.symbols-list .list-item-enum::before,
.symbols-list .list-item-enum_named_expression::before,
.symbols-list .list-item-enum_expression::before{ content: "E"; color: #FFF;}
.symbols-list .list-item-union,
.symbols-list .list-item-union_named_expression,
.symbols-list .list-item-union_expression{ background: #ee8a1e }
.symbols-list .list-item-union::before,
.symbols-list .list-item-union_named_expression::before,
.symbols-list .list-item-union_expression::before{ content: "U"; color: #FFF;}
.symbols-list .list-item-module{ background: #ee8a1e }
.symbols-list .list-item-module::before{ content: "M"; color: #FFF;}
.symbols-list .list-item-constant{ background: #484748 }
Expand Down
42 changes: 42 additions & 0 deletions tests/source/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <iostream>

struct Foo1 {
int a = 0;
};

union Foo2 {
int a = 0;
};

enum Foo3 {a,b,c}; //TODO: Add more

class Foo4{
public:
Foo4(int n1, int n2) {
a = n1;
b = n2;
}
int getA();
int getB();
private:
int a;
int b;
};

int Foo4::getA() {
return a;
}

int Foo4::getB() {
return a; //FIXME: Return b
}

int sum(int x, int y) {
return x+y;
}

int main(int argc, char const *argv[]) {
Foo4 f(5,4);
std::cout << sum(f.getA(), f.getB()) << std::endl;
return 0; //HACK: Use symbols-list
}