11using System . Collections . Generic ;
22using System . Xml ;
33using JetBrains . ReSharper . Psi ;
4+ using JetBrains . ReSharper . Psi . Html ;
45using JetBrains . ReSharper . Psi . Html . Html ;
6+ using JetBrains . ReSharper . Psi . Html . Impl . Html ;
7+ using JetBrains . ReSharper . Psi . Html . Impl . TagPrefixes ;
58using JetBrains . ReSharper . Psi . Html . Tree ;
69using JetBrains . ReSharper . Psi . Tree ;
10+ using JetBrains . Util ;
711using JetBrains . Util . DataStructures ;
812
913namespace JetBrains . ReSharper . Plugins . AngularJS . Psi . Html
1014{
11- public class AngularJsHtmlTagDeclaredElement : IHtmlTagDeclaredElement
15+ public class AngularJsHtmlTagDeclaredElement : IHtmlTagDeclaredElement , IAngularJsDeclaredElement
1216 {
17+ private readonly IPsiServices psiServices ;
18+ private readonly HtmlDeclaredElementsCache declaredElementsCache ;
19+
20+ public AngularJsHtmlTagDeclaredElement ( IPsiServices psiServices , HtmlDeclaredElementsCache declaredElementsCache ,
21+ string shortName , IEnumerable < AttributeInfo > ownAttributes , IEnumerable < AttributeInfo > inheritedAttributes )
22+ {
23+ ShortName = shortName ;
24+ this . psiServices = psiServices ;
25+ this . declaredElementsCache = declaredElementsCache ;
26+ OwnAttributes = ownAttributes ;
27+ InheritedAttributes = inheritedAttributes ;
28+ }
29+
1330 public IPsiServices GetPsiServices ( )
1431 {
15- throw new System . NotImplementedException ( ) ;
32+ return psiServices ;
1633 }
1734
1835 public IList < IDeclaration > GetDeclarations ( )
1936 {
20- throw new System . NotImplementedException ( ) ;
37+ // TODO: Return proper declarations
38+ // Can this work? Declaration might be a comment node!?
39+ return EmptyList < IDeclaration > . InstanceList ;
2140 }
2241
2342 public IList < IDeclaration > GetDeclarationsIn ( IPsiSourceFile sourceFile )
2443 {
25- throw new System . NotImplementedException ( ) ;
44+ // TODO: Return proper declarations
45+ // Can this work? Declaration might be a comment node!?
46+ return EmptyList < IDeclaration > . InstanceList ;
2647 }
2748
2849 public DeclaredElementType GetElementType ( )
2950 {
30- throw new System . NotImplementedException ( ) ;
51+ return HtmlDeclaredElementType . HTML_TAG ;
3152 }
3253
3354 public XmlNode GetXMLDoc ( bool inherit )
3455 {
35- throw new System . NotImplementedException ( ) ;
56+ return null ;
3657 }
3758
3859 public XmlNode GetXMLDescriptionSummary ( bool inherit )
3960 {
40- throw new System . NotImplementedException ( ) ;
61+ return null ;
4162 }
4263
4364 public bool IsValid ( )
4465 {
45- throw new System . NotImplementedException ( ) ;
66+ return true ;
4667 }
4768
4869 public bool IsSynthetic ( )
4970 {
50- throw new System . NotImplementedException ( ) ;
71+ return false ;
5172 }
5273
5374 public HybridCollection < IPsiSourceFile > GetSourceFiles ( )
5475 {
55- throw new System . NotImplementedException ( ) ;
76+ // TODO: Should be able to return source file
77+ return HybridCollection < IPsiSourceFile > . Empty ;
5678 }
5779
5880 public bool HasDeclarationsIn ( IPsiSourceFile sourceFile )
5981 {
60- throw new System . NotImplementedException ( ) ;
82+ // TODO: Should be able to return source file
83+ return false ;
6184 }
6285
6386 public string ShortName { get ; private set ; }
64- public bool CaseSensistiveName { get ; private set ; }
65- public PsiLanguageType PresentationLanguage { get ; private set ; }
66- public bool Obsolete { get ; private set ; }
67- public bool NonStandard { get ; private set ; }
87+ public bool CaseSensistiveName { get { return false ; } }
88+ public PsiLanguageType PresentationLanguage { get { return HtmlLanguage . Instance ; } }
89+ public bool Obsolete { get { return false ; } }
90+ public bool NonStandard { get { return false ; } }
91+
6892 public IEnumerable < AttributeInfo > GetAllowedAttributes ( IPsiSourceFile sourceFile , bool strict = false )
6993 {
70- throw new System . NotImplementedException ( ) ;
94+ return CollectionUtil . EnumerateAll ( OwnAttributes , InheritedAttributes ,
95+ declaredElementsCache . GetAdditionalAttributesForTag ( sourceFile , this , strict ) ) ;
7196 }
7297
7398 public IType GetType ( IHtmlTag treeTag )
7499 {
75- throw new System . NotImplementedException ( ) ;
100+ // This is used by asp.net, to map tags to controls, I think
101+ return TypeFactory . CreateUnknownType ( treeTag . GetPsiModule ( ) , treeTag . GetResolveContext ( ) ) ;
76102 }
77103
78- public TagClosingRequirement ClosingRequirement { get ; private set ; }
104+ public TagClosingRequirement ClosingRequirement { get { return TagClosingRequirement . REGULAR_TAG_CLOSING_REQUIRED ; } }
105+
106+ // OwnAttributes are tag specific. InheritedAttributes are shared between tags (e.g. I18N, events, etc.)
107+ // The only real difference here is sorting when showing a description - own are shown before inherited
79108 public IEnumerable < AttributeInfo > OwnAttributes { get ; private set ; }
80109 public IEnumerable < AttributeInfo > InheritedAttributes { get ; private set ; }
81- public bool OnlyOnce { get ; private set ; }
110+
111+ public bool OnlyOnce { get { return false ; } }
112+
113+ public override bool Equals ( object obj )
114+ {
115+ if ( ReferenceEquals ( this , obj ) ) return true ;
116+
117+ var attribute = obj as AngularJsHtmlAttributeDeclaredElement ;
118+ if ( attribute == null ) return false ;
119+
120+ // TODO: Other fields?
121+ return attribute . ShortName == ShortName ;
122+ }
123+
124+ public override int GetHashCode ( )
125+ {
126+ // TODO: Other fields?
127+ return ShortName . GetHashCode ( ) ;
128+ }
82129 }
83130}
0 commit comments