Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.11/HeuristicLab.ExtLibs/HeuristicLab.NRefactory/5.5.0/NRefactory.CSharp-5.5.0/TypeSystem/AliasNamespaceReference.cs @ 12011

Last change on this file since 12011 was 11700, checked in by jkarder, 10 years ago

#2077: created branch and added first version

File size: 2.5 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 ICSharpCode.NRefactory.CSharp.Resolver;
21using ICSharpCode.NRefactory.Semantics;
22using ICSharpCode.NRefactory.TypeSystem;
23
24namespace ICSharpCode.NRefactory.CSharp.TypeSystem
25{
26  /// <summary>
27  /// Looks up an alias (identifier in front of :: operator).
28  /// </summary>
29  /// <remarks>
30  /// The member lookup performed by the :: operator is handled
31  /// by <see cref="MemberTypeOrNamespaceReference"/>.
32  /// </remarks>
33  [Serializable]
34  public sealed class AliasNamespaceReference : TypeOrNamespaceReference, ISupportsInterning
35  {
36    readonly string identifier;
37   
38    public AliasNamespaceReference(string identifier)
39    {
40      if (identifier == null)
41        throw new ArgumentNullException("identifier");
42      this.identifier = identifier;
43    }
44   
45    public string Identifier {
46      get { return identifier; }
47    }
48   
49    public override ResolveResult Resolve(CSharpResolver resolver)
50    {
51      return resolver.ResolveAlias(identifier);
52    }
53   
54    public override IType ResolveType(CSharpResolver resolver)
55    {
56      // alias cannot refer to types
57      return SpecialType.UnknownType;
58    }
59   
60    public override string ToString()
61    {
62      return identifier + "::";
63    }
64   
65    int ISupportsInterning.GetHashCodeForInterning()
66    {
67      return identifier.GetHashCode();
68    }
69   
70    bool ISupportsInterning.EqualsForInterning(ISupportsInterning other)
71    {
72      AliasNamespaceReference anr = other as AliasNamespaceReference;
73      return anr != null && this.identifier == anr.identifier;
74    }
75  }
76}
Note: See TracBrowser for help on using the repository browser.