mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 21:17:03 +00:00
59 lines
1.8 KiB
Plaintext
Executable File
59 lines
1.8 KiB
Plaintext
Executable File
#!/usr/bin/env objj
|
|
|
|
require("narwhal").ensureEngine("rhino");
|
|
|
|
@import <Foundation/Foundation.j>
|
|
|
|
@import "../lib/cappuccino/objj-analysis-tools.j"
|
|
|
|
var FILE = require("file");
|
|
|
|
var stream = require("narwhal/term").stream
|
|
var parser = new (require("narwhal/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)");
|
|
});
|
|
}
|
|
}
|
|
}
|
|
} |