Merge remote-tracking branch 'lucas/Code injection in debugger'
authorJean Privat <jean@pryen.org>
Mon, 20 Jan 2014 14:48:46 +0000 (09:48 -0500)
committerJean Privat <jean@pryen.org>
Mon, 20 Jan 2014 14:48:46 +0000 (09:48 -0500)
25 files changed:
.gitignore
Makefile
contrib/nitcc/tests/lexer-shortest.input1 [new file with mode: 0644]
contrib/nitcc/tests/lexer-shortest.input2 [new file with mode: 0644]
contrib/nitcc/tests/lexer-shortest.sablecc [new file with mode: 0644]
contrib/nitcc/tests/sav/lexer-shortest.input1.res [new file with mode: 0644]
contrib/nitcc/tests/sav/lexer-shortest.input2.res [new file with mode: 0644]
lib/nitcc_runtime.nit
lib/standard/collection/range.nit
misc/vim/syntax_checkers/nit/nitc.vim
share/nitdoc/scripts/Nitdoc.QuickSearch.js
share/nitdoc/styles/Nitdoc.QuickSearch.css
share/nitdoc/styles/main.css
src/highlight.nit
src/mkcsrc [moved from src/mkcsrc2 with 100% similarity]
src/ngall.sh
src/nitdoc.nit
src/nitlight.nit
tests/base_attr_gen.nit
tests/base_class_name.nit
tests/sav/base_attr_gen.res
tests/sav/base_attr_gen_alt1.res
tests/sav/nitdoc.res
tests/sav/nitg-e/fixme/base_attr_gen_alt1.res
tests/sav/nitlight.res

index 06197ac..42258a6 100644 (file)
@@ -9,6 +9,7 @@ EIFGENs
 *.orig
 bin/nit*
 doc/stdlib
+doc/nitc
 doc/newmodel
 
 *.aux
index 66eeea6..d3eb558 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ NITCOPT=
 
 all: tools doc/stdlib/index.html
 
-docs: doc/stdlib/index.html doc/newmodel/index.html
+docs: doc/stdlib/index.html doc/nitc/index.html
        #cd doc; make
 
 tools:
@@ -36,19 +36,26 @@ doc/stdlib/index.html: bin/nitdoc
                --custom-menu-items "<li><a href=\"http://nitlanguage.org/\">Nitlanguage.org</a></li>" \
                --custom-overview-text "<p>Documentation for the standard library of Nit<br/>Version $$(git describe)<br/>Date: $$(git show --format="%cd" | head -1)</p>" \
                --custom-footer-text "Nit standard library. Version $$(git describe)." \
-               --source "https://github.com/privat/nit/blob/$$(git rev-parse HEAD)/%f#L%l-%L"
+               --github-upstream "privat:nit:master" \
+               --github-base-sha1 "$$(git rev-parse HEAD)" \
+               --github-gitdir "." \
+               --source "https://github.com/privat/nit/blob/$$(git rev-parse HEAD)/%f#L%l-%L" \
+               --piwik-tracker "pratchett.info.uqam.ca/piwik/" \
+               --piwik-site-id "2"
 
-doc/newmodel/index.html: bin/nitdoc
-       bin/nitdoc src/nit.nit src/nitmetrics.nit src/nitg.nit src/nitx.nit src/nitunit.nit src/nitlight.nit src/dbgcli.nit src/netdbg.nit -d doc/newmodel \
+doc/nitc/index.html: bin/nitdoc
+       bin/nitdoc src/nit.nit src/nitmetrics.nit src/nitg.nit src/nitx.nit src/nitunit.nit src/nitlight.nit src/dbgcli.nit src/netdbg.nit -d doc/nitc \
                --private \
-               --custom-title "Nit New Model" \
+               --custom-title "Nit Compilers and Tools" \
                --custom-menu-items "<li><a href=\"http://nitlanguage.org/\">Nitlanguage.org</a></li>" \
-               --custom-overview-text "<p>Documentation for the Nit tools based on the new metamodel<br/>Version $$(git describe)<br/>Date: $$(git show --format="%cd" | head -1)</p>" \
-               --custom-footer-text "Nit new metamodel. Version $$(git describe)." \
+               --custom-overview-text "<p>Documentation for the Nit tools<br/>Version $$(git describe)<br/>Date: $$(git show --format="%cd" | head -1)</p>" \
+               --custom-footer-text "Nit tools. Version $$(git describe)." \
                --github-upstream "privat:nit:master" \
                --github-base-sha1 "$$(git rev-parse HEAD)" \
                --github-gitdir "." \
-               --source "https://github.com/privat/nit/blob/$$(git rev-parse HEAD)/%f#L%l-%L"
+               --source "https://github.com/privat/nit/blob/$$(git rev-parse HEAD)/%f#L%l-%L" \
+               --piwik-tracker "pratchett.info.uqam.ca/piwik/" \
+               --piwik-site-id "3"
 
 clean:
        rm -rf -- .nit_compile 2> /dev/null || true
diff --git a/contrib/nitcc/tests/lexer-shortest.input1 b/contrib/nitcc/tests/lexer-shortest.input1
new file mode 100644 (file)
index 0000000..2ed7d32
--- /dev/null
@@ -0,0 +1 @@
+{gffffdg}
\ No newline at end of file
diff --git a/contrib/nitcc/tests/lexer-shortest.input2 b/contrib/nitcc/tests/lexer-shortest.input2
new file mode 100644 (file)
index 0000000..915d212
--- /dev/null
@@ -0,0 +1 @@
+{gffffdg
\ No newline at end of file
diff --git a/contrib/nitcc/tests/lexer-shortest.sablecc b/contrib/nitcc/tests/lexer-shortest.sablecc
new file mode 100644 (file)
index 0000000..0e61d95
--- /dev/null
@@ -0,0 +1,8 @@
+Grammar x;
+
+Lexer
+    c = Shortest ('{' Any* '}') ;
+
+Parser
+    p = c ;
+
diff --git a/contrib/nitcc/tests/sav/lexer-shortest.input1.res b/contrib/nitcc/tests/sav/lexer-shortest.input1.res
new file mode 100644 (file)
index 0000000..830ca2d
--- /dev/null
@@ -0,0 +1,4 @@
+Start
+  p
+    c@(1:1-1:10)='{gffffdg}'
+  Eof@(1:10-1:10)=''
diff --git a/contrib/nitcc/tests/sav/lexer-shortest.input2.res b/contrib/nitcc/tests/sav/lexer-shortest.input2.res
new file mode 100644 (file)
index 0000000..cef128b
--- /dev/null
@@ -0,0 +1,3 @@
+NLexerError@(1:1-1:9)='{gffffdg'
+Nodes[Node]
+  NLexerError@(1:1-1:9)='{gffffdg'
index b5fb0fb..1342c59 100644 (file)
@@ -186,12 +186,14 @@ abstract class Lexer
                                last_state = state
                        end
                        var c
+                       var next
                        if pos >= length then
                                c = '\0'
+                               next = null
                        else
                                c = text[pos]
+                               next = state.trans(c)
                        end
-                       var next = state.trans(c)
                        if next == null then
                                if pos_start < length then
                                        if last_state == null then
index 1c3e934..eb3aef3 100644 (file)
@@ -90,10 +90,15 @@ class IteratorRange[E: Discrete]
        end
 end
 
-redef class Discrete
+redef class Int
        # Returns the range from 0 to `self-1`, is used to do:
        #
-       #    for i in 3.times do print "Cool"
-       #    for i in 100.times do print "{i}/100"
-       fun times: Range[OTHER] do return new Range[OTHER](0, self-1)
+       #    var s = new Array[String]
+       #    for i in 3.times do s.add "cool"
+       #    assert s.join(" ") == "cool cool cool"
+       #
+       #    s.clear
+       #    for i in 10.times do s.add(i.to_s)
+       #    assert s.to_s == "0123456789"
+       fun times: Range[Int] do return [0 .. self[
 end
index 448c7ae..563e478 100644 (file)
@@ -37,7 +37,7 @@ function! SyntaxCheckers_nit_nitc_IsAvailable()
 endfunction
 
 function! SyntaxCheckers_nit_nitc_GetLocList()
-       let makeprg = s:nitc . " --no-color --only-metamodel 2>&1 " . shellescape(expand("%"))
+       let makeprg = s:nitc . " --no-color --only-metamodel "
 
        " custom NIT_DIR
        if exists('g:syntastic_nit_dir')
@@ -56,9 +56,22 @@ function! SyntaxCheckers_nit_nitc_GetLocList()
                endfor
        end
 
+       " alternative main module
+       if exists('g:nit_main')
+               let makeprg .= " " . g:nit_main
+       else
+               let makeprg .= " " . shellescape(expand("%"))
+       end
+
+       " pipe stderr
+       let makeprg .= " 2>&1 "
+
        " possible combinations of error messages
-       let ef_start = [ '%f:%l\,%c--%*[0-9]:', '%f:%l\,%c--%*[0-9]\,%*[0-9]:', '%f:%l\,%c:' ]
-       let ef_type = [ ' %tarning: ', '' ]
+       let ef_start = [ '%f:%l\,%c--%*[0-9]:',
+                                  \ '%f:%l\,%c--%*[0-9]\,%*[0-9]:',
+                                  \ '%f:%l\,%c:' ]
+       let ef_type = [ ' %tarning: ',
+                                 \ '' ]
 
        " generate errorformat from combinations
        let errorformat = ""
index 25e3b94..20dcf60 100644 (file)
@@ -39,8 +39,11 @@ Nitdoc.QuickSearch = function() {
                        value: "quick search..."
                })
                .addClass("nitdoc-qs-field-notused")
+               .keydown(function(event) {
+                       return Nitdoc.QuickSearch.doKeyDownAction(event.keyCode);
+               })
                .keyup(function(event) {
-                       Nitdoc.QuickSearch.doKeyAction(event.keyCode);
+                       Nitdoc.QuickSearch.doKeyUpAction(event.keyCode);
                })
                .focusout(function() {
                        if($(this).val() == "") {
@@ -67,15 +70,23 @@ Nitdoc.QuickSearch = function() {
                });
        }
 
-       // Respond to key event
-       var doKeyAction = function(key) {
+       var doKeyDownAction = function(key) {
                switch(key) {
                        case 38: // Up
                                selectPrevResult();
-                       break;
-
+                               return false;
                        case 40: // Down
                                selectNextResult();
+                               return false;
+                       default:
+                               return true;
+                }
+       }
+
+       var doKeyUpAction = function(key) {
+               switch(key) {
+                       case 38: // Up
+                       case 40: // Down
                        break;
 
                        case 13: // Enter
@@ -93,32 +104,55 @@ Nitdoc.QuickSearch = function() {
                                if(!query) {
                                        return false;
                                }
-                               var results = rankResults(query);
-                               results.sort(resultsSort);
+                               var results = getResults(query);
                                displayResultsTable(query, results);
                        break;
                }
        }
 
-       // Rank raw list entries corresponding to query
-       var rankResults = function(query) {
-               var results = new Array();
+       // Get results corresponding to search query
+       var getResults = function(query) {
+               var results = {};
+               results.matches = new Array();
                for(var entry in rawList) {
-                       for(var i in rawList[entry]) {
-                               var result = rawList[entry][i];
-                               result.entry = entry;
-                               result.distance = query.dice(entry);
-                               results[results.length] = result;
+                       if(!entry.startsWith(query, true)) {
+                               continue;
+                       }
+                       var cat = new Object();
+                       cat.name = entry;
+                       cat.entries = rawList[entry];
+                       results.matches[results.matches.length] = cat;
+
+                       if(entry == query) {
+                               cat.rank = 3;
+                       } else if(entry.toUpperCase() == query.toUpperCase()) {
+                               cat.rank = 2;
+                       } else {
+                               cat.rank = 1 + query.dice(entry);
                        }
                }
+               results.matches.sort(rankSorter);
+               results.partials = new Array();
+               if(results.matches.length == 0) {
+                       for(var entry in rawList) {
+                               var cat = new Object();
+                               cat.name = entry;
+                               cat.entries = rawList[entry];
+                               cat.rank = query.dice(entry);
+                               if(cat.rank > 0) {
+                                       results.partials[results.partials.length] = cat;
+                               }
+                       }
+                       results.partials.sort(rankSorter);
+               }
                return results;
        }
 
-       // Sort an array of results
-       var resultsSort = function(a, b){
-               if(a.distance < b.distance) {
+       // Sort an array of results by rank
+       var rankSorter = function(a, b){
+               if(a.rank < b.rank) {
                        return 1;
-               } else if(a.distance > b.distance) {
+               } else if(a.rank > b.rank) {
                        return -1;
                }
                return 0;
@@ -132,91 +166,173 @@ Nitdoc.QuickSearch = function() {
                // Build results table
                currentIndex = -1;
                currentTable = $(document.createElement("table"));
+               currentTable.attr("id", "nitdoc-qs-table");
+               currentTable.css("position", "absolute");
+               currentTable.width(searchField.outerWidth());
 
-               for(var i in results) {
-                       if(i > 10) {
-                               break;
+               var maxSize = 10;
+               var count = 0;
+               var resultSet;
+               if(results.matches.length == 0) {
+                       resultSet = results.partials
+               } else {
+                       resultSet = results.matches
+               }
+               for(var i in resultSet) {
+                       var cat = resultSet[i];
+                       var result = cat.entries[0];
+
+                       addResultRow(count, cat.name, result.txt, result.url, "nitdoc-qs-cat")
+                       if(count >= maxSize) {
+                               currentTable.find("tbody").children().last().hide();
                        }
-                       var result = results[i];
-                       currentTable.append(
+                       count++;
+
+                       for(var j = 1; j < cat.entries.length; j++) {
+                               var result = cat.entries[j];
+                               addResultRow(count, cat.name, result.txt, result.url, "nitdoc-qs-sub")
+                               if(count >= maxSize) {
+                                       currentTable.find("tr.nitdoc-qs-row").last().hide();
+                               }
+                               count++;
+                       }
+               }
+               if(count >= maxSize) {
+                       currentTable.prepend(
                                $(document.createElement("tr"))
-                               .data("searchDetails", {name: result.entry, url: result.url})
-                               .data("index", i)
-                               .append($(document.createElement("td")).html(result.entry))
+                               .addClass("nitdoc-qs-overflow-up")
+                               .addClass("nitdoc-qs-overflow-inactive")
                                .append(
                                        $(document.createElement("td"))
-                                               .addClass("nitdoc-qs-info")
-                                               .html(result.txt + "&nbsp;&raquo;")
+                                       .attr("colspan", 2)
+                                       .html("&#x25B2;")
                                )
-                               .mouseover( function() {
-                                       $(currentTable.find("tr")[currentIndex]).removeClass("nitdoc-qs-active");
-                                       $(this).addClass("nitdoc-qs-active");
-                                       currentIndex = $(this).data("index");
+                               .click( function(e) {
+                                       e.stopPropagation();
+                                       selectPrevResult();
                                })
-                               .mouseout( function() {
-                                       $(this).removeClass("nitdoc-qs-active");
-                                })
-                               .click( function() {
-                                       window.location = $(this).data("searchDetails")["url"];
+                       );
+                       currentTable.append(
+                               $(document.createElement("tr"))
+                               .addClass("nitdoc-qs-overflow-down")
+                               .addClass(count >= maxSize ? "nitdoc-qs-overflow-active" : "nitdoc-qs-overflow-inactive")
+                               .append(
+                                       $(document.createElement("td"))
+                                       .attr("colspan", 2)
+                                       .html("&#x25BC;")
+                               )
+                               .click( function(e) {
+                                       e.stopPropagation();
+                                       console.log("nest");
+                                       selectNextResult();
                                })
                        );
                }
+               if(results.matches.length == 0) {
+                       currentTable.prepend(
+                               $("<tr class='nitdoc-qs-noresult'>")
+                               .append(
+                                       $("<td colspan='2'>")
+                                       .html("Sorry, there is no match, best results are:")
+                               )
+                       );
+               }
+
+               // Initialize table
+               $("body").append(currentTable);
+               resizeResultsTable();
+               if(currentTable.find("tr").length > 0) {
+                       setIndex(0);
+               }
+       }
+
+       // adds a result row to the current result table
+       var addResultRow = function(index, name, txt, url, cls) {
                currentTable.append(
-                       $("<tr class='nitdoc-qs-overflow'>")
+                       $(document.createElement("tr"))
+                       .addClass("nitdoc-qs-row")
+                       .data("searchDetails", {name: name, url: url})
+                       .data("index", index)
+                       .append(
+                               $(document.createElement("td")).html(name)
+                               .addClass(cls)
+                       )
                        .append(
-                               $("<td colspan='2'>")
-                               .html("Best results for '" + query + "'")
+                               $(document.createElement("td"))
+                                       .addClass("nitdoc-qs-info")
+                                       .html(txt + "&nbsp;&raquo;")
                        )
+                       .mouseover( function() {
+                               setIndex($(this).data("index"));
+                       })
+                       .mouseout( function() {
+                               $(this).removeClass("nitdoc-qs-active");
+                        })
+                       .click( function() {
+                               window.location = $(this).data("searchDetails")["url"];
+                       })
                );
+       }
 
-               // Initialize table properties
-               currentTable.attr("id", "nitdoc-qs-table");
-               currentTable.css("position", "absolute");
-               currentTable.width(searchField.outerWidth());
-               $("body").append(currentTable);
-               currentTable.offset({left: searchField.offset().left + (searchField.outerWidth() - currentTable.outerWidth()), top: searchField.offset().top + searchField.outerHeight()});
-               // Preselect first entry
-               if(currentTable.find("tr").length > 0) {
-                       currentIndex = 0;
-                       $(currentTable.find("tr")[currentIndex]).addClass("nitdoc-qs-active");
-                       searchField.focus();
-               }
+       // adapts result table to content
+       var resizeResultsTable = function() {
+               currentTable.offset({
+                       left: searchField.offset().left + (searchField.outerWidth() - currentTable.outerWidth()),
+                       top: searchField.offset().top + searchField.outerHeight()
+               });
+       }
+
+       // select row at index
+       var setIndex = function(index) {
+               $(currentTable.find("tr.nitdoc-qs-row")[currentIndex]).removeClass("nitdoc-qs-active");
+               currentIndex = index;
+               var currentRow = $(currentTable.find("tr.nitdoc-qs-row")[currentIndex]);
+               currentRow.addClass("nitdoc-qs-active");
+               //searchField.val(currentRow.data("searchDetails").name);
+       }
+
+       var hasPrev = function(index) {
+               return index - 1 >= 0;
+       }
+
+       var hasNext = function(index) {
+               return index + 1 < currentTable.find("tr.nitdoc-qs-row").length;
        }
 
-       // Select the previous result on current table
        var selectPrevResult = function() {
-               // If already on first result, focus search input
-               if(currentIndex == 0) {
-                       searchField.val($(currentTable.find("tr")[currentIndex]).data("searchDetails").name);
-                       searchField.focus();
-               // Else select previous result
-               } else if(currentIndex > 0) {
-                       $(currentTable.find("tr")[currentIndex]).removeClass("nitdoc-qs-active");
-                       currentIndex--;
-                       $(currentTable.find("tr")[currentIndex]).addClass("nitdoc-qs-active");
-                       searchField.val($(currentTable.find("tr")[currentIndex]).data("searchDetails").name);
-                       searchField.focus();
+               if(hasPrev(currentIndex)) {
+                       setIndex(currentIndex - 1);
+                       if(!$(currentTable.find("tr.nitdoc-qs-row")[currentIndex]).is(":visible")) {
+                               currentTable.find("tr.nitdoc-qs-row:visible").last().hide();
+                               currentTable.find("tr.nitdoc-qs-overflow-down").addClass("nitdoc-qs-overflow-active");
+                               $(currentTable.find("tr.nitdoc-qs-row")[currentIndex]).show();
+                               if(!hasPrev(currentIndex)) {
+                                       currentTable.find("tr.nitdoc-qs-overflow-up").removeClass("nitdoc-qs-overflow-active");
+                               }
+                               resizeResultsTable();
+                       }
                }
        }
 
-       // Select the next result on current table
        var selectNextResult = function() {
-               if(currentIndex < currentTable.find("tr").length - 1) {
-                       if($(currentTable.find("tr")[currentIndex + 1]).hasClass("nitdoc-qs-overflow")) {
-                               return;
+               if(hasNext(currentIndex)) {
+                       setIndex(currentIndex + 1);
+                       if(!$(currentTable.find("tr.nitdoc-qs-row")[currentIndex]).is(":visible")) {
+                               currentTable.find("tr.nitdoc-qs-row:visible").first().hide();
+                               currentTable.find("tr.nitdoc-qs-overflow-up").addClass("nitdoc-qs-overflow-active");
+                               $(currentTable.find("tr.nitdoc-qs-row")[currentIndex]).show();
+                               if(!hasNext(currentIndex)) {
+                                       currentTable.find("tr.nitdoc-qs-overflow-down").removeClass("nitdoc-qs-overflow-active");
+                               }
+                               resizeResultsTable();
                        }
-                       $(currentTable.find("tr")[currentIndex]).removeClass("nitdoc-qs-active");
-                       currentIndex++;
-                       $(currentTable.find("tr")[currentIndex]).addClass("nitdoc-qs-active");
-                       searchField.val($(currentTable.find("tr")[currentIndex]).data("searchDetails").name);
-                       searchField.focus();
                }
        }
 
        // Load selected search result page
        var goToResult = function() {
                if(currentIndex > -1) {
-                       window.location = $(currentTable.find("tr")[currentIndex]).data("searchDetails").url;
+                       window.location = $(currentTable.find("tr.nitdoc-qs-row")[currentIndex]).data("searchDetails").url;
                        return;
                }
 
@@ -241,7 +357,8 @@ Nitdoc.QuickSearch = function() {
        // Public interface
        var quicksearch = {
                enableQuickSearch: enableQuickSearch,
-               doKeyAction: doKeyAction,
+               doKeyUpAction: doKeyUpAction,
+               doKeyDownAction: doKeyDownAction,
                closeResultsTable: closeResultsTable
        };
 
@@ -256,36 +373,11 @@ $(document).ready(function() {
  * Utils
  */
 
-// Calculate levenshtein distance beetween two strings
-// see: http://en.wikipedia.org/wiki/Levenshtein_distance
-String.prototype.levenshtein = function(other) {
-       var matrix = new Array();
-
-       for(var i = 0; i <= this.length; i++) {
-               matrix[i] = new Array();
-               matrix[i][0] = i;
+String.prototype.startsWith = function(prefix, caseSensitive) {
+       if(caseSensitive) {
+               return this.toUpperCase().indexOf(prefix.toUpperCase()) === 0;
        }
-       for(var j = 0; j <= other.length; j++) {
-               matrix[0][j] = j;
-       }
-       var cost = 0;
-       for(var i = 1; i <= this.length; i++) {
-               for(var j = 1; j <= other.length; j++) {
-                       if(this.charAt(i - 1) == other.charAt(j - 1)) {
-                               cost = 0;
-                       } else if(this.charAt(i - 1).toLowerCase() == other.charAt(j - 1).toLowerCase()) {
-                               cost = 0.5;
-                       } else {
-                               cost = 1;
-                       }
-                       matrix[i][j] = Math.min(
-                               matrix[i - 1][j] + 1, // deletion
-                               matrix[i][j - 1] + 1, // insertion
-                               matrix[i - 1][j - 1] + cost // substitution
-                       );
-               }
-       }
-       return matrix[this.length][other.length]
+    return this.indexOf(prefix) === 0;
 }
 
 // Compare two strings using Sorensen-Dice Coefficient
@@ -305,11 +397,7 @@ String.prototype.dice = function(other) {
                var bigram1 = this.substr(i, 2);
                for(var j = 0; j < length2; j++) {
                        if(bigram1 == bigrams2[j]) {
-                               intersection += 2;
-                               bigrams2[j] = null;
-                               break;
-                       } else if (bigram1 && bigrams2[j] && bigram1.toLowerCase() == bigrams2[j].toLowerCase()) {
-                               intersection += 1;
+                               intersection++;
                                bigrams2[j] = null;
                                break;
                        }
index 98f5728..b0a434c 100644 (file)
@@ -40,6 +40,9 @@
        border: 1px solid #E0E0E0;\r
        border-spacing: 0px;\r
        z-index: 1000;\r
+       -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);\r
+       -moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);\r
+       box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);\r
 }\r
 \r
 #nitdoc-qs-table .nitdoc-qs-active {\r
@@ -47,7 +50,7 @@
        background: #EEE;\r
 }\r
 \r
-#nitdoc-qs-table td {\r
+#nitdoc-qs-table td, th {\r
        white-space: nowrap;\r
        overflow: hidden;\r
        line-height: 22px;\r
        width: 25%;\r
 }\r
 \r
+#nitdoc-qs-table td.nitdoc-qs-sub {\r
+       color: #6C6C6C;\r
+       padding-left: 12px;\r
+}\r
+\r
 #nitdoc-qs-table td.nitdoc-qs-info {\r
        color: #0D8921;\r
        font-size: small;\r
        text-align: right;\r
 }\r
 \r
-#nitdoc-qs-table tr.nitdoc-qs-overflow td {\r
+#nitdoc-qs-table tr.nitdoc-qs-noresult td {\r
+       color: #6C6C6C;\r
+       font-size: small;\r
+       line-height: 15px;\r
+}\r
+\r
+#nitdoc-qs-table tr.nitdoc-qs-overflow-up td,\r
+#nitdoc-qs-table tr.nitdoc-qs-overflow-down td {\r
        text-align: center;\r
-       background-color: #E0E0E0;\r
+       font-size:      x-small;\r
+       line-height: 10px;\r
+       color: #FFF;\r
+       -webkit-touch-callout: none;\r
+       -webkit-user-select: none;\r
+       -khtml-user-select: none;\r
+       -moz-user-select: none;\r
+       -ms-user-select: none;\r
+       user-select: none;\r
 }\r
 \r
+#nitdoc-qs-table tr.nitdoc-qs-overflow-active td {\r
+       color: #0D8921;\r
+       cursor: pointer;\r
+}\r
+\r
+#nitdoc-qs-table tr.nitdoc-qs-overflow-active td:hover {\r
+       background-color: #E0E0E0;\r
+}\r
index d9174f4..d617b92 100644 (file)
@@ -219,6 +219,12 @@ header nav.main ul li.current {
        padding: 5px;\r
        background: #f1f1f1;\r
        font-size: 1em;\r
+       -webkit-touch-callout: none;\r
+       -webkit-user-select: none;\r
+       -khtml-user-select: none;\r
+       -moz-user-select: none;\r
+       -ms-user-select: none;\r
+       user-select: none;\r
 }\r
 \r
 .sidebar nav h4 {\r
index 78d7a23..c44773c 100644 (file)
@@ -54,6 +54,15 @@ class HighlightVisitor
        # Used to print parts of the source betwen tokens of the AST
        private var pos = 0
 
+       # The line position in the source file.
+       private var line_pos = 0
+
+       # The first line to generate, null if start at the first line
+       var first_line: nullable Int writable = null
+
+       # The last line to generate, null if finish at the last line
+       var last_line: nullable Int writable = null
+
        init
        do
                html.add_class("nitcode")
@@ -77,7 +86,9 @@ class HighlightVisitor
 
                # Add text between `last_token` and `node`
                var pstart = node.location.pstart
-               if pos < pstart then
+               var line_start = node.location.line_start
+               var line_end = node.location.line_end
+               if pos < pstart and (first_line == null or first_line <= line_start) and (last_line == null or last_line >= line_end) then
                        var text = node.location.file.string.substring(pos, pstart-pos)
                        token_head.append(text)
                        #node.debug("WRT: {token_head.classes} << '{text.escape_to_c}' ")
@@ -261,6 +272,12 @@ redef class Token
        # Use `empty_tag` to create the tag ; then fill it and add it to the html
        redef fun accept_highlight_visitor(v)
        do
+               var fl = v.first_line
+               if fl != null and fl > location.line_start then return
+
+               var ll = v.last_line
+               if ll != null and ll < location.line_end then return
+
                var n = make_tag(v)
                if n.attrs.is_empty and n.classes.is_empty then
                        for c in n.children do
similarity index 100%
rename from src/mkcsrc2
rename to src/mkcsrc
index 1dff25f..02e8d53 100755 (executable)
@@ -1,8 +1,8 @@
 #!/bin/bash
-rm nitg nitg.bin hello_world.bin 2>/dev/null
+rm nitg nitg_? hello_world 2>/dev/null
 set -x
 set -e
-time ../bin/nitg nitg.nit -v -o nitg
+time ../c_src/nitg nitg.nit -v -o nitg
 time ./nitg nitg.nit -v "$@" -o nitg_2
 time ./nitg_2 nitg.nit -v "$@" -o nitg_3
 time ./nitg_3 nitg.nit -v "$@" -o nitg_4
index 716c6b8..f8bb81c 100644 (file)
@@ -54,6 +54,9 @@ class NitdocContext
        private var opt_github_base_sha1: OptionString = new OptionString("The sha1 of the base commit used to create pull request", "--github-base-sha1")
        private var opt_github_gitdir: OptionString = new OptionString("The git working directory used to resolve path name (ex: /home/me/myproject/)", "--github-gitdir")
 
+       private var opt_piwik_tracker: OptionString = new OptionString("The URL of the Piwik tracker (ex: nitlanguage.org/piwik/)", "--piwik-tracker")
+       private var opt_piwik_site_id: OptionString = new OptionString("The site ID in Piwik tracker", "--piwik-site-id")
+
        init do
                toolcontext.option_context.add_option(opt_dir)
                toolcontext.option_context.add_option(opt_source)
@@ -67,6 +70,8 @@ class NitdocContext
                toolcontext.option_context.add_option(opt_github_upstream)
                toolcontext.option_context.add_option(opt_github_base_sha1)
                toolcontext.option_context.add_option(opt_github_gitdir)
+               toolcontext.option_context.add_option(opt_piwik_tracker)
+               toolcontext.option_context.add_option(opt_piwik_site_id)
                toolcontext.process_options
                self.arguments = toolcontext.option_context.rest
 
@@ -323,6 +328,26 @@ abstract class NitdocPage
                if ctx.opt_custom_footer_text.value != null then footed = "footed"
                append("<div class='page {footed}'>")
                content
+
+               # piwik tracking
+               var tracker_url = ctx.opt_piwik_tracker.value
+               var site_id = ctx.opt_piwik_site_id.value
+               if tracker_url != null and site_id != null then
+                       append("<!-- Piwik -->")
+                       append("<script type=\"text/javascript\">")
+                       append("  var _paq = _paq || [];")
+                       append("  _paq.push([\"trackPageView\"]);")
+                       append("  _paq.push([\"enableLinkTracking\"]);")
+                       append("  (function() \{")
+                       append("    var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\") + \"://{tracker_url}\";")
+                       append("    _paq.push([\"setTrackerUrl\", u+\"piwik.php\"]);")
+                       append("    _paq.push([\"setSiteId\", \"{site_id}\"]);")
+                       append("    var d=document, g=d.createElement(\"script\"), s=d.getElementsByTagName(\"script\")[0]; g.type=\"text/javascript\";")
+                       append("    g.defer=true; g.async=true; g.src=u+\"piwik.js\"; s.parentNode.insertBefore(g,s);")
+                       append("  \})();")
+                       append(" </script>")
+                       append("<!-- End Piwik Code -->")
+               end
                append("</div>")
                footer
                append("</body>")
index a5e492e..4243ca9 100644 (file)
@@ -20,10 +20,12 @@ import highlight
 var toolcontext = new ToolContext
 
 var opt_fragment = new OptionBool("Omit document header and footer", "-f", "--fragment")
+var opt_first_line = new OptionInt("Start the source file at this line (default: 1)", 0, "--first-line")
+var opt_last_line = new OptionInt("End the source file at this line (default: to the end)", 0, "--last-line")
 var opt_dir = new OptionString("Output html files in a specific directory (required if more than one module)", "-d", "--dir")
 var opt_full = new OptionBool("Process also imported modules", "--full")
 var opt_ast = new OptionBool("Generate specific HTML elements for each Node of the AST", "--ast")
-toolcontext.option_context.add_option(opt_fragment, opt_dir, opt_full)
+toolcontext.option_context.add_option(opt_fragment, opt_first_line, opt_last_line, opt_dir, opt_full)
 
 var model = new Model
 var modelbuilder = new ModelBuilder(model, toolcontext)
@@ -54,6 +56,9 @@ for mm in mmodules do
        if dir != null then toolcontext.info("write {dir}/{mm.name}.html", 1)
 
        var v = new HighlightVisitor
+
+       if opt_first_line.value != 0 then v.first_line = opt_first_line.value
+       if opt_last_line.value != 0 then v.last_line = opt_last_line.value
        if opt_ast.value then v.with_ast = true
        var page = null
        if not opt_fragment.value then
index 480c5ee..8a8a346 100644 (file)
@@ -1,3 +1,21 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2006-2008 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
 class A[E]
        var e: E
        init do end
index 6866ca0..95dbdbc 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import string
+
 class Test end
 class MyArray[E] end
 
@@ -26,10 +28,16 @@ var test2: Object = new Test
 var test3 = new MyArray[Int]
 var test4 = new Toto
 
-print "".class_name
-print 1.class_name
+"".class_name.output
+'\n'.output
+1.class_name.output
+'\n'.output
 
-print test1.class_name
-print test2.class_name
-print test3.class_name
-print test4.class_name
+test1.class_name.output
+'\n'.output
+test2.class_name.output
+'\n'.output
+test3.class_name.output
+'\n'.output
+test4.class_name.output
+'\n'.output
index 56618fe..afe7755 100644 (file)
@@ -1 +1 @@
-Runtime error: Reciever is null (base_attr_gen.nit:8)
+Runtime error: Reciever is null (base_attr_gen.nit:26)
index 72f3c0b..8b464b6 100644 (file)
@@ -1 +1 @@
-Runtime error: Uninitialized attribute @e (alt/base_attr_gen_alt1.nit:7)
+Runtime error: Uninitialized attribute @e (alt/base_attr_gen_alt1.nit:25)
index ee72676..243fc46 100644 (file)
@@ -23,3 +23,5 @@ usage: nitdoc [options] file...
   --github-upstream        The branch where edited commits will be pulled into (ex: user:repo:branch)
   --github-base-sha1       The sha1 of the base commit used to create pull request
   --github-gitdir          The git working directory used to resolve path name (ex: /home/me/myproject/)
+  --piwik-tracker          The URL of the Piwik tracker (ex: nitlanguage.org/piwik/)
+  --piwik-site-id          The site ID in Piwik tracker
index 2b323b6..3b45242 100644 (file)
@@ -1 +1 @@
-Runtime error: Cast failed (alt/base_attr_gen_alt1.nit:8)
+Runtime error: Cast failed (alt/base_attr_gen_alt1.nit:26)
index 279a318..64e6643 100644 (file)
@@ -12,5 +12,7 @@ usage: nitlight [options] files...
   --only-parse            Only proceed to parse step of loaders
   --only-metamodel        Stop after meta-model processing
   -f, --fragment          Omit document header and footer
+  --first-line            Start the source file at this line (default: 1)
+  --last-line             End the source file at this line (default: to the end)
   -d, --dir               Output html files in a specific directory (required if more than one module)
   --full                  Process also imported modules