Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: compiler/java/com/google/dart/compiler/DartCompilationError.java

Issue 10704180: Use 'int' instead of Position. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
Brian Wilkerson 2012/07/12 15:35:11 nit: copyright year
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 package com.google.dart.compiler; 5 package com.google.dart.compiler;
6 6
7 import com.google.dart.compiler.common.HasSourceInfo; 7 import com.google.dart.compiler.common.HasSourceInfo;
8 import com.google.dart.compiler.common.SourceInfo; 8 import com.google.dart.compiler.common.SourceInfo;
9 import com.google.dart.compiler.parser.DartScanner.Location; 9 import com.google.dart.compiler.parser.DartScanner.Location;
10 import com.google.dart.compiler.parser.DartScanner.Position;
11 10
12 /** 11 /**
13 * Information about a compilation error. 12 * Information about a compilation error.
14 * 13 *
15 * @see DartCompilerListener 14 * @see DartCompilerListener
16 */ 15 */
17 public class DartCompilationError { 16 public class DartCompilationError {
18 17
19 /** 18 /**
20 * The character offset from the beginning of the source (zero based) where th e error occurred. 19 * The character offset from the beginning of the source (zero based) where th e error occurred.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 * @param arguments the arguments used to build the error message 101 * @param arguments the arguments used to build the error message
103 */ 102 */
104 public DartCompilationError(Source source, 103 public DartCompilationError(Source source,
105 Location location, 104 Location location,
106 ErrorCode errorCode, 105 ErrorCode errorCode,
107 Object... arguments) { 106 Object... arguments) {
108 this.source = source; 107 this.source = source;
109 this.errorCode = errorCode; 108 this.errorCode = errorCode;
110 this.message = String.format(errorCode.getMessage(), arguments); 109 this.message = String.format(errorCode.getMessage(), arguments);
111 if (location != null) { 110 if (location != null) {
112 Position begin = location.getBegin(); 111 offset = location.getBegin();
113 if (begin != null) { 112 SourceInfo sourceInfo = new SourceInfo(source, offset, 0);
114 offset = begin.getPos(); 113 lineNumber = sourceInfo.getLine();
115 lineNumber = begin.getLine(); 114 columnNumber = sourceInfo.getColumn();
116 columnNumber = begin.getCol(); 115 length = location.getEnd() - offset;
117 }
118 Position end = location.getEnd();
119 if (end != null) {
120 length = end.getPos() - offset;
121 if (length < 0) {
122 length = 0;
123 }
124 }
125 } 116 }
126 } 117 }
127 118
128 /** 119 /**
129 * The column number in the source (one based) where the error occurred. 120 * The column number in the source (one based) where the error occurred.
130 */ 121 */
131 public int getColumnNumber() { 122 public int getColumnNumber() {
132 return columnNumber; 123 return columnNumber;
133 } 124 }
134 125
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 182
192 @Override 183 @Override
193 public String toString() { 184 public String toString() {
194 StringBuilder sb = new StringBuilder(); 185 StringBuilder sb = new StringBuilder();
195 sb.append((source != null) ? source.getName() : "<unknown source>"); 186 sb.append((source != null) ? source.getName() : "<unknown source>");
196 sb.append("(" + lineNumber + ":" + columnNumber + "): "); 187 sb.append("(" + lineNumber + ":" + columnNumber + "): ");
197 sb.append(message); 188 sb.append(message);
198 return sb.toString(); 189 return sb.toString();
199 } 190 }
200 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698