Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 22102:4918409846d8
mx eclipseformat: no need to pass a -vm argument to eclipse
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Fri, 26 Jun 2015 12:24:47 +0200 |
parents | c30b055ed79a |
children | 6b5221d7b5c1 |
comparison
equal
deleted
inserted
replaced
22101:e2793adeaa43 | 22102:4918409846d8 |
---|---|
3299 projects = sorted_deps() | 3299 projects = sorted_deps() |
3300 if args.projects is not None: | 3300 if args.projects is not None: |
3301 projects = [project(name) for name in args.projects.split(',')] | 3301 projects = [project(name) for name in args.projects.split(',')] |
3302 | 3302 |
3303 class Batch: | 3303 class Batch: |
3304 def __init__(self, settingsDir, javaCompliance): | 3304 def __init__(self, settingsDir): |
3305 self.path = join(settingsDir, 'org.eclipse.jdt.core.prefs') | 3305 self.path = join(settingsDir, 'org.eclipse.jdt.core.prefs') |
3306 self.javaCompliance = javaCompliance | |
3307 with open(join(settingsDir, 'org.eclipse.jdt.ui.prefs')) as fp: | 3306 with open(join(settingsDir, 'org.eclipse.jdt.ui.prefs')) as fp: |
3308 jdtUiPrefs = fp.read() | 3307 jdtUiPrefs = fp.read() |
3309 self.removeTrailingWhitespace = 'sp_cleanup.remove_trailing_whitespaces_all=true' in jdtUiPrefs | 3308 self.removeTrailingWhitespace = 'sp_cleanup.remove_trailing_whitespaces_all=true' in jdtUiPrefs |
3310 if self.removeTrailingWhitespace: | 3309 if self.removeTrailingWhitespace: |
3311 assert 'sp_cleanup.remove_trailing_whitespaces=true' in jdtUiPrefs and 'sp_cleanup.remove_trailing_whitespaces_ignore_empty=false' in jdtUiPrefs | 3310 assert 'sp_cleanup.remove_trailing_whitespaces=true' in jdtUiPrefs and 'sp_cleanup.remove_trailing_whitespaces_ignore_empty=false' in jdtUiPrefs |
3312 self.cachedHash = None | 3311 self.cachedHash = None |
3313 | 3312 |
3314 def __hash__(self): | 3313 def __hash__(self): |
3315 if not self.cachedHash: | 3314 if not self.cachedHash: |
3316 with open(self.path) as fp: | 3315 with open(self.path) as fp: |
3317 self.cachedHash = (fp.read(), self.javaCompliance, self.removeTrailingWhitespace).__hash__() | 3316 self.cachedHash = (fp.read(), self.removeTrailingWhitespace).__hash__() |
3318 return self.cachedHash | 3317 return self.cachedHash |
3319 | 3318 |
3320 def __eq__(self, other): | 3319 def __eq__(self, other): |
3321 if not isinstance(other, Batch): | 3320 if not isinstance(other, Batch): |
3322 return False | 3321 return False |
3323 if self.removeTrailingWhitespace != other.removeTrailingWhitespace: | 3322 if self.removeTrailingWhitespace != other.removeTrailingWhitespace: |
3324 return False | |
3325 if self.javaCompliance != other.javaCompliance: | |
3326 return False | 3323 return False |
3327 if self.path == other.path: | 3324 if self.path == other.path: |
3328 return True | 3325 return True |
3329 with open(self.path) as fp: | 3326 with open(self.path) as fp: |
3330 with open(other.path) as ofp: | 3327 with open(other.path) as ofp: |
3365 for p in projects: | 3362 for p in projects: |
3366 if p.native: | 3363 if p.native: |
3367 continue | 3364 continue |
3368 sourceDirs = p.source_dirs() | 3365 sourceDirs = p.source_dirs() |
3369 | 3366 |
3370 batch = Batch(join(p.dir, '.settings'), p.javaCompliance) | 3367 batch = Batch(join(p.dir, '.settings')) |
3371 | 3368 |
3372 if not exists(batch.path): | 3369 if not exists(batch.path): |
3373 if _opts.verbose: | 3370 if _opts.verbose: |
3374 log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path)) | 3371 log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path)) |
3375 continue | 3372 continue |
3391 for chunk in _chunk_files_for_command_line(javafiles, pathFunction=lambda f: f.path): | 3388 for chunk in _chunk_files_for_command_line(javafiles, pathFunction=lambda f: f.path): |
3392 run([args.eclipse_exe, | 3389 run([args.eclipse_exe, |
3393 '-nosplash', | 3390 '-nosplash', |
3394 '-application', | 3391 '-application', |
3395 'org.eclipse.jdt.core.JavaCodeFormatter', | 3392 'org.eclipse.jdt.core.JavaCodeFormatter', |
3396 '-vm', java(batch.javaCompliance).java, | |
3397 '-config', batch.path] | 3393 '-config', batch.path] |
3398 + [f.path for f in chunk]) | 3394 + [f.path for f in chunk]) |
3399 for fi in chunk: | 3395 for fi in chunk: |
3400 if fi.update(batch.removeTrailingWhitespace): | 3396 if fi.update(batch.removeTrailingWhitespace): |
3401 modified.append(fi) | 3397 modified.append(fi) |