// The Nova Project by Ken Beckett. // Copyright (C) 2007-2012 Inevitable Software, all rights reserved. // Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php using Nova.CodeDOM; namespace Nova.Analysis { /// <summary> /// Represents the result of a Find operation - a <see cref="CodeObject"/> and its location (<see cref="Project"/> and <see cref="CodeUnit"/>). /// </summary> public class Result { #region /* FIELDS */ private readonly CodeObject _codeObject; private readonly CodeUnit _codeUnit; #endregion #region /* CONSTRUCTORS */ /// <summary> /// Create a <see cref="Result"/>. /// </summary> public Result(CodeObject codeObject, CodeUnit codeUnit) { _codeObject = codeObject; _codeUnit = codeUnit; } #endregion #region /* PROPERTIES */ /// <summary> /// The associated <see cref="CodeObject"/>. /// </summary> public CodeObject CodeObject { get { return _codeObject; } } /// <summary> /// The associated <see cref="CodeUnit"/>. /// </summary> public CodeUnit CodeUnit { get { return _codeUnit; } } /// <summary> /// The associated <see cref="Project"/>. /// </summary> public Project Project { get { return (_codeUnit != null ? _codeUnit.Parent as Project : null); } } /// <summary> /// The associated line number and column in "9999/99" format (if any, otherwise empty string). /// </summary> public string LineCol { get { int lineNumber = _codeObject.LineNumber; return (lineNumber != 0 ? lineNumber + "-" + _codeObject.ColumnNumber : null); } } #endregion #region /* RENDERING */ /// <summary> /// Format the <see cref="Result"/> as a string. /// </summary> /// <returns>The text representation of the <see cref="Result"/>.</returns> public override string ToString() { string result = ""; Project project = Project; if (project != null) result += "Project '" + project.Name + "': "; if (_codeUnit != null) result += "File '" + _codeUnit.Name + "': "; result += _codeObject.AsString(); return result; } public string Render { get { // If the object is a SymbolicRef, use the parent instead for better context if (_codeObject is SymbolicRef && _codeObject.Parent != null) return _codeObject.Parent.GetDescription(); return _codeObject.GetDescription(); } } #endregion } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)