Skip to content

Commit

Permalink
Merge pull request #8 from florianb/iss58
Browse files Browse the repository at this point in the history
quick fix AtomLinter#58 by cutting off source files
  • Loading branch information
Florian Breisch committed Feb 19, 2016
2 parents f7c967a + 6ae5714 commit a9294f9
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion lib/init.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{Directory, CompositeDisposable} = require 'atom'
_os = require 'os'
path = require 'path'
helpers = require 'atom-linter'
voucher = require 'voucher'
fs = require 'fs'
cpConfigFileName = '.classpath'

module.exports =
# coffeelint: disable=max_line_length
config:
javacExecutablePath:
type: 'string'
Expand Down Expand Up @@ -34,10 +36,12 @@ module.exports =
description: 'Your additional options will be inserted between
the javac-command and the sourcefiles. Example: `-d /root/class-cache`
will become `javac -Xlint:all -d /root/class-cache .../Test.java`
take a look to the [javac-docs](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html)
take a look to the
[javac-docs](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html)
for further information on valid options. Keep in mind that placeholders
like `~` do **not** work.'


activate: ->
require('atom-package-deps').install()
@subscriptions = new CompositeDisposable
Expand All @@ -55,6 +59,8 @@ module.exports =
else
@additionalOptions = []

# coffeelint: enable=max_line_length

deactivate: ->
@subscriptions.dispose()

Expand Down Expand Up @@ -99,6 +105,37 @@ module.exports =

args.push.apply(args, files)




# TODO: remove this quick fix
# count the size of expected execution-command
# see issue #58 for further details
cliLimit = if _os.platform() == 'win32' then 7900 else 130000
expectedCmdSize = @javaExecutablePath.length
sliceIndex = 0
for arg in args
expectedCmdSize++ # add prepending space
if (typeof arg) == 'string'
expectedCmdSize += arg.length
else
expectedCmdSize += arg.toString().length
if expectedCmdSize < cliLimit
sliceIndex++

if sliceIndex < (args.length - 1)
# coffeelint: disable=max_line_length
console.warn """
linter-javac: The lint-command is presumed to break the limit of #{cliLimit} characters on the #{_os.platform()}-platform.
Dropping #{args.length - sliceIndex} source files, as a result javac may not resolve all dependencies.
"""
# coffeelint: enable=max_line_length
args.push(filePath)
args = args.slice(0, sliceIndex)




# Execute javac
helpers.exec(@javaExecutablePath, args, {stream: 'stderr', cwd: wd})
.then (val) =>
Expand Down

0 comments on commit a9294f9

Please sign in to comment.