Update the hover 'containingLibraryName' to not include the 'file:///' prefix.

This is a follow up on a comment in the previous change https://dart-review.googlesource.com/c/sdk/+/103481/.

Change-Id: I0f377d6c7d68d55464a4e111a6a65715a82e0591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103546
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
diff --git a/pkg/analysis_server/doc/api.html b/pkg/analysis_server/doc/api.html
index c10faf7..b39b090 100644
--- a/pkg/analysis_server/doc/api.html
+++ b/pkg/analysis_server/doc/api.html
@@ -3923,8 +3923,9 @@
         
         <p>
           The URI of the containing library, examples here include
-          "dart:core", "package:.." and even "file:.." URIs. The data
-          is omitted if the element is declared inside an HTML file.
+          "dart:core", "package:.." and file uris represented by the
+          path on disk, "/..". The data is omitted if the element is
+          declared inside an HTML file.
         </p>
       </dd><dt class="field"><b>containingClassDescription: String<span style="color:#999999"> (optional)</span></b></dt><dd>
         
diff --git a/pkg/analysis_server/lib/protocol/protocol_generated.dart b/pkg/analysis_server/lib/protocol/protocol_generated.dart
index bc2c256..8973481 100644
--- a/pkg/analysis_server/lib/protocol/protocol_generated.dart
+++ b/pkg/analysis_server/lib/protocol/protocol_generated.dart
@@ -15941,15 +15941,15 @@
 
   /**
    * The URI of the containing library, examples here include "dart:core",
-   * "package:.." and even "file:.." URIs. The data is omitted if the element
-   * is declared inside an HTML file.
+   * "package:.." and file uris represented by the path on disk, "/..". The
+   * data is omitted if the element is declared inside an HTML file.
    */
   String get containingLibraryName => _containingLibraryName;
 
   /**
    * The URI of the containing library, examples here include "dart:core",
-   * "package:.." and even "file:.." URIs. The data is omitted if the element
-   * is declared inside an HTML file.
+   * "package:.." and file uris represented by the path on disk, "/..". The
+   * data is omitted if the element is declared inside an HTML file.
    */
   void set containingLibraryName(String value) {
     this._containingLibraryName = value;
diff --git a/pkg/analysis_server/lib/src/computer/computer_hover.dart b/pkg/analysis_server/lib/src/computer/computer_hover.dart
index b5f3e7a..c3a3fba 100644
--- a/pkg/analysis_server/lib/src/computer/computer_hover.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_hover.dart
@@ -8,6 +8,7 @@
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/file_system/file_system.dart';
 import 'package:analyzer/src/dart/ast/element_locator.dart';
 import 'package:analyzer/src/dart/ast/utilities.dart';
 import 'package:analyzer/src/dartdoc/dartdoc_directive_info.dart';
@@ -72,7 +73,15 @@
           // containing library
           LibraryElement library = element.library;
           if (library != null) {
-            hover.containingLibraryName = library.source.uri.toString();
+            Uri uri = library.source.uri;
+            if (uri.scheme != '' && uri.scheme == 'file') {
+              // for 'file:' URIs, use the path (contents after 'file:///')
+              hover.containingLibraryName = _unit
+                  .declaredElement.session.resourceProvider.pathContext
+                  .fromUri(uri);
+            } else {
+              hover.containingLibraryName = uri.toString();
+            }
             hover.containingLibraryPath = library.source.fullName;
           }
         }
diff --git a/pkg/analysis_server/test/analysis/get_hover_test.dart b/pkg/analysis_server/test/analysis/get_hover_test.dart
index ae1938f..9926291 100644
--- a/pkg/analysis_server/test/analysis/get_hover_test.dart
+++ b/pkg/analysis_server/test/analysis/get_hover_test.dart
@@ -7,6 +7,7 @@
 
 import 'package:analysis_server/protocol/protocol.dart';
 import 'package:analysis_server/protocol/protocol_generated.dart';
+import 'package:path/path.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -21,8 +22,8 @@
 
 @reflectiveTest
 class AnalysisHoverTest extends AbstractAnalysisTest {
-  /// If windows, return 'C:/', otherwise return the empty string
-  String get windowsCColon => Platform.isWindows ? 'C:/' : '';
+  /// If windows, return 'C:', otherwise return the empty string
+  String get windowsCColon => Platform.isWindows ? 'C:' : '';
 
   Future<HoverInformation> prepareHover(String search) {
     int offset = findOffset(search);
@@ -121,7 +122,7 @@
     expect(hover.length, 'A(0)'.length);
     // element
     expect(hover.containingLibraryName,
-        'file:///${windowsCColon}project/bin/test.dart');
+        normalize('$windowsCColon/project/bin/test.dart'));
     expect(hover.containingLibraryPath, testFile);
     expect(hover.dartdoc, isNull);
     expect(hover.elementDescription, '(const) A(int i) → A');
@@ -147,7 +148,7 @@
     expect(hover.length, 'A()'.length);
     // element
     expect(hover.containingLibraryName,
-        'file:///${windowsCColon}project/bin/test.dart');
+        normalize('$windowsCColon/project/bin/test.dart'));
     expect(hover.containingLibraryPath, testFile);
     expect(hover.dartdoc, isNull);
     expect(hover.elementDescription, '(new) A() → A');
@@ -174,7 +175,7 @@
     expect(hover.length, 'new A()'.length);
     // element
     expect(hover.containingLibraryName,
-        'file:///${windowsCColon}project/bin/test.dart');
+        normalize('$windowsCColon/project/bin/test.dart'));
     expect(hover.containingLibraryPath, testFile);
     expect(hover.dartdoc, isNull);
     expect(hover.elementDescription, 'A() → A');
@@ -200,7 +201,7 @@
       expect(hover.length, 'new A<String>()'.length);
       // element
       expect(hover.containingLibraryName,
-          'file:///${windowsCColon}project/bin/test.dart');
+          normalize('$windowsCColon/project/bin/test.dart'));
       expect(hover.containingLibraryPath, testFile);
       expect(hover.dartdoc, isNull);
       expect(hover.elementDescription, 'A() → A<String>');
@@ -339,7 +340,7 @@
     HoverInformation hover = await prepareHover('fff(int a');
     // element
     expect(hover.containingLibraryName,
-        'file:///${windowsCColon}project/bin/test.dart');
+        normalize('$windowsCColon/project/bin/test.dart'));
     expect(hover.containingLibraryPath, testFile);
     expect(hover.containingClassDescription, isNull);
     expect(hover.dartdoc, '''doc aaa\ndoc bbb''');
@@ -367,7 +368,7 @@
     HoverInformation hover = await prepareHover('fff);');
     // element
     expect(hover.containingLibraryName,
-        'file:///${windowsCColon}project/bin/test.dart');
+        normalize('$windowsCColon/project/bin/test.dart'));
     expect(hover.containingLibraryPath, testFile);
     expect(hover.containingClassDescription, 'A');
     expect(hover.dartdoc, '''doc aaa\ndoc bbb''');
@@ -506,7 +507,7 @@
     HoverInformation hover = await prepareHover('mmm(int a');
     // element
     expect(hover.containingLibraryName,
-        'file:///${windowsCColon}project/bin/test.dart');
+        normalize('$windowsCColon/project/bin/test.dart'));
     expect(hover.containingLibraryPath, testFile);
     expect(hover.containingClassDescription, 'A');
     expect(hover.dartdoc, '''doc aaa\ndoc bbb''');
@@ -536,7 +537,7 @@
     expect(hover.length, 'mmm'.length);
     // element
     expect(hover.containingLibraryName,
-        'file:///${windowsCColon}project/bin/test.dart');
+        normalize('$windowsCColon/project/bin/test.dart'));
     expect(hover.containingLibraryPath, testFile);
     expect(hover.elementDescription, 'mmm(int a, String b) → List<String>');
     expect(hover.elementKind, 'method');
@@ -585,7 +586,7 @@
     expect(hover.length, 'transform'.length);
     // element
     expect(hover.containingLibraryName,
-        'file:///${windowsCColon}project/bin/test.dart');
+        normalize('$windowsCColon/project/bin/test.dart'));
     expect(hover.containingLibraryPath, testFile);
     expect(hover.elementDescription,
         'Stream.transform<S>(StreamTransformer<int, S> streamTransformer) → Stream<S>');
diff --git a/pkg/analysis_server/test/lsp/hover_test.dart b/pkg/analysis_server/test/lsp/hover_test.dart
index 46e1a70..7f06e69 100644
--- a/pkg/analysis_server/test/lsp/hover_test.dart
+++ b/pkg/analysis_server/test/lsp/hover_test.dart
@@ -6,6 +6,7 @@
 
 import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
 import 'package:analysis_server/src/lsp/constants.dart';
+import 'package:path/path.dart' as path;
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -68,11 +69,14 @@
     String [[a^bc]];
     ''';
 
+    final containingLibraryName =
+        path.normalize("$windowsCColon/project/lib/main.dart");
+
     final expectedHoverContent = '''
 ```dart
 String abc
 ```
-*file:///${windowsCColon}project/lib/main.dart*
+*$containingLibraryName*
 
 ---
 This is a string.
@@ -168,11 +172,14 @@
     String [[a^bc]];
     ''';
 
+    final containingLibraryName =
+        path.normalize("$windowsCColon/project/lib/main.dart");
+
     final expectedHoverContent = '''
 ```dart
 String abc
 ```
-*file:///${windowsCColon}project/lib/main.dart*
+*$containingLibraryName*
     '''
         .trim();
 
diff --git a/pkg/analysis_server/tool/spec/generated/java/types/HoverInformation.java b/pkg/analysis_server/tool/spec/generated/java/types/HoverInformation.java
index 36b21ae..88e6f0b 100644
--- a/pkg/analysis_server/tool/spec/generated/java/types/HoverInformation.java
+++ b/pkg/analysis_server/tool/spec/generated/java/types/HoverInformation.java
@@ -55,8 +55,9 @@
   private final String containingLibraryPath;
 
   /**
-   * The URI of the containing library, examples here include "dart:core", "package:.." and even
-   * "file:.." URIs. The data is omitted if the element is declared inside an HTML file.
+   * The URI of the containing library, examples here include "dart:core", "package:.." and file uris
+   * represented by the path on disk, "/..". The data is omitted if the element is declared inside an
+   * HTML file.
    */
   private final String containingLibraryName;
 
@@ -185,8 +186,9 @@
   }
 
   /**
-   * The URI of the containing library, examples here include "dart:core", "package:.." and even
-   * "file:.." URIs. The data is omitted if the element is declared inside an HTML file.
+   * The URI of the containing library, examples here include "dart:core", "package:.." and file uris
+   * represented by the path on disk, "/..". The data is omitted if the element is declared inside an
+   * HTML file.
    */
   public String getContainingLibraryName() {
     return containingLibraryName;
diff --git a/pkg/analysis_server/tool/spec/spec_input.html b/pkg/analysis_server/tool/spec/spec_input.html
index 2edfc64..237ae9b 100644
--- a/pkg/analysis_server/tool/spec/spec_input.html
+++ b/pkg/analysis_server/tool/spec/spec_input.html
@@ -4325,8 +4325,9 @@
         <ref>String</ref>
         <p>
           The URI of the containing library, examples here include
-          "dart:core", "package:.." and even "file:.." URIs. The data
-          is omitted if the element is declared inside an HTML file.
+          "dart:core", "package:.." and file uris represented by the
+          path on disk, "/..". The data is omitted if the element is
+          declared inside an HTML file.
         </p>
       </field>
       <field name="containingClassDescription" optional="true">
diff --git a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
index ec76e66..bed4e0b 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
@@ -15941,15 +15941,15 @@
 
   /**
    * The URI of the containing library, examples here include "dart:core",
-   * "package:.." and even "file:.." URIs. The data is omitted if the element
-   * is declared inside an HTML file.
+   * "package:.." and file uris represented by the path on disk, "/..". The
+   * data is omitted if the element is declared inside an HTML file.
    */
   String get containingLibraryName => _containingLibraryName;
 
   /**
    * The URI of the containing library, examples here include "dart:core",
-   * "package:.." and even "file:.." URIs. The data is omitted if the element
-   * is declared inside an HTML file.
+   * "package:.." and file uris represented by the path on disk, "/..". The
+   * data is omitted if the element is declared inside an HTML file.
    */
   void set containingLibraryName(String value) {
     this._containingLibraryName = value;