Browse Source

Updated mcs & improved try context handling.

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

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

@ -435,14 +435,20 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -435,14 +435,20 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
var identifierStart = GetExpressionAtCursor ();
if (identifierStart != null && identifierStart.Node is TypeParameterDeclaration)
return null;
if (identifierStart != null && identifierStart.Node is VariableInitializer && location <= ((VariableInitializer)identifierStart.Node).NameToken.EndLocation) {
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))) {
return controlSpace ? HandleAccessorContext () ?? DefaultControlSpaceItems (identifierStart) : null;
}
char prevCh = offset > 2 ? document.GetCharAt (offset - 2) : ';';
char nextCh = offset < document.TextLength ? document.GetCharAt (offset) : ' ';
const string allowedChars = ";,.[](){}+-*/%^?:&|~!<>=";
@ -2119,21 +2125,21 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -2119,21 +2125,21 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (expr == null) {
expr = baseUnit.GetNodeAt<AstType> (location.Line, location.Column - 1);
}
// try insertStatement
if (expr == null && baseUnit.GetNodeAt<EmptyStatement> (location.Line, location.Column) != null) {
tmpUnit = baseUnit = ParseStub ("a();", false);
expr = baseUnit.GetNodeAt<InvocationExpression> (location.Line, location.Column + 1);
}
if (expr == null) {
baseUnit = ParseStub ("()");
expr = baseUnit.GetNodeAt<IdentifierExpression> (location.Line, location.Column - 1);
}
if (expr == null) {
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 @@ -2463,7 +2469,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
"true", "false", "typeof", "checked", "unchecked", "from", "break", "checked",
"unchecked", "const", "continue", "do", "finally", "fixed", "for", "foreach",
"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 [] {
"namespace", "using", "extern", "public", "internal",

2
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs

@ -403,7 +403,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -403,7 +403,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
} else {
memberLocation = new TextLocation (1, 1);
}
using (var stream = new System.IO.StringReader (wrapper.ToString ())) {
try {
var parser = new CSharpParser ();

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

@ -3544,9 +3544,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -3544,9 +3544,9 @@ namespace ICSharpCode.NRefactory.CSharp
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));
Errors.Add (newError);
}
@ -3561,7 +3561,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -3561,7 +3561,7 @@ namespace ICSharpCode.NRefactory.CSharp
public bool HasErrors {
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 { @@ -1107,6 +1107,8 @@ namespace Mono.CSharp {
}
} catch (CompletionResult) {
throw;
} catch (FatalException) {
throw;
} catch (Exception e) {
throw new InternalErrorException (e, loc);
}

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

@ -784,25 +784,38 @@ namespace Mono.CSharp @@ -784,25 +784,38 @@ namespace Mono.CSharp
public void Save ()
{
PortableExecutableKinds pekind;
PortableExecutableKinds pekind = PortableExecutableKinds.ILOnly;
ImageFileMachine machine;
switch (Compiler.Settings.Platform) {
case Platform.X86:
pekind = PortableExecutableKinds.Required32Bit | PortableExecutableKinds.ILOnly;
pekind |= PortableExecutableKinds.Required32Bit;
machine = ImageFileMachine.I386;
break;
case Platform.X64:
pekind = PortableExecutableKinds.ILOnly;
pekind |= PortableExecutableKinds.PE32Plus;
machine = ImageFileMachine.AMD64;
break;
case Platform.IA64:
pekind = PortableExecutableKinds.ILOnly;
machine = ImageFileMachine.IA64;
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:
default:
pekind = PortableExecutableKinds.ILOnly;
machine = ImageFileMachine.I386;
break;
}

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

@ -278,7 +278,7 @@ namespace Mono.CSharp { @@ -278,7 +278,7 @@ namespace Mono.CSharp {
void ResolveAttributeType ()
{
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 t2_is_attr = false;

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

@ -256,7 +256,14 @@ namespace Mono.CSharp @@ -256,7 +256,14 @@ namespace Mono.CSharp
{
if (containers != null) {
foreach (var t in containers) {
t.PrepareEmit ();
try {
t.PrepareEmit ();
} catch (Exception e) {
if (MemberName == MemberName.Null)
throw;
throw new InternalErrorException (t, e);
}
}
}
}
@ -642,6 +649,12 @@ namespace Mono.CSharp @@ -642,6 +649,12 @@ namespace Mono.CSharp
}
}
public bool IsPartial {
get {
return (ModFlags & Modifiers.PARTIAL) != 0;
}
}
//
// Returns true for secondary partial containers
//
@ -1509,6 +1522,9 @@ namespace Mono.CSharp @@ -1509,6 +1522,9 @@ namespace Mono.CSharp
public override void PrepareEmit ()
{
if ((caching_flags & Flags.CloseTypeCreated) != 0)
return;
foreach (var member in members) {
var pm = member as IParametersMember;
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 @@ -4696,6 +4696,11 @@ block_prepared
--lexer.parsing_block;
$$ = end_block (GetLocation ($4));
}
| CLOSE_BRACE {
report.Error (1525, GetLocation ($1), "Unexpected symbol '}', expected '{'");
lexer.putback ('}');
$$ = end_block (GetLocation ($1));
}
;
opt_statement_list

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

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

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

@ -213,6 +213,11 @@ namespace Mono.CSharp @@ -213,6 +213,11 @@ namespace Mono.CSharp
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);
ctx.TimeReporter = tr;
tr.StartTotal ();

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

@ -398,7 +398,7 @@ namespace Mono.CSharp { @@ -398,7 +398,7 @@ namespace Mono.CSharp {
return e;
} 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;
ec.Report.Error (584, loc, "Internal compiler error: {0}", ex.Message);
@ -2513,8 +2513,8 @@ namespace Mono.CSharp { @@ -2513,8 +2513,8 @@ namespace Mono.CSharp {
return null;
if (right_side != null) {
if (e is TypeExpr) {
e.Error_UnexpectedKind (ec, ResolveFlags.VariableOrValue, loc);
if (e is FullNamedExpression && e.eclass != ExprClass.Unresolved) {
e.Error_UnexpectedKind (ec, e, "variable", e.ExprClassName, loc);
return null;
}
@ -2523,7 +2523,6 @@ namespace Mono.CSharp { @@ -2523,7 +2523,6 @@ namespace Mono.CSharp {
e = e.Resolve (ec);
}
//if (ec.CurrentBlock == null || ec.CurrentBlock.CheckInvariantMeaningInBlock (Name, e, Location))
return e;
}

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

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

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

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

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

@ -415,7 +415,7 @@ namespace Mono.CSharp { @@ -415,7 +415,7 @@ namespace Mono.CSharp {
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)) {
if (extension_method_types == null)
extension_method_types = new List<TypeSpec> ();

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

@ -232,7 +232,7 @@ namespace Mono.CSharp { @@ -232,7 +232,7 @@ namespace Mono.CSharp {
}
extra_information.Clear ();
printer.Print (msg);
printer.Print (msg, settings.ShowFullPaths);
}
public void Warning (int code, int level, Location loc, string format, string arg)
@ -285,7 +285,13 @@ namespace Mono.CSharp { @@ -285,7 +285,13 @@ namespace Mono.CSharp {
ErrorMessage msg = new ErrorMessage (code, loc, error, extra_information);
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)
@ -401,7 +407,42 @@ namespace Mono.CSharp { @@ -401,7 +407,42 @@ namespace Mono.CSharp {
sb.Append (")");
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
@ -515,17 +556,8 @@ namespace Mono.CSharp { @@ -515,17 +556,8 @@ namespace Mono.CSharp {
{
#region Properties
public int FatalCounter { get; 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; }
//
@ -543,23 +575,20 @@ namespace Mono.CSharp { @@ -543,23 +575,20 @@ namespace Mono.CSharp {
return txt;
}
public virtual void Print (AbstractMessage msg)
public virtual void Print (AbstractMessage msg, bool showFullPath)
{
if (msg.IsWarning) {
++WarningsCount;
} else {
++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 ();
if (!msg.Location.IsNull) {
if (ShowFullPaths)
if (showFullPath)
txt.Append (msg.Location.ToStringFullName ());
else
txt.Append (msg.Location.ToString ());
@ -612,7 +641,9 @@ namespace Mono.CSharp { @@ -612,7 +641,9 @@ namespace Mono.CSharp {
//
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
@ -624,7 +655,8 @@ namespace Mono.CSharp { @@ -624,7 +655,8 @@ namespace Mono.CSharp {
session_messages.Add (msg);
base.Print (msg);
this.showFullPaths = showFullPath;
base.Print (msg, showFullPath);
}
public void EndSession ()
@ -698,7 +730,7 @@ namespace Mono.CSharp { @@ -698,7 +730,7 @@ namespace Mono.CSharp {
bool error_msg = false;
foreach (AbstractMessage msg in messages_to_print) {
dest.Print (msg);
dest.Print (msg, showFullPaths);
error_msg |= !msg.IsWarning;
}
@ -715,10 +747,10 @@ namespace Mono.CSharp { @@ -715,10 +747,10 @@ namespace Mono.CSharp {
this.writer = writer;
}
public override void Print (AbstractMessage msg)
public override void Print (AbstractMessage msg, bool showFullPath)
{
Print (msg, writer);
base.Print (msg);
Print (msg, writer, showFullPath);
base.Print (msg, showFullPath);
}
}
@ -835,60 +867,6 @@ namespace Mono.CSharp { @@ -835,60 +867,6 @@ namespace Mono.CSharp {
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
@ -1015,6 +993,14 @@ namespace Mono.CSharp { @@ -1015,6 +993,14 @@ namespace Mono.CSharp {
}
}
class FatalException : Exception
{
public FatalException (string message)
: base (message)
{
}
}
/// <summary>
/// Handles #pragma warning
/// </summary>

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

@ -47,7 +47,12 @@ namespace Mono.CSharp { @@ -47,7 +47,12 @@ namespace Mono.CSharp {
public enum Platform
{
AnyCPU, X86, X64, IA64
AnyCPU,
AnyCPU32Preferred,
Arm,
X86,
X64,
IA64
}
public class CompilerSettings
@ -135,10 +140,15 @@ namespace Mono.CSharp { @@ -135,10 +140,15 @@ namespace Mono.CSharp {
public bool GenerateDebugInfo;
// Compiler debug flags only
#region Compiler debug flags only
public bool ParseOnly, TokenizeOnly, Timestamps;
public int DebugFlags;
public int VerboseParserFlag;
public int FatalCounter;
public bool Stacktrace;
#endregion
public bool ShowFullPaths;
//
// Whether we are being linked against the standard libraries.
@ -1044,7 +1054,10 @@ namespace Mono.CSharp { @@ -1044,7 +1054,10 @@ namespace Mono.CSharp {
return ParseResult.Error;
}
switch (value.ToLower (CultureInfo.InvariantCulture)) {
switch (value.ToLowerInvariant ()) {
case "arm":
settings.Platform = Platform.Arm;
break;
case "anycpu":
settings.Platform = Platform.AnyCPU;
break;
@ -1057,8 +1070,12 @@ namespace Mono.CSharp { @@ -1057,8 +1070,12 @@ namespace Mono.CSharp {
case "itanium":
settings.Platform = Platform.IA64;
break;
case "anycpu32bitpreferred":
settings.Platform = Platform.AnyCPU32Preferred;
break;
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;
}
@ -1111,7 +1128,7 @@ namespace Mono.CSharp { @@ -1111,7 +1128,7 @@ namespace Mono.CSharp {
return ParseResult.Success;
case "/fullpaths":
report.Printer.ShowFullPaths = true;
settings.ShowFullPaths = true;
return ParseResult.Success;
case "/keyfile":
@ -1271,7 +1288,7 @@ namespace Mono.CSharp { @@ -1271,7 +1288,7 @@ namespace Mono.CSharp {
return ParseResult.Success;
case "--stacktrace":
report.Printer.Stacktrace = true;
settings.Stacktrace = true;
return ParseResult.Success;
case "--linkresource":
@ -1435,12 +1452,12 @@ namespace Mono.CSharp { @@ -1435,12 +1452,12 @@ namespace Mono.CSharp {
return ParseResult.Success;
default:
if (arg.StartsWith ("--fatal")){
if (arg.StartsWith ("--fatal", StringComparison.Ordinal)){
int fatal = 1;
if (arg.StartsWith ("--fatal="))
if (arg.StartsWith ("--fatal=", StringComparison.Ordinal))
int.TryParse (arg.Substring (8), out fatal);
report.Printer.FatalCounter = fatal;
settings.FatalCounter = fatal;
return ParseResult.Success;
}
if (arg.StartsWith ("--runtime:", StringComparison.Ordinal)) {
@ -1517,7 +1534,7 @@ namespace Mono.CSharp { @@ -1517,7 +1534,7 @@ namespace Mono.CSharp {
void Usage ()
{
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" +
" --about About the Mono C# compiler\n" +
" -addmodule:M1[,Mn] Adds the module to the generated assembly\n" +
@ -1542,7 +1559,8 @@ namespace Mono.CSharp { @@ -1542,7 +1559,8 @@ namespace Mono.CSharp {
" -out:FILE Specifies output assembly name\n" +
" -pkg:P1[,Pn] References packages P1..Pn\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" +
" -reference:A1[,An] Imports metadata from the specified assembly (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 { @@ -2877,7 +2877,7 @@ namespace Mono.CSharp {
unreachable = top_level.End ();
}
} catch (Exception e) {
if (e is CompletionResult || rc.Report.IsDisabled)
if (e is CompletionResult || rc.Report.IsDisabled || e is FatalException)
throw;
if (rc.CurrentBlock != null) {
@ -5482,7 +5482,7 @@ namespace Mono.CSharp { @@ -5482,7 +5482,7 @@ namespace Mono.CSharp {
// Add conditional call when disposing possible null variable
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;
}

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

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

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

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

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

@ -62,6 +62,23 @@ class Class @@ -62,6 +62,23 @@ class Class
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()]
public void CaseKeywordTestCase2 ()
{

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

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

Loading…
Cancel
Save