Debian Codegraph @

rhino/src/org/mozilla/javascript/ast/ParseProblem.java

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 package org.mozilla.javascript.ast;
8
9 /**
10 * Encapsulates information for a JavaScript parse error or warning.
11 */
12 public class ParseProblem {
13
14 public static enum Type {Error, Warning}
15
16 private Type type;
17 private String message;
18 private String sourceName;
19 private int offset;
20 private int length;
21
22 /**
23 * Constructs a new ParseProblem.
24 */
25 public ParseProblem(ParseProblem.Type type, String message,
26 String sourceName, int offset, int length) {
27 setType(type);
28 setMessage(message);
29 setSourceName(sourceName);
30 setFileOffset(offset);
31 setLength(length);
32 }
33
34 public ParseProblem.Type getType() {
35 return type;
36 }
37
38 public void setType(ParseProblem.Type type) {
39 this.type = type;
40 }
41
42 public String getMessage() {
43 return message;
44 }
45
46 public void setMessage(String msg) {
47 this.message = msg;
48 }
49
50 public String getSourceName() {
51 return sourceName;
52 }
53
54 public void setSourceName(String name) {
55 this.sourceName = name;
56 }
57
58 public int getFileOffset() {
59 return offset;
60 }
61
62 public void setFileOffset(int offset) {
63 this.offset = offset;
64 }
65
66 public int getLength() {
67 return length;
68 }
69
70 public void setLength(int length) {
71 this.length = length;
72 }
73
74 @Override
75 public String toString() {
76 StringBuilder sb = new StringBuilder(200);
77 sb.append(sourceName).append(":");
78 sb.append("offset=").append(offset).append(",");
79 sb.append("length=").append(length).append(",");
80 sb.append(type == Type.Error ? "error: " : "warning: ");
81 sb.append(message);
82 return sb.toString();
83 }
84 }