Browse Source

Updated mcs & improved try context handling.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
36456b4d15
  1. 11
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
  2. 6
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  3. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs
  4. 23
      ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs
  5. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs
  6. 16
      ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs
  7. 6860
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  8. 5
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  9. 1
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
  10. 5
      ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs
  11. 7
      ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs
  12. 6
      ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs
  13. 12
      ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs
  14. 2
      ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs
  15. 140
      ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs
  16. 40
      ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs
  17. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs
  18. 7
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs
  19. 13
      ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs
  20. 17
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/KeywordTests.cs
  21. 1
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/NameContextTests.cs

11
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs

@ -439,6 +439,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (identifierStart != null && identifierStart.Node is VariableInitializer && location <= ((VariableInitializer)identifierStart.Node).NameToken.EndLocation) { if (identifierStart != null && identifierStart.Node is VariableInitializer && location <= ((VariableInitializer)identifierStart.Node).NameToken.EndLocation) {
return controlSpace ? HandleAccessorContext () ?? DefaultControlSpaceItems (identifierStart) : null; return controlSpace ? HandleAccessorContext () ?? DefaultControlSpaceItems (identifierStart) : null;
} }
if (identifierStart != null && identifierStart.Node is CatchClause) {
if (((CatchClause)identifierStart.Node).VariableNameToken.Contains (location))
return null;
identifierStart = null;
}
if (!(char.IsLetter (completionChar) || completionChar == '_') && (!controlSpace || identifierStart == null || !(identifierStart.Node.Parent is ArrayInitializerExpression))) { if (!(char.IsLetter (completionChar) || completionChar == '_') && (!controlSpace || identifierStart == null || !(identifierStart.Node.Parent is ArrayInitializerExpression))) {
return controlSpace ? HandleAccessorContext () ?? DefaultControlSpaceItems (identifierStart) : null; return controlSpace ? HandleAccessorContext () ?? DefaultControlSpaceItems (identifierStart) : null;
} }
@ -2133,7 +2139,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (expr == null) { if (expr == null) {
baseUnit = ParseStub ("a", false); baseUnit = ParseStub ("a", false);
expr = baseUnit.GetNodeAt (location, n => n is IdentifierExpression || n is MemberReferenceExpression); expr = baseUnit.GetNodeAt (location, n => n is IdentifierExpression || n is MemberReferenceExpression || n is CatchClause);
} }
@ -2463,7 +2469,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
"true", "false", "typeof", "checked", "unchecked", "from", "break", "checked", "true", "false", "typeof", "checked", "unchecked", "from", "break", "checked",
"unchecked", "const", "continue", "do", "finally", "fixed", "for", "foreach", "unchecked", "const", "continue", "do", "finally", "fixed", "for", "foreach",
"goto", "if", "lock", "return", "stackalloc", "switch", "throw", "try", "unsafe", "goto", "if", "lock", "return", "stackalloc", "switch", "throw", "try", "unsafe",
"using", "while", "yield", "dynamic", "var", "dynamic" "using", "while", "yield", "dynamic", "var", "dynamic",
"catch"
}; };
static string[] globalLevelKeywords = new string [] { static string[] globalLevelKeywords = new string [] {
"namespace", "using", "extern", "public", "internal", "namespace", "using", "extern", "public", "internal",

6
ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

@ -3544,9 +3544,9 @@ namespace ICSharpCode.NRefactory.CSharp
this.fileName = fileName; this.fileName = fileName;
} }
public override void Print (AbstractMessage msg) public override void Print (AbstractMessage msg, bool showFullPath)
{ {
base.Print (msg); base.Print (msg, showFullPath);
var newError = new Error (msg.IsWarning ? ErrorType.Warning : ErrorType.Error, msg.Text, new DomRegion (fileName, msg.Location.Row, msg.Location.Column)); var newError = new Error (msg.IsWarning ? ErrorType.Warning : ErrorType.Error, msg.Text, new DomRegion (fileName, msg.Location.Row, msg.Location.Column));
Errors.Add (newError); Errors.Add (newError);
} }
@ -3561,7 +3561,7 @@ namespace ICSharpCode.NRefactory.CSharp
public bool HasErrors { public bool HasErrors {
get { get {
return errorReportPrinter.ErrorsCount + errorReportPrinter.FatalCounter > 0; return errorReportPrinter.ErrorsCount > 0;
} }
} }

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs

@ -1107,6 +1107,8 @@ namespace Mono.CSharp {
} }
} catch (CompletionResult) { } catch (CompletionResult) {
throw; throw;
} catch (FatalException) {
throw;
} catch (Exception e) { } catch (Exception e) {
throw new InternalErrorException (e, loc); throw new InternalErrorException (e, loc);
} }

23
ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs

@ -784,25 +784,38 @@ namespace Mono.CSharp
public void Save () public void Save ()
{ {
PortableExecutableKinds pekind; PortableExecutableKinds pekind = PortableExecutableKinds.ILOnly;
ImageFileMachine machine; ImageFileMachine machine;
switch (Compiler.Settings.Platform) { switch (Compiler.Settings.Platform) {
case Platform.X86: case Platform.X86:
pekind = PortableExecutableKinds.Required32Bit | PortableExecutableKinds.ILOnly; pekind |= PortableExecutableKinds.Required32Bit;
machine = ImageFileMachine.I386; machine = ImageFileMachine.I386;
break; break;
case Platform.X64: case Platform.X64:
pekind = PortableExecutableKinds.ILOnly; pekind |= PortableExecutableKinds.PE32Plus;
machine = ImageFileMachine.AMD64; machine = ImageFileMachine.AMD64;
break; break;
case Platform.IA64: case Platform.IA64:
pekind = PortableExecutableKinds.ILOnly;
machine = ImageFileMachine.IA64; machine = ImageFileMachine.IA64;
break; break;
case Platform.AnyCPU32Preferred:
#if STATIC
pekind |= PortableExecutableKinds.Preferred32Bit;
machine = ImageFileMachine.I386;
break;
#else
throw new NotSupportedException ();
#endif
case Platform.Arm:
#if STATIC
machine = ImageFileMachine.ARM;
break;
#else
throw new NotSupportedException ();
#endif
case Platform.AnyCPU: case Platform.AnyCPU:
default: default:
pekind = PortableExecutableKinds.ILOnly;
machine = ImageFileMachine.I386; machine = ImageFileMachine.I386;
break; break;
} }

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs

@ -278,7 +278,7 @@ namespace Mono.CSharp {
void ResolveAttributeType () void ResolveAttributeType ()
{ {
SessionReportPrinter resolve_printer = new SessionReportPrinter (); SessionReportPrinter resolve_printer = new SessionReportPrinter ();
ReportPrinter prev_recorder = context.Module.Compiler.Report.SetPrinter (resolve_printer); ReportPrinter prev_recorder = Report.SetPrinter (resolve_printer);
bool t1_is_attr = false; bool t1_is_attr = false;
bool t2_is_attr = false; bool t2_is_attr = false;

16
ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs

@ -256,7 +256,14 @@ namespace Mono.CSharp
{ {
if (containers != null) { if (containers != null) {
foreach (var t in containers) { foreach (var t in containers) {
try {
t.PrepareEmit (); t.PrepareEmit ();
} catch (Exception e) {
if (MemberName == MemberName.Null)
throw;
throw new InternalErrorException (t, e);
}
} }
} }
} }
@ -642,6 +649,12 @@ namespace Mono.CSharp
} }
} }
public bool IsPartial {
get {
return (ModFlags & Modifiers.PARTIAL) != 0;
}
}
// //
// Returns true for secondary partial containers // Returns true for secondary partial containers
// //
@ -1509,6 +1522,9 @@ namespace Mono.CSharp
public override void PrepareEmit () public override void PrepareEmit ()
{ {
if ((caching_flags & Flags.CloseTypeCreated) != 0)
return;
foreach (var member in members) { foreach (var member in members) {
var pm = member as IParametersMember; var pm = member as IParametersMember;
if (pm != null) { if (pm != null) {

6860
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs

File diff suppressed because it is too large Load Diff

5
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

@ -4696,6 +4696,11 @@ block_prepared
--lexer.parsing_block; --lexer.parsing_block;
$$ = end_block (GetLocation ($4)); $$ = end_block (GetLocation ($4));
} }
| CLOSE_BRACE {
report.Error (1525, GetLocation ($1), "Unexpected symbol '}', expected '{'");
lexer.putback ('}');
$$ = end_block (GetLocation ($1));
}
; ;
opt_statement_list opt_statement_list

1
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs

@ -971,6 +971,7 @@ namespace Mono.CSharp
case Token.UNCHECKED: case Token.UNCHECKED:
case Token.UNSAFE: case Token.UNSAFE:
case Token.DEFAULT: case Token.DEFAULT:
case Token.AWAIT:
// //
// These can be part of a member access // These can be part of a member access

5
ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs

@ -213,6 +213,11 @@ namespace Mono.CSharp
return false; return false;
} }
if (settings.Platform == Platform.AnyCPU32Preferred && (settings.Target == Target.Library || settings.Target == Target.Module)) {
Report.Error (4023, "Platform option `anycpu32bitpreferred' is valid only for executables");
return false;
}
TimeReporter tr = new TimeReporter (settings.Timestamps); TimeReporter tr = new TimeReporter (settings.Timestamps);
ctx.TimeReporter = tr; ctx.TimeReporter = tr;
tr.StartTotal (); tr.StartTotal ();

7
ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs

@ -398,7 +398,7 @@ namespace Mono.CSharp {
return e; return e;
} catch (Exception ex) { } catch (Exception ex) {
if (loc.IsNull || ec.Module.Compiler.Settings.DebugFlags > 0 || ex is CompletionResult || ec.Report.IsDisabled) if (loc.IsNull || ec.Module.Compiler.Settings.DebugFlags > 0 || ex is CompletionResult || ec.Report.IsDisabled || ex is FatalException)
throw; throw;
ec.Report.Error (584, loc, "Internal compiler error: {0}", ex.Message); ec.Report.Error (584, loc, "Internal compiler error: {0}", ex.Message);
@ -2513,8 +2513,8 @@ namespace Mono.CSharp {
return null; return null;
if (right_side != null) { if (right_side != null) {
if (e is TypeExpr) { if (e is FullNamedExpression && e.eclass != ExprClass.Unresolved) {
e.Error_UnexpectedKind (ec, ResolveFlags.VariableOrValue, loc); e.Error_UnexpectedKind (ec, e, "variable", e.ExprClassName, loc);
return null; return null;
} }
@ -2523,7 +2523,6 @@ namespace Mono.CSharp {
e = e.Resolve (ec); e = e.Resolve (ec);
} }
//if (ec.CurrentBlock == null || ec.CurrentBlock.CheckInvariantMeaningInBlock (Name, e, Location))
return e; return e;
} }

6
ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs

@ -422,6 +422,12 @@ namespace Mono.CSharp {
} }
} }
bool ITypeDefinition.IsPartial {
get {
return false;
}
}
public bool IsMethodTypeParameter { public bool IsMethodTypeParameter {
get { get {
return spec.IsMethodOwned; return spec.IsMethodOwned;

12
ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs

@ -1744,6 +1744,12 @@ namespace Mono.CSharp
} }
} }
bool ITypeDefinition.IsPartial {
get {
return false;
}
}
public override string Name { public override string Name {
get { get {
if (name == null) { if (name == null) {
@ -2068,6 +2074,12 @@ namespace Mono.CSharp
} }
} }
bool ITypeDefinition.IsPartial {
get {
return false;
}
}
public string Namespace { public string Namespace {
get { get {
return null; return null;

2
ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs

@ -415,7 +415,7 @@ namespace Mono.CSharp {
types = new Dictionary<string, IList<TypeSpec>> (64); types = new Dictionary<string, IList<TypeSpec>> (64);
} }
if (ts.IsStatic && ts.Arity == 0 && if ((ts.IsStatic || ts.MemberDefinition.IsPartial) && ts.Arity == 0 &&
(ts.MemberDefinition.DeclaringAssembly == null || ts.MemberDefinition.DeclaringAssembly.HasExtensionMethod)) { (ts.MemberDefinition.DeclaringAssembly == null || ts.MemberDefinition.DeclaringAssembly.HasExtensionMethod)) {
if (extension_method_types == null) if (extension_method_types == null)
extension_method_types = new List<TypeSpec> (); extension_method_types = new List<TypeSpec> ();

140
ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs

@ -232,7 +232,7 @@ namespace Mono.CSharp {
} }
extra_information.Clear (); extra_information.Clear ();
printer.Print (msg); printer.Print (msg, settings.ShowFullPaths);
} }
public void Warning (int code, int level, Location loc, string format, string arg) public void Warning (int code, int level, Location loc, string format, string arg)
@ -285,7 +285,13 @@ namespace Mono.CSharp {
ErrorMessage msg = new ErrorMessage (code, loc, error, extra_information); ErrorMessage msg = new ErrorMessage (code, loc, error, extra_information);
extra_information.Clear (); extra_information.Clear ();
printer.Print (msg); printer.Print (msg, settings.ShowFullPaths);
if (settings.Stacktrace)
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
if (printer.ErrorsCount == settings.FatalCounter)
throw new FatalException (msg.Text);
} }
public void Error (int code, Location loc, string format, string arg) public void Error (int code, Location loc, string format, string arg)
@ -402,6 +408,41 @@ namespace Mono.CSharp {
return sb.ToString (); return sb.ToString ();
} }
*/ */
static string FriendlyStackTrace (StackTrace t)
{
StringBuilder sb = new StringBuilder ();
bool foundUserCode = false;
for (int i = 0; i < t.FrameCount; i++) {
StackFrame f = t.GetFrame (i);
var mb = f.GetMethod ();
if (!foundUserCode && mb.ReflectedType == typeof (Report))
continue;
foundUserCode = true;
sb.Append ("\tin ");
if (f.GetFileLineNumber () > 0)
sb.AppendFormat ("(at {0}:{1}) ", f.GetFileName (), f.GetFileLineNumber ());
sb.AppendFormat ("{0}.{1} (", mb.ReflectedType.Name, mb.Name);
bool first = true;
foreach (var pi in mb.GetParameters ()) {
if (!first)
sb.Append (", ");
first = false;
sb.Append (pi.ParameterType.FullName);
}
sb.Append (")\n");
}
return sb.ToString ();
}
} }
public abstract class AbstractMessage public abstract class AbstractMessage
@ -515,17 +556,8 @@ namespace Mono.CSharp {
{ {
#region Properties #region Properties
public int FatalCounter { get; set; }
public int ErrorsCount { get; protected set; } public int ErrorsCount { get; protected set; }
public bool ShowFullPaths { get; set; }
//
// Whether to dump a stack trace on errors.
//
public bool Stacktrace { get; set; }
public int WarningsCount { get; private set; } public int WarningsCount { get; private set; }
// //
@ -543,23 +575,20 @@ namespace Mono.CSharp {
return txt; return txt;
} }
public virtual void Print (AbstractMessage msg) public virtual void Print (AbstractMessage msg, bool showFullPath)
{ {
if (msg.IsWarning) { if (msg.IsWarning) {
++WarningsCount; ++WarningsCount;
} else { } else {
++ErrorsCount; ++ErrorsCount;
if (ErrorsCount == FatalCounter)
throw new Exception (msg.Text);
} }
} }
protected void Print (AbstractMessage msg, TextWriter output) protected void Print (AbstractMessage msg, TextWriter output, bool showFullPath)
{ {
StringBuilder txt = new StringBuilder (); StringBuilder txt = new StringBuilder ();
if (!msg.Location.IsNull) { if (!msg.Location.IsNull) {
if (ShowFullPaths) if (showFullPath)
txt.Append (msg.Location.ToStringFullName ()); txt.Append (msg.Location.ToStringFullName ());
else else
txt.Append (msg.Location.ToString ()); txt.Append (msg.Location.ToString ());
@ -612,7 +641,9 @@ namespace Mono.CSharp {
// //
List<AbstractMessage> merged_messages; List<AbstractMessage> merged_messages;
public override void Print (AbstractMessage msg) bool showFullPaths;
public override void Print (AbstractMessage msg, bool showFullPath)
{ {
// //
// This line is useful when debugging recorded messages // This line is useful when debugging recorded messages
@ -624,7 +655,8 @@ namespace Mono.CSharp {
session_messages.Add (msg); session_messages.Add (msg);
base.Print (msg); this.showFullPaths = showFullPath;
base.Print (msg, showFullPath);
} }
public void EndSession () public void EndSession ()
@ -698,7 +730,7 @@ namespace Mono.CSharp {
bool error_msg = false; bool error_msg = false;
foreach (AbstractMessage msg in messages_to_print) { foreach (AbstractMessage msg in messages_to_print) {
dest.Print (msg); dest.Print (msg, showFullPaths);
error_msg |= !msg.IsWarning; error_msg |= !msg.IsWarning;
} }
@ -715,10 +747,10 @@ namespace Mono.CSharp {
this.writer = writer; this.writer = writer;
} }
public override void Print (AbstractMessage msg) public override void Print (AbstractMessage msg, bool showFullPath)
{ {
Print (msg, writer); Print (msg, writer, showFullPath);
base.Print (msg); base.Print (msg, showFullPath);
} }
} }
@ -835,60 +867,6 @@ namespace Mono.CSharp {
return txt; return txt;
} }
static string FriendlyStackTrace (StackTrace t)
{
StringBuilder sb = new StringBuilder ();
bool foundUserCode = false;
for (int i = 0; i < t.FrameCount; i++) {
StackFrame f = t.GetFrame (i);
var mb = f.GetMethod ();
if (!foundUserCode && mb.ReflectedType == typeof (Report))
continue;
foundUserCode = true;
sb.Append ("\tin ");
if (f.GetFileLineNumber () > 0)
sb.AppendFormat ("(at {0}:{1}) ", f.GetFileName (), f.GetFileLineNumber ());
sb.AppendFormat ("{0}.{1} (", mb.ReflectedType.Name, mb.Name);
bool first = true;
foreach (var pi in mb.GetParameters ()) {
if (!first)
sb.Append (", ");
first = false;
sb.Append (pi.ParameterType.FullName);
}
sb.Append (")\n");
}
return sb.ToString ();
}
public override void Print (AbstractMessage msg)
{
base.Print (msg);
if (Stacktrace)
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
}
public static string FriendlyStackTrace (Exception e)
{
return FriendlyStackTrace (new StackTrace (e, true));
}
public static void StackTrace ()
{
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
}
} }
class TimeReporter class TimeReporter
@ -1015,6 +993,14 @@ namespace Mono.CSharp {
} }
} }
class FatalException : Exception
{
public FatalException (string message)
: base (message)
{
}
}
/// <summary> /// <summary>
/// Handles #pragma warning /// Handles #pragma warning
/// </summary> /// </summary>

40
ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs

@ -47,7 +47,12 @@ namespace Mono.CSharp {
public enum Platform public enum Platform
{ {
AnyCPU, X86, X64, IA64 AnyCPU,
AnyCPU32Preferred,
Arm,
X86,
X64,
IA64
} }
public class CompilerSettings public class CompilerSettings
@ -135,10 +140,15 @@ namespace Mono.CSharp {
public bool GenerateDebugInfo; public bool GenerateDebugInfo;
// Compiler debug flags only #region Compiler debug flags only
public bool ParseOnly, TokenizeOnly, Timestamps; public bool ParseOnly, TokenizeOnly, Timestamps;
public int DebugFlags; public int DebugFlags;
public int VerboseParserFlag; public int VerboseParserFlag;
public int FatalCounter;
public bool Stacktrace;
#endregion
public bool ShowFullPaths;
// //
// Whether we are being linked against the standard libraries. // Whether we are being linked against the standard libraries.
@ -1044,7 +1054,10 @@ namespace Mono.CSharp {
return ParseResult.Error; return ParseResult.Error;
} }
switch (value.ToLower (CultureInfo.InvariantCulture)) { switch (value.ToLowerInvariant ()) {
case "arm":
settings.Platform = Platform.Arm;
break;
case "anycpu": case "anycpu":
settings.Platform = Platform.AnyCPU; settings.Platform = Platform.AnyCPU;
break; break;
@ -1057,8 +1070,12 @@ namespace Mono.CSharp {
case "itanium": case "itanium":
settings.Platform = Platform.IA64; settings.Platform = Platform.IA64;
break; break;
case "anycpu32bitpreferred":
settings.Platform = Platform.AnyCPU32Preferred;
break;
default: default:
report.Error (1672, "Invalid platform type for -platform. Valid options are `anycpu', `x86', `x64' or `itanium'"); report.Error (1672, "Invalid -platform option `{0}'. Valid options are `anycpu', `anycpu32bitpreferred', `arm', `x86', `x64' or `itanium'",
value);
return ParseResult.Error; return ParseResult.Error;
} }
@ -1111,7 +1128,7 @@ namespace Mono.CSharp {
return ParseResult.Success; return ParseResult.Success;
case "/fullpaths": case "/fullpaths":
report.Printer.ShowFullPaths = true; settings.ShowFullPaths = true;
return ParseResult.Success; return ParseResult.Success;
case "/keyfile": case "/keyfile":
@ -1271,7 +1288,7 @@ namespace Mono.CSharp {
return ParseResult.Success; return ParseResult.Success;
case "--stacktrace": case "--stacktrace":
report.Printer.Stacktrace = true; settings.Stacktrace = true;
return ParseResult.Success; return ParseResult.Success;
case "--linkresource": case "--linkresource":
@ -1435,12 +1452,12 @@ namespace Mono.CSharp {
return ParseResult.Success; return ParseResult.Success;
default: default:
if (arg.StartsWith ("--fatal")){ if (arg.StartsWith ("--fatal", StringComparison.Ordinal)){
int fatal = 1; int fatal = 1;
if (arg.StartsWith ("--fatal=")) if (arg.StartsWith ("--fatal=", StringComparison.Ordinal))
int.TryParse (arg.Substring (8), out fatal); int.TryParse (arg.Substring (8), out fatal);
report.Printer.FatalCounter = fatal; settings.FatalCounter = fatal;
return ParseResult.Success; return ParseResult.Success;
} }
if (arg.StartsWith ("--runtime:", StringComparison.Ordinal)) { if (arg.StartsWith ("--runtime:", StringComparison.Ordinal)) {
@ -1517,7 +1534,7 @@ namespace Mono.CSharp {
void Usage () void Usage ()
{ {
output.WriteLine ( output.WriteLine (
"Mono C# compiler, Copyright 2001 - 2011 Novell, Inc.\n" + "Mono C# compiler, Copyright 2001-2011 Novell, Inc., Copyright 2011-2012 Xamarin, Inc\n" +
"mcs [options] source-files\n" + "mcs [options] source-files\n" +
" --about About the Mono C# compiler\n" + " --about About the Mono C# compiler\n" +
" -addmodule:M1[,Mn] Adds the module to the generated assembly\n" + " -addmodule:M1[,Mn] Adds the module to the generated assembly\n" +
@ -1542,7 +1559,8 @@ namespace Mono.CSharp {
" -out:FILE Specifies output assembly name\n" + " -out:FILE Specifies output assembly name\n" +
" -pkg:P1[,Pn] References packages P1..Pn\n" + " -pkg:P1[,Pn] References packages P1..Pn\n" +
" -platform:ARCH Specifies the target platform of the output assembly\n" + " -platform:ARCH Specifies the target platform of the output assembly\n" +
" ARCH can be one of: anycpu, x86, x64 or itanium\n" + " ARCH can be one of: anycpu, anycpu32bitpreferred, arm,\n" +
" x86, x64 or itanium. The default is anycpu.\n" +
" -recurse:SPEC Recursively compiles files according to SPEC pattern\n" + " -recurse:SPEC Recursively compiles files according to SPEC pattern\n" +
" -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" + " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" +
" -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" + " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" +

4
ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs

@ -2877,7 +2877,7 @@ namespace Mono.CSharp {
unreachable = top_level.End (); unreachable = top_level.End ();
} }
} catch (Exception e) { } catch (Exception e) {
if (e is CompletionResult || rc.Report.IsDisabled) if (e is CompletionResult || rc.Report.IsDisabled || e is FatalException)
throw; throw;
if (rc.CurrentBlock != null) { if (rc.CurrentBlock != null) {
@ -5482,7 +5482,7 @@ namespace Mono.CSharp {
// Add conditional call when disposing possible null variable // Add conditional call when disposing possible null variable
if (!type.IsStruct || type.IsNullableType) if (!type.IsStruct || type.IsNullableType)
dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc), loc), dispose, loc); dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc), loc), dispose, dispose.loc);
return dispose; return dispose;
} }

7
ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs

@ -464,6 +464,7 @@ namespace Mono.CSharp
false), false),
btypes.Int)); btypes.Int));
var tp = new TypeParameter(0, new MemberName("T"), null, null, Variance.None);
InterlockedCompareExchange_T = new PredefinedMember<MethodSpec> (module, types.Interlocked, InterlockedCompareExchange_T = new PredefinedMember<MethodSpec> (module, types.Interlocked,
MemberFilter.Method ("CompareExchange", 1, MemberFilter.Method ("CompareExchange", 1,
new ParametersImported ( new ParametersImported (
@ -473,9 +474,9 @@ namespace Mono.CSharp
new ParameterData (null, Parameter.Modifier.NONE) new ParameterData (null, Parameter.Modifier.NONE)
}, },
new[] { new[] {
new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null),
}, false), }, false),
null)); null));

13
ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs

@ -1303,6 +1303,7 @@ namespace Mono.CSharp
{ {
IAssemblyDefinition DeclaringAssembly { get; } IAssemblyDefinition DeclaringAssembly { get; }
string Namespace { get; } string Namespace { get; }
bool IsPartial { get; }
int TypeParametersCount { get; } int TypeParametersCount { get; }
TypeParameterSpec[] TypeParameters { get; } TypeParameterSpec[] TypeParameters { get; }
@ -1356,6 +1357,12 @@ namespace Mono.CSharp
} }
} }
bool ITypeDefinition.IsPartial {
get {
return false;
}
}
public override string Name { public override string Name {
get { get {
return name; return name;
@ -1468,6 +1475,12 @@ namespace Mono.CSharp
public TypeSpec Element { get; private set; } public TypeSpec Element { get; private set; }
bool ITypeDefinition.IsPartial {
get {
return false;
}
}
public override string Name { public override string Name {
get { get {
throw new NotSupportedException (); throw new NotSupportedException ();

17
ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/KeywordTests.cs

@ -62,6 +62,23 @@ class Class
Assert.IsNotNull (provider.Find ("case"), "keyword 'case' not found."); Assert.IsNotNull (provider.Find ("case"), "keyword 'case' not found.");
} }
[Test()]
public void CatchKeywordTest ()
{
var provider = CodeCompletionBugTests.CreateProvider (
@"
class Class
{
void Test (string t)
{
$try {} c$
}
}
");
Assert.IsNotNull (provider, "provider == null");
Assert.IsNotNull (provider.Find ("catch"), "keyword 'catch' not found.");
}
[Test()] [Test()]
public void CaseKeywordTestCase2 () public void CaseKeywordTestCase2 ()
{ {

1
ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/NameContextTests.cs

@ -122,7 +122,6 @@ namespace ICSharpCode.NRefactory.CSharp.CodeCompletion
Assert.IsTrue (provider == null || provider.Count == 0, "provider should be empty."); Assert.IsTrue (provider == null || provider.Count == 0, "provider should be empty.");
} }
[Ignore("MCS TODO!")]
[Test()] [Test()]
public void TestCatchExceptionName () public void TestCatchExceptionName ()
{ {

Loading…
Cancel
Save