Expose `FilePath` on `MappingLocation`.
- We had the `FilePath` information available to us but we weren't exposing it on the `MappingLocation` context object. - By exposing the `FilePath` the Razor editor can 100% know where a `MappingLocation` is resolved from. If `null` the location is deemed to be the current source/generated file. #552
This commit is contained in:
parent
deaf2dc828
commit
be324b220a
|
|
@ -98,6 +98,7 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
{
|
{
|
||||||
documentMapping = new MappingLocation(
|
documentMapping = new MappingLocation(
|
||||||
location: new SourceLocation(
|
location: new SourceLocation(
|
||||||
|
_documentMapping.FilePath,
|
||||||
_documentMapping.AbsoluteIndex,
|
_documentMapping.AbsoluteIndex,
|
||||||
_documentMapping.LineIndex,
|
_documentMapping.LineIndex,
|
||||||
_documentMapping.CharacterIndex),
|
_documentMapping.CharacterIndex),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Microsoft.Extensions.Internal;
|
using Microsoft.Extensions.Internal;
|
||||||
|
|
||||||
|
|
@ -18,6 +19,7 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
AbsoluteIndex = location.AbsoluteIndex;
|
AbsoluteIndex = location.AbsoluteIndex;
|
||||||
LineIndex = location.LineIndex;
|
LineIndex = location.LineIndex;
|
||||||
CharacterIndex = location.CharacterIndex;
|
CharacterIndex = location.CharacterIndex;
|
||||||
|
FilePath = location.FilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ContentLength { get; }
|
public int ContentLength { get; }
|
||||||
|
|
@ -28,6 +30,8 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
|
|
||||||
public int CharacterIndex { get; }
|
public int CharacterIndex { get; }
|
||||||
|
|
||||||
|
public string FilePath { get; }
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
var other = obj as MappingLocation;
|
var other = obj as MappingLocation;
|
||||||
|
|
@ -36,7 +40,8 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AbsoluteIndex == other.AbsoluteIndex &&
|
return string.Equals(FilePath, other.FilePath, StringComparison.Ordinal) &&
|
||||||
|
AbsoluteIndex == other.AbsoluteIndex &&
|
||||||
ContentLength == other.ContentLength &&
|
ContentLength == other.ContentLength &&
|
||||||
LineIndex == other.LineIndex &&
|
LineIndex == other.LineIndex &&
|
||||||
CharacterIndex == other.CharacterIndex;
|
CharacterIndex == other.CharacterIndex;
|
||||||
|
|
@ -45,6 +50,7 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
var hashCodeCombiner = HashCodeCombiner.Start();
|
var hashCodeCombiner = HashCodeCombiner.Start();
|
||||||
|
hashCodeCombiner.Add(FilePath, StringComparer.Ordinal);
|
||||||
hashCodeCombiner.Add(AbsoluteIndex);
|
hashCodeCombiner.Add(AbsoluteIndex);
|
||||||
hashCodeCombiner.Add(ContentLength);
|
hashCodeCombiner.Add(ContentLength);
|
||||||
hashCodeCombiner.Add(LineIndex);
|
hashCodeCombiner.Add(LineIndex);
|
||||||
|
|
@ -56,11 +62,12 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format(
|
return string.Format(
|
||||||
CultureInfo.CurrentCulture, "({0}:{1},{2} [{3}])",
|
CultureInfo.CurrentCulture, "({0}:{1},{2} [{3}] {4})",
|
||||||
AbsoluteIndex,
|
AbsoluteIndex,
|
||||||
LineIndex,
|
LineIndex,
|
||||||
CharacterIndex,
|
CharacterIndex,
|
||||||
ContentLength);
|
ContentLength,
|
||||||
|
FilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator ==(MappingLocation left, MappingLocation right)
|
public static bool operator ==(MappingLocation left, MappingLocation right)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue