OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "go/ast" | 8 "go/ast" |
9 "regexp" | 9 "regexp" |
10 "strings" | 10 "strings" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 // Variables matching this regexp are assumed to have type os.Error. | 81 // Variables matching this regexp are assumed to have type os.Error. |
82 var errVar = regexp.MustCompile(`^(e|err|error)_?([A-Z0-9].*)?$`) | 82 var errVar = regexp.MustCompile(`^(e|err|error)_?([A-Z0-9].*)?$`) |
83 | 83 |
84 // Types matching this regexp are assumed to be implementations of os.Error. | 84 // Types matching this regexp are assumed to be implementations of os.Error. |
85 var errType = regexp.MustCompile(`^\*?([Ee]rror|.*Error)$`) | 85 var errType = regexp.MustCompile(`^\*?([Ee]rror|.*Error)$`) |
86 | 86 |
87 // Type-checking configuration: tell the type-checker this basic | 87 // Type-checking configuration: tell the type-checker this basic |
88 // information about types, functions, and variables in external packages. | 88 // information about types, functions, and variables in external packages. |
89 var errorTypeConfig = &TypeConfig{ | 89 var errorTypeConfig = &TypeConfig{ |
90 » Type: map[string]*Type{ | 90 » Type: { |
91 "os.Error": {}, | 91 "os.Error": {}, |
92 }, | 92 }, |
93 » Func: map[string]string{ | 93 » Func: { |
94 "fmt.Errorf": "os.Error", | 94 "fmt.Errorf": "os.Error", |
95 "os.NewError": "os.Error", | 95 "os.NewError": "os.Error", |
96 }, | 96 }, |
97 » Var: map[string]string{ | 97 » Var: { |
98 "os.EPERM": "os.Error", | 98 "os.EPERM": "os.Error", |
99 "os.ENOENT": "os.Error", | 99 "os.ENOENT": "os.Error", |
100 "os.ESRCH": "os.Error", | 100 "os.ESRCH": "os.Error", |
101 "os.EINTR": "os.Error", | 101 "os.EINTR": "os.Error", |
102 "os.EIO": "os.Error", | 102 "os.EIO": "os.Error", |
103 "os.ENXIO": "os.Error", | 103 "os.ENXIO": "os.Error", |
104 "os.E2BIG": "os.Error", | 104 "os.E2BIG": "os.Error", |
105 "os.ENOEXEC": "os.Error", | 105 "os.ENOEXEC": "os.Error", |
106 "os.EBADF": "os.Error", | 106 "os.EBADF": "os.Error", |
107 "os.ECHILD": "os.Error", | 107 "os.ECHILD": "os.Error", |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 id, ok := typ.(*ast.Ident) | 344 id, ok := typ.(*ast.Ident) |
345 if ok { | 345 if ok { |
346 return id.Name | 346 return id.Name |
347 } | 347 } |
348 sel, ok := typ.(*ast.SelectorExpr) | 348 sel, ok := typ.(*ast.SelectorExpr) |
349 if ok { | 349 if ok { |
350 return typeName(sel.X) + "." + sel.Sel.Name | 350 return typeName(sel.X) + "." + sel.Sel.Name |
351 } | 351 } |
352 return "" | 352 return "" |
353 } | 353 } |
OLD | NEW |