| 1 | package main |
|---|---|
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "go/build" |
| 6 | subselImp "go_viewer_test/test_files/sel/subsel" |
| 7 | ) |
| 8 | |
| 9 | type CompisiteScopeType int |
| 10 | |
| 11 | const ( |
| 12 | CompisiteScopeTop CompisiteScopeType = 0 |
| 13 | CompisiteScopeNon CompisiteScopeType = 1 |
| 14 | CompisiteScopeFuncDecl CompisiteScopeType = 2 |
| 15 | CompisiteScopeTypeDecl CompisiteScopeType = 3 |
| 16 | CompisiteScopeTypeRecv CompisiteScopeType = 4 |
| 17 | CompisiteScopeStructAssign CompisiteScopeType = 5 |
| 18 | CompisiteScopeRangeStmt CompisiteScopeType = 6 |
| 19 | |
| 20 | ScopePathSep = ":" |
| 21 | ScopeDefineSep = "." |
| 22 | ScopePackageName = "pkg" |
| 23 | |
| 24 | ScopeBlockStmt = "BlockStmt" |
| 25 | ScopeRangeStmt = "RangeStmt" |
| 26 | ScopeElts = "Elts" |
| 27 | ) |
| 28 | |
| 29 | var test string = "test" |
| 30 | |
| 31 | var ignoreVendor build.ImportMode |
| 32 | |
| 33 | type TestStructSubMethod struct { |
| 34 | methodTest string |
| 35 | Build *build.Context |
| 36 | FindPackage func(ctxt *build.Context, importPath, fromDir string, mode build.ImportMode) (*build.Package, error) |
| 37 | } |
| 38 | |
| 39 | func (ts TestStructSubMethod) testSelCopy() string { |
| 40 | stt := ts.methodTest |
| 41 | return stt |
| 42 | } |
| 43 | |
| 44 | func (ts TestStructSubMethod) build() *build.Context { |
| 45 | return &build.Default |
| 46 | } |
| 47 | |
| 48 | type TestStructKey struct { |
| 49 | A string |
| 50 | B int |
| 51 | C TestStructSub |
| 52 | TestASN string |
| 53 | } |
| 54 | |
| 55 | type TestStructSub struct { |
| 56 | TestStructSubMethodMap map[string]*TestStructSubMethod // ast file map |
| 57 | TestStructSubMethodMapMap map[subselImp.TestStruct]map[string]map[string]*TestStructSubMethod // ast file map |
| 58 | TestStructSubMethodKeyMap map[*subselImp.TestStruct]*TestStructSubMethod // ast file map |
| 59 | |
| 60 | EEEEEEEEEEE string |
| 61 | F int |
| 62 | |
| 63 | Sub *TestStructSubSub |
| 64 | SubArray []TestStructSubSub |
| 65 | } |
| 66 | |
| 67 | func (ts *TestStructSub) SayGood(sts *subselImp.TestStructOther) (b *TestStructSub, d *subselImp.TestStructOther, e TestStructSubSub) { |
| 68 | |
| 69 | var testStructSubMethodMapC []*subselImp.TestStructOther |
| 70 | for index, item := range testStructSubMethodMapC { |
| 71 | fmt.Printf("%d, %s", index, item.A) |
| 72 | } |
| 73 | |
| 74 | var testStructSubMethodArray []*TestStructSubMethod |
| 75 | for index, item := range testStructSubMethodArray { |
| 76 | fmt.Printf("%d, %s", index, item.methodTest) |
| 77 | } |
| 78 | |
| 79 | fmt.Printf("%d %s", (int)(CompisiteScopeTop), ScopeRangeStmt) |
| 80 | ts.Sub.SayGood("") |
| 81 | for _, item := range ts.TestStructSubMethodMapMap { |
| 82 | fmt.Printf("%d", len(item)) |
| 83 | for index1, item1 := range item { |
| 84 | fmt.Printf("%s, %d", index1, len(item1)) |
| 85 | |
| 86 | for index2, item2 := range item1 { |
| 87 | fmt.Printf("%s, %s", index2, item2.methodTest) |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | for index, item := range ts.TestStructSubMethodMap { |
| 92 | fmt.Printf("%d, %s", index, item.methodTest) |
| 93 | } |
| 94 | var testStructSubMethodMap map[string]*TestStructSubMethod |
| 95 | for index, item := range testStructSubMethodMap { |
| 96 | fmt.Printf("%d, %s", index, item.methodTest) |
| 97 | } |
| 98 | //testStructSubMethodMapB := &testStructSubMethodMap //make(map[subselImp.TestStructOther]*subselImp.TestStructOther) |
| 99 | //testStructSubMethodMapC := make(map[subselImp.TestStructOther]*subselImp.TestStructOther) |
| 100 | for index, item := range testStructSubMethodMapC { |
| 101 | fmt.Printf("%d, %s", index, item.A) |
| 102 | } |
| 103 | |
| 104 | rtnSubsetOther := &subselImp.TestStructOther{} |
| 105 | rtnSubsetOtherStar := subselImp.TestStructOther{} |
| 106 | rtnSubsetOtherB := *rtnSubsetOther |
| 107 | rtnSubsetOtherG := &rtnSubsetOtherStar |
| 108 | rtnSubsetOtherH := rtnSubsetOther |
| 109 | rtnSubsetOtherH.SayGood2("") |
| 110 | rtnSubsetOtherB.SayGood("") |
| 111 | rtnSubsetOtherG.SayGood2("") |
| 112 | rtnSubsetOtherC := "" |
| 113 | rtnSubsetOtherD := 100 |
| 114 | rtnSubsetOtherE := TestStructSub{} |
| 115 | rtnSubsetOtherF := &TestStructSub{} |
| 116 | fmt.Printf("%s %d", rtnSubsetOtherC, rtnSubsetOtherD) |
| 117 | rtnSubsetOtherE.SayGood2("") |
| 118 | rtnSubsetOtherF.SayGood2("") |
| 119 | |
| 120 | sts.SayGoodXXBB("") |
| 121 | d.SayGoodXXBB("") |
| 122 | b.TestStructSubBB("") |
| 123 | |
| 124 | tst := ts.TestStructSub("") |
| 125 | |
| 126 | fmt.Printf("hello good %s", ts.EEEEEEEEEEE[0:len(tst.EEEEEEEEEEE)-1]) |
| 127 | subselImp := subselImp.SayGoodTestWhile("") |
| 128 | { |
| 129 | subselImp := subselImp.SayGoodTestStruct("") |
| 130 | subselImp.SayGood("") |
| 131 | fmt.Println(subselImp) |
| 132 | { |
| 133 | subselImp := subselImp.A |
| 134 | fmt.Printf("%s %s", subselImp, rtnSubsetOther.A) |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return nil, rtnSubsetOther, TestStructSubSub{} |
| 139 | } |
| 140 | |
| 141 | func SayGood(sts *subselImp.TestStructOther) (b *TestStructSub, d *subselImp.TestStructOther, e TestStructSubSub) { |
| 142 | return &TestStructSub{}, &subselImp.TestStructOther{}, TestStructSubSub{} |
| 143 | } |
| 144 | |
| 145 | func (ts *TestStructSub) SayGood2(word string) *subselImp.TestStruct { |
| 146 | fmt.Printf("hello good %s %d", word, ts.F) |
| 147 | return nil |
| 148 | } |
| 149 | |
| 150 | func (ts *TestStructSub) TestStructSub(word string) TestStructSub { |
| 151 | return TestStructSub{} |
| 152 | } |
| 153 | |
| 154 | func (ts *TestStructSub) TestStructSubBB(word string) TestStructSub { |
| 155 | return TestStructSub{} |
| 156 | } |
| 157 | |
| 158 | func (ts *TestStructSub) TestStructOther(word string) subselImp.TestStructOther { |
| 159 | return subselImp.TestStructOther{} |
| 160 | } |
| 161 | |
| 162 | func (ts *TestStructSub) TestStructSubMethod(word string) TestStructSubMethod { |
| 163 | return TestStructSubMethod{} |
| 164 | } |
| 165 | |
| 166 | func main() { |
| 167 | TestPackageSayGood("") |
| 168 | GetTestStructSubMethod().SayGood("") |
| 169 | |
| 170 | var abc TestStructSub |
| 171 | test = abc.SubArray[0].SubSub.SubSubSub.SayGoodSubSubSub("").SubSubSubEEEE |
| 172 | testSub, testSubB, testSubC := SayGood(nil) |
| 173 | testSub.EEEEEEEEEEE = "tttt" |
| 174 | testSubB.B = 1 |
| 175 | testSubC.SubEEEE = "ss" |
| 176 | |
| 177 | testresult := abc.SayGood2("").SayGoodTest("").Sub.SayGood("") |
| 178 | fmt.Printf("test%s", testresult) |
| 179 | |
| 180 | abc.Sub.SubSub.SubSubSub.SubSubSubEEEE = "SUBEEEEEE" |
| 181 | |
| 182 | //TestASN := "" |
| 183 | ts := subselImp.TestStruct{ |
| 184 | TestASN: "", |
| 185 | B: 100, |
| 186 | } |
| 187 | ts.A = "bbbbb" |
| 188 | ts.SayGoodTest("hello") |
| 189 | /* |
| 190 | var abcd, aa TestStructSub |
| 191 | abcd.SayGood(test) |
| 192 | abcd.EEEEEEEEEEE = "tttt" |
| 193 | aa.Sub.SubF = 1 |
| 194 | |
| 195 | abc, efg := TestStructSub{}, TestStructSubSub{} |
| 196 | //var abc TestStructSub |
| 197 | abc.SayGood(test) |
| 198 | abc.F = 1 |
| 199 | |
| 200 | efg.SubEEEE = "" |
| 201 | efg.SayGood("") |
| 202 | |
| 203 | |
| 204 | */ |
| 205 | |
| 206 | //hello := "Hello" //test comment |
| 207 | //world := "World" // test comment |
| 208 | //words := []string{""} //[]string{hello /*testcomment*/, world /**test comment*/} |
| 209 | |
| 210 | TestPackageSelector("input") |
| 211 | if test == "" { |
| 212 | test = "" |
| 213 | test2 = "" |
| 214 | } |
| 215 | |
| 216 | //var abcIn TestStructSubSub |
| 217 | |
| 218 | //abcIn.SubEEEE = "feeeeeee" |
| 219 | |
| 220 | //SayHello(words) |
| 221 | //test = "" |
| 222 | //fmt.Print(test) |
| 223 | } |
| 224 | |
| 225 | func TestPackageSelector(str string) { |
| 226 | //SayHello([]string{""}) |
| 227 | test = "aaaa" |
| 228 | |
| 229 | a := 0 |
| 230 | a = 1 |
| 231 | { |
| 232 | a := 2 |
| 233 | if a == 2 { |
| 234 | a = 3 |
| 235 | } |
| 236 | } |
| 237 | if a == 3 { |
| 238 | a = 1 |
| 239 | } |
| 240 | test = str |
| 241 | |
| 242 | ts := subselImp.TestStruct{ |
| 243 | A: "aaaa", |
| 244 | B: 100, |
| 245 | } |
| 246 | |
| 247 | ts.B = 1000 |
| 248 | ts.C.E = "ttt" |
| 249 | ts.SayGood("sel hello") |
| 250 | |
| 251 | /* |
| 252 | { |
| 253 | ts := subsel.TestStruct{ |
| 254 | A: str, |
| 255 | B: 100, |
| 256 | } |
| 257 | ts.B = 1001 |
| 258 | |
| 259 | { |
| 260 | ts := subsel.TestStruct{ |
| 261 | A: str, |
| 262 | B: 100, |
| 263 | } |
| 264 | ts.B = 1001 |
| 265 | |
| 266 | { |
| 267 | ts := subsel.TestStruct{ |
| 268 | A: str, |
| 269 | B: 100, |
| 270 | } |
| 271 | ts.B = 1001 |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | */ |
| 276 | } |
| 277 | |
| 278 | /* |
| 279 | // SayHello says Hello |
| 280 | func SayHello(words []string) { |
| 281 | fmt.Println(joinStrings(words)) |
| 282 | } |
| 283 | |
| 284 | // joinStrings joins strings |
| 285 | func joinStrings(words []string) string { |
| 286 | return strings.Join(words, ", ") |
| 287 | } |
| 288 | */ |
| 289 | |
| 290 | type TestStructSubSubSubSub struct { |
| 291 | SubSubSubEEEE string |
| 292 | SubSubSubF int |
| 293 | } |
| 294 | |
| 295 | func (ts TestStructSubSubSubSub) SayGoodSubSubSub(word string) *TestStructSubSubSubSub { |
| 296 | fmt.Printf("hello good %s %d", word, ts.SubSubSubF) |
| 297 | return nil |
| 298 | } |
| 299 | |
| 300 | type TestStructSubSubSub struct { |
| 301 | SubSubEEEE string |
| 302 | SubSubF int |
| 303 | |
| 304 | SubSubSub TestStructSubSubSubSub |
| 305 | } |
| 306 | |
| 307 | type TestStructSubSub struct { |
| 308 | SubEEEE string |
| 309 | SubF int |
| 310 | |
| 311 | SubSub TestStructSubSubSub |
| 312 | } |
| 313 | |
| 314 | func (ts TestStructSubSub) SayGood(word string) *TestStructSubSub { |
| 315 | fmt.Printf("hello good %s %d", word, ts.SubF) |
| 316 | return nil |
| 317 | } |
| 318 |
Members