Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.11/HeuristicLab.ExtLibs/HeuristicLab.NRefactory/5.5.0/NRefactory-5.5.0/Semantics/UnknownMemberResolveResult.cs @ 13398

Last change on this file since 13398 was 11700, checked in by jkarder, 9 years ago

#2077: created branch and added first version

File size: 3.8 KB
Line 
1// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4// software and associated documentation files (the "Software"), to deal in the Software
5// without restriction, including without limitation the rights to use, copy, modify, merge,
6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7// to whom the Software is furnished to do so, subject to the following conditions:
8//
9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11//
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20using System.Collections.Generic;
21using System.Collections.ObjectModel;
22using System.Globalization;
23using System.Linq;
24using ICSharpCode.NRefactory.TypeSystem;
25
26namespace ICSharpCode.NRefactory.Semantics
27{
28  /// <summary>
29  /// Represents an unknown member.
30  /// </summary>
31  public class UnknownMemberResolveResult : ResolveResult
32  {
33    readonly IType targetType;
34    readonly string memberName;
35    readonly ReadOnlyCollection<IType> typeArguments;
36   
37    public UnknownMemberResolveResult(IType targetType, string memberName, IEnumerable<IType> typeArguments)
38      : base(SpecialType.UnknownType)
39    {
40      if (targetType == null)
41        throw new ArgumentNullException("targetType");
42      this.targetType = targetType;
43      this.memberName = memberName;
44      this.typeArguments = new ReadOnlyCollection<IType>(typeArguments.ToArray());
45    }
46   
47    /// <summary>
48    /// The type on which the method is being called.
49    /// </summary>
50    public IType TargetType {
51      get { return targetType; }
52    }
53   
54    public string MemberName {
55      get { return memberName; }
56    }
57   
58    public ReadOnlyCollection<IType> TypeArguments {
59      get { return typeArguments; }
60    }
61   
62    public override bool IsError {
63      get { return true; }
64    }
65   
66    public override string ToString()
67    {
68      return string.Format(CultureInfo.InvariantCulture, "[{0} {1}.{2}]", GetType().Name, targetType, memberName);
69    }
70  }
71 
72  /// <summary>
73  /// Represents an unknown method.
74  /// </summary>
75  public class UnknownMethodResolveResult : UnknownMemberResolveResult
76  {
77    readonly ReadOnlyCollection<IParameter> parameters;
78   
79    public UnknownMethodResolveResult(IType targetType, string methodName, IEnumerable<IType> typeArguments, IEnumerable<IParameter> parameters)
80      : base(targetType, methodName, typeArguments)
81    {
82      this.parameters = new ReadOnlyCollection<IParameter>(parameters.ToArray());
83    }
84   
85    public ReadOnlyCollection<IParameter> Parameters {
86      get { return parameters; }
87    }
88  }
89 
90  /// <summary>
91  /// Represents an unknown identifier.
92  /// </summary>
93  public class UnknownIdentifierResolveResult : ResolveResult
94  {
95    readonly string identifier;
96    readonly int typeArgumentCount;
97   
98    public UnknownIdentifierResolveResult(string identifier, int typeArgumentCount = 0)
99      : base(SpecialType.UnknownType)
100    {
101      this.identifier = identifier;
102      this.typeArgumentCount = typeArgumentCount;
103    }
104   
105    public string Identifier {
106      get { return identifier; }
107    }
108   
109    public int TypeArgumentCount {
110      get { return typeArgumentCount; }
111    }
112   
113    public override bool IsError {
114      get { return true; }
115    }
116   
117    public override string ToString()
118    {
119      return string.Format(CultureInfo.InvariantCulture, "[{0} {1}]", GetType().Name, identifier);
120    }
121  }
122}
Note: See TracBrowser for help on using the repository browser.