|
Revision 2404, 1.4 KB
(checked in by Chuck.Esterbrook, 23 months ago)
|
|
Fixed: The warning File is empty. does not mention a filename.
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | # TODO: Share the WarningAction between Compiler and CobraParser |
|---|
| 2 | |
|---|
| 3 | enum WarningActionEnum |
|---|
| 4 | Print |
|---|
| 5 | Throw |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | class CobraWarning inherits SourceException |
|---|
| 9 | |
|---|
| 10 | # invariant not .isError |
|---|
| 11 | |
|---|
| 12 | var _fileName as String? |
|---|
| 13 | var _lineNum as int? |
|---|
| 14 | var _token as IToken? |
|---|
| 15 | |
|---|
| 16 | cue init(message as String?) |
|---|
| 17 | .init(nil, nil, message) |
|---|
| 18 | |
|---|
| 19 | cue init(fileName as String, lineNum as int, message as String) |
|---|
| 20 | base.init(message) |
|---|
| 21 | _fileName, _lineNum = fileName, lineNum |
|---|
| 22 | |
|---|
| 23 | cue init(fileName as String?, token as IToken?, message as String) |
|---|
| 24 | base.init(message) |
|---|
| 25 | _fileName = fileName |
|---|
| 26 | _token = token |
|---|
| 27 | |
|---|
| 28 | cue init(token as IToken, message as String) |
|---|
| 29 | base.init(message) |
|---|
| 30 | _token = token |
|---|
| 31 | _message = message |
|---|
| 32 | |
|---|
| 33 | get isError as bool is override |
|---|
| 34 | return false |
|---|
| 35 | |
|---|
| 36 | get hasSourceSite as bool is override |
|---|
| 37 | return _token or _fileName |
|---|
| 38 | |
|---|
| 39 | get fileName as String is override |
|---|
| 40 | return _fileName ? _token.fileName |
|---|
| 41 | |
|---|
| 42 | get lineNum as int is override |
|---|
| 43 | if _lineNum, return _lineNum |
|---|
| 44 | if _token, return _token.lineNum |
|---|
| 45 | return 1 |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | class DoNotUseException |
|---|
| 49 | inherits SystemException |
|---|
| 50 | """ |
|---|
| 51 | Throw this exception from a property or method that a class dictates should not be used. |
|---|
| 52 | Essentially, this is dis-inheritance. |
|---|
| 53 | Use of this exception, however, should make one question the design of the class hierarchy. |
|---|
| 54 | """ |
|---|
| 55 | |
|---|
| 56 | cue init(msg as String?) |
|---|
| 57 | base.init(msg) |
|---|
| 58 | pass |
|---|
| 59 | |
|---|
| 60 | cue init(msg as String?, innerExc as Exception?) |
|---|
| 61 | base.init(msg, innerExc) |
|---|
| 62 | pass |
|---|