/// <summary>
        /// Looks up the fragment representing the name of a <see cref="TSqlObject"/>.
        /// Only some common object types are supported - more can be added as needed.
        ///
        /// Searches for the precise TSqlFragment representing the name of the view.
        /// If it's possible to find this it can provide the most accurate source
        /// position information to support clicking on the error in the errors list
        /// and navigating to that precise view definition in a project file
        /// </summary>
        /// <param name="tSqlObject">The object whose name is requested</param>
        /// <returns><see cref="TSqlFragment"/> or null if no name is found</returns>
        public static TSqlFragment LookupSchemaObjectName(TSqlObject tSqlObject)
        {
            TSqlFragment fragment;

            if (TSqlModelUtils.TryGetFragmentForAnalysis(tSqlObject, out fragment))
            {
                NameFindingVisitor visitor = new NameFindingVisitor(tSqlObject);
                fragment.Accept(visitor);
                return(visitor.Name);
            }
            return(null);
        }
예제 #2
0
 /// <summary>
 /// Looks up the fragment representing the name of a <see cref="TSqlObject"/>. 
 /// Only some common object types are supported - more can be added as needed.
 /// 
 /// Searches for the precise TSqlFragment representing the name of the view. 
 /// If it's possible to find this it can provide the most accurate source 
 /// position information to support clicking on the error in the errors list
 /// and navigating to that precise view definition in a project file 
 /// </summary>
 /// <param name="tSqlObject">The object whose name is requested</param>
 /// <returns><see cref="TSqlFragment"/> or null if no name is found</returns>
 public static TSqlFragment LookupSchemaObjectName(TSqlObject tSqlObject)
 {
     TSqlFragment fragment;
     if (TSqlModelUtils.TryGetFragmentForAnalysis(tSqlObject, out fragment))
     {
         NameFindingVisitor visitor = new NameFindingVisitor(tSqlObject);
         fragment.Accept(visitor);
         return visitor.Name;
     }
     return null;
 }