Skip to content

Commit

Permalink
convert one more method to SourceFileHelpers
Browse files Browse the repository at this point in the history
  • Loading branch information
svonworl committed May 21, 2024
1 parent 6653e58 commit 3b5ae1f
Showing 1 changed file with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,33 +200,29 @@ public List<String> listFiles(String pathToDirectory) {
.indexWorkflowFiles(filepath, content, reader);
Map<String, SourceFile> results = new HashMap<>();
for (Map.Entry<String, FileMetadata> entry : stringPairMap.entrySet()) {
final SourceFile sourceFile = new SourceFile();
sourceFile.setPath(entry.getKey());
SourceFileHelper.setContentWithLimits(sourceFile, entry.getValue().content(), entry.getKey());
sourceFile.getMetadata().setTypeVersion(entry.getValue().languageVersion());
if (minimalLanguageInterface.getDescriptorLanguage().isServiceLanguage()) {
// TODO: this needs to be more sophisticated
sourceFile.setType(DescriptorLanguage.FileType.DOCKSTORE_SERVICE_YML);
}

// The language plugins don't necessarily set the file type
// so query the plugin to find out what the imported file
// type should be, because this is needed in downstream code.
// We assume if imported files are not descriptors or not test files they are Dockerfiles,
// however this may not be true for some languages, and we may have to change this
if (sourceFile.getType() == null) {
DescriptorLanguage.FileType importedFileType = null;
if (entry.getValue().genericFileType() == GenericFileType.IMPORTED_DESCRIPTOR) {
importedFileType = minimalLanguageInterface.getDescriptorLanguage().getFileType();
} else if (entry.getValue().genericFileType() == GenericFileType.TEST_PARAMETER_FILE) {
importedFileType = minimalLanguageInterface.getDescriptorLanguage().getTestParamType();
} else {
// For some languages this may be incorrect
importedFileType = FileType.DOCKERFILE;
}
sourceFile.setType(importedFileType);
DescriptorLanguage.FileType type;
if (entry.getValue().genericFileType() == GenericFileType.IMPORTED_DESCRIPTOR) {
type = minimalLanguageInterface.getDescriptorLanguage().getFileType();
} else if (entry.getValue().genericFileType() == GenericFileType.TEST_PARAMETER_FILE) {
type = minimalLanguageInterface.getDescriptorLanguage().getTestParamType();
} else {
// For some languages this may be incorrect
type = FileType.DOCKERFILE;
}
sourceFile.setAbsolutePath(entry.getKey());
if (minimalLanguageInterface.getDescriptorLanguage().isServiceLanguage()) {
// TODO: this needs to be more sophisticated
type = DescriptorLanguage.FileType.DOCKSTORE_SERVICE_YML;

Check warning on line 220 in dockstore-webservice/src/main/java/io/dockstore/webservice/languages/LanguagePluginHandler.java

View check run for this annotation

Codecov / codecov/patch

dockstore-webservice/src/main/java/io/dockstore/webservice/languages/LanguagePluginHandler.java#L220

Added line #L220 was not covered by tests
}
String path = entry.getKey();
String fileContent = entry.getValue().content();
SourceFile sourceFile = SourceFileHelper.create(type, fileContent, path, path);
sourceFile.getMetadata().setTypeVersion(entry.getValue().languageVersion());
results.put(entry.getKey(), sourceFile);
}
return results;
Expand Down

0 comments on commit 3b5ae1f

Please sign in to comment.