/// <summary> /// Visit type members. /// </summary> /// <param name="x"></param> virtual public void VisitTypeDecl(TypeDecl x) { foreach (TypeMemberDecl t in x.Members) { VisitElement(t); } }
public override void VisitTypeDecl(TypeDecl x) { base.VisitTypeDecl(x); var list = ParseDocumentation(x); if (list != null) { x.Annotations.Set<DocBlock>(new DocClassBlock(list)); } }
///// <summary> ///// Process eval expression - if the eval was produced by the TypeDecl, we process the original TypeDecl. ///// </summary> //public override void VisitEvalEx(EvalEx x) //{ // TypeDecl typeDecl; // if (x.Annotations.TryGet<TypeDecl>(out typeDecl)) // { // docResolver.VisitTypeDecl(typeDecl); // VisitTypeDecl(typeDecl); // } // base.VisitEvalEx(x); //} /// <summary> /// Generate type declaration /// </summary> public CodeTypeDeclaration GenerateTypeDecl(PHPDocBlock cmt, TypeDecl x) { CodeTypeDeclaration cls = new CodeTypeDeclaration(MakeCSharpName(x.Name.Value)); var summary = cmt.Summary; if (!string.IsNullOrEmpty(summary)) { cls.Comments.Add(new CodeCommentStatement("<summary>\n " + summary + "\n </summary>", true)); } cls.IsInterface = true; cls.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(DuckTypeAttribute)))); return cls; }
/// <summary> /// Process class - set currentClass and process methods /// </summary> public override void VisitTypeDecl(TypeDecl x) { var cmt = x.PHPDoc; if (cmt == null) return; if (cmt.Access == PhpMemberAttributes.Public) { currentModule.Types = true; currentClass = GenerateTypeDecl(cmt, x); currentModule.Classes.Add(currentClass); } base.VisitTypeDecl(x); }
/// <summary> /// Visit type members. /// </summary> /// <param name="x"></param> virtual public void VisitTypeDecl(TypeDecl x) { foreach (TypeMemberDecl t in x.Members) VisitElement(t); }
public void TypeDeclarationReduced(Parser parser, PHP.Core.AST.TypeDecl decl) { }
private void PreAnalyzePartialDeclaration(Analyzer/*!*/ analyzer, TypeDecl/*!*/ aggregate, ref DTypeDesc aggregateBase, List<DTypeDesc>/*!*/ aggregateInterfaces) { // // little hack, change the sourceUnit in order to match the current partial class declaration with the right file and imported namespaces // var current_sourceUnit = analyzer.SourceUnit; analyzer.SourceUnit = this.type.Declaration.SourceUnit; // // // try { bool valid = true; if (type.IsInterface != aggregate.type.IsInterface) { analyzer.ErrorSink.Add(Errors.IncompatiblePartialDeclarations, type.Declaration.SourceUnit, type.Declaration.Position, type.FullName); analyzer.ErrorSink.Add(Errors.RelatedLocation, aggregate.type.Declaration.SourceUnit, aggregate.type.Declaration.Position); valid = false; } if (type.Visibility != aggregate.type.Visibility) { analyzer.ErrorSink.Add(Errors.ConflictingPartialVisibility, type.Declaration.SourceUnit, type.Declaration.Position, type.FullName); analyzer.ErrorSink.Add(Errors.RelatedLocation, aggregate.type.Declaration.SourceUnit, aggregate.type.Declaration.Position); valid = false; } // merge base types: DTypeDesc base_type = ResolveBaseType(analyzer); if (base_type != null) { if (aggregateBase != null) { if (!base_type.Type.Equals(aggregateBase.Type)) //Edited by Ðonny Jan 07 2009 - missing "!"? { analyzer.ErrorSink.Add(Errors.PartialDeclarationsDifferInBase, type.Declaration.SourceUnit, type.Declaration.Position, type.FullName); analyzer.ErrorSink.Add(Errors.RelatedLocation, aggregate.type.Declaration.SourceUnit, aggregate.type.Declaration.Position); valid = false; } } else { aggregateBase = base_type; } } typeSignature.PreAnalyze(analyzer, type); // merge generic parameters: valid &= aggregate.typeSignature.Merge(analyzer.ErrorSink, this.type, typeSignature); // move members to the aggregate: members.ForEach(member => member.sourceUnit = analyzer.SourceUnit); // override SourceUnit of the members to match the debug information and imported namespaces properly furing the analysis aggregate.members.AddRange(members); members = null; // move attributes to the aggregate: aggregate.attributes.Merge(attributes); // merge interfaces: ResolveBaseInterfaces(analyzer, aggregateInterfaces); // next partial declaration; // (if the declaration is erroneous, stop analysis before reporting more messy errors): if (valid && type.Version.Next != null) { ((TypeDecl)type.Version.Next.Declaration.Node).PreAnalyzePartialDeclaration(analyzer, aggregate, ref aggregateBase, aggregateInterfaces); } } finally { // cut the AST off the tables: type.Declaration.Node = null; type = null; // // change the sourceUnit back // analyzer.SourceUnit = current_sourceUnit; } }