Release 1.0.0

This commit is contained in:
huangsimin 2019-10-14 10:45:25 +08:00
parent c9db603737
commit 41108de00e
3 changed files with 70 additions and 114 deletions

View File

@ -29,7 +29,7 @@
"colors": [ "colors": [
{ {
"id": "QuicklyGenerator.StructSelected", "id": "QuicklyGenerator.StructSelected",
"description": "Background decoration color for large numbers", "description": "Background decoration color for struct selected",
"defaults": { "defaults": {
"dark": "#3bcf1655", "dark": "#3bcf1655",
"light": "#d45b0a55", "light": "#d45b0a55",
@ -40,7 +40,7 @@
"commands": [ "commands": [
{ {
"command": "Go-Quickly-Generator.Go-Gen-GetSet", "command": "Go-Quickly-Generator.Go-Gen-GetSet",
"title": "Generator Get Set", "title": "Go: Generate Get Set",
"category": "go-quickly-generator" "category": "go-quickly-generator"
} }
], ],

View File

@ -100,7 +100,7 @@ function activate(context: vscode.ExtensionContext) {
vscode.window.showQuickPick(["Getter", "Setter"], <vscode.QuickPickOptions>{ canPickMany: true, placeHolder: "select generator type getter or setter" }).then(items => { vscode.window.showQuickPick(["Getter", "Setter"], <vscode.QuickPickOptions>{ canPickMany: true, placeHolder: "select generator type getter or setter" }).then(items => {
console.log(items); console.log(items);
if(items) { if (items) {
let myitems = items as any as string[]; let myitems = items as any as string[];
let gtype = GeneratorType.Unknown; let gtype = GeneratorType.Unknown;
myitems.forEach((value) => { myitems.forEach((value) => {
@ -115,7 +115,7 @@ function activate(context: vscode.ExtensionContext) {
} }
let editor = vscode.window.activeTextEditor; let editor = vscode.window.activeTextEditor;
if(editor) { if (editor) {
editor.setDecorations(dtype, []); editor.setDecorations(dtype, []);
} }
}); });
@ -173,10 +173,12 @@ function GeneratorSetGet(sinfo: StructInfo, stype: GeneratorType) {
const options = <vscode.QuickPickOptions>{ canPickMany: true, placeHolder: "select the fields that would be generator get set" }; const options = <vscode.QuickPickOptions>{ canPickMany: true, placeHolder: "select the fields that would be generator get set" };
var items: vscode.QuickPickItem[] = []; var items: vscode.QuickPickItem[] = [];
var obj = { var obj = {
info: sinfo, info: sinfo,
exists: existsStructFunctions, exists: existsStructFunctions,
items: function () {
fields2items: function () {
this.info.Fields.forEach((value, key) => { this.info.Fields.forEach((value, key) => {
if (this.exists.has(key)) { if (this.exists.has(key)) {
vscode.window.showInformationMessage("Get" + key + " or Set" + key + " is Exists"); vscode.window.showInformationMessage("Get" + key + " or Set" + key + " is Exists");
@ -191,7 +193,8 @@ function GeneratorSetGet(sinfo: StructInfo, stype: GeneratorType) {
}, },
pick: function () { pick: function () {
this.items(); this.fields2items();
if (items.length) {
vscode.window.showQuickPick(items, options).then((item) => { vscode.window.showQuickPick(items, options).then((item) => {
if (item) { if (item) {
let fields = item as any as vscode.QuickPickItem[]; let fields = item as any as vscode.QuickPickItem[];
@ -231,6 +234,7 @@ function GeneratorSetGet(sinfo: StructInfo, stype: GeneratorType) {
} }
}); });
} }
}
}; };
obj.pick(); obj.pick();
@ -245,11 +249,9 @@ function GetStruct(): StructInfo | undefined {
return; return;
} }
let selection = editor.selection; let selection = editor.selection;
// vscode.window.showInformationMessage( editor.document.version.toString() );
// vscode.window.showInformationMessage( text );
let selectline = selection.active.line; let selectline = selection.active.line;
let regex = "type +([^ ]+) +struct"; let regex = "type +([^ ]+) +struct";
// lineText.text.match()
for (let i = selectline; i >= 0; i--) { for (let i = selectline; i >= 0; i--) {
let lineText = editor.document.lineAt(i); let lineText = editor.document.lineAt(i);
let matchs = lineText.text.match(regex); let matchs = lineText.text.match(regex);
@ -384,5 +386,7 @@ function getFieldRange(editor: vscode.TextEditor, pair: string[], startline: num
// export function getStruct(editor: vscode.TextEditor) { // export function getStruct(editor: vscode.TextEditor) {
// } // }
// this method is called when your extension is deactivated // this method is called when your extension is deactivated
function deactivate() { } function deactivate() {
}
exports.deactivate = deactivate; exports.deactivate = deactivate;

View File

@ -45,7 +45,7 @@ func (ms *MyStruct2) GetValue() int {
return ms.Value return ms.Value
} }
// DoFunc 非常丑陋 // DoFunc 非常丑陋的兼容
func DoFunc(a func( func DoFunc(a func(
a int, a int,
b struct { b struct {
@ -58,64 +58,16 @@ func DoFunc(a func(
// ExStruct 升级 // ExStruct 升级
type ExStruct struct { type ExStruct struct {
ChildStruct struct { ChildStruct struct {
A int age int
B interface{} Height interface{}
girl string girl string
boy int boy int
} }
C string Age string
D func(a int, b string) Do func(a int, b string)
child string child string
} }
// GetChildStructBoy Get return boy int
func (es *ExStruct) GetChildStructBoy() int {
return es.ChildStruct.boy
}
// SetChildStructBoy Set boy int
func (es *ExStruct) SetChildStructBoy(boy int) {
es.ChildStruct.boy = boy
}
// GetChildStructGirl Get return girl string
func (es *ExStruct) GetChildStructGirl() string {
return es.ChildStruct.girl
}
// SetChildStructGirl Set girl string
func (es *ExStruct) SetChildStructGirl(girl string) {
es.ChildStruct.girl = girl
}
// GetChildStructGirl
// GetChildStructB Get return B interface{}
func (es *ExStruct) GetChildStructB() interface{} {
return es.ChildStruct.B
}
// SetChildStructB Set B interface{}
func (es *ExStruct) SetChildStructB(B interface{}) {
es.ChildStruct.B = B
}
// SetChildStructA set
func (es *ExStruct) SetChildStructA(a int) {
es.ChildStruct.A = a
}
// GetChildStructA get
func (es *ExStruct) GetChildStructA() int {
return es.ChildStruct.A
}
// GetC get
func (es *ExStruct) GetC(a int) {
es.ChildStruct.A = a
}
func main() { func main() {
a := ExStruct{} a := ExStruct{}
b := MyStruct{} b := MyStruct{}