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": [
{
"id": "QuicklyGenerator.StructSelected",
"description": "Background decoration color for large numbers",
"description": "Background decoration color for struct selected",
"defaults": {
"dark": "#3bcf1655",
"light": "#d45b0a55",
@ -40,7 +40,7 @@
"commands": [
{
"command": "Go-Quickly-Generator.Go-Gen-GetSet",
"title": "Generator Get Set",
"title": "Go: Generate Get Set",
"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 => {
console.log(items);
if(items) {
if (items) {
let myitems = items as any as string[];
let gtype = GeneratorType.Unknown;
myitems.forEach((value) => {
@ -115,7 +115,7 @@ function activate(context: vscode.ExtensionContext) {
}
let editor = vscode.window.activeTextEditor;
if(editor) {
if (editor) {
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" };
var items: vscode.QuickPickItem[] = [];
var obj = {
info: sinfo,
exists: existsStructFunctions,
items: function () {
fields2items: function () {
this.info.Fields.forEach((value, key) => {
if (this.exists.has(key)) {
vscode.window.showInformationMessage("Get" + key + " or Set" + key + " is Exists");
@ -191,7 +193,8 @@ function GeneratorSetGet(sinfo: StructInfo, stype: GeneratorType) {
},
pick: function () {
this.items();
this.fields2items();
if (items.length) {
vscode.window.showQuickPick(items, options).then((item) => {
if (item) {
let fields = item as any as vscode.QuickPickItem[];
@ -231,6 +234,7 @@ function GeneratorSetGet(sinfo: StructInfo, stype: GeneratorType) {
}
});
}
}
};
obj.pick();
@ -245,11 +249,9 @@ function GetStruct(): StructInfo | undefined {
return;
}
let selection = editor.selection;
// vscode.window.showInformationMessage( editor.document.version.toString() );
// vscode.window.showInformationMessage( text );
let selectline = selection.active.line;
let regex = "type +([^ ]+) +struct";
// lineText.text.match()
for (let i = selectline; i >= 0; i--) {
let lineText = editor.document.lineAt(i);
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) {
// }
// this method is called when your extension is deactivated
function deactivate() { }
function deactivate() {
}
exports.deactivate = deactivate;

View File

@ -45,7 +45,7 @@ func (ms *MyStruct2) GetValue() int {
return ms.Value
}
// DoFunc 非常丑陋
// DoFunc 非常丑陋的兼容
func DoFunc(a func(
a int,
b struct {
@ -58,64 +58,16 @@ func DoFunc(a func(
// ExStruct 升级
type ExStruct struct {
ChildStruct struct {
A int
B interface{}
age int
Height interface{}
girl string
boy int
}
C string
D func(a int, b string)
Age string
Do func(a int, b 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() {
a := ExStruct{}
b := MyStruct{}