From bccd1142c002afe93db6ddef24b20ea4a1a8fcb3 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Mon, 25 Oct 2010 10:42:52 -0400 Subject: [PATCH] support better tag matching (esp. in scala) --HG-- branch : pmacs2 --- method/__init__.py | 2 +- mode/scala.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/method/__init__.py b/method/__init__.py index b120da6..6242093 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -989,7 +989,7 @@ class CloseParen(Method): while y >= 0: while i >= 0 and i < len(tokens[y]): token = tokens[y][i] - n = token.name + n = token.fqname() s = token.string if n in w.mode.closetokens and s in w.mode.closetags: tag_stack.append(s) diff --git a/mode/scala.py b/mode/scala.py index 7224bf4..ab8965d 100644 --- a/mode/scala.py +++ b/mode/scala.py @@ -85,8 +85,10 @@ class ScalaGrammar(Grammar): class ScalaTabber(StackTabber2): #open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}} #close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}} - open_tokens = {'delimiter': {'{': '}', '(': ')'}} - close_tokens = {'delimiter': {'}': '{', ')': '('}} + open_tokens = {'delimiter': {'{': '}', '(': ')'}, + 'sub.start': {'[': ']'}} + close_tokens = {'delimiter': {'}': '{', ')': '('}, + 'sub.end': {']': '['}} control_tokens = {'scala.reserved': set(('if', 'else', 'while', 'do', 'for'))} end_at_eof = True start_free_tokens = {'string.start': 'string.end'} @@ -199,9 +201,9 @@ class Scala(Fundamental): grammar = ScalaGrammar commentc = '//' actions = [ScalaStart, ScalaDocBrowse, ScalaDocLookup] - opentokens = ('delimiter',) + opentokens = ('delimiter', 'sub.start') opentags = {'(': ')', '[': ']', '{': '}'} - closetokens = ('delimiter',) + closetokens = ('delimiter', 'sub.end') closetags = {')': '(', ']': '[', '}': '{'} config = { 'scala.api': 'http://www.scala-lang.org/api/current/allclasses.html',