[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdev-ruby] duchain/rails: Polishing
From:       Miquel_Sabaté <mikisabate () gmail ! com>
Date:       2012-10-28 21:06:52
Message-ID: 20121028210652.8D0A1A60CE () git ! kde ! org
[Download RAW message or body]

Git commit 328e57d0853c21cdb3db1e9e7829397ca39037b3 by Miquel Sabaté.
Committed on 28/10/2012 at 22:58.
Pushed by mssola into branch 'master'.

Polishing

M  +0    -9    duchain/rails/autoloader.cpp
M  +26   -14   duchain/rails/autoloader.h

http://commits.kde.org/kdev-ruby/328e57d0853c21cdb3db1e9e7829397ca39037b3

diff --git a/duchain/rails/autoloader.cpp b/duchain/rails/autoloader.cpp
index 25d2710..fed70a6 100644
--- a/duchain/rails/autoloader.cpp
+++ b/duchain/rails/autoloader.cpp
@@ -21,13 +21,7 @@
 
 
 #include <duchain/rails/autoloader.h>
-#include <language/duchain/indexedstring.h>
 
-#include <KUrl> // TODO: remove ?
-#include <QtCore/QStringList>
-#include <KDebug>
-#include <duchain/loader.h>
-#include <rubydefs.h>
 
 namespace Rails
 {
@@ -42,16 +36,13 @@ QList<KDevelop::IndexedString> AutoLoader::computePaths(const KDevelop::IndexedS
     const QString &name = dirs.last();
 
     fillUrlCache();
-
     dirs.removeLast();
-    // TODO: can be optimized to leave earlier.
     for (int i = dirs.size() - 1; i >= 0; --i) {
         if (dirs.at(i) == "models") {
             urls << KDevelop::IndexedString(getGem("active_record/base"));
             urls << getDir(m_root.path(KUrl::AddTrailingSlash) + "lib");
             return urls;
         } else if (dirs.at(i) == "controllers") {
-            // TODO: maybe this is too dumb ?
             if (name == "application_controller.rb")
                 urls << KDevelop::IndexedString(getGem("action_controller/base"));
             else
diff --git a/duchain/rails/autoloader.h b/duchain/rails/autoloader.h
index abab4f1..894b936 100644
--- a/duchain/rails/autoloader.h
+++ b/duchain/rails/autoloader.h
@@ -24,45 +24,57 @@
 #define RAILS_AUTOLOADER_H
 
 
-/*
- * TODO: Cache Rails classes  ¿ and paths ?
- */
-
-
-#include <QtCore/QList> // TODO
-#include <KUrl>
-#include <duchain/duchainexport.h>
 #include <duchain/loader.h>
 
-class KUrl;
-
-namespace KDevelop {
-    class IndexedString;
-}
 
 namespace Rails
 {
 
+/**
+ * @class AutoLoader
+ *
+ * This class implements de "auto-require" feature. That is, it does all the
+ * requiring for Rails projects. It's implemented in a way as it's as optimal
+ * as possible.
+ */
 class KDEVRUBYDUCHAIN_EXPORT AutoLoader : public Ruby::Loader
 {
 public:
+    /**
+     * Compute all the paths to require for the given path.
+     *
+     * @param path The given path.
+     * @returns a QList of KDevelop::IndexedString containing all the paths
+     * to be required later on.
+     */
     static QList<KDevelop::IndexedString> computePaths(const KDevelop::IndexedString &path);
 
+    /// Set the project root to the given @p url.
     inline static void setProjectRoot(const KUrl &url)
     {
         m_root = url;
     }
 
+private:
+    /// @returns the absoulte path to the application controller.
     inline static KDevelop::IndexedString appController()
     {
         return KDevelop::IndexedString(m_root.path(KUrl::AddTrailingSlash) +
                "app/controllers/application_controller.rb");
     }
 
-private:
+    /**
+     * Get all the files inside the given directory path. Note that this
+     * is a recursive functions, and files inside subdirectories will
+     * also be retrieved.
+     *
+     * @param path The directory path.
+     * @returns recursively all the files inside the given directory path.
+     */
     static QList<KDevelop::IndexedString> getDir(const QString &path);
 
 private:
+    /// The root directory for the project.
     static KUrl m_root;
 };
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic