Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

fixes #31. send all java files in the project to javac, so it has the… #32

Merged
merged 2 commits into from
Nov 4, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions lib/init.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports =
lint: (textEditor) =>
filePath = textEditor.getPath()
wd = path.dirname filePath

files = @getFilesEndingWith(@getProjectRootDir(), ".java")
# Classpath
cp = null

Expand All @@ -55,7 +55,7 @@ module.exports =
# Arguments to javac
args = ['-Xlint:all']
args = args.concat(['-cp', cp]) if cp?
args.push filePath
args.push.apply(args, files)

# Execute javac
helpers.exec(@javaExecutablePath, args, {stream: 'stderr', cwd: wd})
Expand Down Expand Up @@ -85,6 +85,27 @@ module.exports =
messages[messages.length - 1].range[1][1] = column + 1
return messages

getProjectRootDir: ->
return atom.project.rootDirectories[0].path

getFilesEndingWith: (startPath, endsWith) ->
foundFiles = []
if !fs.existsSync(startPath)
return foundFiles
files = fs.readdirSync(startPath)
i = 0
while i < files.length
filename = path.join(startPath, files[i])
stat = fs.lstatSync(filename)
if stat.isDirectory()
foundFiles.push.apply(foundFiles, @getFilesEndingWith(filename, endsWith))
else if filename.indexOf(endsWith, filename.length - (endsWith.length)) >= 0
foundFiles.push.apply(foundFiles, [filename])
#Array::push.apply foundFiles, filename
i++
return foundFiles


findClasspathConfig: (d) ->
# Search for the .classpath file starting in the given directory
# and searching parent directories until it is found, or we go outside the
Expand Down