Description
What we've got
- LeetCode problem's
templateMeta
property from GraphQL API:
"templateMeta": {
"name": "addTwoNumbers",
"params": [
{
"name": "l1",
"type": "ListNode",
"dealloc": false
},
{
"name": "l2",
"type": "ListNode",
"dealloc": false
}
],
"return": {
"type": "ListNode",
"dealloc": true
}
}
- Pre- and Post- Solution code template in cpp.
I've written a bunch of robust code in this gist. To successfully build a solution, we should provide:- solution code file
solution.h
. - metadata of the problem
meta.h
:
- solution code file
#ifndef __CLASS
#define __CLASS(name, ...)
#endif
#ifndef __METHOD
#define __METHOD(name, ...)
#endif
__CLASS(Solution);
__METHOD(inorderTraversal, vector<int>, TreeNode*);
#undef __CLASS
#undef __METHOD
#define __TREE_NODE
//#define __SYSTEM_DESIGN
The meta code could be generated by templateMeta
from the extension side.
vscode-cpptool-api
package:
This is not the cpptool
extension, but its api package, from which we can provide custom configuration of our currently writing code.
e.g., we can force-include pre-solution.h
in the solution.h
to provide proper intellisense.
What we may need
- A proper folder structure of leetcode problem files.
I suggest we keep everything about leetcode extension in ~/.leetcode
, or somewhere specified by user in settings, rather than an arbitrary workspace. All the files inside the root should be managed by extension, and user intervention should be reduced as little as possible.
-
How to organize the dependency with each other language tools? Users only need a small set of languages to write leetcode solutions.
-
How to trigger the debugger through a WebView, and feed the testcase data from a WebView textbox?
-
...