Skip to content

Commit

Permalink
Some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
John J. Camilleri authored and John J. Camilleri committed Jun 1, 2012
1 parent ee01cf5 commit f4b59dd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public class GFBuilder extends IncrementalProjectBuilder {
private String gfPath;
private String gfLibPath;
private Boolean buildDependents;

// /**
// * For avoiding duplicate work
// */
// private Long buildStartTime;

/**
* Logger
Expand All @@ -100,6 +105,9 @@ protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor
gfLibPath = GFPreferences.getLibraryPath();
buildDependents = GFPreferences.getBuildDependents();

// // Record start time
// buildStartTime = new Date().getTime();

try {
switch (kind) {
case IncrementalProjectBuilder.FULL_BUILD:
Expand Down Expand Up @@ -149,7 +157,7 @@ public boolean visit(IResourceDelta delta) {
}

// Do we want to bother further?
if (!shouldBuild(delta.getResource())) {
if (!isBuildable(delta.getResource())) {
return true;
}
IFile file = (IFile)delta.getResource();
Expand Down Expand Up @@ -187,7 +195,7 @@ public boolean visit(IResource resource) {
throw new OperationCanceledException();
}
// Build
if (shouldBuild(resource)) {
if (isBuildable(resource)) {
IFile file = (IFile) resource;
Set<String> imports = GFBuilderHelper.getFileImports(file);
if (imports == null) {
Expand Down Expand Up @@ -223,7 +231,7 @@ public boolean visit(IResource resource) {
throw new OperationCanceledException();
}
// Build
if (shouldBuild(resource)) {
if (isBuildable(resource)) {
buildFile((IFile) resource);
}
// Visit children too
Expand Down Expand Up @@ -251,7 +259,7 @@ public boolean visit(IResource resource) {
}

// If it's a buildable file, then clear its 'imports' data!
if (shouldBuild(resource)) {
if (isBuildable(resource)) {
GFBuilderHelper.clearFileImports(resource);
return true;
}
Expand Down Expand Up @@ -319,7 +327,7 @@ private void cleanFile(IFile file) {
* @param resource the resource
* @return true, if this is a source fiel which should be built
*/
private boolean shouldBuild(IResource resource) {
private boolean isBuildable(IResource resource) {
try {
boolean isFile = resource.getType() == IResource.FILE;
boolean isGF = resource.getFileExtension().equals("gf");
Expand All @@ -332,7 +340,7 @@ private boolean shouldBuild(IResource resource) {
}

/**
* Call the respective build method depending on the type of build
* Build an individual file, including pre & post tasks
* @param file
* @return
*/
Expand All @@ -350,7 +358,7 @@ private void buildFile(IFile file) {
buildFileTags(file);

// Process tags file and save imports
Set<String> imports = GFBuilderHelper.readTagsFile(file);
Set<String> imports = GFBuilderHelper.getImportsFromTagsFile(file);
GFBuilderHelper.saveFileImports(file, imports);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static URI getTagsFileURIRelative(String sourceFileName) {
/**
* Gets the tags file path as a raw location.
* Only pieces the name together; does not do any checking!
* @param sourceFileName
* @param file
* @return
*/
public static String getTagsFileFullPath(IFile file) {
Expand All @@ -69,7 +69,27 @@ public static String getTagsFileFullPath(IFile file) {
+ getTagsFileNameRelative(file.getName());
}

public static Set<String> readTagsFile(IFile file) {
// /**
// * Gets the modification time of the file's tags file, or 0 if not found
// * @param file
// * @return
// */
// public static Long getTagsFileMTime(IFile file) {
// String tagsFileName = getTagsFileNameRelative(file.getName());
// try {
// IFile tagsFile = (IFile)file.getParent().findMember(tagsFileName);
// return tagsFile.getLocalTimeStamp();
// } catch (Exception e) {
// return (long) IResource.NULL_STAMP;
// }
// }

/**
* Read tags file for a source module and return a list of the modules it imports/opens
* @param file
* @return
*/
public static Set<String> getImportsFromTagsFile(IFile file) {
boolean includeSelf = false;
String tagsFileName = getTagsFileNameRelative(file.getName());
try {
Expand Down Expand Up @@ -106,7 +126,7 @@ public static Set<String> readTagsFile(IFile file) {
} catch (CoreException e) {
log.warn("Error reading tags file "+tagsFileName, e);
}
return null;
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
if (!opt_Options.isEmpty()) {
command.addAll( Arrays.asList(opt_Options.split("\\s")) );
}

// TODO: Do we want to add the --run command to suppress annoying output?
// command.add("--run");

// Add filenames
command.addAll( Arrays.asList(opt_Files.split("\\s")) );

try {
Expand Down

0 comments on commit f4b59dd

Please sign in to comment.