private static Method ProcessMethod( ExtMember me2 ) { //var owner = GetClass( me2.owner ); //ProcessMemberDocs( me2 ); var clsName = me2.name == "constructor" ? me2.owner : me2.type; //unified "type" is never null var me = new Method { Name = me2.name, Type = GetClass( clsName ), Summary = me2.shortDoc, ParametersDocs = me2.paramsDocs, ReturnsDocs = me2.returnsDocs, IsPrivate = me2.meta.@private, IsProtected = me2.meta.@protected, IsStatic = me2.meta.@static, IsVirtual = me2.shortDoc.Contains( "template method" ), IsConstructor = me2.name == "constructor", ReturnsArray = me2.ReturnsArray }; if ( me2.@params != null && [email protected] > 0 ) me.Parameters.AddRange( [email protected]( ProcessParam ) ); return me; }
private static void SetModifiers( ExtMember me2, Element me ) { me.IsStatic = me2.meta.@static; me.IsPrivate = me2.meta.@private; me.IsProtected = me2.meta.@protected; }
private static Property ProcessProperty( ExtMember p ) { //return ProcessCfg( p ); var pe = new Property { Name = p.name, Type = GetClass( p.type ), Summary = p.shortDoc, IsPrivate = p.meta.@private, IsProtected = p.meta.@protected, IsStatic = p.meta.@static }; if ( pe.Name.Contains( "$" ) ) { pe.Attributes.Add( new Attribute() { Name = "JsProperty", NamedParamters = new Dictionary<string, string>() { { "Name", "\"" + pe.Name + "\"" } } } ); pe.Name = pe.Name.Replace( "$", "@" ); } else { if ( UseProperCaseForPublicPropertys && !pe.IsPrivate )//In this case, we take protected as the same as public because you can use those in your inherited classes { pe.Name = pe.Name.Substring( 0, 1 ).ToUpperInvariant() + pe.Name.Substring( 1 ); if ( pe.DeclaringClass != null && pe.Name.Equals( pe.DeclaringClass.Name, StringComparison.Ordinal ) ) { pe.Remarks = "This property was renamed from: " + pe.Name + ", this is only for C# code, in Javascript it will appear with the original Ext name wich is: " + p.name + "."; pe.Name = "M_" + pe.Name; } pe.Attributes.Add( new Attribute() { Name = "JsProperty" } ); pe.Attributes[ 0 ].NamedParamters.Add( "Name", "\"" + p.name + "\"" ); } } return pe; }
private static Method ProcessEvent( ExtMember ev2 ) { return ProcessMethod( ev2 ); //ProcessMemberDocs( ev2 ); //var pe = new Method { Name = ev2.name, Type = GetClass( "JsString" ), Summary = ev2.shortDoc, IsStatic = true}; //SetModifiers( ev2, pe ); ////pe.IsStatic = true; ////pe.Initializer = "\"" + ev2.name + "\""; //return pe; }
static bool IsDeclared( Class ce, ExtMember me2 ) { return ce.Members.Any( m => m.Name.Replace( "@", "" ).Equals( me2.name.Replace( "@", "" ) ) ); }
static bool IsDeclared( ExtClass ce2, ExtMember me2 ) { if ( me2.owner == ce2.name && me2.defined_in == ce2.name ) return true; //if ( me2.defined_in.IsNullOrEmpty() || me2.defined_in == ce2.name || ( ce2.singleton && !me2.meta.@static ) ) // return true; var ce = GetClass( ce2.name, false ); var ceOwner = GetClass( me2.owner ); if ( ce.IsInterface && ceOwner.IsInterface ) return false; if ( ceOwner.IsInterface ) { if ( ( ce.BaseClass == null || ce.BaseClass.IsInterface || !ce.BaseClass.Interfaces.Contains( ceOwner ) ) && ce.BaseClass.BaseClass != ceOwner ) return true; } if ( me2.defined_in.IsNotNullOrEmpty() ) { var ceDefiner = GetClass( me2.defined_in ); if ( ceDefiner.IsInterface && !ce.IsInterface ) return true; } return me2.defined_in.IsNullOrEmpty() || ce2.singleton && ( ce2.singleton && !me2.meta.@static ); }
private static Field ProcessCfg( ExtMember t ) { //ProcessMemberDocs( t ); var pe = new Field { Name = t.name, Type = GetClass( t.type ), Summary = t.shortDoc }; SetModifiers( t, pe ); //pe.Initializer = "\"" + t.name + "\""; if ( pe.Name.Contains( "$" ) ) { pe.Attributes.Add( new Attribute() { Name = "JsField", NamedParamters = new Dictionary<string, string>() { { "Name", "\"" + pe.Name + "\"" } } } ); pe.Name = pe.Name.Replace( "$", "@" ); } return pe; }
internal static void ProcessMemberDocs( ExtMember me2 ) { var div = CurrHtDoc.GetElementbyId( me2.id ); if ( div != null ) { var divDesc = div.ChildNodes.FirstOrDefault( c => c.Attributes[ "class" ].Value.Equals( "description" ) ); var longDesc = divDesc.ChildNodes.FirstOrDefault( c => c.GetAttributeValue( "class", string.Empty ).Equals( "long", StringComparison.Ordinal ) ); var parameters = longDesc.SelectSingleNode( "h3[text()='Parameters']/following-sibling::ul" ); if ( me2.id.Contains( "property-" ) || me2.id.Contains( "cfg-" ) ) { var propVal = div.SelectSingleNode( "div[@class='title']" );// .ChildNodes.FirstOrDefault( n => n.Attributes[ "class" ].Value.Equals( "title", StringComparison.OrdinalIgnoreCase ) ); var type = "object"; if ( propVal != null ) { var definedIn = propVal.SelectSingleNode( "div/span[@class='defined-in']" ); var a = propVal.SelectNodes( "span/a" );// .ChildNodes.FirstOrDefault( n => n.Name.Equals( "span", StringComparison.OrdinalIgnoreCase ) ).ChildNodes.Where( n => n.Name.Equals( "a", StringComparison.OrdinalIgnoreCase ) ).ToList(); if ( a != null && a.Count == 1 ) { type = a.FirstOrDefault().InnerText; if ( type.Contains( "/" ) ) { type = type.Split( '/' )[ 0 ]; } } if ( propVal.InnerText.Contains( "[]" ) ) { type = type.Trim( '[', ']' ); me2.ReturnsArray = true; } if ( definedIn != null ) { me2.defined_in = definedIn.GetAttributeValue( "rel", string.Empty ); } } me2.type = type.Replace( "void", "Object" ).Replace( "Object", "JsObject" ).Replace( "String", "JsString" ).Replace( "Ext.data.Record", "Ext.data.Model" ).Replace( "Ext.slider.MultiSlider", "Ext.slider.Multi" ).Replace( "MultiSlider", "Multi" ); } else { me2.type = "void"; var ret = longDesc.SelectSingleNode( "h3[text()='Returns']/following-sibling::ul/li" ); var definedIn = div.SelectSingleNode( "div[@class='title']/div[@class='meta']/*[@rel != '']" ); if ( definedIn != null ) { me2.defined_in = definedIn.GetAttributeValue( "rel", string.Empty ); } if ( ret != null ) { if ( ret.InnerText.Contains( "[]" ) ) { me2.ReturnsArray = true; } if ( !me2.meta.@protected && !me2.meta.@private && AllPublicMethodsReturn.IsNotNullOrEmpty() ) { me2.type = AllPublicMethodsReturn; } else if ( me2.meta.@protected || me2.meta.@private || AllPublicMethodsReturn.IsNullOrEmpty() ) { me2.type = ret.SelectSingleNode( "span" ).InnerText.Replace( "object", "Object" ).Replace( "Object", "object" ).Replace( "String", "JsString" ).Replace( "Ext.data.Record", "Ext.data.Model" ).Replace( "Ext.slider.MultiSlider", "Ext.slider.Multi" ).Replace( "MultiSlider", "Multi" ).Replace( "HTMLElement", "JsObject" ); FixHref( ret ); me2.returnsDocs = ret.InnerHtml; me2.type = me2.type.Trim( '[', ']' ); } } } if ( parameters != null ) { foreach ( var li in parameters.SelectNodes( "li" ) ) { var name = li.FirstChild.InnerText.Trim(); if ( !string.IsNullOrEmpty( name ) ) { var a = li.SelectNodes( "a" ); if ( a == null || a.Count == 0 ) { var pre = li.SelectSingleNode( "span[@class='pre']" );// .ChildNodes.FirstOrDefault( n => n.HasAttributes && n.GetAttributeValue( "class", string.Empty ).Equals( "pre", StringComparison.OrdinalIgnoreCase ) ); if ( pre != null ) { a = pre.SelectNodes( "a" );// .ChildNodes.Where( n => n.Name.Equals( "a", StringComparison.OrdinalIgnoreCase ) ).ToList(); } } var desc = string.Empty; var descNode = li.SelectSingleNode( "div[@class='sub-desc']" );// li.ChildNodes.FirstOrDefault( n => n.Name.Equals( "div", StringComparison.OrdinalIgnoreCase ) && n.Attributes[ "class" ].Value.Equals( "sub-desc", StringComparison.OrdinalIgnoreCase ) ); if ( descNode != null ) { FixHref( descNode ); desc = descNode.InnerHtml; } if ( me2.@params == null ) me2.@params = new List<ExtParam>(); var type = "object"; var isOptional = li.InnerText.Contains( "ptional" ) || li.InnerText.Contains( "(defaults" ) || ForcedOptionalParameterNames.Any( p => p.Equals( name, StringComparison.Ordinal ) ); var isParams = li.InnerText.Contains( "Variable number" ); //If the parameter is optional, there is a great chance that the type is wrong... if ( !isOptional && !name.Equals( "fn", StringComparison.OrdinalIgnoreCase ) ) { if ( a != null && a.Count == 1 && !li.InnerText.Contains( "/" ) ) //If there are no items or the parameter accepts more than one type, we use object { var al = a.FirstOrDefault(); type = al.InnerText.Trim(); var isArray = li.InnerText.Contains( "[" ) && li.InnerText.Contains( "]" ); if ( type.IndexOfAny( MultipleObjectDelimiter ) >= 0 ) // Any "complex" type will become "object" for easier casting { type = "object"; } type = type.Trim( '[', ']' ); if ( isArray ) { type = string.Format( "JsArray<{0}>", type ); } } if ( type.Equals( "Object", StringComparison.Ordinal ) ) { type = "object"; } if ( type.Equals( "String", StringComparison.OrdinalIgnoreCase ) ) { type = "JsString"; } type = type.Replace( "Ext.data.Record", "object" ).Replace( "Ext.Element", "Ext.dom.Element" ).Replace( "Ext.core.Element", "Ext.dom.Element" ).Replace( "Ext.slider.MultiSlider", "Ext.slider.Multi" ).Replace( "MultiSlider", "Multi" ); } else if ( name.Equals( "fn", StringComparison.OrdinalIgnoreCase ) ) { type = "System.Delegate";// All functions to... } [email protected]( new ExtParam { name = name, optional = isOptional, type = type, doc = desc } ); me2.paramsDocs = ( string.IsNullOrEmpty( me2.paramsDocs ) ? "" : me2.paramsDocs + Environment.NewLine ) + string.Format( "<param name=\"{0}\">{1}</param>", name, desc ); } } } if ( longDesc.FirstChild != null ) { longDesc = longDesc.CloneNode( true ); FixHref( longDesc ); me2.shortDoc = longDesc.FirstChild.InnerText; if ( longDesc.FirstChild != null && longDesc.FirstChild.NextSibling != null ) { var preCode = longDesc.FirstChild.NextSibling; do { //FixHref( preCode ); if ( preCode.Name.Equals( "pre", StringComparison.OrdinalIgnoreCase ) ) { me2.shortDoc = string.Format( "{0}{1}{2}", Environment.NewLine, me2.shortDoc, preCode.InnerHtml ); } else { me2.shortDoc += preCode.InnerHtml; } preCode = preCode.NextSibling; } while ( preCode != null && !preCode.Name.Equals( "h3", StringComparison.OrdinalIgnoreCase ) ); } } else { me2.shortDoc = longDesc.InnerText; } } }