mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-26 05:27:03 +00:00
Merge branch 'master' of github.com:280north/cappuccino
This commit is contained in:
Binary file not shown.
Binary file not shown.
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env objj
|
||||
|
||||
require("narwhal").ensureEngine("rhino");
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
|
||||
@import "press/objj-analysis-tools.j"
|
||||
|
||||
var FILE = require("file");
|
||||
|
||||
var stream = require("term").stream
|
||||
var parser = new (require("args").Parser)();
|
||||
|
||||
parser.usage("INPUT_PROJECT");
|
||||
parser.help("Checks a project for missing imports.");
|
||||
|
||||
parser.helpful();
|
||||
|
||||
function main(args)
|
||||
{
|
||||
var options = parser.parse(args);
|
||||
|
||||
if (options.args.length < 1) {
|
||||
parser.printUsage(options);
|
||||
return;
|
||||
}
|
||||
|
||||
var rootPath = FILE.path(options.args[0]).join("").absolute();
|
||||
var mainPath = rootPath.join("main.j");
|
||||
|
||||
var analyzer = new ObjectiveJRuntimeAnalyzer(rootPath);
|
||||
|
||||
analyzer.setIncludePaths([rootPath.join("Frameworks")]);
|
||||
analyzer.setEnvironments(["Browser", "ObjJ"]);
|
||||
|
||||
analyzer.initializeGlobalRecorder();
|
||||
|
||||
analyzer.load(mainPath);
|
||||
analyzer.finishLoading();
|
||||
|
||||
var mainExecutable = analyzer.executableForImport(mainPath);
|
||||
|
||||
var context = analyzer.traverseDependencies(mainExecutable, {
|
||||
progressCallback : function(path) { stream.print("Analyzing \0purple(" + path + "\0)..."); }
|
||||
});
|
||||
|
||||
for (var path in context.referencedFiles) {
|
||||
var referencedFiles = context.referencedFiles[path];
|
||||
|
||||
for (var referenced in referencedFiles) {
|
||||
if (!context.importedFiles[path] || !context.importedFiles[path][referenced]) {
|
||||
stream.print("\0purple(" + rootPath.relative(path) + "\0) references but doesn't import \0purple(" + rootPath.relative(referenced) + "\0):")
|
||||
Object.keys(referencedFiles[referenced]).forEach(function(token) {
|
||||
stream.print(" \0cyan(" + token + "\0)");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user