预发布.

This commit is contained in:
eson 2019-10-14 02:45:38 +08:00
parent 7a53ca4d8c
commit c9db603737
3 changed files with 145 additions and 109 deletions

View File

@ -26,6 +26,17 @@
]
}
],
"colors": [
{
"id": "QuicklyGenerator.StructSelected",
"description": "Background decoration color for large numbers",
"defaults": {
"dark": "#3bcf1655",
"light": "#d45b0a55",
"highContrast": "#9806db55"
}
}
],
"commands": [
{
"command": "Go-Quickly-Generator.Go-Gen-GetSet",

View File

@ -55,10 +55,8 @@ class Field {
this.Parent = parent;
this.Type = type;
this.Name = name;
this.Range = range;
this.Range = range
this.Key = (this.Parent.substr(1) + this.Name[0].toUpperCase() + this.Name.substr(1)).replace(new RegExp("\\.", "g"), "");
// TODO: 大小写Map的问题
}
toString(): string {
@ -69,6 +67,11 @@ class Field {
let typeMap = new Map<string, GeneratorType>();
let typeCharMap = new Map<GeneratorType, string>();
const dtype = vscode.window.createTextEditorDecorationType({
cursor: 'crosshair',
backgroundColor: { id: 'QuicklyGenerator.StructSelected' }
});
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context: vscode.ExtensionContext) {
@ -88,43 +91,45 @@ function activate(context: vscode.ExtensionContext) {
// The code you place here will be executed every time your command is executed
// Display a message box to the user
let sinfo = GetStruct();
if(sinfo) {
let editor = vscode.window.activeTextEditor;
if (sinfo && editor) {
let decoration = <vscode.DecorationOptions>{ range: new vscode.Range(sinfo.Range[0], 0, sinfo.Range[1] + 1, 0) };
editor.setDecorations(dtype, [decoration]);
vscode.window.showQuickPick(["Getter", "Setter"], <vscode.QuickPickOptions>{ canPickMany: true, placeHolder: "select generator type getter or setter" }).then(items => {
console.log(items);
if(items) {
let myitems = items as any as string[];
let t = GeneratorType.Unknown;
let gtype = GeneratorType.Unknown;
myitems.forEach((value) => {
let sel = typeMap.get(value);
if (sel) {
t = t | sel;
gtype = gtype | sel;
}
});
if (sinfo) {
GeneratorSetGet(sinfo, t);
GeneratorSetGet(sinfo, gtype);
}
}
let editor = vscode.window.activeTextEditor;
if(editor) {
editor.setDecorations(dtype, []);
}
});
// GeneratorSetGet(sinfo, GeneratorType.Getter | GeneratorType.Setter);
} else {
vscode.window.showErrorMessage("there is no struct(go) to focus. you can move point to struct(go)");
}
}));
// context.subscriptions.push(vscode.languages.registerCodeActionsProvider(
// "go", new Provider(), { providedCodeActionKinds: [vscode.CodeActionKind.Source] }
// ));
context.subscriptions.push(vscode.commands.registerCommand('Go-Quickly-Generator.Getter', function () {
let editor = vscode.window.activeTextEditor;
if (editor !== undefined) {
const currentPos = editor.selection.active;
const lineCount = editor.document.lineCount;
// let selection = editor.selection;
// let lineText = editor.document.lineAt(selection.active);
// vscode.window.showInformationMessage( lineText.text );
}
}));
}
function getAbbreviation(name: string): string | undefined {

View File

@ -25,6 +25,26 @@ type MyStruct2 struct {
S struct{ A struct{ C interface{} } }
}
// SetSAC Set C interface{}
func (ms *MyStruct2) SetSAC(C interface{}) {
ms.S.A.C = C
}
// GetKey Get return Key string
func (ms *MyStruct2) GetKey() string {
return ms.Key
}
// SetKey Set Key string
func (ms *MyStruct2) SetKey(Key string) {
ms.Key = Key
}
// GetValue Get return Value int
func (ms *MyStruct2) GetValue() int {
return ms.Value
}
// DoFunc 非常丑陋
func DoFunc(a func(
a int,