(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / nant / src / Location.cs
blob3a51279d3713de6f19ef101a071672c7d50e457d
1 // NAnt - A .NET build tool
2 // Copyright (C) 2001 Gerry Shaw
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // Ian MacLean (ian_maclean@another.com)
19 // Gerry Shaw (gerry_shaw@yahoo.com)
21 namespace SourceForge.NAnt {
22 using System;
23 using System.IO;
25 /// <summary>
26 /// Stores the file name and line number in a file.
27 /// </summary>
28 public class Location {
29 string _fileName;
30 int _lineNumber;
31 int _columnNumber;
33 public static readonly Location UnknownLocation = new Location();
35 /// <summary>
36 /// Creates a location consisting of a file name and line number.
37 ///</summary>
38 public Location(string fileName, int lineNumber, int columnNumber) {
39 Uri uri = new Uri(fileName);
40 string strfileName = uri.LocalPath; // convert from URI syntax to local path
41 Init(strfileName, lineNumber, columnNumber);
44 /// <summary>
45 /// Creates a location consisting of a file name but no line number.
46 ///</summary>
47 public Location(string fileName) {
48 Init(fileName, 0, 0);
51 /// <summary>
52 /// Creates an "unknown" location.
53 ///</summary>
54 private Location() {
55 Init(null, 0, 0);
58 /// <summary>
59 /// Private Init function.
60 ///</summary>
61 private void Init(string fileName, int lineNumber, int columnNumber) {
62 _fileName = fileName;
63 _lineNumber = lineNumber;
64 _columnNumber = columnNumber;
67 /// <summary>
68 /// Returns the file name, line number and a trailing space. An error
69 /// message can be appended easily. For unknown locations, returns
70 /// an empty string.
71 ///</summary>
72 public override string ToString() {
73 string message = "";
75 if (_fileName != null) {
76 message += _fileName;
78 if (_lineNumber != 0) {
79 message += ":";
80 message += _lineNumber.ToString();
83 message += ":";
86 return message;