support better tag matching (esp. in scala)

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-10-25 10:42:52 -04:00
parent f93c8bed23
commit bccd1142c0
2 changed files with 7 additions and 5 deletions

View File

@ -989,7 +989,7 @@ class CloseParen(Method):
while y >= 0: while y >= 0:
while i >= 0 and i < len(tokens[y]): while i >= 0 and i < len(tokens[y]):
token = tokens[y][i] token = tokens[y][i]
n = token.name n = token.fqname()
s = token.string s = token.string
if n in w.mode.closetokens and s in w.mode.closetags: if n in w.mode.closetokens and s in w.mode.closetags:
tag_stack.append(s) tag_stack.append(s)

View File

@ -85,8 +85,10 @@ class ScalaGrammar(Grammar):
class ScalaTabber(StackTabber2): class ScalaTabber(StackTabber2):
#open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}} #open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}}
#close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}} #close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}}
open_tokens = {'delimiter': {'{': '}', '(': ')'}} open_tokens = {'delimiter': {'{': '}', '(': ')'},
close_tokens = {'delimiter': {'}': '{', ')': '('}} 'sub.start': {'[': ']'}}
close_tokens = {'delimiter': {'}': '{', ')': '('},
'sub.end': {']': '['}}
control_tokens = {'scala.reserved': set(('if', 'else', 'while', 'do', 'for'))} control_tokens = {'scala.reserved': set(('if', 'else', 'while', 'do', 'for'))}
end_at_eof = True end_at_eof = True
start_free_tokens = {'string.start': 'string.end'} start_free_tokens = {'string.start': 'string.end'}
@ -199,9 +201,9 @@ class Scala(Fundamental):
grammar = ScalaGrammar grammar = ScalaGrammar
commentc = '//' commentc = '//'
actions = [ScalaStart, ScalaDocBrowse, ScalaDocLookup] actions = [ScalaStart, ScalaDocBrowse, ScalaDocLookup]
opentokens = ('delimiter',) opentokens = ('delimiter', 'sub.start')
opentags = {'(': ')', '[': ']', '{': '}'} opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',) closetokens = ('delimiter', 'sub.end')
closetags = {')': '(', ']': '[', '}': '{'} closetags = {')': '(', ']': '[', '}': '{'}
config = { config = {
'scala.api': 'http://www.scala-lang.org/api/current/allclasses.html', 'scala.api': 'http://www.scala-lang.org/api/current/allclasses.html',