]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
- cleanups - ui-bugfix
authorFlorian Brosch <flobrosch@src.gnome.org>
Thu, 20 Nov 2008 21:26:41 +0000 (21:26 +0000)
committerFlorian Brosch <flobrosch@src.gnome.org>
Thu, 20 Nov 2008 21:26:41 +0000 (21:26 +0000)
 - cleanups
 - ui-bugfix

svn path=/trunk/; revision=20

src/doclets/devhelp/linkhelper/helper.vala
src/doclets/html/doclet/template.vala
src/doclets/html/linkhelper/helper.vala
src/doclets/htmlhelpers/htmlhelpers.vala
src/doclets/valadoc.org/doclet/template.vala
src/libvaladoc/doctree.vala
src/libvaladoc/drawer.vala
src/libvaladoc/parser.vala
src/libvaladoc/settings.vala
src/valadoc/valadoc.vala

index fdb0fdbbcc0a2c0e5e3cc6317944461587564115..a9bb6bd0e44877eac7f0ebfc07004d9bcc48626b 100755 (executable)
@@ -24,12 +24,12 @@ using GLib;
 
 public interface Valadoc.HtmlHelper {
        protected string? get_html_link ( Settings settings, Basic element, Basic pos ) {
-               string tmp = "";
-               string prefix = "";
-
                if ( element is Package ) {
                        return "../" + element.name + "/index.html";
                }
+
+               string tmp = "";
+               string prefix = "";
        
                if ( element != pos ) {
                        prefix =  "../" + element.file.name;
index 8b064128fe8353fa102794c798e7a16fd1c722dc..80371550753d2c4b2fb805e973df5a22a254310f 100644 (file)
@@ -127,7 +127,7 @@ public class Valadoc.HtmlDoclet : Valadoc.BasicHtmlDoclet, Valadoc.LinkHelper {
        public override void visit_package ( Package file ) {
                this.package_name = file.name;
 
-               this.is_vapi = file.is_external_package;
+               this.is_vapi = file.is_package;
                if ( this.is_vapi )
                        this.files.add ( file );
                else
index 7748fc6c31ec2e43a3bc92eca1bfe83decbb5a8b..d68a1339e596bca71a7fe090e4c2da90246cd064 100755 (executable)
@@ -35,6 +35,10 @@ public interface Valadoc.LinkHelper {
        }
 
        protected string? get_html_link ( Valadoc.Settings settings, Valadoc.Basic element, Valadoc.Basic pos2 ) {
+               Package pkg = ( element is Package )? (Package)element : element.file;
+               if ( pkg.is_visitor_accessible () == false )
+                       return null;
+
                GLib.StringBuilder str = new GLib.StringBuilder ( "" );
                Valadoc.Basic pos = element;
                string? link_id = null;
@@ -44,6 +48,10 @@ public interface Valadoc.LinkHelper {
                                link_id = "#" + element.name;
                                pos = pos.parent;
                        }
+                       else if ( element is Visitable ) {
+                               if ( !((Visitable)element).is_visitor_accessible() )
+                                       return null;
+                       }
 
                        while ( pos != null ) {
                                if ( pos.name == null )
index dd677ca6a1ad0ee29cca32349b3ee28a4a7cb36b..dec2b428bad13229aa80d535c9c711822d2319e7 100644 (file)
@@ -655,7 +655,6 @@ public abstract class Valadoc.BasicHtmlLanglet : Valadoc.Langlet {
        }
 
        public override void write_delegate ( Valadoc.Delegate del, void* ptr ) {
-               GLib.StringBuilder modifiers = new GLib.StringBuilder ( "" );
                weak GLib.FileStream file = (GLib.FileStream)ptr;
                this.position = del;
 
@@ -850,7 +849,7 @@ public abstract class Valadoc.BasicHtmlDoclet : Valadoc.Doclet {
 //             if ( mself == null )
 //                     mself = element;
 
-               string package_name = element.file.name;
+//             string package_name = element.file.name;
 
                this.write_top_element ( file, mself );
 
@@ -895,7 +894,7 @@ public abstract class Valadoc.BasicHtmlDoclet : Valadoc.Doclet {
                file.printf ( "\t\t\t\t<ul class=\"%s\">\n", css_navi );
 
 
-               Namespace globals;
+               Namespace globals = null;
 
                foreach ( Namespace ns in ns_list ) {
                        if ( ns.name == null )
@@ -1648,7 +1647,11 @@ public abstract class Valadoc.BasicHtmlDoclet : Valadoc.Doclet {
 
                file.printf ( "<ul class=\"%s\">\n", css_inline_navigation );
                foreach ( Package p in deps ) {
-                       file.printf ( "\t<li class=\"%s\"><a class=\"%s\" href=\"%s\">%s</a></li>\n", css_inline_navigation_package, css_navi_link, this.get_link(p, mself), p.name );
+                       string link = this.get_link(p, mself);
+                       if ( link == null )
+                               file.printf ( "\t<li class=\"%s\">%s</li>\n", css_inline_navigation_package, p.name );
+                       else
+                               file.printf ( "\t<li class=\"%s\"><a class=\"%s\" href=\"%s\">%s</a></li>\n", css_inline_navigation_package, css_navi_link, link, p.name );
                }
                file.puts ( "</ul>\n" );
        }
index 0d4e7b538868075bcfe524f8a2632295f0aecdee..42eab817b1c016e3225a80ee32af76fc5acff4bb 100644 (file)
@@ -105,7 +105,7 @@ public class Valadoc.HtmlDoclet : Valadoc.BasicHtmlDoclet, Valadoc.LinkHelper {
 
        public override void visit_package ( Package file ) {
                string package_name = file.name;
-               this.is_vapi = file.is_external_package;
+               this.is_vapi = file.is_package;
 
                string new_path = this.settings.path + package_name + "/";
 
@@ -140,7 +140,7 @@ public class Valadoc.HtmlDoclet : Valadoc.BasicHtmlDoclet, Valadoc.LinkHelper {
                var rt = DirUtils.create ( this.current_path, 0777 );
 
                GLib.FileStream navi = GLib.FileStream.open ( this.current_path + "navi.html", "w" );
-               this.write_navi_child_namespaces ( navi, ns, ns );
+               this.write_navi_namespace ( navi, ns );
                navi = null;
 
                GLib.FileStream file = GLib.FileStream.open ( this.current_path + "index.html", "w" );
index 1a29db8b2055e33f8f8ba13c915669194ffd2e3b..4d0099328a683c3c842ff3d92ab9267f3a94bcae 100755 (executable)
@@ -37,14 +37,22 @@ namespace Valadoc {
                return true;
        }
 
-       public void copy_directory ( string src, string dest ) {
+       public bool copy_directory ( string src, string dest ) {
                string _src = (  src.has_suffix ( "/" ) )? src : src + "/";
                string _dest = ( dest.has_suffix ( "/" ) )? dest : dest + "/";
 
-               GLib.Dir dir = GLib.Dir.open ( _src );
-               for ( weak string name = dir.read_name (); name != null ; name = dir.read_name () ) {
-                       copy_file ( _src+name, _dest+name );
+               try {
+                       GLib.Dir dir = GLib.Dir.open ( _src );
+                       for ( weak string name = dir.read_name (); name != null ; name = dir.read_name () ) {
+                               if ( !copy_file ( _src+name, _dest+name ) ) {
+                                       return false;
+                               }
+                       }
+               }
+               catch ( GLib.FileError err ) {
+                       return false;
                }
+               return true;
        }
 
        public string realpath (string name) {
@@ -1023,14 +1031,22 @@ public interface Valadoc.ConstructionMethodHandler : DataType, MethodHandler {
                }
        }
 
+       protected void add_construction_method ( Vala.CreationMethod vm ) {
+               var tmp = new Method ( this.settings, vm, this, this.head );
+               this.construction_methods.add ( tmp );
+               tmp.initialisation ( );
+       }
+
        protected void add_methods_and_construction_methods ( Gee.Collection<Vala.Method> vmethods ) {
                foreach ( Vala.Method vm in vmethods ) {
-                       var tmp = new Method ( this.settings, vm, this, this.head );
-                       tmp.initialisation ( );
-                       if ( tmp.is_constructor )
-                               this.construction_methods.add ( tmp );
-                       else 
-                               this.methods.add ( tmp );
+                       if ( vm is Vala.CreationMethod ) {
+                               if ( ((Vala.CreationMethod)vm).generated == false ) {
+                                       this.add_construction_method ( (Vala.CreationMethod)vm );
+                               }
+                       }
+                       else {
+                               this.add_method ( vm );
+                       }
                }
        }
 }
@@ -1203,7 +1219,7 @@ public interface Valadoc.Visitable : Basic, SymbolAccessibility {
                return true;
        }
 
-       protected bool is_visitor_accessible ( ) {
+       public bool is_visitor_accessible ( ) {
                if ( !this.settings._private && this.is_private )
                        return false;
 
@@ -1416,6 +1432,9 @@ public interface Valadoc.FieldHandler : Basic {
 
        // internal
        public void add_field ( Vala.Field vf ) {
+               if ( vf.generated == true )
+                       return ;
+
                var tmp = new Field ( this.settings, vf, this, this.head );
                this.fields.add ( tmp );
                tmp.initialisation ( );
@@ -1753,6 +1772,7 @@ public class Valadoc.TypeReference : Basic {
                return new Gee.ReadOnlyCollection<TypeReference> ( this.type_arguments );
        }
 
+
        private void set_template_argument_list ( Gee.Collection<Vala.DataType> varguments ) {
                foreach ( Vala.DataType vdtype in varguments ) {
                        var dtype = new TypeReference ( this.settings, vdtype, this, this.head );
@@ -1907,11 +1927,14 @@ public class Valadoc.TypeReference : Basic {
        // internal
        public void set_type_references ( ) {
                Vala.DataType vtype = this.vtyperef;
+
                while ( vtype is Vala.PointerType || vtype is Vala.ArrayType ) {
                        for ( ; vtype is Vala.PointerType ; vtype = ((Vala.PointerType)vtype).base_type );
                        for ( ; vtype is Vala.ArrayType ; vtype = ((Vala.ArrayType)vtype).element_type );
                }
 
+               this.set_template_argument_list ( vtype.get_type_arguments ()  );
+
                if ( vtype is Vala.ErrorType ) {
                        Vala.ErrorDomain verrdom = ((Vala.ErrorType)vtype).error_domain;                
                        if ( verrdom != null )
@@ -4240,13 +4263,25 @@ public class Valadoc.Namespace : Basic, MethodHandler, FieldHandler, NamespaceHa
 
 
 public class Valadoc.Package : Basic, NamespaceHandler {
+       private Gee.ArrayList<Vala.SourceFile> vfiles = new Gee.ArrayList<Vala.SourceFile> ();
+
+       // internal
+       public void add_file ( Vala.SourceFile vfile ) {
+               this.vfiles.add ( vfile );
+       }
+
        public Gee.ArrayList<Namespace> namespaces {
                default = new Gee.ArrayList<Namespace>();
                private set;
                private get;
        }
-
+/*
        public bool is_external_package {
+                /+ internal +/ set;
+                get;
+       }
+*/
+       public bool is_package {
                 private set;
                 get;
        }
@@ -4305,7 +4340,7 @@ public class Valadoc.Package : Basic, NamespaceHandler {
                return new Gee.ReadOnlyCollection<Package> ( this._dependencies );
        }
 
-       private string extract_package_name ( Vala.SourceFile vfile ) {
+       private static string extract_package_name ( Settings settings, Vala.SourceFile vfile ) {
                if ( vfile.filename.has_suffix (".vapi") ) {
                        string file_name = GLib.Path.get_basename (vfile.filename);
                        return file_name.ndup ( file_name.size() - ".vapi".size() );
@@ -4319,12 +4354,18 @@ public class Valadoc.Package : Basic, NamespaceHandler {
                }
        }
 
-       public Package ( Valadoc.Settings settings, Vala.SourceFile vfile, Tree head ) {
+       public Package.with_name ( Valadoc.Settings settings, Vala.SourceFile vfile, string name, Tree head, bool is_package = false ) {
                this.settings = settings;
                this.head = head;
 
-               this.is_external_package = !( vfile.filename.has_suffix ( ".vala" ) || vfile.filename.has_suffix ( ".gs" ) );
-               this.package_name = this.extract_package_name ( vfile );
+               this.is_package = is_package;
+               this.package_name = name;
+
+               this.vfiles.add ( vfile );
+       }
+
+       public Package ( Valadoc.Settings settings, Vala.SourceFile vfile, Tree head, bool is_package = false ) {
+               this.with_name ( settings, vfile, this.extract_package_name ( settings, vfile ), head, is_package );
        }
 
        private string package_name;
@@ -4363,14 +4404,28 @@ public class Valadoc.Package : Basic, NamespaceHandler {
        }
 
        // internal
-       public bool is_package ( Vala.SourceFile vfile ) {
-               return ( this.extract_package_name ( vfile ) == this.package_name );
+       public bool is_vpackage ( Vala.SourceFile vfile ) {
+               return this.vfiles.contains ( vfile );
+       }
+
+/*
+is_package || with_deps || ergebnis
+0          ||         0 || 1
+0          ||         1 || 1
+1          ||         0 || 0
+1          ||         1 || 1
+
+!(is_package == true && with_deps == false)
+*/
+
+       public bool is_visitor_accessible () {
+               return !( this.is_package && this.settings.with_deps == false );
        }
 
        public void visit ( Doclet doclet ) {
-               if ( !settings.to_doc ( this.name ) )
+               if ( !this.is_visitor_accessible () ) {
                        return ;
-
+               }
                doclet.visit_package ( this );
        }
 
@@ -4404,9 +4459,144 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                private get;
        }
 
-       public Tree (Valadoc.Settings settings, Vala.CodeContext context ) {
+       public Tree (   Valadoc.Settings settings,
+                                       bool non_null_experimental,
+                                       bool disable_non_null,
+                                       bool disable_checking,
+                                       string basedir,
+                                       string directory )
+       {
+               this.context = new Vala.CodeContext ( );
                this.settings = settings;
-               this.context = context;
+
+               if ( basedir != null ) {
+                       this.context.basedir = realpath ( basedir );
+               }
+
+               if ( directory != null ) {
+                       this.context.directory = realpath ( directory );
+               }
+               else {
+                       this.context.directory = context.basedir;
+               }
+
+               this.context.non_null = !disable_non_null || non_null_experimental;
+               this.context.non_null_experimental = non_null_experimental;
+               this.context.checking = !disable_checking;
+
+               this.context.memory_management = false;
+               this.context.compile_only = false;
+               this.context.save_temps = false;
+               this.context.save_temps = false;
+               this.context.checking = false;
+               this.context.assert = false;
+               this.context.thread = false;
+               this.context.library = null;
+               this.context.debug = false;
+               this.context.output = null;
+               this.context.optlevel = 0;
+       }
+
+       private Package source_package = null;
+
+       private void add_dependencies_to_source_package () {
+               if ( this.source_package != null ) {
+                       Gee.ArrayList<Package> deplst = new Gee.ArrayList<Package> ();
+                       foreach ( Package pkg in this.files ) {
+                               if ( pkg != this.source_package ) {
+                                       deplst.add ( pkg );
+                               }
+                       }               
+                       this.source_package.set_dependency_list ( deplst );
+               }
+       }
+
+       public bool add_file ( string path ) {
+               string source = realpath ( path );
+
+               if ( FileUtils.test ( source, FileTest.EXISTS ) == false )
+                       return false;
+
+               if ( path.has_suffix ( ".c" ) ) {
+                       this.context.add_c_source_file ( source );
+                       return true;
+               }
+
+               Vala.SourceFile vfile = null;
+
+               if ( path.has_suffix ( ".vala" ) || path.has_suffix ( ".gs" ) ) {
+                       vfile = new Vala.SourceFile (this.context, source, false);
+                       vfile.add_using_directive (new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)));
+                       this.context.add_source_file ( vfile );
+
+               }
+               else if ( path.has_suffix ( ".vapi" ) ) {
+                       vfile = new Vala.SourceFile ( this.context, source, true );
+                       this.context.add_source_file ( vfile );
+               }
+               else {
+                       return false;
+               }
+
+               if ( this.source_package == null ) {
+                       this.source_package = new Package.with_name ( this.settings, vfile, this.settings.pkg_name, this );
+                       this.files.add ( this.source_package );
+               }
+
+               this.source_package.add_file ( vfile );
+               return true;
+       }
+
+       public bool add_external_package ( string[] vapi_directories, string pkg ) {
+               if ( this.context.has_package ( pkg ) ) {
+                       return true;
+               }
+
+               var package_path = this.context.get_package_path ( pkg, vapi_directories );
+               if ( package_path == null ) {
+                       return false;
+               }
+       
+               this.context.add_package ( pkg );
+
+
+               Vala.SourceFile vfile = new Vala.SourceFile ( this.context, package_path, true );
+               this.context.add_source_file ( vfile );
+
+
+               Package vdpkg = new Package ( this.settings, vfile, this, true ); 
+               this.files.add ( vdpkg );
+
+
+               var deps_filename = Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg));
+               if (FileUtils.test (deps_filename, FileTest.EXISTS)) {
+                       try {
+                               Gee.ArrayList<Package> deppkglst = new Gee.ArrayList<Package> ();
+                               string deps_content;
+                               ulong deps_len;
+
+                               FileUtils.get_contents ( deps_filename, out deps_content, out deps_len );
+                               foreach (string dep in deps_content.split ( "\n" )) {
+                                       if (dep != "") {
+                                               if ( add_external_package ( vapi_directories, dep ) ) {
+                                                       Package? deppkg = get_external_package_by_name ( dep );
+                                                       if ( deppkg != null ) {
+                                                               deppkglst.add ( deppkg );
+                                                       }
+                                               }
+                                               else {
+                                                       Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg));
+                                               }
+                                       }
+                               }
+                               vdpkg.set_dependency_list ( deppkglst );
+                       }
+                       catch (FileError e) {
+                               Report.error (null, "Unable to read dependency file: %s".printf (e.message));
+                       }
+               }
+               
+               return true;
        }
 
        public CodeContext context {
@@ -4420,11 +4610,11 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                }
        }
 
-
+/*
        private weak Basic?  search_symbol_in_namespace ( Basic element, string[] params ) {
                return this.search_symbol_in_symbol ( element.nspace, params );
        }
-
+*/
        private weak Basic? search_symbol_in_type ( Basic element, string[] params, int params_offset = 0 ) {
                if ( !( element.parent is ContainerDataType || element.parent is Enum || element.parent is ErrorDomain ) )
                        return null;
@@ -4522,7 +4712,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = vcl.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( vcl );
                ns.add_class ( vcl );
        }
@@ -4532,7 +4722,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = viface.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( viface );
                ns.add_interface ( viface );
        }
@@ -4542,7 +4732,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = vstru.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( vstru );
                ns.add_struct ( vstru );
        }
@@ -4552,7 +4742,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = vf.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( vf );
                ns.add_field ( vf );
        }
@@ -4562,7 +4752,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = vm.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( vm );
                ns.add_method ( vm );
        }
@@ -4572,7 +4762,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = vd.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( vd );
                ns.add_delegate ( vd );
        }
@@ -4582,7 +4772,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = venum.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( venum );
                ns.add_enum ( venum );
        }
@@ -4592,7 +4782,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = vc.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( vc );
                ns.add_constant ( vc );
        }
@@ -4602,22 +4792,50 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                        return ;
 
                Vala.SourceFile vfile = verrdom.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
                Namespace ns = file.get_namespace ( verrdom );
                ns.add_error_domain ( verrdom );
        }
 
-       public void create_tree ( ) {
+       public bool create_tree ( ) {
+               Vala.Parser parser  = new Vala.Parser ();
+               parser.parse ( this.context );
+               if (Report.get_errors () > 0) {
+                       return false;
+               }
+
+               Vala.SymbolResolver resolver = new SymbolResolver ();
+               resolver.resolve( this.context );
+               if (Report.get_errors () > 0) {
+                       return false;
+               }
+
+               Vala.SemanticAnalyzer analyzer = new SemanticAnalyzer ( );
+               analyzer.analyze( this.context );
+               if (Report.get_errors () > 0) {
+                       return false;
+               }
+
+               if ( context.non_null_experimental ) {
+                       Vala.NullChecker null_checker = new NullChecker ();
+                       null_checker.check ( this.context );
+
+                       if (Report.get_errors () > 0) {
+                               return false;
+                       }
+               }
+
                this.context.accept( this );
                this.set_type_references ( );
-               this.inheritance ( ); // remove
-               this.add_dependencies ();
+               this.inheritance ( ); // create a switch!
+               this.add_dependencies_to_source_package ();
+               return true;
        }
 
        // internal
        public Package? find_file ( Vala.SourceFile vfile ) {
                foreach ( Package f in this.files ) {
-                       if ( f.is_package( vfile ) )
+                       if ( f.is_vpackage( vfile ) )
                                return f;
                }
                return null;
@@ -4664,11 +4882,12 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                }
 
                Vala.SourceFile vfile = vnode.source_reference.file;
-               Package file = this.get_file ( vfile );
+               Package file = this.find_file( vfile );
 
                return file.search_element_vala ( params, 0 );
        }
 
+       /*/ => add_external_package
        private Gee.ArrayList<Package>? load_dependency_list ( string vapi_path ) {
                if ( vapi_path.has_suffix ( ".vapi" ) ) {
                        string deps_filename = vapi_path.ndup ( vapi_path.size() - ".vapi".size() ) + ".deps";
@@ -4690,7 +4909,8 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                                                        }
                                                }
                                        }
-                               } catch (FileError e) {
+                               }
+                               catch (FileError e) {
                                        Report.error (null, "Unable to read dependency file: %s".printf (e.message));
                                }
                        }
@@ -4698,10 +4918,10 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                }
                return null;
        }
+*/
+//     private Gee.ArrayList<weak Vala.SourceFile> vfiles = new Gee.ArrayList<weak Vala.SourceFile> ();
 
-       private Gee.ArrayList<weak Vala.SourceFile> vfiles = new Gee.ArrayList<weak Vala.SourceFile> ();
-       private Package source_package;
-
+/*
        private void add_dependencies () {
                foreach ( weak Vala.SourceFile vfile in this.vfiles ) {
                        Gee.ArrayList<Package>? deps = this.load_dependency_list ( vfile.filename );
@@ -4724,21 +4944,25 @@ public class Valadoc.Tree : Vala.CodeVisitor {
                this.source_package = null;
                this.vfiles = null;
        }
+*/
+       private Package? get_external_package_by_name ( string name ) {
+               foreach ( Package pkg in this.files ) {
+                       if ( name == pkg.name ) {
+                               return pkg;
+                       }
+               }
+               return null;
+       }
 
-       // internal
-       public Package get_file ( Vala.SourceFile vfile ) {
+       /*/ internal, deprecated
+       public Package? get_file ( Vala.SourceFile vfile ) {
                Package file = this.find_file( vfile );
                if ( file != null )
                        return file;
 
                Package tmp = new Package ( this.settings, vfile, this ); 
-               if ( tmp.is_external_package )
-                       this.vfiles.add ( vfile );
-               else
-                       this.source_package = tmp;
-
                this.files.add ( tmp );
                return tmp;
-       }
+       } */
 }
 
index 2f0ea1e5562f345bfc7585512a73470203c4a4fe..f16d773f9eb9c17ae7a266b9bfbc742977e30e23 100755 (executable)
@@ -16,59 +16,6 @@ namespace Valadoc.Diagrams {
                return name + type.name;
        }
 
-       private static void draw_package_parents ( Package package, Graphviz.Graph g, Graphviz.Node me ) {
-               weak Graphviz.Node? node = g.find_node ( package.name );
-
-
-               Gee.Collection<Package> packlst = package.get_dependency_list ( );
-
-               foreach ( Package pkg in packlst ) {
-                       weak Graphviz.Node gpkg = draw_package ( g, pkg, me );
-                       draw_package_parents ( pkg, g, gpkg );
-               }
-       }
-
-       private static weak Graphviz.Node draw_package ( Graph g, Package package, Graphviz.Node? parent ) {
-               string name = package.name;
-               weak Graphviz.Node? node = g.find_node ( name );
-               if ( node == null ) {
-                       node = g.node ( name );
-                       node.set_safe ( "shape", "box", "" );
-                       node.set_safe ( "fontname", "Times", "" );
-               }
-
-               if ( parent != null ) {
-                       if ( g.find_edge( parent, node ) == null ) {
-                               weak Edge edge = g.edge ( node, parent );
-                               edge.set_safe ( "dir", "back", "" );
-                       }
-               }
-
-               return node;
-       }
-
-       public static void write_dependency_diagram ( Package package, string path ) {
-               string[] params2 = new string[5];
-               params2[0] = "";
-               params2[1] = "-T";
-               params2[2] = "png";
-               params2[3] = "-o";
-               params2[4] = path;
-
-               Graphviz.Context cntxt = Context.context( );
-               cntxt.parse_args ( params2 );
-
-               Graphviz.Graph g = Graph.open ( "g", GraphType.AGRAPH );
-               g.set_safe ( "rank", "", "" );
-
-               weak Graphviz.Node me = draw_package ( g, package, null );
-               draw_package_parents ( package, g, me );
-
-               cntxt.layout_jobs ( g );
-               cntxt.render_jobs ( g );
-               cntxt.free_layout ( g );
-       }
-
        public static void write_struct_diagram ( Struct stru, string path ) {
                string[] params2 = new string[5];
                params2[0] = "";
index 1e0737511879ff01918f9a1e287aa442377dcbb7..428c3e0dcaf588be4615f20a57a9fc85a49044b7 100644 (file)
@@ -340,7 +340,7 @@ public class DocumentationTree : Object {
                bool tmp;
 
                int max = this.description.size;
-               int i;
+               int i = 0;
 
                foreach ( InlineTaglet tag in this.description ) {
                        tmp = tag.write ( res, max, i );
@@ -577,7 +577,6 @@ public class Parser : Object {
 
                string tagline = linestart;
 
-               string? currtagname = "";
                unichar prevprevchr = '\0';
                unichar prevchr = '\0';
 
index 5195a0530ce394fed6d17ca83639dbd1ae1c8b25..c90e8c8d84e16e89b4f5715ed6c0371930a2b222 100755 (executable)
@@ -44,7 +44,7 @@ public class Valadoc.Settings : Object {
                return this.rpath;
        }
 
-       // wtf?
+       /*/
        public bool application {
                get {
                        foreach ( string path in this.files ) {
@@ -54,7 +54,7 @@ public class Valadoc.Settings : Object {
                        return false;
                }
        }
-
+*/
        // remove!
        public bool to_doc ( string name ) {
                if ( with_deps == true )
index a08ca01dd069a1f4d4d896b86a73f10a13369106..d92803e6667d1acde839f6ee21b63a4c7eaa1e7b 100755 (executable)
@@ -32,7 +32,6 @@ using Gee;
 public class ValaDoc : Object {
        private static string basedir = null;
        private static string directory = null;
-       private static string xmlsource = null;
        private static string pkg_name = null;
        private static string pkg_version = null;
 
@@ -55,8 +54,6 @@ public class ValaDoc : Object {
        [NoArrayLength ()]
        private static weak string[] tsources;
        [NoArrayLength ()]
-       private static string library;
-       [NoArrayLength ()]
        private static weak string[] tpackages;
 
 
@@ -64,8 +61,8 @@ public class ValaDoc : Object {
        private Type doclettype;
 
 
-       private Gee.ArrayList<string> packages = new Gee.ArrayList<string>();
-       private Gee.ArrayList<string> sources  = new Gee.ArrayList<string>();
+       private Gee.ArrayList<string> packages = new Gee.ArrayList<string>(); // remove
+       private Gee.ArrayList<string> sources  = new Gee.ArrayList<string>(); // remove
 
 
        private const GLib.OptionEntry[] options = {
@@ -93,7 +90,7 @@ public class ValaDoc : Object {
                { null }
        };
 
-       private int quit () {
+       private static int quit () {
                if (Report.get_errors () == 0) {
                        stdout.printf ("Succeeded - %d warning(s)\n", Report.get_warnings ());
                        return 0;
@@ -103,7 +100,7 @@ public class ValaDoc : Object {
                        return 1;
                }
        }
-
+/*
        private bool add_package (CodeContext context, string pkg) {
                if (context.has_package (pkg)) {
                        // ignore multiple occurences of the same package
@@ -140,7 +137,7 @@ public class ValaDoc : Object {
                
                return true;
        }
-
+*/
 /*
        private string? get_package_path (string pkg) {
                if (FileUtils.test ( pkg, FileTest.EXISTS))
@@ -194,6 +191,7 @@ public class ValaDoc : Object {
                }
        }
 
+       // remove
        private Gee.ArrayList<string> sort_sources ( ) {
                var to_doc = new Gee.ArrayList<string>();
 
@@ -215,12 +213,9 @@ public class ValaDoc : Object {
                        }
                }
 
-               this.tpackages = null;
-               this.tsources = null;
                return to_doc;
        }
 
-
 /*
        private static Gee.HashMap<string, Valadoc.TagletCreator> get_taglets ( ) {
                Gee.HashMap<string, Valadoc.TagletCreator> taglets
@@ -335,7 +330,6 @@ public class ValaDoc : Object {
                        module->symbol( "register_plugin", out function );
                        Valadoc.TagletRegisterFunction tagletregisterfkt = (Valadoc.TagletRegisterFunction) function;
 
-                       string? name;
 
                        GLib.Type type = tagletregisterfkt ( taglets2 );
 
@@ -366,14 +360,14 @@ public class ValaDoc : Object {
                return (Doclet)GLib.Object.new (doclettype);
        }
 
-       private bool check_pkg_name () {
+       private static bool check_pkg_name () {
                if ( pkg_name == null )
                        return true;
 
                if ( pkg_name == "glib-2.0" || pkg_name == "gobject-2.0" )
                        return false;
 
-               foreach (string package in this.packages ) {
+               foreach (string package in tsources ) {
                        if ( pkg_name == package )
                                return false;
                }
@@ -392,73 +386,83 @@ public class ValaDoc : Object {
        }
 
        private int run (  ) {
-               if ( !check_pkg_name () ) {
-                       Report.error (null, "Invalid package name." );
-               }
-
                var settings = new Valadoc.Settings ( );
                settings.pkg_name = this.get_pkg_name ( );
                settings.pkg_version = this.pkg_version;
 
                settings.add_inherited = this.add_inherited;
-               settings.files = this.sort_sources ( );
+
+               settings.files = this.sort_sources ( ); /// <--- remove!
+
                settings._protected = this._protected;
                settings.with_deps = this.with_deps;
                settings._private = this._private;
                settings.path = this.directory;
 
-               var context = new Vala.CodeContext();
-               context.library = this.library;
-               context.memory_management = false;
-               context.assert = false;
-               context.checking = false;
-               context.ccode_only = false;
-               context.compile_only = false;
-               context.output = null;
 
-               context.checking = !disable_checking;
-               context.non_null = !disable_non_null || non_null_experimental;
-               context.non_null_experimental = non_null_experimental;
+               Reporter reporter = new Reporter();
 
+               string fulldirpath = (pluginpath == null)? Config.plugin_dir : pluginpath;
+               bool tmp = this.check_doclet_structure ( pluginpath );
 
-               if ( this.basedir != null ) {
-                       context.basedir = realpath ( this.basedir );
+               if ( tmp == false ) {
+                       Report.error (null, "failed to load plugin" );
+                       return quit ();
                }
 
-               if ( this.directory != null ) {
-                       context.directory = realpath ( this.directory );
+
+               Gee.HashMap<string, Type> taglets;
+               GLib.Type strtag;
+
+               tmp = this.load_taglets ( fulldirpath, out taglets, out strtag );
+               if ( tmp == false ) {
+                       Report.error (null, "failed to load plugin" );
+                       return quit ();
                }
-               else {
-                       context.directory = context.basedir;
+
+               Valadoc.Doclet doclet = this.load_doclet ( fulldirpath );
+               if ( doclet == null ) {
+                       Report.error (null, "failed to load plugin" );
+                       return quit ();
                }
 
-               context.optlevel = 0;
-               context.debug = false;
-               context.thread = false;
-               context.save_temps = false;
+               Valadoc.Parser docparser = new Valadoc.Parser ();
+               docparser.init ( settings, reporter, strtag, taglets );
+
+               Valadoc.Tree doctree = new Valadoc.Tree ( settings, non_null_experimental, disable_non_null, disable_checking, basedir, directory );
 
-               if (!add_package (context, "glib-2.0")) {
-                       Report.error (null, "glib-2.0 not found in specified Vala API directories");
+               if (!doctree.add_external_package ( vapi_directories, "glib-2.0" )) {
+                       Report.error (null, "glib-2.0 not found in specified Vala API directories" );
+                       return quit ();
                }
 
-               if (!add_package (context, "gobject-2.0")) {
+               if (!doctree.add_external_package ( vapi_directories, "gobject-2.0" )) {
                        Report.error (null, "gobject-2.0 not found in specified Vala API directories");
+                       return quit ();
                }
 
-               if ( this.packages != null ) {
-                       foreach (string package in this.packages ) {
-                               if (!add_package (context, package)) {
+               if ( this.tpackages != null ) {
+                       foreach (string package in this.tpackages ) {
+                               if (!doctree.add_external_package ( vapi_directories, package )) {
                                        Report.error (null, "%s not found in specified Vala API directories".printf (package));
+                                       return quit ();
                                }
                        }
-                       this.packages = null;
+                       this.tpackages = null;
                }
 
-               if (Report.get_errors () > 0) {
-                       return quit ();
+               if ( this.tsources != null ) {
+                       foreach ( string src in this.tsources ) {
+                               stdout.printf ( ">__>%s\n", src );
+                               if ( !doctree.add_file ( src ) ) {
+                                       Report.error (null, "%s not found".printf (src));
+                                       return quit ();
+                               }
+                       }
+                       this.tsources = null;
                }
 
-
+/*
                if ( this.sources != null ) {
                        this.add_files( context );
                        this.sources = null;
@@ -466,74 +470,9 @@ public class ValaDoc : Object {
                                return quit ();
                        }
                }
+*/
 
-               var parser  = new Vala.Parser ();
-               parser.parse ( context );
-               if (Report.get_errors () > 0) {
-                       return quit ();
-               }
-
-               var resolver = new SymbolResolver ();
-               resolver.resolve( context );
-               if (Report.get_errors () > 0) {
-                       return quit ();
-               }
-
-               var analyzer = new SemanticAnalyzer ( );
-               analyzer.analyze( context );
-               if (Report.get_errors () > 0) {
-                       return quit ();
-               }
-
-               if (context.non_null_experimental) {
-                       var null_checker = new NullChecker ();
-                       null_checker.check (context);
-
-                       if (Report.get_errors () > 0) {
-                               return quit ();
-                       }
-               }
-
-               Reporter reporter = new Reporter();
-
-
-
-               string fulldirpath = (pluginpath == null)? Config.plugin_dir : pluginpath;
-
-
-               bool tmp = this.check_doclet_structure ( pluginpath );
-
-
-
-               if ( tmp == false ) {
-                       stdout.printf ( "Error: failed to load plugin.\n" );
-                       return 1;
-               }
-
-
-               Gee.HashMap<string, Type> taglets;
-               GLib.Type strtag;
-
-
-               tmp = this.load_taglets ( fulldirpath, out taglets, out strtag );
-               if ( tmp == false ) {
-                       stdout.printf ( "Error: failed to load plugin.\n" );
-                       return 1;
-               }
-
-               Valadoc.Doclet doclet = this.load_doclet ( fulldirpath );
-               if ( doclet == null ) {
-                       stdout.printf ( "Error: failed to load plugin.\n" );
-                       return 1;
-               }
-
-               Valadoc.Parser docparser = new Valadoc.Parser ();
-               docparser.init ( settings, reporter, strtag, taglets );
-
-
-               Valadoc.Tree doctree = new Valadoc.Tree ( settings, context );
-               doctree.create_tree( );
-               if ( reporter.errors > 0 )
+               if ( !doctree.create_tree( ) )
                        return quit ();
 
                doctree.parse_comments ( docparser );
@@ -594,7 +533,7 @@ public class ValaDoc : Object {
                catch (OptionError e) {
                        stdout.printf ("%s\n", e.message);
                        stdout.printf ("Run '%s --help' to see a full list of available command line options.\n", args[0]);
-                       return 1;
+                       return quit ();
                }
 
                if ( version ) {
@@ -602,14 +541,9 @@ public class ValaDoc : Object {
                        return 0;
                }
 
-               if ( tsources == null ) {
-                       stderr.printf ("No source file specified.\n");
-                       return -1;
-               }
-
                if ( directory == null ) {
-                       stderr.printf ("No output directory specified.\n");
-                       return -1;
+                       Report.error (null, "No output directory specified." );
+                       return quit ();
                }
 
                if ( directory[ directory.len() - 1 ] != '/' ) {
@@ -621,8 +555,8 @@ public class ValaDoc : Object {
                                remove_directory ( directory );
                        }
                        else {
-                               stderr.printf ("File already exists.\n");
-                               return -1;
+                               Report.error (null, "File already exists." );
+                               return quit ();
                        }
                }
 
@@ -635,6 +569,11 @@ public class ValaDoc : Object {
                                pluginpath = pluginpath + "/";
                }
 
+               if ( !check_pkg_name () ) {
+                       Report.error (null, "Invalid package name." );
+                       return quit ();
+               }
+
                var valadoc = new ValaDoc( );
                valadoc.run();
                return 0;