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

Keyword autocompletion #2975

Merged
merged 20 commits into from Aug 2, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

implemented auto-completion for all keywords

  • Loading branch information...
RomitKumar committed Jul 6, 2019
commit 0720ea124f5a5eed93ac4f1c482ef4ef0f29f71d
@@ -44,7 +44,8 @@ AbstractNode *GroupModule::instantiate(const Context *ctx, const ModuleInstantia

void register_builtin_group()
{
std::list<std::string> group;
group.push_back("group");
Builtins::init("group", new GroupModule(), group);
Builtins::init("group", new GroupModule(),
{
"group",
});
}
@@ -23,32 +23,6 @@ void Builtins::init(const std::string &name, class AbstractModule *module)
Builtins::instance()->modules.emplace(name, module);
}

void Builtins::init(const std::string &name, class AbstractFunction *function)
{
#ifndef ENABLE_EXPERIMENTAL
if (function->is_experimental()) return;
#endif
Builtins::instance()->functions.emplace(name, function);
}

void Builtins::init(const std::string &name, class AbstractModule *module, const std::list<std::string> &calltipList)
{
#ifndef ENABLE_EXPERIMENTAL
if (module->is_experimental()) return;
#endif
Builtins::instance()->modules.emplace(name, module);
// keywordList[name] = calltipList;
}

void Builtins::init(const std::string &name, class AbstractFunction *function, const std::list<std::string> &calltipList)
{
#ifndef ENABLE_EXPERIMENTAL
if (function->is_experimental()) return;
#endif
Builtins::instance()->functions.emplace(name, function);
// Builtins::keywordList[name] = calltipList;
}

void Builtins::init(const std::string &name, class AbstractModule *module, const std::vector<std::string> &calltipList)
{
#ifndef ENABLE_EXPERIMENTAL
@@ -14,9 +14,6 @@ class Builtins

static Builtins *instance(bool erase = false);
static void init(const std::string &name, class AbstractModule *module);
static void init(const std::string &name, class AbstractFunction *function);
static void init(const std::string &name, class AbstractModule *module, const std::list<std::string> &calltipList);
static void init(const std::string &name, class AbstractFunction *function, const std::list<std::string> &calltipList);
static void init(const std::string &name, class AbstractModule *module, const std::vector<std::string> &calltipList);
static void init(const std::string &name, class AbstractFunction *function, const std::vector<std::string> &calltipList);
void initialize();
@@ -143,17 +143,20 @@ std::string CgaladvNode::toString() const

void register_builtin_cgaladv()
{
std::list<std::string> minkowski;
minkowski.push_back("minkowski()");
Builtins::init("minkowski", new CgaladvModule(CgaladvType::MINKOWSKI), minkowski);

std::list<std::string> hull;
hull.push_back("hull()");
Builtins::init("hull", new CgaladvModule(CgaladvType::HULL), hull);

std::list<std::string> resize;
resize.push_back("resize(newsize = [x, y, z])");
resize.push_back("resize(newsize = [x, y, z], auto = boolean)");
resize.push_back("resize(newsize = [x, y, z], auto = [boolean, boolean, boolean])");
Builtins::init("resize", new CgaladvModule(CgaladvType::RESIZE), resize);
Builtins::init("minkowski", new CgaladvModule(CgaladvType::MINKOWSKI),
{
"minkowski()",
});

Builtins::init("hull", new CgaladvModule(CgaladvType::HULL),
{
"hull()",
});

Builtins::init("resize", new CgaladvModule(CgaladvType::RESIZE),
{
"resize(newsize = [x, y, z])",
"resize(newsize = [x, y, z], auto = boolean)",
"resize(newsize = [x, y, z], auto = [boolean, boolean, boolean])",
});
}
@@ -311,10 +311,11 @@ std::string ColorNode::name() const

void register_builtin_color()
{
std::list<std::string> color;
color.push_back("color(c = [r, g, b, a])");
color.push_back("color(c = [r, g, b], alpha = 1.0)");
color.push_back("color(\"#hexvalue\")");
color.push_back("color(\"colorname\", 1.0)");
Builtins::init("color", new ColorModule(), color);
Builtins::init("color", new ColorModule(),
{
"color(c = [r, g, b, a])",
"color(c = [r, g, b], alpha = 1.0)",
"color(\"#hexvalue\")",
"color(\"colorname\", 1.0)",
});
}
@@ -339,49 +339,58 @@ AbstractNode *ControlModule::instantiate(const Context* ctx, const ModuleInstant

void register_builtin_control()
{
std::list<std::string> child;
child.push_back("child()");
child.push_back("child(number)");
Builtins::init("child", new ControlModule(ControlModule::Type::CHILD), child);

std::list<std::string> children;
children.push_back("childern()");
children.push_back("childern(number)");
children.push_back("childern([start : step : end])");
children.push_back("childern([start : end])");
children.push_back("childern([vector])");
Builtins::init("children", new ControlModule(ControlModule::Type::CHILDREN), children);

std::list<std::string> echo;
echo.push_back("echo(arg, ...)");
Builtins::init("echo", new ControlModule(ControlModule::Type::ECHO), echo);

std::list<std::string> assert;
assert.push_back("assert(boolean)");
assert.push_back("assert(boolean, string)");
Builtins::init("assert", new ControlModule(ControlModule::Type::ASSERT), assert);

std::list<std::string> assign;
assign.push_back("assign(var = value, ...)");
Builtins::init("assign", new ControlModule(ControlModule::Type::ASSIGN), assign);

std::list<std::string> for_;
for_.push_back("for(variable = [start : increment : end])");
for_.push_back("for(variable = [start : end])");
for_.push_back("for(variable = [vector])");
Builtins::init("for", new ControlModule(ControlModule::Type::FOR), for_);

std::list<std::string> let;
let.push_back("let(var = value, ...) expression");
Builtins::init("let", new ControlModule(ControlModule::Type::LET), let);

std::list<std::string> intersection_for;
intersection_for.push_back("intersection_for(variable = [start : increment : end])");
intersection_for.push_back("intersection_for(variable = [start : end])");
intersection_for.push_back("intersection_for(variable = [vector])");
Builtins::init("intersection_for", new ControlModule(ControlModule::Type::INT_FOR), intersection_for);

std::list<std::string> if_;
if_.push_back("if(boolean)");
Builtins::init("if", new ControlModule(ControlModule::Type::IF), if_);
Builtins::init("child", new ControlModule(ControlModule::Type::CHILD),
This conversation was marked as resolved by t-paul

This comment has been minimized.

Copy link
@t-paul

t-paul Jul 29, 2019

Member

As child() is deprecated, we probably don't want to show calltips same as with the import_* modules.

{
"child()",
"child(number)",
});

Builtins::init("children", new ControlModule(ControlModule::Type::CHILDREN),
{
"children()",
"children(number)",
"children([start : step : end])",
"children([start : end])",
"children([vector])",
});

Builtins::init("echo", new ControlModule(ControlModule::Type::ECHO),
{
"echo(arg, ...)",
});

Builtins::init("assert", new ControlModule(ControlModule::Type::ASSERT),
{
"assert(boolean)",
"assert(boolean, string)",
});

Builtins::init("assign", new ControlModule(ControlModule::Type::ASSIGN),
{
"assign(var = value, ...)",
});

Builtins::init("for", new ControlModule(ControlModule::Type::FOR),
{
"for(variable = [start : increment : end])",
"for(variable = [start : end])",
"for(variable = [vector])",
});

Builtins::init("let", new ControlModule(ControlModule::Type::LET),
{
"let(var = value, ...) expression",
});

Builtins::init("intersection_for", new ControlModule(ControlModule::Type::INT_FOR),
{
"intersection_for(variable = [start : increment : end])",
"intersection_for(variable = [start : end])",
"intersection_for(variable = [vector])",
});

Builtins::init("if", new ControlModule(ControlModule::Type::IF),
{
"if(boolean)",
});
}
@@ -76,16 +76,19 @@ std::string CsgOpNode::name() const

void register_builtin_csgops()
{
std::list<std::string> union_;
union_.push_back("union()");
Builtins::init("union", new CsgModule(OpenSCADOperator::UNION), union_);
Builtins::init("union", new CsgModule(OpenSCADOperator::UNION),
{
"union()",
});

std::list<std::string> difference;
difference.push_back("difference()");
Builtins::init("difference", new CsgModule(OpenSCADOperator::DIFFERENCE), difference);
Builtins::init("difference", new CsgModule(OpenSCADOperator::DIFFERENCE),
{
"difference()",
});

std::list<std::string> intersection;
intersection.push_back("intersection()");
Builtins::init("intersection", new CsgModule(OpenSCADOperator::INTERSECTION), intersection);
Builtins::init("intersection", new CsgModule(OpenSCADOperator::INTERSECTION),
{
"intersection()",
});
}

@@ -248,11 +248,13 @@ ValuePtr builtin_dxf_cross(const Context *ctx, const EvalContext *evalctx)

void initialize_builtin_dxf_dim()
{
std::list<std::string> dxf_dim;
dxf_dim.push_back("dxf_dim()");
Builtins::init("dxf_dim", new BuiltinFunction(&builtin_dxf_dim), dxf_dim);
Builtins::init("dxf_dim", new BuiltinFunction(&builtin_dxf_dim),
{
"dxf_dim()",
});

std::list<std::string> dxf_cross;
dxf_cross.push_back("dxf_cross()");
Builtins::init("dxf_cross", new BuiltinFunction(&builtin_dxf_cross), dxf_cross);
Builtins::init("dxf_cross", new BuiltinFunction(&builtin_dxf_cross),
{
"dxf_cross()",
});
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.