Skip to content

Commit 368cb45

Browse files
committed
Merge remote-tracking branch 'KL/master'
2 parents 906ec44 + ba4ce4f commit 368cb45

File tree

7 files changed

+45
-11
lines changed

7 files changed

+45
-11
lines changed

Grammars/CSharp/CSharp.Grammar/CSharp/AST/AstUtils2.n

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ namespace DotNet
299299
def double = context.GetVoidType().FullName;
300300
def decimal = context.GetVoidType().FullName;
301301

302-
match(from) {
302+
match(from)
303+
{
304+
| x when !x.IsFullNameEvaluated => false
303305
| x when x.FullName == sbyte => [short, int, long, float, double, decimal].Any(s => s == to.FullName)
304306
| x when x.FullName == byte => [short, ushort, int, uint, long, ulong, float, double, decimal].Any(s => s == to.FullName)
305307
| x when x.FullName == short => [int, long, float, double, decimal].Any(s => s == to.FullName)

Nitra/Nitra.Runtime/DependentProperties/FileEvalPropertiesData.n

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace Nitra.Declarations
4949
{
5050
when (Ast != null)
5151
{
52-
def errorCollector = CollectSymbolErrorsVisitor(GetCompilerMessage());
52+
def errorCollector = CollectSymbolErrorsVisitor(GetCompilerMessage(), Ast.Location.Source.File.UseHintMl);
5353
errorCollector.Visit(Ast);
5454
}
5555
}

Nitra/Nitra.Runtime/Errors/CollectSymbolErrorsVisitor.n

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ namespace Nitra
2121
public class CollectSymbolErrorsVisitor : IAstVisitor
2222
{
2323
public CompilerMessages : CompilerMessageList;
24+
public UseHintMl : bool;
2425

25-
public this()
26+
public this(useHintMl : bool)
2627
{
27-
this(CompilerMessageList())
28+
this(CompilerMessageList(), useHintMl)
2829
}
2930

30-
public this(compilerMessages : CompilerMessageList)
31+
public this(compilerMessages : CompilerMessageList, useHintMl : bool)
3132
{
3233
CompilerMessages = compilerMessages;
34+
UseHintMl = useHintMl;
3335
}
3436

3537
public Visit(parseTree : IAst) : void
@@ -50,11 +52,32 @@ namespace Nitra
5052
CompilerMessages.Error(reference, $"Unresolved reference '$reference'");
5153
else when (r.IsAmbiguous && !r.IgnoreAmbiguities)
5254
{
53-
def builder = StringBuilder(64)
54-
.Append("<hint>'").HintMlEscape(reference).Append("' is an ambiguous reference between ")
55-
.JoinAnd(r.Ambiguities, HintML.MakeHintMlPath(_, _, ".", true)).Append("</hint>");
55+
def message =
56+
if (UseHintMl)
57+
{
58+
StringBuilder(64).Append("<hint>'").HintMlEscape(reference).Append("' is an ambiguous reference between ")
59+
.JoinAnd(r.Ambiguities, HintML.MakeHintMlPath(_, _, ".", true)).Append("</hint>").ToString();
60+
}
61+
else
62+
{
63+
def format(symbol : DeclarationSymbol) : string
64+
{
65+
if (symbol.IsFullNameEvaluated)
66+
symbol.FullName
67+
else if (symbol.IsDeclaredInOptEvaluated)
68+
match (symbol.DeclaredInOpt)
69+
{
70+
| VSome(parentSymbol) => format(parentSymbol) + "." + symbol.Name
71+
| VNone => symbol.Name
72+
}
73+
else
74+
symbol.Name
75+
}
5676

57-
CompilerMessages.Error(reference, builder.ToString());
77+
$"'$(reference)' is an ambiguous reference between ..$(r.Ambiguities.Select(format))"
78+
};
79+
80+
CompilerMessages.Error(reference, message);
5881
}
5982
}
6083

Nitra/Nitra.Runtime/ProjectSystem/CompilerMessage.n

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ namespace Nitra.ProjectSystem
3232
}
3333

3434
public override ToString() : string
35+
{
36+
ToString(false)
37+
}
38+
39+
public ToString(warningsAsErrors : bool) : string
3540
{
3641
def type =
3742
match (Type)
3843
{
3944
| FatalError
40-
| Error => "error: "
45+
| Error
46+
| Warning when warningsAsErrors => "error: "
4147
| Warning => "warning: "
4248
| Hint => "hint: "
4349
}

Nitra/Nitra.Runtime/ProjectSystem/File.n

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace Nitra.ProjectSystem
3838
public event Redraw : Action;
3939
public virtual IsFake : bool { get { false } }
4040
public IsActive : bool { get; protected set; }
41+
public UseHintMl : bool { get { Project != null && Project.UseHintMl } }
4142

4243
[RecordIgnore] protected mutable _parseMessages : CompilerMessageList = CompilerMessageList();
4344
public ParseMessages : Seq[CompilerMessage] { get { _parseMessages } }
@@ -71,7 +72,7 @@ namespace Nitra.ProjectSystem
7172
def symbolErrors =
7273
if (HasAst)
7374
{
74-
def errorCollector = CollectSymbolErrorsVisitor();
75+
def errorCollector = CollectSymbolErrorsVisitor(UseHintMl);
7576
errorCollector.Visit(Ast);
7677
errorCollector.CompilerMessages
7778
}

Nitra/Nitra.Runtime/ProjectSystem/FileBased/FsProject.n

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace Nitra.ProjectSystem
2020
{
2121
public FsSolution : FsSolution[TAst] { get; internal set; }
2222
public FsFiles : ObservableCollection[FsFile[TAst]] { get; private set; }
23+
public override UseHintMl : bool { get { false } }
2324

2425
public this([NotNull] solution : FsSolution[TAst], projectDir : string, libs : Seq[LibReference])
2526
{

Nitra/Nitra.Runtime/ProjectSystem/Project.n

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace Nitra.ProjectSystem
3232
public virtual Libs : Seq[LibReference] { get; protected set; }
3333
public ProjectDir : string { get; protected set; }
3434
public event OnSymbolAssemblyResolve : Func[Project, AssemblyName, Assembly];
35+
public virtual UseHintMl : bool { get { true } }
3536

3637
protected this()
3738
{

0 commit comments

Comments
 (0)