|
|
|
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
|
|
|
|
// Copyright (c) 2010-2020 AlphaSierraPapa for the SharpDevelop Team
|
|
|
|
|
// Copyright (c) 2010-2020 AlphaSierraPapa for the SharpDevelop Team
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
|
|
|
// software and associated documentation files (the "Software"), to deal in the Software
|
|
|
|
@ -426,8 +426,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
@@ -426,8 +426,9 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether the specified identifier is a keyword in the given context.
|
|
|
|
|
/// If <paramref name="context"/> is <see langword="null" /> all keywords are treated as unconditional.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static bool IsKeyword(string identifier, AstNode context) |
|
|
|
|
public static bool IsKeyword(string identifier, AstNode context = null) |
|
|
|
|
{ |
|
|
|
|
// only 2-10 char lower-case identifiers can be keywords
|
|
|
|
|
if (identifier.Length > maxKeywordLength || identifier.Length < 2 || identifier[0] < 'a') |
|
|
|
@ -440,10 +441,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
@@ -440,10 +441,12 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
|
|
|
|
|
} |
|
|
|
|
if (queryKeywords.Contains(identifier)) |
|
|
|
|
{ |
|
|
|
|
return context.Ancestors.Any(ancestor => ancestor is QueryExpression); |
|
|
|
|
return context == null || context.Ancestors.Any(ancestor => ancestor is QueryExpression); |
|
|
|
|
} |
|
|
|
|
if (identifier == "await") |
|
|
|
|
{ |
|
|
|
|
if (context == null) |
|
|
|
|
return true; |
|
|
|
|
foreach (AstNode ancestor in context.Ancestors) |
|
|
|
|
{ |
|
|
|
|
// with lambdas/anonymous methods,
|
|
|
|
|