start working on support classpath in mode.scala
--HG-- branch : pmacs2
This commit is contained in:
parent
733d522314
commit
bd90421ddc
|
@ -31,10 +31,10 @@ class StringGrammar(Grammar):
|
|||
class SubTypeGrammar(Grammar): pass
|
||||
SubTypeGrammar.rules = [
|
||||
RegionRule('sub', r'\[', SubTypeGrammar, r'\]'),
|
||||
#PatternRule('scala.type', '(?:[a-zA-Z0-9_.]+| *=> *)+'),
|
||||
PatternRule('scala.type', '[A-Z][a-zA-Z0-9_.]*'),
|
||||
PatternRule('spaces', ' +'),
|
||||
PatternRule('scala.annotation', '@[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
RegionRule('scala.string', '"', StringGrammar, '"'),
|
||||
]
|
||||
|
||||
class ScalaGrammar(Grammar):
|
||||
|
@ -43,25 +43,13 @@ class ScalaGrammar(Grammar):
|
|||
RegionRule('scala.comment', r'/\*', NestedCommentGrammar, r'\*/'),
|
||||
RegionRule('scala.script', r'#!.+$', ShGrammar, r'!#'),
|
||||
|
||||
#PatternMatchRule('x', r'(?<!:)(:)((?:[a-zA-Z0-9_.]+| *=> *)+)',
|
||||
# 'delimiter', 'scala.type'),
|
||||
#PatternMatchRule('x', r'(?<!:)(:)( +)((?:[a-zA-Z0-9_.]+| *=> *)+)',
|
||||
# 'delimiter', 'spaces', 'scala.type'),
|
||||
PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)([a-zA-Z0-9_]+)',
|
||||
'delimiter', 'scala.type'),
|
||||
PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)( +)([a-zA-Z0-9_]+)',
|
||||
'delimiter', 'spaces', 'scala.type'),
|
||||
|
||||
#PatternMatchRule('x', r'(extends|with|new)( +)([a-zA-Z0-9_.]+)',
|
||||
# 'scala.reserved', 'spaces', 'scala.type'),
|
||||
#PatternMatchRule('x', r'(with)( +)([a-zA-Z0-9_.]+)',
|
||||
# 'scala.reserved', 'spaces', 'scala.type'),
|
||||
#PatternMatchRule('x', r'(new)( +)([a-zA-Z0-9_.]+)',
|
||||
# 'scala.reserved', 'spaces', 'scala.type'),
|
||||
|
||||
PatternRule('scala.def', '(?<=(?<![a-zA-Z0-9_])def )[^0-9:\[\( ][^:\[\( ]*'),
|
||||
|
||||
#PatternRule('delimiter', r'(?:;|{|}|\[|\]|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'),
|
||||
RegionRule('sub', r'(?<=:)\(', SubTypeGrammar, r'\)'),
|
||||
PatternRule('delimiter', r'(?:;|{|}|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'),
|
||||
RegionRule('sub', r'\[', SubTypeGrammar, r'\]'),
|
||||
|
@ -70,9 +58,6 @@ class ScalaGrammar(Grammar):
|
|||
PatternRule('spaces', r'(?:\t| )+'),
|
||||
PatternRule('eol', r'\n'),
|
||||
|
||||
#PatternRule('scala.def', '(?<=(?<![a-zA-Z0-9_])def )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
#PatternRule('scala.def', '(?<=(?<![a-zA-Z0-9_])def )[^0-9\[\( ][^\[\( ]*'),
|
||||
|
||||
PatternRule('scala.class', '(?<=(?<![a-zA-Z0-9_])class )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule('scala.object', '(?<=(?<![a-zA-Z0-9_])object )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
PatternRule('scala.trait', '(?<=(?<![a-zA-Z0-9_])trait )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
|
@ -117,9 +102,8 @@ class ScalaTabber(StackTabber2):
|
|||
tokens = self._get_tokens(y)
|
||||
if not tokens: return False
|
||||
|
||||
# if it looks like a top-level class, object or function, then say ok
|
||||
t = tokens[0]
|
||||
if t.fqmatchs('scala.reserved', ('class', 'object', 'def')):
|
||||
# if it looks like a top-level class or object, then say ok
|
||||
if tokens[0].fqmatchs('scala.reserved', ('class', 'object')):
|
||||
return True
|
||||
|
||||
# the default is to assume no
|
||||
|
@ -315,6 +299,23 @@ class ScalaDecompile(Method):
|
|||
name = "*Javap:%s*" % clsname
|
||||
w.application.data_buffer(name, output, modename='javap', switch_to=True)
|
||||
|
||||
class ScalaSetClasspath(Method):
|
||||
'''Set Scala's classpath'''
|
||||
args = [arg("lib", dt='path', p="Lib: ", dv=lambda w: '.')]
|
||||
def _execute(self, w, **vargs):
|
||||
w.application.config['scala.cp'] = vargs['lib'].split(':')
|
||||
|
||||
class ScalaAddClasspath(ScalaSetClasspath):
|
||||
'''Add path(s) to Scala's classpath'''
|
||||
def _execute(self, w, **vargs):
|
||||
w.application.config['scala.cp'].extend(vargs['lib'].split(':'))
|
||||
|
||||
class ScalaShowClasspath(ScalaSetClasspath):
|
||||
'''Display Scala's classpath'''
|
||||
def _execute(self, w, **vargs):
|
||||
w.set_error(w.application.config.get('scala.cp'))
|
||||
w.application.config['scala.cp'].extend(vargs['lib'].split(':'))
|
||||
|
||||
# white is for delimiters, operators, numbers
|
||||
default = ('default', 'default')
|
||||
|
||||
|
@ -353,8 +354,10 @@ class Scala(Fundamental):
|
|||
tabbercls = ScalaTabber
|
||||
grammar = ScalaGrammar
|
||||
commentc = '//'
|
||||
#actions = [ScalaStart, ScalaDocBrowse, ScalaDocLookup, ScalaGetType, ScalaGotoDefinition]
|
||||
actions = [ScalaStart, ScalaDecompile]
|
||||
|
||||
actions = [ScalaStart, ScalaDecompile, ScalaSetClasspath,
|
||||
ScalaAddClasspath, ScalaShowClasspath]
|
||||
|
||||
opentokens = ('delimiter', 'sub.start', 'sub.sub.start', 'sub.sub.sub.start')
|
||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||
closetokens = ('delimiter', 'sub.end', 'sub.sub.end', 'sub.sub.sub.end')
|
||||
|
|
Loading…
Reference in New Issue