Commit 96e5dbe4 authored by Daniel Espinosa Ortiz's avatar Daniel Espinosa Ortiz

sourceview: highlight text literals

parent ccd1acd5
......@@ -29,7 +29,8 @@ public class GVls.GContainer : Gee.ArrayList<Object>, GLib.ListModel, GVls.Conta
_map.@set ((object as ContainerHashable).hash (), object);
}
public new void remove (Object object) {
foreach (Object ob in this as Gee.ArrayList<Object>) {
for (int i = 0; i < get_n_items (); i++) {
Object ob = get_item (i);
if (ob == object) {
(this as Gee.ArrayList<Object>).remove (ob);
}
......
......@@ -20,6 +20,7 @@ using Vala;
public class GVls.GScanner : Object {
public signal void keyword (Symbol k);
public signal void identifier (Location loc, string name);
public signal void string_literal (Location loc);
private GLib.File _file = null;
private string _content = null;
......@@ -164,12 +165,14 @@ public class GVls.GScanner : Object {
n = l.substring (loc.start.character - 1, loc.end.character - loc.start.character + 1);
identifier (loc, n);
break;
case Vala.TokenType.STRING_LITERAL:
string_literal (loc);
break;
// literals and signs
case Vala.TokenType.INTEGER_LITERAL:
case Vala.TokenType.REAL_LITERAL:
case Vala.TokenType.CHARACTER_LITERAL:
case Vala.TokenType.REGEX_LITERAL:
case Vala.TokenType.STRING_LITERAL:
case Vala.TokenType.TEMPLATE_STRING_LITERAL:
case Vala.TokenType.VERBATIM_STRING_LITERAL:
case Vala.TokenType.ASSIGN:
......
......@@ -17,6 +17,7 @@
*/
using Vala;
using Config;
using GLib;
public class GVls.GServer : GLib.Object, ContainerHashable, Server
{
......@@ -201,6 +202,11 @@ public class GVls.GServer : GLib.Object, ContainerHashable, Server
l.add (ns);
}
});
sc.string_literal.connect ((loc)=>{
var ns = new GStringLiteral (loc);
var ds = new GDocumentSymbol (ns, loc);
l.add (ds);
});
try {
sc.start ();
} catch (GLib.Error e) {
......
/* gvls-gstring-literal.vala
*
* Copyright 2018 Daniel Espinosa <esodan@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Vala;
using GLib;
public class GVls.GStringLiteral : GVls.GStatement
{
construct {
_location = new GLocation ();
_name = "@STRINGLITERAL@";
_kind = SymbolKind.STRING;
}
public GStringLiteral (Location loc) {
_location = loc;
_name = "@STRINGLITERAL@" + GLib.Uuid.string_random ();
}
}
......@@ -65,6 +65,7 @@ gvls_sources = [
'gvls-gserver.vala',
'gvls-gscanner.vala',
'gvls-gstatement.vala',
'gvls-gstring-literal.vala',
'gvls-gsymbol.vala',
'gvls-location.vala',
'gvls-message.vala',
......
......@@ -65,13 +65,10 @@ public class GVlsui.CompletionProvider : GLib.Object, Gtk.SourceCompletionProvid
break;
}
if (uc.ispunct () && !puntfound) {
message ("Puntation....");
if (uc.to_string () == ".") {
message ("Puntation.... POINT");
istr.assign (iter);
iter.forward_char ();
sw = iter.get_visible_text (end);
message ("Text before the DOT: %s", sw);
iter.backward_char ();
puntfound = true;
}
......
......@@ -82,7 +82,7 @@ public class GVlsui.SourceView : Gtk.SourceView
buffer.get_iter_at_line_offset (out start, sym.range.start.line - 1, sym.range.start.character - 1);
buffer.get_iter_at_line_offset (out end, sym.range.end.line - 1, sym.range.end.character);
string current_text = get_buffer ().get_text (start, end, false);
if (current_text != sym.name) continue;
if (current_text != sym.name && sym .kind != GVls.SymbolKind.STRING) continue;
switch (sym.kind) {
case GVls.SymbolKind.KEY:
get_buffer ().apply_tag_by_name ("keyword", start, end);
......@@ -97,6 +97,9 @@ public class GVlsui.SourceView : Gtk.SourceView
case GVls.SymbolKind.METHOD:
get_buffer ().apply_tag_by_name ("method", start, end);
break;
case GVls.SymbolKind.STRING:
get_buffer ().apply_tag_by_name ("text", start, end);
break;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment