Skip to content

Commit

Permalink
Squashed 'NRefactory/' changes from 36c9cae..858d4cc
Browse files Browse the repository at this point in the history
858d4cc Fixed NullReferenceException in ControlFlow.NodeCreationVisitor.VisitSwitchStatement.
f70a726 Fixed resolving "-2147483648".
dd59e41 Add missing mscorlib reference
f1a1ab3 Added ResolverTest to consistency check and fixed some crashing bugs in the resolver.
3e8eb1e Add NRefactory.ConsistencyCheck with round-tripping test. Added parser unit tests for bugs discovered by the round-tripping test.
93a5c13 FindReferences: add support for searching in a different compilation than the entity is defined in.
119bc9b Fix formatting tests on Windows with git autocrlf enabled.
37795e4 Fixed parsing of some statements, improved "foreach" context in code completion.
6b7acf5 Added foreach statement variable declaration test.
3d551ed Fixed parsing of some incomplete statements.
8007d25 Fix CSharpOutputVisitorTests.AssignmentInCollectionInitializer. Ignore some failing parser unit tests.
38b35b7 Fixed formatting unit tests on windows.
df4805f Fixed compiler warnings.
94bad6c Fixed "InactiveIf" unit test.
41f4589 Fixed unit test.
3e9a85d Fixed complex generic class unit test.
77a7581 Fixed constraints parsing #2.
8124aeb Fixed some more cases of "new" completion.
fa8e9a2 Fixed bug in "new" completion.
b84c06e Make CSharpResolver immutable.
92c8bd6 Fix NullReferenceException in DefaultResolvedField.ConstantValue when the field is not a constant.
1464b5d For IAssembly.GetTypeDefinition, treat ns==null the same as ns==string.Empty.
3b48632 Fixed bug in constraints parsing.
a781604 Corrected parameter index.
e90bf1c fixed "Bug 2072 - Duplicate entries in the code completion list".
fa5ec27 Resolve object create expression, if the parent is one. That causes a jump/tooltip for the constructor rather than the class on a object create expression.
831c059 Added unit test for reported md bug.
4bf1ddb Updated Gtk demo.
d7d9a55 Added mono compiler bug workaround.
48b6968 Updated mcs sources.
63367b9 Fixed some keyword cc tests.
0e92f47 Prevented a key already exists exception (but it's not a real fix for the problem).
d5880aa Fixed possible null reference exception.
27f18d7 Fixed possible null reference exception.
ae54fd5 Added GetTypeResolveContext implementation.
9606b56 Added GetTypeResolveContext to IParsedFile.
b1bfe5c Added full name constructor to defaultunresolvedTypeDefinition.

git-subtree-dir: NRefactory
git-subtree-split: 858d4cc673d3029460f6a009a3fb268884304c7f
  • Loading branch information
dgrunwald committed Dec 9, 2011
1 parent 14a4d88 commit 8f45b7e
Show file tree
Hide file tree
Showing 91 changed files with 5,859 additions and 4,228 deletions.
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs
Expand Up @@ -436,7 +436,7 @@ public override ControlFlowNode VisitSwitchStatement(SwitchStatement switchState
}
}
}
if (constant.IsCompileTimeConstant && sectionMatchedByConstant == null)
if (constant != null && constant.IsCompileTimeConstant && sectionMatchedByConstant == null)
sectionMatchedByConstant = defaultSection;

int gotoCaseOrDefaultInOuterScope = gotoCaseOrDefault.Count;
Expand Down
31 changes: 29 additions & 2 deletions ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs
Expand Up @@ -27,16 +27,43 @@

namespace ICSharpCode.NRefactory.CSharp
{
public class ErrorExpression : EmptyExpression
public class ErrorExpression : Expression
{
TextLocation location;

public override TextLocation StartLocation {
get {
return location;
}
}

public override TextLocation EndLocation {
get {
return location;
}
}

public ErrorExpression ()
{
}

public ErrorExpression (TextLocation location) : base (location)
public ErrorExpression (TextLocation location)
{
this.location = location;
}


public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
{
// nothing
return default(S);
}

protected internal override bool DoMatch (AstNode other, PatternMatching.Match match)
{
var o = other as ErrorExpression;
return o != null;
}
}
}

9 changes: 5 additions & 4 deletions ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Constraint.cs
Expand Up @@ -38,19 +38,20 @@ public class Constraint : AstNode
{
public readonly static Role<CSharpTokenNode> ColonRole = TypeDeclaration.ColonRole;
public readonly static Role<AstType> BaseTypeRole = TypeDeclaration.BaseTypeRole;
public readonly static Role<SimpleType> TypeParameterRole = new Role<SimpleType> ("TypeParameter", SimpleType.Null);

public override NodeType NodeType {
get {
return NodeType.Unknown;
}
}

public string TypeParameter {
public SimpleType TypeParameter {
get {
return GetChildByRole (Roles.Identifier).Name;
return GetChildByRole (TypeParameterRole);
}
set {
SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty));
SetChildByRole(TypeParameterRole, value);
}
}

Expand All @@ -66,7 +67,7 @@ public class Constraint : AstNode
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
Constraint o = other as Constraint;
return o != null && MatchString(this.TypeParameter, o.TypeParameter) && this.BaseTypes.DoMatch(o.BaseTypes, match);
return o != null && this.TypeParameter.DoMatch (o.TypeParameter, match) && this.BaseTypes.DoMatch(o.BaseTypes, match);
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs
Expand Up @@ -33,6 +33,29 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class SimpleType : AstType
{
#region Null
public new static readonly SimpleType Null = new NullSimpleType ();

sealed class NullSimpleType : SimpleType
{
public override bool IsNull {
get {
return true;
}
}

public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data = default(T))
{
return default (S);
}

protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return other == null || other.IsNull;
}
}
#endregion

public SimpleType()
{
}
Expand All @@ -42,6 +65,11 @@ public SimpleType(string identifier)
this.Identifier = identifier;
}

public SimpleType (Identifier identifier)
{
this.IdentifierToken = identifier;
}

public SimpleType(string identifier, TextLocation location)
{
SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (identifier, location));
Expand Down
13 changes: 12 additions & 1 deletion ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs
Expand Up @@ -139,7 +139,18 @@ public IProjectContent UpdateProjectContent(IParsedFile oldFile, IParsedFile new

public IProjectContent UpdateProjectContent(IEnumerable<IParsedFile> oldFiles, IEnumerable<IParsedFile> newFiles)
{
throw new NotImplementedException();
CSharpProjectContent pc = new CSharpProjectContent(this);
if (oldFiles != null) {
foreach (var oldFile in oldFiles) {
pc.parsedFiles.Remove(oldFile.FileName);
}
}
if (newFiles != null) {
foreach (var newFile in newFiles) {
pc.parsedFiles.Add(newFile.FileName, newFile);
}
}
return pc;
}

IAssembly IAssemblyReference.Resolve(ITypeResolveContext context)
Expand Down

0 comments on commit 8f45b7e

Please sign in to comment.