id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
159,700
eBay/parallec
src/main/java/io/parallec/core/util/PcErrorMsgUtils.java
PcErrorMsgUtils.replaceErrorMsg
public static String replaceErrorMsg(String origMsg) { String replaceMsg = origMsg; for (ERROR_TYPE errorType : ERROR_TYPE.values()) { if (origMsg == null) { replaceMsg = PcConstants.NA; return replaceMsg; } if (origMsg.contains(errorMapOrig.get(errorType))) { replaceMsg = errorMapReplace.get(errorType); break; } } return replaceMsg; }
java
public static String replaceErrorMsg(String origMsg) { String replaceMsg = origMsg; for (ERROR_TYPE errorType : ERROR_TYPE.values()) { if (origMsg == null) { replaceMsg = PcConstants.NA; return replaceMsg; } if (origMsg.contains(errorMapOrig.get(errorType))) { replaceMsg = errorMapReplace.get(errorType); break; } } return replaceMsg; }
[ "public", "static", "String", "replaceErrorMsg", "(", "String", "origMsg", ")", "{", "String", "replaceMsg", "=", "origMsg", ";", "for", "(", "ERROR_TYPE", "errorType", ":", "ERROR_TYPE", ".", "values", "(", ")", ")", "{", "if", "(", "origMsg", "==", "null", ")", "{", "replaceMsg", "=", "PcConstants", ".", "NA", ";", "return", "replaceMsg", ";", "}", "if", "(", "origMsg", ".", "contains", "(", "errorMapOrig", ".", "get", "(", "errorType", ")", ")", ")", "{", "replaceMsg", "=", "errorMapReplace", ".", "get", "(", "errorType", ")", ";", "break", ";", "}", "}", "return", "replaceMsg", ";", "}" ]
Replace error msg. @param origMsg the orig msg @return the string
[ "Replace", "error", "msg", "." ]
1b4f1628f34fedfb06b24c33a5372d64d3df0952
https://github.com/eBay/parallec/blob/1b4f1628f34fedfb06b24c33a5372d64d3df0952/src/main/java/io/parallec/core/util/PcErrorMsgUtils.java#L53-L72
159,701
eBay/parallec
src/main/java/io/parallec/core/resources/AsyncHttpClientFactoryEmbed.java
AsyncHttpClientFactoryEmbed.disableCertificateVerification
private void disableCertificateVerification() throws KeyManagementException, NoSuchAlgorithmException { // Create a trust manager that does not validate certificate chains final TrustManager[] trustAllCerts = new TrustManager[] { new CustomTrustManager() }; // Install the all-trusting trust manager final SSLContext sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustAllCerts, new SecureRandom()); final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory); final HostnameVerifier verifier = new HostnameVerifier() { @Override public boolean verify(final String hostname, final SSLSession session) { return true; } }; HttpsURLConnection.setDefaultHostnameVerifier(verifier); }
java
private void disableCertificateVerification() throws KeyManagementException, NoSuchAlgorithmException { // Create a trust manager that does not validate certificate chains final TrustManager[] trustAllCerts = new TrustManager[] { new CustomTrustManager() }; // Install the all-trusting trust manager final SSLContext sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustAllCerts, new SecureRandom()); final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory); final HostnameVerifier verifier = new HostnameVerifier() { @Override public boolean verify(final String hostname, final SSLSession session) { return true; } }; HttpsURLConnection.setDefaultHostnameVerifier(verifier); }
[ "private", "void", "disableCertificateVerification", "(", ")", "throws", "KeyManagementException", ",", "NoSuchAlgorithmException", "{", "// Create a trust manager that does not validate certificate chains", "final", "TrustManager", "[", "]", "trustAllCerts", "=", "new", "TrustManager", "[", "]", "{", "new", "CustomTrustManager", "(", ")", "}", ";", "// Install the all-trusting trust manager", "final", "SSLContext", "sslContext", "=", "SSLContext", ".", "getInstance", "(", "\"SSL\"", ")", ";", "sslContext", ".", "init", "(", "null", ",", "trustAllCerts", ",", "new", "SecureRandom", "(", ")", ")", ";", "final", "SSLSocketFactory", "sslSocketFactory", "=", "sslContext", ".", "getSocketFactory", "(", ")", ";", "HttpsURLConnection", ".", "setDefaultSSLSocketFactory", "(", "sslSocketFactory", ")", ";", "final", "HostnameVerifier", "verifier", "=", "new", "HostnameVerifier", "(", ")", "{", "@", "Override", "public", "boolean", "verify", "(", "final", "String", "hostname", ",", "final", "SSLSession", "session", ")", "{", "return", "true", ";", "}", "}", ";", "HttpsURLConnection", ".", "setDefaultHostnameVerifier", "(", "verifier", ")", ";", "}" ]
Disable certificate verification. @throws KeyManagementException the key management exception @throws NoSuchAlgorithmException the no such algorithm exception
[ "Disable", "certificate", "verification", "." ]
1b4f1628f34fedfb06b24c33a5372d64d3df0952
https://github.com/eBay/parallec/blob/1b4f1628f34fedfb06b24c33a5372d64d3df0952/src/main/java/io/parallec/core/resources/AsyncHttpClientFactoryEmbed.java#L128-L147
159,702
eBay/parallec
src/main/java/io/parallec/core/bean/HttpMeta.java
HttpMeta.replaceFullRequestContent
public static String replaceFullRequestContent( String requestContentTemplate, String replacementString) { return (requestContentTemplate.replace( PcConstants.COMMAND_VAR_DEFAULT_REQUEST_CONTENT, replacementString)); }
java
public static String replaceFullRequestContent( String requestContentTemplate, String replacementString) { return (requestContentTemplate.replace( PcConstants.COMMAND_VAR_DEFAULT_REQUEST_CONTENT, replacementString)); }
[ "public", "static", "String", "replaceFullRequestContent", "(", "String", "requestContentTemplate", ",", "String", "replacementString", ")", "{", "return", "(", "requestContentTemplate", ".", "replace", "(", "PcConstants", ".", "COMMAND_VAR_DEFAULT_REQUEST_CONTENT", ",", "replacementString", ")", ")", ";", "}" ]
Replace full request content. @param requestContentTemplate the request content template @param replacementString the replacement string @return the string
[ "Replace", "full", "request", "content", "." ]
1b4f1628f34fedfb06b24c33a5372d64d3df0952
https://github.com/eBay/parallec/blob/1b4f1628f34fedfb06b24c33a5372d64d3df0952/src/main/java/io/parallec/core/bean/HttpMeta.java#L249-L254
159,703
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/freemarker/problemsummary/ProblemSummary.java
ProblemSummary.addFile
public void addFile(String description, FileModel fileModel) { Map<FileModel, ProblemFileSummary> files = addDescription(description); if (files.containsKey(fileModel)) { files.get(fileModel).addOccurrence(); } else { files.put(fileModel, new ProblemFileSummary(fileModel, 1)); } }
java
public void addFile(String description, FileModel fileModel) { Map<FileModel, ProblemFileSummary> files = addDescription(description); if (files.containsKey(fileModel)) { files.get(fileModel).addOccurrence(); } else { files.put(fileModel, new ProblemFileSummary(fileModel, 1)); } }
[ "public", "void", "addFile", "(", "String", "description", ",", "FileModel", "fileModel", ")", "{", "Map", "<", "FileModel", ",", "ProblemFileSummary", ">", "files", "=", "addDescription", "(", "description", ")", ";", "if", "(", "files", ".", "containsKey", "(", "fileModel", ")", ")", "{", "files", ".", "get", "(", "fileModel", ")", ".", "addOccurrence", "(", ")", ";", "}", "else", "{", "files", ".", "put", "(", "fileModel", ",", "new", "ProblemFileSummary", "(", "fileModel", ",", "1", ")", ")", ";", "}", "}" ]
Adds a file with the provided description.
[ "Adds", "a", "file", "with", "the", "provided", "description", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/freemarker/problemsummary/ProblemSummary.java#L144-L154
159,704
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/decompiler/ClassFilePreDecompilationScan.java
ClassFilePreDecompilationScan.shouldIgnore
private boolean shouldIgnore(String typeReference) { typeReference = typeReference.replace('/', '.').replace('\\', '.'); return JavaClassIgnoreResolver.singletonInstance().matches(typeReference); }
java
private boolean shouldIgnore(String typeReference) { typeReference = typeReference.replace('/', '.').replace('\\', '.'); return JavaClassIgnoreResolver.singletonInstance().matches(typeReference); }
[ "private", "boolean", "shouldIgnore", "(", "String", "typeReference", ")", "{", "typeReference", "=", "typeReference", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "return", "JavaClassIgnoreResolver", ".", "singletonInstance", "(", ")", ".", "matches", "(", "typeReference", ")", ";", "}" ]
This method is called on every reference that is in the .class file. @param typeReference @return
[ "This", "method", "is", "called", "on", "every", "reference", "that", "is", "in", "the", ".", "class", "file", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/decompiler/ClassFilePreDecompilationScan.java#L176-L180
159,705
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/config/classification/Classification.java
Classification.resolvePayload
@Override public FileModel resolvePayload(GraphRewrite event, EvaluationContext context, WindupVertexFrame payload) { checkVariableName(event, context); if (payload instanceof FileReferenceModel) { return ((FileReferenceModel) payload).getFile(); } if (payload instanceof FileModel) { return (FileModel) payload; } return null; }
java
@Override public FileModel resolvePayload(GraphRewrite event, EvaluationContext context, WindupVertexFrame payload) { checkVariableName(event, context); if (payload instanceof FileReferenceModel) { return ((FileReferenceModel) payload).getFile(); } if (payload instanceof FileModel) { return (FileModel) payload; } return null; }
[ "@", "Override", "public", "FileModel", "resolvePayload", "(", "GraphRewrite", "event", ",", "EvaluationContext", "context", ",", "WindupVertexFrame", "payload", ")", "{", "checkVariableName", "(", "event", ",", "context", ")", ";", "if", "(", "payload", "instanceof", "FileReferenceModel", ")", "{", "return", "(", "(", "FileReferenceModel", ")", "payload", ")", ".", "getFile", "(", ")", ";", "}", "if", "(", "payload", "instanceof", "FileModel", ")", "{", "return", "(", "FileModel", ")", "payload", ";", "}", "return", "null", ";", "}" ]
Set the payload to the fileModel of the given instance even though the variable is not directly referencing it. This is mainly to simplify the creation of the rule, when the FileModel itself is not being iterated but just a model referencing it.
[ "Set", "the", "payload", "to", "the", "fileModel", "of", "the", "given", "instance", "even", "though", "the", "variable", "is", "not", "directly", "referencing", "it", ".", "This", "is", "mainly", "to", "simplify", "the", "creation", "of", "the", "rule", "when", "the", "FileModel", "itself", "is", "not", "being", "iterated", "but", "just", "a", "model", "referencing", "it", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/config/classification/Classification.java#L102-L115
159,706
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/freemarker/FreeMarkerOperation.java
FreeMarkerOperation.create
public static FreeMarkerOperation create(Furnace furnace, String templatePath, String outputFilename, String... varNames) { return new FreeMarkerOperation(furnace, templatePath, outputFilename, varNames); }
java
public static FreeMarkerOperation create(Furnace furnace, String templatePath, String outputFilename, String... varNames) { return new FreeMarkerOperation(furnace, templatePath, outputFilename, varNames); }
[ "public", "static", "FreeMarkerOperation", "create", "(", "Furnace", "furnace", ",", "String", "templatePath", ",", "String", "outputFilename", ",", "String", "...", "varNames", ")", "{", "return", "new", "FreeMarkerOperation", "(", "furnace", ",", "templatePath", ",", "outputFilename", ",", "varNames", ")", ";", "}" ]
Create a FreeMarkerOperation with the provided furnace instance template path, and varNames. The variables in varNames will be provided to the template, and a new ReportModel will be created with these variables attached.
[ "Create", "a", "FreeMarkerOperation", "with", "the", "provided", "furnace", "instance", "template", "path", "and", "varNames", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/freemarker/FreeMarkerOperation.java#L52-L56
159,707
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/scan/operation/UnzipArchiveToOutputFolder.java
UnzipArchiveToOutputFolder.recurseAndAddFiles
private void recurseAndAddFiles(GraphRewrite event, EvaluationContext context, Path tempFolder, FileService fileService, ArchiveModel archiveModel, FileModel parentFileModel, boolean subArchivesOnly) { checkCancelled(event); int numberAdded = 0; FileFilter filter = TrueFileFilter.TRUE; if (archiveModel instanceof IdentifiedArchiveModel) { filter = new IdentifiedArchiveFileFilter(archiveModel); } File fileReference; if (parentFileModel instanceof ArchiveModel) fileReference = new File(((ArchiveModel) parentFileModel).getUnzippedDirectory()); else fileReference = parentFileModel.asFile(); WindupJavaConfigurationService windupJavaConfigurationService = new WindupJavaConfigurationService(event.getGraphContext()); File[] subFiles = fileReference.listFiles(); if (subFiles == null) return; for (File subFile : subFiles) { if (!filter.accept(subFile)) continue; if (subArchivesOnly && !ZipUtil.endsWithZipExtension(subFile.getAbsolutePath())) continue; FileModel subFileModel = fileService.createByFilePath(parentFileModel, subFile.getAbsolutePath()); // check if this file should be ignored if (windupJavaConfigurationService.checkIfIgnored(event, subFileModel)) continue; numberAdded++; if (numberAdded % 250 == 0) event.getGraphContext().commit(); if (subFile.isFile() && ZipUtil.endsWithZipExtension(subFileModel.getFilePath())) { File newZipFile = subFileModel.asFile(); ArchiveModel newArchiveModel = GraphService.addTypeToModel(event.getGraphContext(), subFileModel, ArchiveModel.class); newArchiveModel.setParentArchive(archiveModel); newArchiveModel.setArchiveName(newZipFile.getName()); /* * New archive must be reloaded in case the archive should be ignored */ newArchiveModel = GraphService.refresh(event.getGraphContext(), newArchiveModel); ArchiveModel canonicalArchiveModel = null; for (FileModel otherMatches : fileService.findAllByProperty(FileModel.SHA1_HASH, newArchiveModel.getSHA1Hash())) { if (otherMatches instanceof ArchiveModel && !otherMatches.equals(newArchiveModel) && !(otherMatches instanceof DuplicateArchiveModel)) { canonicalArchiveModel = (ArchiveModel)otherMatches; break; } } if (canonicalArchiveModel != null) { // handle as duplicate DuplicateArchiveModel duplicateArchive = GraphService.addTypeToModel(event.getGraphContext(), newArchiveModel, DuplicateArchiveModel.class); duplicateArchive.setCanonicalArchive(canonicalArchiveModel); // create dupes for child archives unzipToTempDirectory(event, context, tempFolder, newZipFile, duplicateArchive, true); } else { unzipToTempDirectory(event, context, tempFolder, newZipFile, newArchiveModel, false); } } else if (subFile.isDirectory()) { recurseAndAddFiles(event, context, tempFolder, fileService, archiveModel, subFileModel, false); } } }
java
private void recurseAndAddFiles(GraphRewrite event, EvaluationContext context, Path tempFolder, FileService fileService, ArchiveModel archiveModel, FileModel parentFileModel, boolean subArchivesOnly) { checkCancelled(event); int numberAdded = 0; FileFilter filter = TrueFileFilter.TRUE; if (archiveModel instanceof IdentifiedArchiveModel) { filter = new IdentifiedArchiveFileFilter(archiveModel); } File fileReference; if (parentFileModel instanceof ArchiveModel) fileReference = new File(((ArchiveModel) parentFileModel).getUnzippedDirectory()); else fileReference = parentFileModel.asFile(); WindupJavaConfigurationService windupJavaConfigurationService = new WindupJavaConfigurationService(event.getGraphContext()); File[] subFiles = fileReference.listFiles(); if (subFiles == null) return; for (File subFile : subFiles) { if (!filter.accept(subFile)) continue; if (subArchivesOnly && !ZipUtil.endsWithZipExtension(subFile.getAbsolutePath())) continue; FileModel subFileModel = fileService.createByFilePath(parentFileModel, subFile.getAbsolutePath()); // check if this file should be ignored if (windupJavaConfigurationService.checkIfIgnored(event, subFileModel)) continue; numberAdded++; if (numberAdded % 250 == 0) event.getGraphContext().commit(); if (subFile.isFile() && ZipUtil.endsWithZipExtension(subFileModel.getFilePath())) { File newZipFile = subFileModel.asFile(); ArchiveModel newArchiveModel = GraphService.addTypeToModel(event.getGraphContext(), subFileModel, ArchiveModel.class); newArchiveModel.setParentArchive(archiveModel); newArchiveModel.setArchiveName(newZipFile.getName()); /* * New archive must be reloaded in case the archive should be ignored */ newArchiveModel = GraphService.refresh(event.getGraphContext(), newArchiveModel); ArchiveModel canonicalArchiveModel = null; for (FileModel otherMatches : fileService.findAllByProperty(FileModel.SHA1_HASH, newArchiveModel.getSHA1Hash())) { if (otherMatches instanceof ArchiveModel && !otherMatches.equals(newArchiveModel) && !(otherMatches instanceof DuplicateArchiveModel)) { canonicalArchiveModel = (ArchiveModel)otherMatches; break; } } if (canonicalArchiveModel != null) { // handle as duplicate DuplicateArchiveModel duplicateArchive = GraphService.addTypeToModel(event.getGraphContext(), newArchiveModel, DuplicateArchiveModel.class); duplicateArchive.setCanonicalArchive(canonicalArchiveModel); // create dupes for child archives unzipToTempDirectory(event, context, tempFolder, newZipFile, duplicateArchive, true); } else { unzipToTempDirectory(event, context, tempFolder, newZipFile, newArchiveModel, false); } } else if (subFile.isDirectory()) { recurseAndAddFiles(event, context, tempFolder, fileService, archiveModel, subFileModel, false); } } }
[ "private", "void", "recurseAndAddFiles", "(", "GraphRewrite", "event", ",", "EvaluationContext", "context", ",", "Path", "tempFolder", ",", "FileService", "fileService", ",", "ArchiveModel", "archiveModel", ",", "FileModel", "parentFileModel", ",", "boolean", "subArchivesOnly", ")", "{", "checkCancelled", "(", "event", ")", ";", "int", "numberAdded", "=", "0", ";", "FileFilter", "filter", "=", "TrueFileFilter", ".", "TRUE", ";", "if", "(", "archiveModel", "instanceof", "IdentifiedArchiveModel", ")", "{", "filter", "=", "new", "IdentifiedArchiveFileFilter", "(", "archiveModel", ")", ";", "}", "File", "fileReference", ";", "if", "(", "parentFileModel", "instanceof", "ArchiveModel", ")", "fileReference", "=", "new", "File", "(", "(", "(", "ArchiveModel", ")", "parentFileModel", ")", ".", "getUnzippedDirectory", "(", ")", ")", ";", "else", "fileReference", "=", "parentFileModel", ".", "asFile", "(", ")", ";", "WindupJavaConfigurationService", "windupJavaConfigurationService", "=", "new", "WindupJavaConfigurationService", "(", "event", ".", "getGraphContext", "(", ")", ")", ";", "File", "[", "]", "subFiles", "=", "fileReference", ".", "listFiles", "(", ")", ";", "if", "(", "subFiles", "==", "null", ")", "return", ";", "for", "(", "File", "subFile", ":", "subFiles", ")", "{", "if", "(", "!", "filter", ".", "accept", "(", "subFile", ")", ")", "continue", ";", "if", "(", "subArchivesOnly", "&&", "!", "ZipUtil", ".", "endsWithZipExtension", "(", "subFile", ".", "getAbsolutePath", "(", ")", ")", ")", "continue", ";", "FileModel", "subFileModel", "=", "fileService", ".", "createByFilePath", "(", "parentFileModel", ",", "subFile", ".", "getAbsolutePath", "(", ")", ")", ";", "// check if this file should be ignored", "if", "(", "windupJavaConfigurationService", ".", "checkIfIgnored", "(", "event", ",", "subFileModel", ")", ")", "continue", ";", "numberAdded", "++", ";", "if", "(", "numberAdded", "%", "250", "==", "0", ")", "event", ".", "getGraphContext", "(", ")", ".", "commit", "(", ")", ";", "if", "(", "subFile", ".", "isFile", "(", ")", "&&", "ZipUtil", ".", "endsWithZipExtension", "(", "subFileModel", ".", "getFilePath", "(", ")", ")", ")", "{", "File", "newZipFile", "=", "subFileModel", ".", "asFile", "(", ")", ";", "ArchiveModel", "newArchiveModel", "=", "GraphService", ".", "addTypeToModel", "(", "event", ".", "getGraphContext", "(", ")", ",", "subFileModel", ",", "ArchiveModel", ".", "class", ")", ";", "newArchiveModel", ".", "setParentArchive", "(", "archiveModel", ")", ";", "newArchiveModel", ".", "setArchiveName", "(", "newZipFile", ".", "getName", "(", ")", ")", ";", "/*\n * New archive must be reloaded in case the archive should be ignored\n */", "newArchiveModel", "=", "GraphService", ".", "refresh", "(", "event", ".", "getGraphContext", "(", ")", ",", "newArchiveModel", ")", ";", "ArchiveModel", "canonicalArchiveModel", "=", "null", ";", "for", "(", "FileModel", "otherMatches", ":", "fileService", ".", "findAllByProperty", "(", "FileModel", ".", "SHA1_HASH", ",", "newArchiveModel", ".", "getSHA1Hash", "(", ")", ")", ")", "{", "if", "(", "otherMatches", "instanceof", "ArchiveModel", "&&", "!", "otherMatches", ".", "equals", "(", "newArchiveModel", ")", "&&", "!", "(", "otherMatches", "instanceof", "DuplicateArchiveModel", ")", ")", "{", "canonicalArchiveModel", "=", "(", "ArchiveModel", ")", "otherMatches", ";", "break", ";", "}", "}", "if", "(", "canonicalArchiveModel", "!=", "null", ")", "{", "// handle as duplicate", "DuplicateArchiveModel", "duplicateArchive", "=", "GraphService", ".", "addTypeToModel", "(", "event", ".", "getGraphContext", "(", ")", ",", "newArchiveModel", ",", "DuplicateArchiveModel", ".", "class", ")", ";", "duplicateArchive", ".", "setCanonicalArchive", "(", "canonicalArchiveModel", ")", ";", "// create dupes for child archives", "unzipToTempDirectory", "(", "event", ",", "context", ",", "tempFolder", ",", "newZipFile", ",", "duplicateArchive", ",", "true", ")", ";", "}", "else", "{", "unzipToTempDirectory", "(", "event", ",", "context", ",", "tempFolder", ",", "newZipFile", ",", "newArchiveModel", ",", "false", ")", ";", "}", "}", "else", "if", "(", "subFile", ".", "isDirectory", "(", ")", ")", "{", "recurseAndAddFiles", "(", "event", ",", "context", ",", "tempFolder", ",", "fileService", ",", "archiveModel", ",", "subFileModel", ",", "false", ")", ";", "}", "}", "}" ]
Recurses the given folder and adds references to these files to the graph as FileModels. We don't set the parent file model in the case of the initial children, as the direct parent is really the archive itself. For example for file "root.zip/pom.xml" - the parent for pom.xml is root.zip, not the directory temporary directory that happens to hold it.
[ "Recurses", "the", "given", "folder", "and", "adds", "references", "to", "these", "files", "to", "the", "graph", "as", "FileModels", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/scan/operation/UnzipArchiveToOutputFolder.java#L158-L241
159,708
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/reporting/freemarker/RenderLinkDirective.java
RenderLinkDirective.renderAsLI
private void renderAsLI(Writer writer, ProjectModel project, Iterator<Link> links, boolean wrap) throws IOException { if (!links.hasNext()) return; if (wrap) writer.append("<ul>"); while (links.hasNext()) { Link link = links.next(); writer.append("<li>"); renderLink(writer, project, link); writer.append("</li>"); } if (wrap) writer.append("</ul>"); }
java
private void renderAsLI(Writer writer, ProjectModel project, Iterator<Link> links, boolean wrap) throws IOException { if (!links.hasNext()) return; if (wrap) writer.append("<ul>"); while (links.hasNext()) { Link link = links.next(); writer.append("<li>"); renderLink(writer, project, link); writer.append("</li>"); } if (wrap) writer.append("</ul>"); }
[ "private", "void", "renderAsLI", "(", "Writer", "writer", ",", "ProjectModel", "project", ",", "Iterator", "<", "Link", ">", "links", ",", "boolean", "wrap", ")", "throws", "IOException", "{", "if", "(", "!", "links", ".", "hasNext", "(", ")", ")", "return", ";", "if", "(", "wrap", ")", "writer", ".", "append", "(", "\"<ul>\"", ")", ";", "while", "(", "links", ".", "hasNext", "(", ")", ")", "{", "Link", "link", "=", "links", ".", "next", "(", ")", ";", "writer", ".", "append", "(", "\"<li>\"", ")", ";", "renderLink", "(", "writer", ",", "project", ",", "link", ")", ";", "writer", ".", "append", "(", "\"</li>\"", ")", ";", "}", "if", "(", "wrap", ")", "writer", ".", "append", "(", "\"</ul>\"", ")", ";", "}" ]
Renders in LI tags, Wraps with UL tags optionally.
[ "Renders", "in", "LI", "tags", "Wraps", "with", "UL", "tags", "optionally", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/reporting/freemarker/RenderLinkDirective.java#L246-L262
159,709
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/rules/CreateApplicationReportIndexRuleProvider.java
CreateApplicationReportIndexRuleProvider.createApplicationReportIndex
private ApplicationReportIndexModel createApplicationReportIndex(GraphContext context, ProjectModel applicationProjectModel) { ApplicationReportIndexService applicationReportIndexService = new ApplicationReportIndexService(context); ApplicationReportIndexModel index = applicationReportIndexService.create(); addAllProjectModels(index, applicationProjectModel); return index; }
java
private ApplicationReportIndexModel createApplicationReportIndex(GraphContext context, ProjectModel applicationProjectModel) { ApplicationReportIndexService applicationReportIndexService = new ApplicationReportIndexService(context); ApplicationReportIndexModel index = applicationReportIndexService.create(); addAllProjectModels(index, applicationProjectModel); return index; }
[ "private", "ApplicationReportIndexModel", "createApplicationReportIndex", "(", "GraphContext", "context", ",", "ProjectModel", "applicationProjectModel", ")", "{", "ApplicationReportIndexService", "applicationReportIndexService", "=", "new", "ApplicationReportIndexService", "(", "context", ")", ";", "ApplicationReportIndexModel", "index", "=", "applicationReportIndexService", ".", "create", "(", ")", ";", "addAllProjectModels", "(", "index", ",", "applicationProjectModel", ")", ";", "return", "index", ";", "}" ]
Create the index and associate it with all project models in the Application
[ "Create", "the", "index", "and", "associate", "it", "with", "all", "project", "models", "in", "the", "Application" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/rules/CreateApplicationReportIndexRuleProvider.java#L69-L78
159,710
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/rules/CreateApplicationReportIndexRuleProvider.java
CreateApplicationReportIndexRuleProvider.addAllProjectModels
private void addAllProjectModels(ApplicationReportIndexModel navIdx, ProjectModel projectModel) { navIdx.addProjectModel(projectModel); for (ProjectModel childProject : projectModel.getChildProjects()) { if (!Iterators.asSet(navIdx.getProjectModels()).contains(childProject)) addAllProjectModels(navIdx, childProject); } }
java
private void addAllProjectModels(ApplicationReportIndexModel navIdx, ProjectModel projectModel) { navIdx.addProjectModel(projectModel); for (ProjectModel childProject : projectModel.getChildProjects()) { if (!Iterators.asSet(navIdx.getProjectModels()).contains(childProject)) addAllProjectModels(navIdx, childProject); } }
[ "private", "void", "addAllProjectModels", "(", "ApplicationReportIndexModel", "navIdx", ",", "ProjectModel", "projectModel", ")", "{", "navIdx", ".", "addProjectModel", "(", "projectModel", ")", ";", "for", "(", "ProjectModel", "childProject", ":", "projectModel", ".", "getChildProjects", "(", ")", ")", "{", "if", "(", "!", "Iterators", ".", "asSet", "(", "navIdx", ".", "getProjectModels", "(", ")", ")", ".", "contains", "(", "childProject", ")", ")", "addAllProjectModels", "(", "navIdx", ",", "childProject", ")", ";", "}", "}" ]
Attach all project models within the application to the index. This will make it easy to navigate from the projectModel to the application index.
[ "Attach", "all", "project", "models", "within", "the", "application", "to", "the", "index", ".", "This", "will", "make", "it", "easy", "to", "navigate", "from", "the", "projectModel", "to", "the", "application", "index", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/rules/CreateApplicationReportIndexRuleProvider.java#L84-L92
159,711
windup/windup
utils/src/main/java/org/jboss/windup/util/ProgressEstimate.java
ProgressEstimate.getTimeRemainingInMillis
public long getTimeRemainingInMillis() { long batchTime = System.currentTimeMillis() - startTime; double timePerIteration = (double) batchTime / (double) worked.get(); return (long) (timePerIteration * (total - worked.get())); }
java
public long getTimeRemainingInMillis() { long batchTime = System.currentTimeMillis() - startTime; double timePerIteration = (double) batchTime / (double) worked.get(); return (long) (timePerIteration * (total - worked.get())); }
[ "public", "long", "getTimeRemainingInMillis", "(", ")", "{", "long", "batchTime", "=", "System", ".", "currentTimeMillis", "(", ")", "-", "startTime", ";", "double", "timePerIteration", "=", "(", "double", ")", "batchTime", "/", "(", "double", ")", "worked", ".", "get", "(", ")", ";", "return", "(", "long", ")", "(", "timePerIteration", "*", "(", "total", "-", "worked", ".", "get", "(", ")", ")", ")", ";", "}" ]
Gets the estimated time remaining in milliseconds based upon the total number of work units, the start time, and how many units have been done so far. This should not be called before any work units have been done.
[ "Gets", "the", "estimated", "time", "remaining", "in", "milliseconds", "based", "upon", "the", "total", "number", "of", "work", "units", "the", "start", "time", "and", "how", "many", "units", "have", "been", "done", "so", "far", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/ProgressEstimate.java#L55-L60
159,712
windup/windup
graph/api/src/main/java/org/jboss/windup/graph/service/ArchiveService.java
ArchiveService.getChildFile
public FileModel getChildFile(ArchiveModel archiveModel, String filePath) { filePath = FilenameUtils.separatorsToUnix(filePath); StringTokenizer stk = new StringTokenizer(filePath, "/"); FileModel currentFileModel = archiveModel; while (stk.hasMoreTokens() && currentFileModel != null) { String pathElement = stk.nextToken(); currentFileModel = findFileModel(currentFileModel, pathElement); } return currentFileModel; }
java
public FileModel getChildFile(ArchiveModel archiveModel, String filePath) { filePath = FilenameUtils.separatorsToUnix(filePath); StringTokenizer stk = new StringTokenizer(filePath, "/"); FileModel currentFileModel = archiveModel; while (stk.hasMoreTokens() && currentFileModel != null) { String pathElement = stk.nextToken(); currentFileModel = findFileModel(currentFileModel, pathElement); } return currentFileModel; }
[ "public", "FileModel", "getChildFile", "(", "ArchiveModel", "archiveModel", ",", "String", "filePath", ")", "{", "filePath", "=", "FilenameUtils", ".", "separatorsToUnix", "(", "filePath", ")", ";", "StringTokenizer", "stk", "=", "new", "StringTokenizer", "(", "filePath", ",", "\"/\"", ")", ";", "FileModel", "currentFileModel", "=", "archiveModel", ";", "while", "(", "stk", ".", "hasMoreTokens", "(", ")", "&&", "currentFileModel", "!=", "null", ")", "{", "String", "pathElement", "=", "stk", ".", "nextToken", "(", ")", ";", "currentFileModel", "=", "findFileModel", "(", "currentFileModel", ",", "pathElement", ")", ";", "}", "return", "currentFileModel", ";", "}" ]
Finds the file at the provided path within the archive. Eg, getChildFile(ArchiveModel, "/META-INF/MANIFEST.MF") will return a {@link FileModel} if a file named /META-INF/MANIFEST.MF exists within the archive @return Returns the located {@link FileModel} or null if no file with this path could be located
[ "Finds", "the", "file", "at", "the", "provided", "path", "within", "the", "archive", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/graph/api/src/main/java/org/jboss/windup/graph/service/ArchiveService.java#L50-L63
159,713
windup/windup
config/impl/src/main/java/org/jboss/windup/config/loader/RuleProviderSorter.java
RuleProviderSorter.sort
private void sort() { DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph = new DefaultDirectedWeightedGraph<>( DefaultEdge.class); for (RuleProvider provider : providers) { graph.addVertex(provider); } addProviderRelationships(graph); checkForCycles(graph); List<RuleProvider> result = new ArrayList<>(this.providers.size()); TopologicalOrderIterator<RuleProvider, DefaultEdge> iterator = new TopologicalOrderIterator<>(graph); while (iterator.hasNext()) { RuleProvider provider = iterator.next(); result.add(provider); } this.providers = Collections.unmodifiableList(result); int index = 0; for (RuleProvider provider : this.providers) { if (provider instanceof AbstractRuleProvider) ((AbstractRuleProvider) provider).setExecutionIndex(index++); } }
java
private void sort() { DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph = new DefaultDirectedWeightedGraph<>( DefaultEdge.class); for (RuleProvider provider : providers) { graph.addVertex(provider); } addProviderRelationships(graph); checkForCycles(graph); List<RuleProvider> result = new ArrayList<>(this.providers.size()); TopologicalOrderIterator<RuleProvider, DefaultEdge> iterator = new TopologicalOrderIterator<>(graph); while (iterator.hasNext()) { RuleProvider provider = iterator.next(); result.add(provider); } this.providers = Collections.unmodifiableList(result); int index = 0; for (RuleProvider provider : this.providers) { if (provider instanceof AbstractRuleProvider) ((AbstractRuleProvider) provider).setExecutionIndex(index++); } }
[ "private", "void", "sort", "(", ")", "{", "DefaultDirectedWeightedGraph", "<", "RuleProvider", ",", "DefaultEdge", ">", "graph", "=", "new", "DefaultDirectedWeightedGraph", "<>", "(", "DefaultEdge", ".", "class", ")", ";", "for", "(", "RuleProvider", "provider", ":", "providers", ")", "{", "graph", ".", "addVertex", "(", "provider", ")", ";", "}", "addProviderRelationships", "(", "graph", ")", ";", "checkForCycles", "(", "graph", ")", ";", "List", "<", "RuleProvider", ">", "result", "=", "new", "ArrayList", "<>", "(", "this", ".", "providers", ".", "size", "(", ")", ")", ";", "TopologicalOrderIterator", "<", "RuleProvider", ",", "DefaultEdge", ">", "iterator", "=", "new", "TopologicalOrderIterator", "<>", "(", "graph", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "RuleProvider", "provider", "=", "iterator", ".", "next", "(", ")", ";", "result", ".", "add", "(", "provider", ")", ";", "}", "this", ".", "providers", "=", "Collections", ".", "unmodifiableList", "(", "result", ")", ";", "int", "index", "=", "0", ";", "for", "(", "RuleProvider", "provider", ":", "this", ".", "providers", ")", "{", "if", "(", "provider", "instanceof", "AbstractRuleProvider", ")", "(", "(", "AbstractRuleProvider", ")", "provider", ")", ".", "setExecutionIndex", "(", "index", "++", ")", ";", "}", "}" ]
Perform the entire sort operation
[ "Perform", "the", "entire", "sort", "operation" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/impl/src/main/java/org/jboss/windup/config/loader/RuleProviderSorter.java#L85-L115
159,714
windup/windup
config/impl/src/main/java/org/jboss/windup/config/loader/RuleProviderSorter.java
RuleProviderSorter.checkForCycles
private void checkForCycles(DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph) { CycleDetector<RuleProvider, DefaultEdge> cycleDetector = new CycleDetector<>(graph); if (cycleDetector.detectCycles()) { // if we have cycles, then try to throw an exception with some usable data Set<RuleProvider> cycles = cycleDetector.findCycles(); StringBuilder errorSB = new StringBuilder(); for (RuleProvider cycle : cycles) { errorSB.append("Found dependency cycle involving: " + cycle.getMetadata().getID()).append(System.lineSeparator()); Set<RuleProvider> subCycleSet = cycleDetector.findCyclesContainingVertex(cycle); for (RuleProvider subCycle : subCycleSet) { errorSB.append("\tSubcycle: " + subCycle.getMetadata().getID()).append(System.lineSeparator()); } } throw new RuntimeException("Dependency cycles detected: " + errorSB.toString()); } }
java
private void checkForCycles(DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph) { CycleDetector<RuleProvider, DefaultEdge> cycleDetector = new CycleDetector<>(graph); if (cycleDetector.detectCycles()) { // if we have cycles, then try to throw an exception with some usable data Set<RuleProvider> cycles = cycleDetector.findCycles(); StringBuilder errorSB = new StringBuilder(); for (RuleProvider cycle : cycles) { errorSB.append("Found dependency cycle involving: " + cycle.getMetadata().getID()).append(System.lineSeparator()); Set<RuleProvider> subCycleSet = cycleDetector.findCyclesContainingVertex(cycle); for (RuleProvider subCycle : subCycleSet) { errorSB.append("\tSubcycle: " + subCycle.getMetadata().getID()).append(System.lineSeparator()); } } throw new RuntimeException("Dependency cycles detected: " + errorSB.toString()); } }
[ "private", "void", "checkForCycles", "(", "DefaultDirectedWeightedGraph", "<", "RuleProvider", ",", "DefaultEdge", ">", "graph", ")", "{", "CycleDetector", "<", "RuleProvider", ",", "DefaultEdge", ">", "cycleDetector", "=", "new", "CycleDetector", "<>", "(", "graph", ")", ";", "if", "(", "cycleDetector", ".", "detectCycles", "(", ")", ")", "{", "// if we have cycles, then try to throw an exception with some usable data", "Set", "<", "RuleProvider", ">", "cycles", "=", "cycleDetector", ".", "findCycles", "(", ")", ";", "StringBuilder", "errorSB", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "RuleProvider", "cycle", ":", "cycles", ")", "{", "errorSB", ".", "append", "(", "\"Found dependency cycle involving: \"", "+", "cycle", ".", "getMetadata", "(", ")", ".", "getID", "(", ")", ")", ".", "append", "(", "System", ".", "lineSeparator", "(", ")", ")", ";", "Set", "<", "RuleProvider", ">", "subCycleSet", "=", "cycleDetector", ".", "findCyclesContainingVertex", "(", "cycle", ")", ";", "for", "(", "RuleProvider", "subCycle", ":", "subCycleSet", ")", "{", "errorSB", ".", "append", "(", "\"\\tSubcycle: \"", "+", "subCycle", ".", "getMetadata", "(", ")", ".", "getID", "(", ")", ")", ".", "append", "(", "System", ".", "lineSeparator", "(", ")", ")", ";", "}", "}", "throw", "new", "RuntimeException", "(", "\"Dependency cycles detected: \"", "+", "errorSB", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Use the jgrapht cycle checker to detect any cycles in the provided dependency graph.
[ "Use", "the", "jgrapht", "cycle", "checker", "to", "detect", "any", "cycles", "in", "the", "provided", "dependency", "graph", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/impl/src/main/java/org/jboss/windup/config/loader/RuleProviderSorter.java#L267-L287
159,715
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/scan/operation/RecurseDirectoryAndAddFiles.java
RecurseDirectoryAndAddFiles.recurseAndAddFiles
private void recurseAndAddFiles(GraphRewrite event, FileService fileService, WindupJavaConfigurationService javaConfigurationService, FileModel file) { if (javaConfigurationService.checkIfIgnored(event, file)) return; String filePath = file.getFilePath(); File fileReference = new File(filePath); Long directorySize = new Long(0); if (fileReference.isDirectory()) { File[] subFiles = fileReference.listFiles(); if (subFiles != null) { for (File reference : subFiles) { FileModel subFile = fileService.createByFilePath(file, reference.getAbsolutePath()); recurseAndAddFiles(event, fileService, javaConfigurationService, subFile); if (subFile.isDirectory()) { directorySize = directorySize + subFile.getDirectorySize(); } else { directorySize = directorySize + subFile.getSize(); } } } file.setDirectorySize(directorySize); } }
java
private void recurseAndAddFiles(GraphRewrite event, FileService fileService, WindupJavaConfigurationService javaConfigurationService, FileModel file) { if (javaConfigurationService.checkIfIgnored(event, file)) return; String filePath = file.getFilePath(); File fileReference = new File(filePath); Long directorySize = new Long(0); if (fileReference.isDirectory()) { File[] subFiles = fileReference.listFiles(); if (subFiles != null) { for (File reference : subFiles) { FileModel subFile = fileService.createByFilePath(file, reference.getAbsolutePath()); recurseAndAddFiles(event, fileService, javaConfigurationService, subFile); if (subFile.isDirectory()) { directorySize = directorySize + subFile.getDirectorySize(); } else { directorySize = directorySize + subFile.getSize(); } } } file.setDirectorySize(directorySize); } }
[ "private", "void", "recurseAndAddFiles", "(", "GraphRewrite", "event", ",", "FileService", "fileService", ",", "WindupJavaConfigurationService", "javaConfigurationService", ",", "FileModel", "file", ")", "{", "if", "(", "javaConfigurationService", ".", "checkIfIgnored", "(", "event", ",", "file", ")", ")", "return", ";", "String", "filePath", "=", "file", ".", "getFilePath", "(", ")", ";", "File", "fileReference", "=", "new", "File", "(", "filePath", ")", ";", "Long", "directorySize", "=", "new", "Long", "(", "0", ")", ";", "if", "(", "fileReference", ".", "isDirectory", "(", ")", ")", "{", "File", "[", "]", "subFiles", "=", "fileReference", ".", "listFiles", "(", ")", ";", "if", "(", "subFiles", "!=", "null", ")", "{", "for", "(", "File", "reference", ":", "subFiles", ")", "{", "FileModel", "subFile", "=", "fileService", ".", "createByFilePath", "(", "file", ",", "reference", ".", "getAbsolutePath", "(", ")", ")", ";", "recurseAndAddFiles", "(", "event", ",", "fileService", ",", "javaConfigurationService", ",", "subFile", ")", ";", "if", "(", "subFile", ".", "isDirectory", "(", ")", ")", "{", "directorySize", "=", "directorySize", "+", "subFile", ".", "getDirectorySize", "(", ")", ";", "}", "else", "{", "directorySize", "=", "directorySize", "+", "subFile", ".", "getSize", "(", ")", ";", "}", "}", "}", "file", ".", "setDirectorySize", "(", "directorySize", ")", ";", "}", "}" ]
Recurses the given folder and creates the FileModels vertices for the child files to the graph.
[ "Recurses", "the", "given", "folder", "and", "creates", "the", "FileModels", "vertices", "for", "the", "child", "files", "to", "the", "graph", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/scan/operation/RecurseDirectoryAndAddFiles.java#L51-L81
159,716
windup/windup
utils/src/main/java/org/jboss/windup/util/Checks.java
Checks.checkFileOrDirectoryToBeRead
public static void checkFileOrDirectoryToBeRead(File fileOrDir, String fileDesc) { if (fileOrDir == null) throw new IllegalArgumentException(fileDesc + " must not be null."); if (!fileOrDir.exists()) throw new IllegalArgumentException(fileDesc + " does not exist: " + fileOrDir.getAbsolutePath()); if (!(fileOrDir.isDirectory() || fileOrDir.isFile())) throw new IllegalArgumentException(fileDesc + " must be a file or a directory: " + fileOrDir.getPath()); if (fileOrDir.isDirectory()) { if (fileOrDir.list().length == 0) throw new IllegalArgumentException(fileDesc + " is an empty directory: " + fileOrDir.getPath()); } }
java
public static void checkFileOrDirectoryToBeRead(File fileOrDir, String fileDesc) { if (fileOrDir == null) throw new IllegalArgumentException(fileDesc + " must not be null."); if (!fileOrDir.exists()) throw new IllegalArgumentException(fileDesc + " does not exist: " + fileOrDir.getAbsolutePath()); if (!(fileOrDir.isDirectory() || fileOrDir.isFile())) throw new IllegalArgumentException(fileDesc + " must be a file or a directory: " + fileOrDir.getPath()); if (fileOrDir.isDirectory()) { if (fileOrDir.list().length == 0) throw new IllegalArgumentException(fileDesc + " is an empty directory: " + fileOrDir.getPath()); } }
[ "public", "static", "void", "checkFileOrDirectoryToBeRead", "(", "File", "fileOrDir", ",", "String", "fileDesc", ")", "{", "if", "(", "fileOrDir", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "fileDesc", "+", "\" must not be null.\"", ")", ";", "if", "(", "!", "fileOrDir", ".", "exists", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", "fileDesc", "+", "\" does not exist: \"", "+", "fileOrDir", ".", "getAbsolutePath", "(", ")", ")", ";", "if", "(", "!", "(", "fileOrDir", ".", "isDirectory", "(", ")", "||", "fileOrDir", ".", "isFile", "(", ")", ")", ")", "throw", "new", "IllegalArgumentException", "(", "fileDesc", "+", "\" must be a file or a directory: \"", "+", "fileOrDir", ".", "getPath", "(", ")", ")", ";", "if", "(", "fileOrDir", ".", "isDirectory", "(", ")", ")", "{", "if", "(", "fileOrDir", ".", "list", "(", ")", ".", "length", "==", "0", ")", "throw", "new", "IllegalArgumentException", "(", "fileDesc", "+", "\" is an empty directory: \"", "+", "fileOrDir", ".", "getPath", "(", ")", ")", ";", "}", "}" ]
Throws if the given file is null, is not a file or directory, or is an empty directory.
[ "Throws", "if", "the", "given", "file", "is", "null", "is", "not", "a", "file", "or", "directory", "or", "is", "an", "empty", "directory", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/Checks.java#L45-L58
159,717
windup/windup
utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java
FurnaceClasspathScanner.scan
public List<URL> scan(Predicate<String> filter) { List<URL> discoveredURLs = new ArrayList<>(128); // For each Forge addon... for (Addon addon : furnace.getAddonRegistry().getAddons(AddonFilters.allStarted())) { List<String> filteredResourcePaths = filterAddonResources(addon, filter); for (String filePath : filteredResourcePaths) { URL ruleFile = addon.getClassLoader().getResource(filePath); if (ruleFile != null) discoveredURLs.add(ruleFile); } } return discoveredURLs; }
java
public List<URL> scan(Predicate<String> filter) { List<URL> discoveredURLs = new ArrayList<>(128); // For each Forge addon... for (Addon addon : furnace.getAddonRegistry().getAddons(AddonFilters.allStarted())) { List<String> filteredResourcePaths = filterAddonResources(addon, filter); for (String filePath : filteredResourcePaths) { URL ruleFile = addon.getClassLoader().getResource(filePath); if (ruleFile != null) discoveredURLs.add(ruleFile); } } return discoveredURLs; }
[ "public", "List", "<", "URL", ">", "scan", "(", "Predicate", "<", "String", ">", "filter", ")", "{", "List", "<", "URL", ">", "discoveredURLs", "=", "new", "ArrayList", "<>", "(", "128", ")", ";", "// For each Forge addon...", "for", "(", "Addon", "addon", ":", "furnace", ".", "getAddonRegistry", "(", ")", ".", "getAddons", "(", "AddonFilters", ".", "allStarted", "(", ")", ")", ")", "{", "List", "<", "String", ">", "filteredResourcePaths", "=", "filterAddonResources", "(", "addon", ",", "filter", ")", ";", "for", "(", "String", "filePath", ":", "filteredResourcePaths", ")", "{", "URL", "ruleFile", "=", "addon", ".", "getClassLoader", "(", ")", ".", "getResource", "(", "filePath", ")", ";", "if", "(", "ruleFile", "!=", "null", ")", "discoveredURLs", ".", "add", "(", "ruleFile", ")", ";", "}", "}", "return", "discoveredURLs", ";", "}" ]
Scans all Forge addons for files accepted by given filter.
[ "Scans", "all", "Forge", "addons", "for", "files", "accepted", "by", "given", "filter", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java#L76-L92
159,718
windup/windup
utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java
FurnaceClasspathScanner.scanClasses
public List<Class<?>> scanClasses(Predicate<String> filter) { List<Class<?>> discoveredClasses = new ArrayList<>(128); // For each Forge addon... for (Addon addon : furnace.getAddonRegistry().getAddons(AddonFilters.allStarted())) { List<String> discoveredFileNames = filterAddonResources(addon, filter); // Then try to load the classes. for (String discoveredFilename : discoveredFileNames) { String clsName = PathUtil.classFilePathToClassname(discoveredFilename); try { Class<?> clazz = addon.getClassLoader().loadClass(clsName); discoveredClasses.add(clazz); } catch (ClassNotFoundException ex) { LOG.log(Level.WARNING, "Failed to load class for name '" + clsName + "':\n" + ex.getMessage(), ex); } } } return discoveredClasses; }
java
public List<Class<?>> scanClasses(Predicate<String> filter) { List<Class<?>> discoveredClasses = new ArrayList<>(128); // For each Forge addon... for (Addon addon : furnace.getAddonRegistry().getAddons(AddonFilters.allStarted())) { List<String> discoveredFileNames = filterAddonResources(addon, filter); // Then try to load the classes. for (String discoveredFilename : discoveredFileNames) { String clsName = PathUtil.classFilePathToClassname(discoveredFilename); try { Class<?> clazz = addon.getClassLoader().loadClass(clsName); discoveredClasses.add(clazz); } catch (ClassNotFoundException ex) { LOG.log(Level.WARNING, "Failed to load class for name '" + clsName + "':\n" + ex.getMessage(), ex); } } } return discoveredClasses; }
[ "public", "List", "<", "Class", "<", "?", ">", ">", "scanClasses", "(", "Predicate", "<", "String", ">", "filter", ")", "{", "List", "<", "Class", "<", "?", ">", ">", "discoveredClasses", "=", "new", "ArrayList", "<>", "(", "128", ")", ";", "// For each Forge addon...", "for", "(", "Addon", "addon", ":", "furnace", ".", "getAddonRegistry", "(", ")", ".", "getAddons", "(", "AddonFilters", ".", "allStarted", "(", ")", ")", ")", "{", "List", "<", "String", ">", "discoveredFileNames", "=", "filterAddonResources", "(", "addon", ",", "filter", ")", ";", "// Then try to load the classes.", "for", "(", "String", "discoveredFilename", ":", "discoveredFileNames", ")", "{", "String", "clsName", "=", "PathUtil", ".", "classFilePathToClassname", "(", "discoveredFilename", ")", ";", "try", "{", "Class", "<", "?", ">", "clazz", "=", "addon", ".", "getClassLoader", "(", ")", ".", "loadClass", "(", "clsName", ")", ";", "discoveredClasses", ".", "add", "(", "clazz", ")", ";", "}", "catch", "(", "ClassNotFoundException", "ex", ")", "{", "LOG", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Failed to load class for name '\"", "+", "clsName", "+", "\"':\\n\"", "+", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "}", "}", "}", "return", "discoveredClasses", ";", "}" ]
Scans all Forge addons for classes accepted by given filter. TODO: Could be refactored - scan() is almost the same.
[ "Scans", "all", "Forge", "addons", "for", "classes", "accepted", "by", "given", "filter", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java#L99-L124
159,719
windup/windup
utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java
FurnaceClasspathScanner.filterAddonResources
public List<String> filterAddonResources(Addon addon, Predicate<String> filter) { List<String> discoveredFileNames = new ArrayList<>(); List<File> addonResources = addon.getRepository().getAddonResources(addon.getId()); for (File addonFile : addonResources) { if (addonFile.isDirectory()) handleDirectory(filter, addonFile, discoveredFileNames); else handleArchiveByFile(filter, addonFile, discoveredFileNames); } return discoveredFileNames; }
java
public List<String> filterAddonResources(Addon addon, Predicate<String> filter) { List<String> discoveredFileNames = new ArrayList<>(); List<File> addonResources = addon.getRepository().getAddonResources(addon.getId()); for (File addonFile : addonResources) { if (addonFile.isDirectory()) handleDirectory(filter, addonFile, discoveredFileNames); else handleArchiveByFile(filter, addonFile, discoveredFileNames); } return discoveredFileNames; }
[ "public", "List", "<", "String", ">", "filterAddonResources", "(", "Addon", "addon", ",", "Predicate", "<", "String", ">", "filter", ")", "{", "List", "<", "String", ">", "discoveredFileNames", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "File", ">", "addonResources", "=", "addon", ".", "getRepository", "(", ")", ".", "getAddonResources", "(", "addon", ".", "getId", "(", ")", ")", ";", "for", "(", "File", "addonFile", ":", "addonResources", ")", "{", "if", "(", "addonFile", ".", "isDirectory", "(", ")", ")", "handleDirectory", "(", "filter", ",", "addonFile", ",", "discoveredFileNames", ")", ";", "else", "handleArchiveByFile", "(", "filter", ",", "addonFile", ",", "discoveredFileNames", ")", ";", "}", "return", "discoveredFileNames", ";", "}" ]
Returns a list of files in given addon passing given filter.
[ "Returns", "a", "list", "of", "files", "in", "given", "addon", "passing", "given", "filter", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java#L129-L141
159,720
windup/windup
utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java
FurnaceClasspathScanner.handleArchiveByFile
private void handleArchiveByFile(Predicate<String> filter, File archive, List<String> discoveredFiles) { try { try (ZipFile zip = new ZipFile(archive)) { Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (filter.accept(name)) discoveredFiles.add(name); } } } catch (IOException e) { throw new RuntimeException("Error handling file " + archive, e); } }
java
private void handleArchiveByFile(Predicate<String> filter, File archive, List<String> discoveredFiles) { try { try (ZipFile zip = new ZipFile(archive)) { Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (filter.accept(name)) discoveredFiles.add(name); } } } catch (IOException e) { throw new RuntimeException("Error handling file " + archive, e); } }
[ "private", "void", "handleArchiveByFile", "(", "Predicate", "<", "String", ">", "filter", ",", "File", "archive", ",", "List", "<", "String", ">", "discoveredFiles", ")", "{", "try", "{", "try", "(", "ZipFile", "zip", "=", "new", "ZipFile", "(", "archive", ")", ")", "{", "Enumeration", "<", "?", "extends", "ZipEntry", ">", "entries", "=", "zip", ".", "entries", "(", ")", ";", "while", "(", "entries", ".", "hasMoreElements", "(", ")", ")", "{", "ZipEntry", "entry", "=", "entries", ".", "nextElement", "(", ")", ";", "String", "name", "=", "entry", ".", "getName", "(", ")", ";", "if", "(", "filter", ".", "accept", "(", "name", ")", ")", "discoveredFiles", ".", "add", "(", "name", ")", ";", "}", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error handling file \"", "+", "archive", ",", "e", ")", ";", "}", "}" ]
Scans given archive for files passing given filter, adds the results into given list.
[ "Scans", "given", "archive", "for", "files", "passing", "given", "filter", "adds", "the", "results", "into", "given", "list", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java#L146-L167
159,721
windup/windup
utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java
FurnaceClasspathScanner.handleDirectory
private void handleDirectory(final Predicate<String> filter, final File rootDir, final List<String> discoveredFiles) { try { new DirectoryWalker<String>() { private Path startDir; public void walk() throws IOException { this.startDir = rootDir.toPath(); this.walk(rootDir, discoveredFiles); } @Override protected void handleFile(File file, int depth, Collection<String> discoveredFiles) throws IOException { String newPath = startDir.relativize(file.toPath()).toString(); if (filter.accept(newPath)) discoveredFiles.add(newPath); } }.walk(); } catch (IOException ex) { LOG.log(Level.SEVERE, "Error reading Furnace addon directory", ex); } }
java
private void handleDirectory(final Predicate<String> filter, final File rootDir, final List<String> discoveredFiles) { try { new DirectoryWalker<String>() { private Path startDir; public void walk() throws IOException { this.startDir = rootDir.toPath(); this.walk(rootDir, discoveredFiles); } @Override protected void handleFile(File file, int depth, Collection<String> discoveredFiles) throws IOException { String newPath = startDir.relativize(file.toPath()).toString(); if (filter.accept(newPath)) discoveredFiles.add(newPath); } }.walk(); } catch (IOException ex) { LOG.log(Level.SEVERE, "Error reading Furnace addon directory", ex); } }
[ "private", "void", "handleDirectory", "(", "final", "Predicate", "<", "String", ">", "filter", ",", "final", "File", "rootDir", ",", "final", "List", "<", "String", ">", "discoveredFiles", ")", "{", "try", "{", "new", "DirectoryWalker", "<", "String", ">", "(", ")", "{", "private", "Path", "startDir", ";", "public", "void", "walk", "(", ")", "throws", "IOException", "{", "this", ".", "startDir", "=", "rootDir", ".", "toPath", "(", ")", ";", "this", ".", "walk", "(", "rootDir", ",", "discoveredFiles", ")", ";", "}", "@", "Override", "protected", "void", "handleFile", "(", "File", "file", ",", "int", "depth", ",", "Collection", "<", "String", ">", "discoveredFiles", ")", "throws", "IOException", "{", "String", "newPath", "=", "startDir", ".", "relativize", "(", "file", ".", "toPath", "(", ")", ")", ".", "toString", "(", ")", ";", "if", "(", "filter", ".", "accept", "(", "newPath", ")", ")", "discoveredFiles", ".", "add", "(", "newPath", ")", ";", "}", "}", ".", "walk", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "LOG", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Error reading Furnace addon directory\"", ",", "ex", ")", ";", "}", "}" ]
Scans given directory for files passing given filter, adds the results into given list.
[ "Scans", "given", "directory", "for", "files", "passing", "given", "filter", "adds", "the", "results", "into", "given", "list", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/furnace/FurnaceClasspathScanner.java#L172-L200
159,722
windup/windup
rules-java-project/addon/src/main/java/org/jboss/windup/project/condition/Project.java
Project.dependsOnArtifact
public static Project dependsOnArtifact(Artifact artifact) { Project project = new Project(); project.artifact = artifact; return project; }
java
public static Project dependsOnArtifact(Artifact artifact) { Project project = new Project(); project.artifact = artifact; return project; }
[ "public", "static", "Project", "dependsOnArtifact", "(", "Artifact", "artifact", ")", "{", "Project", "project", "=", "new", "Project", "(", ")", ";", "project", ".", "artifact", "=", "artifact", ";", "return", "project", ";", "}" ]
Specify the Artifact for which the condition should search for. @param artifact @return
[ "Specify", "the", "Artifact", "for", "which", "the", "condition", "should", "search", "for", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java-project/addon/src/main/java/org/jboss/windup/project/condition/Project.java#L43-L48
159,723
windup/windup
utils/src/main/java/org/jboss/windup/util/Util.java
Util.getSingle
public static final <T> T getSingle( Iterable<T> it ) { if( ! it.iterator().hasNext() ) return null; final Iterator<T> iterator = it.iterator(); T o = iterator.next(); if(iterator.hasNext()) throw new IllegalStateException("Found multiple items in iterator over " + o.getClass().getName() ); return o; }
java
public static final <T> T getSingle( Iterable<T> it ) { if( ! it.iterator().hasNext() ) return null; final Iterator<T> iterator = it.iterator(); T o = iterator.next(); if(iterator.hasNext()) throw new IllegalStateException("Found multiple items in iterator over " + o.getClass().getName() ); return o; }
[ "public", "static", "final", "<", "T", ">", "T", "getSingle", "(", "Iterable", "<", "T", ">", "it", ")", "{", "if", "(", "!", "it", ".", "iterator", "(", ")", ".", "hasNext", "(", ")", ")", "return", "null", ";", "final", "Iterator", "<", "T", ">", "iterator", "=", "it", ".", "iterator", "(", ")", ";", "T", "o", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "iterator", ".", "hasNext", "(", ")", ")", "throw", "new", "IllegalStateException", "(", "\"Found multiple items in iterator over \"", "+", "o", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "return", "o", ";", "}" ]
Returns a single item from the Iterator. If there's none, returns null. If there are more, throws an IllegalStateException. @throws IllegalStateException
[ "Returns", "a", "single", "item", "from", "the", "Iterator", ".", "If", "there", "s", "none", "returns", "null", ".", "If", "there", "are", "more", "throws", "an", "IllegalStateException", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/Util.java#L24-L34
159,724
windup/windup
rules-xml/api/src/main/java/org/jboss/windup/rules/apps/xml/operation/xslt/XSLTTransformation.java
XSLTTransformation.perform
@Override public void perform(GraphRewrite event, EvaluationContext context) { checkVariableName(event, context); WindupVertexFrame payload = resolveVariable(event, getVariableName()); if (payload instanceof FileReferenceModel) { FileModel file = ((FileReferenceModel) payload).getFile(); perform(event, context, (XmlFileModel) file); } else { super.perform(event, context); } }
java
@Override public void perform(GraphRewrite event, EvaluationContext context) { checkVariableName(event, context); WindupVertexFrame payload = resolveVariable(event, getVariableName()); if (payload instanceof FileReferenceModel) { FileModel file = ((FileReferenceModel) payload).getFile(); perform(event, context, (XmlFileModel) file); } else { super.perform(event, context); } }
[ "@", "Override", "public", "void", "perform", "(", "GraphRewrite", "event", ",", "EvaluationContext", "context", ")", "{", "checkVariableName", "(", "event", ",", "context", ")", ";", "WindupVertexFrame", "payload", "=", "resolveVariable", "(", "event", ",", "getVariableName", "(", ")", ")", ";", "if", "(", "payload", "instanceof", "FileReferenceModel", ")", "{", "FileModel", "file", "=", "(", "(", "FileReferenceModel", ")", "payload", ")", ".", "getFile", "(", ")", ";", "perform", "(", "event", ",", "context", ",", "(", "XmlFileModel", ")", "file", ")", ";", "}", "else", "{", "super", ".", "perform", "(", "event", ",", "context", ")", ";", "}", "}" ]
Set the payload to the fileModel of the given instance even though the variable is not directly of it's type. This is mainly to simplify the creation of the rule, when the FileModel itself is not being iterated but just a model referencing it.
[ "Set", "the", "payload", "to", "the", "fileModel", "of", "the", "given", "instance", "even", "though", "the", "variable", "is", "not", "directly", "of", "it", "s", "type", ".", "This", "is", "mainly", "to", "simplify", "the", "creation", "of", "the", "rule", "when", "the", "FileModel", "itself", "is", "not", "being", "iterated", "but", "just", "a", "model", "referencing", "it", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-xml/api/src/main/java/org/jboss/windup/rules/apps/xml/operation/xslt/XSLTTransformation.java#L124-L139
159,725
windup/windup
rules-java-project/addon/src/main/java/org/jboss/windup/project/condition/ProjectFrom.java
ProjectFrom.dependsOnArtifact
public Project dependsOnArtifact(Artifact artifact) { Project project = new Project(); project.setArtifact(artifact); project.setInputVariablesName(inputVarName); return project; }
java
public Project dependsOnArtifact(Artifact artifact) { Project project = new Project(); project.setArtifact(artifact); project.setInputVariablesName(inputVarName); return project; }
[ "public", "Project", "dependsOnArtifact", "(", "Artifact", "artifact", ")", "{", "Project", "project", "=", "new", "Project", "(", ")", ";", "project", ".", "setArtifact", "(", "artifact", ")", ";", "project", ".", "setInputVariablesName", "(", "inputVarName", ")", ";", "return", "project", ";", "}" ]
Specify the artifact configuration to be searched for @param artifact configured artifact object @return
[ "Specify", "the", "artifact", "configuration", "to", "be", "searched", "for" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java-project/addon/src/main/java/org/jboss/windup/project/condition/ProjectFrom.java#L21-L27
159,726
windup/windup
rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/JmsDestinationService.java
JmsDestinationService.getTypeFromClass
public static JmsDestinationType getTypeFromClass(String aClass) { if (StringUtils.equals(aClass, "javax.jms.Queue") || StringUtils.equals(aClass, "javax.jms.QueueConnectionFactory")) { return JmsDestinationType.QUEUE; } else if (StringUtils.equals(aClass, "javax.jms.Topic") || StringUtils.equals(aClass, "javax.jms.TopicConnectionFactory")) { return JmsDestinationType.TOPIC; } else { return null; } }
java
public static JmsDestinationType getTypeFromClass(String aClass) { if (StringUtils.equals(aClass, "javax.jms.Queue") || StringUtils.equals(aClass, "javax.jms.QueueConnectionFactory")) { return JmsDestinationType.QUEUE; } else if (StringUtils.equals(aClass, "javax.jms.Topic") || StringUtils.equals(aClass, "javax.jms.TopicConnectionFactory")) { return JmsDestinationType.TOPIC; } else { return null; } }
[ "public", "static", "JmsDestinationType", "getTypeFromClass", "(", "String", "aClass", ")", "{", "if", "(", "StringUtils", ".", "equals", "(", "aClass", ",", "\"javax.jms.Queue\"", ")", "||", "StringUtils", ".", "equals", "(", "aClass", ",", "\"javax.jms.QueueConnectionFactory\"", ")", ")", "{", "return", "JmsDestinationType", ".", "QUEUE", ";", "}", "else", "if", "(", "StringUtils", ".", "equals", "(", "aClass", ",", "\"javax.jms.Topic\"", ")", "||", "StringUtils", ".", "equals", "(", "aClass", ",", "\"javax.jms.TopicConnectionFactory\"", ")", ")", "{", "return", "JmsDestinationType", ".", "TOPIC", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Gets JmsDestinationType from java class name Returns null for unrecognized class
[ "Gets", "JmsDestinationType", "from", "java", "class", "name" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/JmsDestinationService.java#L75-L89
159,727
windup/windup
config/api/src/main/java/org/jboss/windup/config/operation/iteration/AbstractIterationOperation.java
AbstractIterationOperation.checkVariableName
protected void checkVariableName(GraphRewrite event, EvaluationContext context) { if (variableName == null) { setVariableName(Iteration.getPayloadVariableName(event, context)); } }
java
protected void checkVariableName(GraphRewrite event, EvaluationContext context) { if (variableName == null) { setVariableName(Iteration.getPayloadVariableName(event, context)); } }
[ "protected", "void", "checkVariableName", "(", "GraphRewrite", "event", ",", "EvaluationContext", "context", ")", "{", "if", "(", "variableName", "==", "null", ")", "{", "setVariableName", "(", "Iteration", ".", "getPayloadVariableName", "(", "event", ",", "context", ")", ")", ";", "}", "}" ]
Check the variable name and if not set, set it with the singleton variable name being on the top of the stack.
[ "Check", "the", "variable", "name", "and", "if", "not", "set", "set", "it", "with", "the", "singleton", "variable", "name", "being", "on", "the", "top", "of", "the", "stack", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/operation/iteration/AbstractIterationOperation.java#L77-L83
159,728
windup/windup
java-ast/addon/src/main/java/org/jboss/windup/ast/java/ASTProcessor.java
ASTProcessor.analyze
public static List<ClassReference> analyze(WildcardImportResolver importResolver, Set<String> libraryPaths, Set<String> sourcePaths, Path sourceFile) { ASTParser parser = ASTParser.newParser(AST.JLS11); parser.setEnvironment(libraryPaths.toArray(new String[libraryPaths.size()]), sourcePaths.toArray(new String[sourcePaths.size()]), null, true); parser.setBindingsRecovery(false); parser.setResolveBindings(true); Map options = JavaCore.getOptions(); JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options); parser.setCompilerOptions(options); String fileName = sourceFile.getFileName().toString(); parser.setUnitName(fileName); try { parser.setSource(FileUtils.readFileToString(sourceFile.toFile()).toCharArray()); } catch (IOException e) { throw new ASTException("Failed to get source for file: " + sourceFile.toString() + " due to: " + e.getMessage(), e); } parser.setKind(ASTParser.K_COMPILATION_UNIT); CompilationUnit cu = (CompilationUnit) parser.createAST(null); ReferenceResolvingVisitor visitor = new ReferenceResolvingVisitor(importResolver, cu, sourceFile.toString()); cu.accept(visitor); return visitor.getJavaClassReferences(); }
java
public static List<ClassReference> analyze(WildcardImportResolver importResolver, Set<String> libraryPaths, Set<String> sourcePaths, Path sourceFile) { ASTParser parser = ASTParser.newParser(AST.JLS11); parser.setEnvironment(libraryPaths.toArray(new String[libraryPaths.size()]), sourcePaths.toArray(new String[sourcePaths.size()]), null, true); parser.setBindingsRecovery(false); parser.setResolveBindings(true); Map options = JavaCore.getOptions(); JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options); parser.setCompilerOptions(options); String fileName = sourceFile.getFileName().toString(); parser.setUnitName(fileName); try { parser.setSource(FileUtils.readFileToString(sourceFile.toFile()).toCharArray()); } catch (IOException e) { throw new ASTException("Failed to get source for file: " + sourceFile.toString() + " due to: " + e.getMessage(), e); } parser.setKind(ASTParser.K_COMPILATION_UNIT); CompilationUnit cu = (CompilationUnit) parser.createAST(null); ReferenceResolvingVisitor visitor = new ReferenceResolvingVisitor(importResolver, cu, sourceFile.toString()); cu.accept(visitor); return visitor.getJavaClassReferences(); }
[ "public", "static", "List", "<", "ClassReference", ">", "analyze", "(", "WildcardImportResolver", "importResolver", ",", "Set", "<", "String", ">", "libraryPaths", ",", "Set", "<", "String", ">", "sourcePaths", ",", "Path", "sourceFile", ")", "{", "ASTParser", "parser", "=", "ASTParser", ".", "newParser", "(", "AST", ".", "JLS11", ")", ";", "parser", ".", "setEnvironment", "(", "libraryPaths", ".", "toArray", "(", "new", "String", "[", "libraryPaths", ".", "size", "(", ")", "]", ")", ",", "sourcePaths", ".", "toArray", "(", "new", "String", "[", "sourcePaths", ".", "size", "(", ")", "]", ")", ",", "null", ",", "true", ")", ";", "parser", ".", "setBindingsRecovery", "(", "false", ")", ";", "parser", ".", "setResolveBindings", "(", "true", ")", ";", "Map", "options", "=", "JavaCore", ".", "getOptions", "(", ")", ";", "JavaCore", ".", "setComplianceOptions", "(", "JavaCore", ".", "VERSION_1_8", ",", "options", ")", ";", "parser", ".", "setCompilerOptions", "(", "options", ")", ";", "String", "fileName", "=", "sourceFile", ".", "getFileName", "(", ")", ".", "toString", "(", ")", ";", "parser", ".", "setUnitName", "(", "fileName", ")", ";", "try", "{", "parser", ".", "setSource", "(", "FileUtils", ".", "readFileToString", "(", "sourceFile", ".", "toFile", "(", ")", ")", ".", "toCharArray", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "ASTException", "(", "\"Failed to get source for file: \"", "+", "sourceFile", ".", "toString", "(", ")", "+", "\" due to: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "parser", ".", "setKind", "(", "ASTParser", ".", "K_COMPILATION_UNIT", ")", ";", "CompilationUnit", "cu", "=", "(", "CompilationUnit", ")", "parser", ".", "createAST", "(", "null", ")", ";", "ReferenceResolvingVisitor", "visitor", "=", "new", "ReferenceResolvingVisitor", "(", "importResolver", ",", "cu", ",", "sourceFile", ".", "toString", "(", ")", ")", ";", "cu", ".", "accept", "(", "visitor", ")", ";", "return", "visitor", ".", "getJavaClassReferences", "(", ")", ";", "}" ]
Parses the provided file, using the given libraryPaths and sourcePaths as context. The libraries may be either jar files or references to directories containing class files. The sourcePaths must be a reference to the top level directory for sources (eg, for a file src/main/java/org/example/Foo.java, the source path would be src/main/java). The wildcard resolver provides a fallback for processing wildcard imports that the underlying parser was unable to resolve.
[ "Parses", "the", "provided", "file", "using", "the", "given", "libraryPaths", "and", "sourcePaths", "as", "context", ".", "The", "libraries", "may", "be", "either", "jar", "files", "or", "references", "to", "directories", "containing", "class", "files", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/java-ast/addon/src/main/java/org/jboss/windup/ast/java/ASTProcessor.java#L41-L66
159,729
windup/windup
graph/api/src/main/java/org/jboss/windup/graph/GraphUtil.java
GraphUtil.vertexAsString
public static final String vertexAsString(Vertex vertex, int depth, String withEdgesOfLabel) { StringBuilder sb = new StringBuilder(); vertexAsString(vertex, depth, withEdgesOfLabel, sb, 0, new HashSet<>()); return sb.toString(); }
java
public static final String vertexAsString(Vertex vertex, int depth, String withEdgesOfLabel) { StringBuilder sb = new StringBuilder(); vertexAsString(vertex, depth, withEdgesOfLabel, sb, 0, new HashSet<>()); return sb.toString(); }
[ "public", "static", "final", "String", "vertexAsString", "(", "Vertex", "vertex", ",", "int", "depth", ",", "String", "withEdgesOfLabel", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "vertexAsString", "(", "vertex", ",", "depth", ",", "withEdgesOfLabel", ",", "sb", ",", "0", ",", "new", "HashSet", "<>", "(", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Formats a vertex using it's properties. Debugging purposes.
[ "Formats", "a", "vertex", "using", "it", "s", "properties", ".", "Debugging", "purposes", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/graph/api/src/main/java/org/jboss/windup/graph/GraphUtil.java#L21-L26
159,730
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/MavenizationService.java
MavenizationService.normalizeDirName
private static String normalizeDirName(String name) { if(name == null) return null; return name.toLowerCase().replaceAll("[^a-zA-Z0-9]", "-"); }
java
private static String normalizeDirName(String name) { if(name == null) return null; return name.toLowerCase().replaceAll("[^a-zA-Z0-9]", "-"); }
[ "private", "static", "String", "normalizeDirName", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "return", "null", ";", "return", "name", ".", "toLowerCase", "(", ")", ".", "replaceAll", "(", "\"[^a-zA-Z0-9]\"", ",", "\"-\"", ")", ";", "}" ]
Normalizes the name so it can be used as Maven artifactId or groupId.
[ "Normalizes", "the", "name", "so", "it", "can", "be", "used", "as", "Maven", "artifactId", "or", "groupId", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/MavenizationService.java#L249-L254
159,731
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/MavenizationService.java
MavenizationService.guessPackaging
private static String guessPackaging(ProjectModel projectModel) { String projectType = projectModel.getProjectType(); if (projectType != null) return projectType; LOG.warning("WINDUP-983 getProjectType() returned null for: " + projectModel.getRootFileModel().getPrettyPath()); String suffix = StringUtils.substringAfterLast(projectModel.getRootFileModel().getFileName(), "."); if ("jar war ear sar har ".contains(suffix+" ")){ projectModel.setProjectType(suffix); // FIXME: Remove when WINDUP-983 is fixed. return suffix; } // Should we try something more? Used APIs? What if it's a source? return "unknown"; }
java
private static String guessPackaging(ProjectModel projectModel) { String projectType = projectModel.getProjectType(); if (projectType != null) return projectType; LOG.warning("WINDUP-983 getProjectType() returned null for: " + projectModel.getRootFileModel().getPrettyPath()); String suffix = StringUtils.substringAfterLast(projectModel.getRootFileModel().getFileName(), "."); if ("jar war ear sar har ".contains(suffix+" ")){ projectModel.setProjectType(suffix); // FIXME: Remove when WINDUP-983 is fixed. return suffix; } // Should we try something more? Used APIs? What if it's a source? return "unknown"; }
[ "private", "static", "String", "guessPackaging", "(", "ProjectModel", "projectModel", ")", "{", "String", "projectType", "=", "projectModel", ".", "getProjectType", "(", ")", ";", "if", "(", "projectType", "!=", "null", ")", "return", "projectType", ";", "LOG", ".", "warning", "(", "\"WINDUP-983 getProjectType() returned null for: \"", "+", "projectModel", ".", "getRootFileModel", "(", ")", ".", "getPrettyPath", "(", ")", ")", ";", "String", "suffix", "=", "StringUtils", ".", "substringAfterLast", "(", "projectModel", ".", "getRootFileModel", "(", ")", ".", "getFileName", "(", ")", ",", "\".\"", ")", ";", "if", "(", "\"jar war ear sar har \"", ".", "contains", "(", "suffix", "+", "\" \"", ")", ")", "{", "projectModel", ".", "setProjectType", "(", "suffix", ")", ";", "// FIXME: Remove when WINDUP-983 is fixed.", "return", "suffix", ";", "}", "// Should we try something more? Used APIs? What if it's a source?", "return", "\"unknown\"", ";", "}" ]
Tries to guess the packaging of the archive - whether it's an EAR, WAR, JAR. Maybe not needed as we can rely on the suffix?
[ "Tries", "to", "guess", "the", "packaging", "of", "the", "archive", "-", "whether", "it", "s", "an", "EAR", "WAR", "JAR", ".", "Maybe", "not", "needed", "as", "we", "can", "rely", "on", "the", "suffix?" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/MavenizationService.java#L260-L277
159,732
windup/windup
utils/src/main/java/org/jboss/windup/util/xml/XmlUtil.java
XmlUtil.xpathExists
public static boolean xpathExists(Node document, String xpathExpression, Map<String, String> namespaceMapping) throws XPathException, MarshallingException { Boolean result = (Boolean) executeXPath(document, xpathExpression, namespaceMapping, XPathConstants.BOOLEAN); return result != null && result; }
java
public static boolean xpathExists(Node document, String xpathExpression, Map<String, String> namespaceMapping) throws XPathException, MarshallingException { Boolean result = (Boolean) executeXPath(document, xpathExpression, namespaceMapping, XPathConstants.BOOLEAN); return result != null && result; }
[ "public", "static", "boolean", "xpathExists", "(", "Node", "document", ",", "String", "xpathExpression", ",", "Map", "<", "String", ",", "String", ">", "namespaceMapping", ")", "throws", "XPathException", ",", "MarshallingException", "{", "Boolean", "result", "=", "(", "Boolean", ")", "executeXPath", "(", "document", ",", "xpathExpression", ",", "namespaceMapping", ",", "XPathConstants", ".", "BOOLEAN", ")", ";", "return", "result", "!=", "null", "&&", "result", ";", "}" ]
Runs the given xpath and returns a boolean result.
[ "Runs", "the", "given", "xpath", "and", "returns", "a", "boolean", "result", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/xml/XmlUtil.java#L137-L142
159,733
windup/windup
utils/src/main/java/org/jboss/windup/util/xml/XmlUtil.java
XmlUtil.executeXPath
public static Object executeXPath(Node document, String xpathExpression, Map<String, String> namespaceMapping, QName result) throws XPathException, MarshallingException { NamespaceMapContext mapContext = new NamespaceMapContext(namespaceMapping); try { XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); xpath.setNamespaceContext(mapContext); XPathExpression expr = xpath.compile(xpathExpression); return executeXPath(document, expr, result); } catch (XPathExpressionException e) { throw new XPathException("Xpath(" + xpathExpression + ") cannot be compiled", e); } catch (Exception e) { throw new MarshallingException("Exception unmarshalling XML.", e); } }
java
public static Object executeXPath(Node document, String xpathExpression, Map<String, String> namespaceMapping, QName result) throws XPathException, MarshallingException { NamespaceMapContext mapContext = new NamespaceMapContext(namespaceMapping); try { XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); xpath.setNamespaceContext(mapContext); XPathExpression expr = xpath.compile(xpathExpression); return executeXPath(document, expr, result); } catch (XPathExpressionException e) { throw new XPathException("Xpath(" + xpathExpression + ") cannot be compiled", e); } catch (Exception e) { throw new MarshallingException("Exception unmarshalling XML.", e); } }
[ "public", "static", "Object", "executeXPath", "(", "Node", "document", ",", "String", "xpathExpression", ",", "Map", "<", "String", ",", "String", ">", "namespaceMapping", ",", "QName", "result", ")", "throws", "XPathException", ",", "MarshallingException", "{", "NamespaceMapContext", "mapContext", "=", "new", "NamespaceMapContext", "(", "namespaceMapping", ")", ";", "try", "{", "XPathFactory", "xPathfactory", "=", "XPathFactory", ".", "newInstance", "(", ")", ";", "XPath", "xpath", "=", "xPathfactory", ".", "newXPath", "(", ")", ";", "xpath", ".", "setNamespaceContext", "(", "mapContext", ")", ";", "XPathExpression", "expr", "=", "xpath", ".", "compile", "(", "xpathExpression", ")", ";", "return", "executeXPath", "(", "document", ",", "expr", ",", "result", ")", ";", "}", "catch", "(", "XPathExpressionException", "e", ")", "{", "throw", "new", "XPathException", "(", "\"Xpath(\"", "+", "xpathExpression", "+", "\") cannot be compiled\"", ",", "e", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "MarshallingException", "(", "\"Exception unmarshalling XML.\"", ",", "e", ")", ";", "}", "}" ]
Executes the given xpath and returns the result with the type specified.
[ "Executes", "the", "given", "xpath", "and", "returns", "the", "result", "with", "the", "type", "specified", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/xml/XmlUtil.java#L173-L194
159,734
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ModuleAnalysisHelper.java
ModuleAnalysisHelper.deriveGroupIdFromPackages
String deriveGroupIdFromPackages(ProjectModel projectModel) { Map<Object, Long> pkgsMap = new HashMap<>(); Set<String> pkgs = new HashSet<>(1000); GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(graphContext.getGraph()).V(projectModel); pkgsMap = pipeline.out(ProjectModel.PROJECT_MODEL_TO_FILE) .has(WindupVertexFrame.TYPE_PROP, new P(new BiPredicate<String, String>() { @Override public boolean test(String o, String o2) { return o.contains(o2); } }, GraphTypeManager.getTypeValue(JavaClassFileModel.class))) .hasKey(JavaClassFileModel.PROPERTY_PACKAGE_NAME) .groupCount() .by(v -> upToThirdDot(graphContext, (Vertex)v)).toList().get(0); Map.Entry<Object, Long> biggest = null; for (Map.Entry<Object, Long> entry : pkgsMap.entrySet()) { if (biggest == null || biggest.getValue() < entry.getValue()) biggest = entry; } // More than a half is of this package. if (biggest != null && biggest.getValue() > pkgsMap.size() / 2) return biggest.getKey().toString(); return null; }
java
String deriveGroupIdFromPackages(ProjectModel projectModel) { Map<Object, Long> pkgsMap = new HashMap<>(); Set<String> pkgs = new HashSet<>(1000); GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(graphContext.getGraph()).V(projectModel); pkgsMap = pipeline.out(ProjectModel.PROJECT_MODEL_TO_FILE) .has(WindupVertexFrame.TYPE_PROP, new P(new BiPredicate<String, String>() { @Override public boolean test(String o, String o2) { return o.contains(o2); } }, GraphTypeManager.getTypeValue(JavaClassFileModel.class))) .hasKey(JavaClassFileModel.PROPERTY_PACKAGE_NAME) .groupCount() .by(v -> upToThirdDot(graphContext, (Vertex)v)).toList().get(0); Map.Entry<Object, Long> biggest = null; for (Map.Entry<Object, Long> entry : pkgsMap.entrySet()) { if (biggest == null || biggest.getValue() < entry.getValue()) biggest = entry; } // More than a half is of this package. if (biggest != null && biggest.getValue() > pkgsMap.size() / 2) return biggest.getKey().toString(); return null; }
[ "String", "deriveGroupIdFromPackages", "(", "ProjectModel", "projectModel", ")", "{", "Map", "<", "Object", ",", "Long", ">", "pkgsMap", "=", "new", "HashMap", "<>", "(", ")", ";", "Set", "<", "String", ">", "pkgs", "=", "new", "HashSet", "<>", "(", "1000", ")", ";", "GraphTraversal", "<", "Vertex", ",", "Vertex", ">", "pipeline", "=", "new", "GraphTraversalSource", "(", "graphContext", ".", "getGraph", "(", ")", ")", ".", "V", "(", "projectModel", ")", ";", "pkgsMap", "=", "pipeline", ".", "out", "(", "ProjectModel", ".", "PROJECT_MODEL_TO_FILE", ")", ".", "has", "(", "WindupVertexFrame", ".", "TYPE_PROP", ",", "new", "P", "(", "new", "BiPredicate", "<", "String", ",", "String", ">", "(", ")", "{", "@", "Override", "public", "boolean", "test", "(", "String", "o", ",", "String", "o2", ")", "{", "return", "o", ".", "contains", "(", "o2", ")", ";", "}", "}", ",", "GraphTypeManager", ".", "getTypeValue", "(", "JavaClassFileModel", ".", "class", ")", ")", ")", ".", "hasKey", "(", "JavaClassFileModel", ".", "PROPERTY_PACKAGE_NAME", ")", ".", "groupCount", "(", ")", ".", "by", "(", "v", "->", "upToThirdDot", "(", "graphContext", ",", "(", "Vertex", ")", "v", ")", ")", ".", "toList", "(", ")", ".", "get", "(", "0", ")", ";", "Map", ".", "Entry", "<", "Object", ",", "Long", ">", "biggest", "=", "null", ";", "for", "(", "Map", ".", "Entry", "<", "Object", ",", "Long", ">", "entry", ":", "pkgsMap", ".", "entrySet", "(", ")", ")", "{", "if", "(", "biggest", "==", "null", "||", "biggest", ".", "getValue", "(", ")", "<", "entry", ".", "getValue", "(", ")", ")", "biggest", "=", "entry", ";", "}", "// More than a half is of this package.", "if", "(", "biggest", "!=", "null", "&&", "biggest", ".", "getValue", "(", ")", ">", "pkgsMap", ".", "size", "(", ")", "/", "2", ")", "return", "biggest", ".", "getKey", "(", ")", ".", "toString", "(", ")", ";", "return", "null", ";", "}" ]
Counts the packages prefixes appearing in this project and if some of them make more than half of the total of existing packages, this prefix is returned. Otherwise, returns null. This is just a helper, it isn't something really hard-setting the package. It's something to use if the user didn't specify using --mavenize.groupId, and the archive or project name is something insane, like few sencences paragraph (a description) or a number or such.
[ "Counts", "the", "packages", "prefixes", "appearing", "in", "this", "project", "and", "if", "some", "of", "them", "make", "more", "than", "half", "of", "the", "total", "of", "existing", "packages", "this", "prefix", "is", "returned", ".", "Otherwise", "returns", "null", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ModuleAnalysisHelper.java#L87-L117
159,735
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/condition/JavaClass.java
JavaClass.at
@Override public JavaClassBuilderAt at(TypeReferenceLocation... locations) { if (locations != null) this.locations = Arrays.asList(locations); return this; }
java
@Override public JavaClassBuilderAt at(TypeReferenceLocation... locations) { if (locations != null) this.locations = Arrays.asList(locations); return this; }
[ "@", "Override", "public", "JavaClassBuilderAt", "at", "(", "TypeReferenceLocation", "...", "locations", ")", "{", "if", "(", "locations", "!=", "null", ")", "this", ".", "locations", "=", "Arrays", ".", "asList", "(", "locations", ")", ";", "return", "this", ";", "}" ]
Only match if the TypeReference is at the specified location within the file.
[ "Only", "match", "if", "the", "TypeReference", "is", "at", "the", "specified", "location", "within", "the", "file", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/condition/JavaClass.java#L135-L141
159,736
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/condition/JavaClass.java
JavaClass.as
@Override public ConditionBuilder as(String variable) { Assert.notNull(variable, "Variable name must not be null."); this.setOutputVariablesName(variable); return this; }
java
@Override public ConditionBuilder as(String variable) { Assert.notNull(variable, "Variable name must not be null."); this.setOutputVariablesName(variable); return this; }
[ "@", "Override", "public", "ConditionBuilder", "as", "(", "String", "variable", ")", "{", "Assert", ".", "notNull", "(", "variable", ",", "\"Variable name must not be null.\"", ")", ";", "this", ".", "setOutputVariablesName", "(", "variable", ")", ";", "return", "this", ";", "}" ]
Optionally specify the variable name to use for the output of this condition
[ "Optionally", "specify", "the", "variable", "name", "to", "use", "for", "the", "output", "of", "this", "condition" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/condition/JavaClass.java#L146-L152
159,737
windup/windup
config/api/src/main/java/org/jboss/windup/config/condition/GraphCondition.java
GraphCondition.setResults
protected void setResults(GraphRewrite event, String variable, Iterable<? extends WindupVertexFrame> results) { Variables variables = Variables.instance(event); Iterable<? extends WindupVertexFrame> existingVariables = variables.findVariable(variable, 1); if (existingVariables != null) { variables.setVariable(variable, Iterables.concat(existingVariables, results)); } else { variables.setVariable(variable, results); } }
java
protected void setResults(GraphRewrite event, String variable, Iterable<? extends WindupVertexFrame> results) { Variables variables = Variables.instance(event); Iterable<? extends WindupVertexFrame> existingVariables = variables.findVariable(variable, 1); if (existingVariables != null) { variables.setVariable(variable, Iterables.concat(existingVariables, results)); } else { variables.setVariable(variable, results); } }
[ "protected", "void", "setResults", "(", "GraphRewrite", "event", ",", "String", "variable", ",", "Iterable", "<", "?", "extends", "WindupVertexFrame", ">", "results", ")", "{", "Variables", "variables", "=", "Variables", ".", "instance", "(", "event", ")", ";", "Iterable", "<", "?", "extends", "WindupVertexFrame", ">", "existingVariables", "=", "variables", ".", "findVariable", "(", "variable", ",", "1", ")", ";", "if", "(", "existingVariables", "!=", "null", ")", "{", "variables", ".", "setVariable", "(", "variable", ",", "Iterables", ".", "concat", "(", "existingVariables", ",", "results", ")", ")", ";", "}", "else", "{", "variables", ".", "setVariable", "(", "variable", ",", "results", ")", ";", "}", "}" ]
This sets the variable with the given name to the given value. If there is already a variable with the same name in the top-most stack frame, we will combine them here. This helps in the case of multiple conditions tied together with "or" or "and".
[ "This", "sets", "the", "variable", "with", "the", "given", "name", "to", "the", "given", "value", ".", "If", "there", "is", "already", "a", "variable", "with", "the", "same", "name", "in", "the", "top", "-", "most", "stack", "frame", "we", "will", "combine", "them", "here", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/condition/GraphCondition.java#L76-L88
159,738
windup/windup
config/api/src/main/java/org/jboss/windup/config/phase/RulePhaseFinder.java
RulePhaseFinder.loadPhases
private Map<String, Class<? extends RulePhase>> loadPhases() { Map<String, Class<? extends RulePhase>> phases; phases = new HashMap<>(); Furnace furnace = FurnaceHolder.getFurnace(); for (RulePhase phase : furnace.getAddonRegistry().getServices(RulePhase.class)) { @SuppressWarnings("unchecked") Class<? extends RulePhase> unwrappedClass = (Class<? extends RulePhase>) Proxies.unwrap(phase).getClass(); String simpleName = unwrappedClass.getSimpleName(); phases.put(classNameToMapKey(simpleName), unwrappedClass); } return Collections.unmodifiableMap(phases); }
java
private Map<String, Class<? extends RulePhase>> loadPhases() { Map<String, Class<? extends RulePhase>> phases; phases = new HashMap<>(); Furnace furnace = FurnaceHolder.getFurnace(); for (RulePhase phase : furnace.getAddonRegistry().getServices(RulePhase.class)) { @SuppressWarnings("unchecked") Class<? extends RulePhase> unwrappedClass = (Class<? extends RulePhase>) Proxies.unwrap(phase).getClass(); String simpleName = unwrappedClass.getSimpleName(); phases.put(classNameToMapKey(simpleName), unwrappedClass); } return Collections.unmodifiableMap(phases); }
[ "private", "Map", "<", "String", ",", "Class", "<", "?", "extends", "RulePhase", ">", ">", "loadPhases", "(", ")", "{", "Map", "<", "String", ",", "Class", "<", "?", "extends", "RulePhase", ">", ">", "phases", ";", "phases", "=", "new", "HashMap", "<>", "(", ")", ";", "Furnace", "furnace", "=", "FurnaceHolder", ".", "getFurnace", "(", ")", ";", "for", "(", "RulePhase", "phase", ":", "furnace", ".", "getAddonRegistry", "(", ")", ".", "getServices", "(", "RulePhase", ".", "class", ")", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Class", "<", "?", "extends", "RulePhase", ">", "unwrappedClass", "=", "(", "Class", "<", "?", "extends", "RulePhase", ">", ")", "Proxies", ".", "unwrap", "(", "phase", ")", ".", "getClass", "(", ")", ";", "String", "simpleName", "=", "unwrappedClass", ".", "getSimpleName", "(", ")", ";", "phases", ".", "put", "(", "classNameToMapKey", "(", "simpleName", ")", ",", "unwrappedClass", ")", ";", "}", "return", "Collections", ".", "unmodifiableMap", "(", "phases", ")", ";", "}" ]
Loads the currently known phases from Furnace to the map.
[ "Loads", "the", "currently", "known", "phases", "from", "Furnace", "to", "the", "map", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/phase/RulePhaseFinder.java#L42-L55
159,739
windup/windup
rules-base/api/src/main/java/org/jboss/windup/rules/files/condition/FileContent.java
FileContent.allInput
private void allInput(List<FileModel> vertices, GraphRewrite event, ParameterStore store) { if (StringUtils.isBlank(getInputVariablesName()) && this.filenamePattern == null) { FileService fileModelService = new FileService(event.getGraphContext()); for (FileModel fileModel : fileModelService.findAll()) { vertices.add(fileModel); } } }
java
private void allInput(List<FileModel> vertices, GraphRewrite event, ParameterStore store) { if (StringUtils.isBlank(getInputVariablesName()) && this.filenamePattern == null) { FileService fileModelService = new FileService(event.getGraphContext()); for (FileModel fileModel : fileModelService.findAll()) { vertices.add(fileModel); } } }
[ "private", "void", "allInput", "(", "List", "<", "FileModel", ">", "vertices", ",", "GraphRewrite", "event", ",", "ParameterStore", "store", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "getInputVariablesName", "(", ")", ")", "&&", "this", ".", "filenamePattern", "==", "null", ")", "{", "FileService", "fileModelService", "=", "new", "FileService", "(", "event", ".", "getGraphContext", "(", ")", ")", ";", "for", "(", "FileModel", "fileModel", ":", "fileModelService", ".", "findAll", "(", ")", ")", "{", "vertices", ".", "add", "(", "fileModel", ")", ";", "}", "}", "}" ]
Generating the input vertices is quite complex. Therefore there are multiple methods that handles the input vertices based on the attribute specified in specific order. This method generates all the vertices if there is no other way how to handle the input.
[ "Generating", "the", "input", "vertices", "is", "quite", "complex", ".", "Therefore", "there", "are", "multiple", "methods", "that", "handles", "the", "input", "vertices", "based", "on", "the", "attribute", "specified", "in", "specific", "order", ".", "This", "method", "generates", "all", "the", "vertices", "if", "there", "is", "no", "other", "way", "how", "to", "handle", "the", "input", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-base/api/src/main/java/org/jboss/windup/rules/files/condition/FileContent.java#L330-L340
159,740
windup/windup
graph/api/src/main/java/org/jboss/windup/graph/service/GraphService.java
GraphService.getById
@Override public T getById(Object id) { return context.getFramed().getFramedVertex(this.type, id); }
java
@Override public T getById(Object id) { return context.getFramed().getFramedVertex(this.type, id); }
[ "@", "Override", "public", "T", "getById", "(", "Object", "id", ")", "{", "return", "context", ".", "getFramed", "(", ")", ".", "getFramedVertex", "(", "this", ".", "type", ",", "id", ")", ";", "}" ]
Returns the vertex with given ID framed into given interface.
[ "Returns", "the", "vertex", "with", "given", "ID", "framed", "into", "given", "interface", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/graph/api/src/main/java/org/jboss/windup/graph/service/GraphService.java#L187-L191
159,741
windup/windup
graph/api/src/main/java/org/jboss/windup/graph/service/GraphService.java
GraphService.addTypeToModel
public static <T extends WindupVertexFrame> T addTypeToModel(GraphContext graphContext, WindupVertexFrame frame, Class<T> type) { Vertex vertex = frame.getElement(); graphContext.getGraphTypeManager().addTypeToElement(type, vertex); return graphContext.getFramed().frameElement(vertex, type); }
java
public static <T extends WindupVertexFrame> T addTypeToModel(GraphContext graphContext, WindupVertexFrame frame, Class<T> type) { Vertex vertex = frame.getElement(); graphContext.getGraphTypeManager().addTypeToElement(type, vertex); return graphContext.getFramed().frameElement(vertex, type); }
[ "public", "static", "<", "T", "extends", "WindupVertexFrame", ">", "T", "addTypeToModel", "(", "GraphContext", "graphContext", ",", "WindupVertexFrame", "frame", ",", "Class", "<", "T", ">", "type", ")", "{", "Vertex", "vertex", "=", "frame", ".", "getElement", "(", ")", ";", "graphContext", ".", "getGraphTypeManager", "(", ")", ".", "addTypeToElement", "(", "type", ",", "vertex", ")", ";", "return", "graphContext", ".", "getFramed", "(", ")", ".", "frameElement", "(", "vertex", ",", "type", ")", ";", "}" ]
Adds the specified type to this frame, and returns a new object that implements this type.
[ "Adds", "the", "specified", "type", "to", "this", "frame", "and", "returns", "a", "new", "object", "that", "implements", "this", "type", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/graph/api/src/main/java/org/jboss/windup/graph/service/GraphService.java#L297-L302
159,742
windup/windup
graph/api/src/main/java/org/jboss/windup/graph/service/GraphService.java
GraphService.removeTypeFromModel
public static <T extends WindupVertexFrame> WindupVertexFrame removeTypeFromModel(GraphContext graphContext, WindupVertexFrame frame, Class<T> type) { Vertex vertex = frame.getElement(); graphContext.getGraphTypeManager().removeTypeFromElement(type, vertex); return graphContext.getFramed().frameElement(vertex, WindupVertexFrame.class); }
java
public static <T extends WindupVertexFrame> WindupVertexFrame removeTypeFromModel(GraphContext graphContext, WindupVertexFrame frame, Class<T> type) { Vertex vertex = frame.getElement(); graphContext.getGraphTypeManager().removeTypeFromElement(type, vertex); return graphContext.getFramed().frameElement(vertex, WindupVertexFrame.class); }
[ "public", "static", "<", "T", "extends", "WindupVertexFrame", ">", "WindupVertexFrame", "removeTypeFromModel", "(", "GraphContext", "graphContext", ",", "WindupVertexFrame", "frame", ",", "Class", "<", "T", ">", "type", ")", "{", "Vertex", "vertex", "=", "frame", ".", "getElement", "(", ")", ";", "graphContext", ".", "getGraphTypeManager", "(", ")", ".", "removeTypeFromElement", "(", "type", ",", "vertex", ")", ";", "return", "graphContext", ".", "getFramed", "(", ")", ".", "frameElement", "(", "vertex", ",", "WindupVertexFrame", ".", "class", ")", ";", "}" ]
Removes the specified type from the frame.
[ "Removes", "the", "specified", "type", "from", "the", "frame", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/graph/api/src/main/java/org/jboss/windup/graph/service/GraphService.java#L307-L312
159,743
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/service/ClassificationServiceCache.java
ClassificationServiceCache.getCache
@SuppressWarnings("unchecked") private static synchronized Map<String, Boolean> getCache(GraphRewrite event) { Map<String, Boolean> result = (Map<String, Boolean>)event.getRewriteContext().get(ClassificationServiceCache.class); if (result == null) { result = Collections.synchronizedMap(new LRUMap(30000)); event.getRewriteContext().put(ClassificationServiceCache.class, result); } return result; }
java
@SuppressWarnings("unchecked") private static synchronized Map<String, Boolean> getCache(GraphRewrite event) { Map<String, Boolean> result = (Map<String, Boolean>)event.getRewriteContext().get(ClassificationServiceCache.class); if (result == null) { result = Collections.synchronizedMap(new LRUMap(30000)); event.getRewriteContext().put(ClassificationServiceCache.class, result); } return result; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "synchronized", "Map", "<", "String", ",", "Boolean", ">", "getCache", "(", "GraphRewrite", "event", ")", "{", "Map", "<", "String", ",", "Boolean", ">", "result", "=", "(", "Map", "<", "String", ",", "Boolean", ">", ")", "event", ".", "getRewriteContext", "(", ")", ".", "get", "(", "ClassificationServiceCache", ".", "class", ")", ";", "if", "(", "result", "==", "null", ")", "{", "result", "=", "Collections", ".", "synchronizedMap", "(", "new", "LRUMap", "(", "30000", ")", ")", ";", "event", ".", "getRewriteContext", "(", ")", ".", "put", "(", "ClassificationServiceCache", ".", "class", ",", "result", ")", ";", "}", "return", "result", ";", "}" ]
Keep a cache of items files associated with classification in order to improve performance.
[ "Keep", "a", "cache", "of", "items", "files", "associated", "with", "classification", "in", "order", "to", "improve", "performance", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/ClassificationServiceCache.java#L25-L35
159,744
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/service/EffortReportService.java
EffortReportService.getEffortLevelDescription
public static String getEffortLevelDescription(Verbosity verbosity, int points) { EffortLevel level = EffortLevel.forPoints(points); switch (verbosity) { case ID: return level.name(); case VERBOSE: return level.getVerboseDescription(); case SHORT: default: return level.getShortDescription(); } }
java
public static String getEffortLevelDescription(Verbosity verbosity, int points) { EffortLevel level = EffortLevel.forPoints(points); switch (verbosity) { case ID: return level.name(); case VERBOSE: return level.getVerboseDescription(); case SHORT: default: return level.getShortDescription(); } }
[ "public", "static", "String", "getEffortLevelDescription", "(", "Verbosity", "verbosity", ",", "int", "points", ")", "{", "EffortLevel", "level", "=", "EffortLevel", ".", "forPoints", "(", "points", ")", ";", "switch", "(", "verbosity", ")", "{", "case", "ID", ":", "return", "level", ".", "name", "(", ")", ";", "case", "VERBOSE", ":", "return", "level", ".", "getVerboseDescription", "(", ")", ";", "case", "SHORT", ":", "default", ":", "return", "level", ".", "getShortDescription", "(", ")", ";", "}", "}" ]
Returns the right string representation of the effort level based on given number of points.
[ "Returns", "the", "right", "string", "representation", "of", "the", "effort", "level", "based", "on", "given", "number", "of", "points", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/EffortReportService.java#L75-L89
159,745
windup/windup
exec/api/src/main/java/org/jboss/windup/exec/configuration/WindupConfiguration.java
WindupConfiguration.setOptionValue
public WindupConfiguration setOptionValue(String name, Object value) { configurationOptions.put(name, value); return this; }
java
public WindupConfiguration setOptionValue(String name, Object value) { configurationOptions.put(name, value); return this; }
[ "public", "WindupConfiguration", "setOptionValue", "(", "String", "name", ",", "Object", "value", ")", "{", "configurationOptions", ".", "put", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Sets a configuration option to the specified value.
[ "Sets", "a", "configuration", "option", "to", "the", "specified", "value", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/exec/api/src/main/java/org/jboss/windup/exec/configuration/WindupConfiguration.java#L108-L112
159,746
windup/windup
exec/api/src/main/java/org/jboss/windup/exec/configuration/WindupConfiguration.java
WindupConfiguration.getOptionValue
@SuppressWarnings("unchecked") public <T> T getOptionValue(String name) { return (T) configurationOptions.get(name); }
java
@SuppressWarnings("unchecked") public <T> T getOptionValue(String name) { return (T) configurationOptions.get(name); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "getOptionValue", "(", "String", "name", ")", "{", "return", "(", "T", ")", "configurationOptions", ".", "get", "(", "name", ")", ";", "}" ]
Returns the configuration value with the specified name.
[ "Returns", "the", "configuration", "value", "with", "the", "specified", "name", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/exec/api/src/main/java/org/jboss/windup/exec/configuration/WindupConfiguration.java#L137-L141
159,747
windup/windup
config/api/src/main/java/org/jboss/windup/config/RuleSubset.java
RuleSubset.logTimeTakenByRuleProvider
private void logTimeTakenByRuleProvider(GraphContext graphContext, Context context, int ruleIndex, int timeTaken) { AbstractRuleProvider ruleProvider = (AbstractRuleProvider) context.get(RuleMetadataType.RULE_PROVIDER); if (ruleProvider == null) return; if (!timeTakenByProvider.containsKey(ruleProvider)) { RuleProviderExecutionStatisticsModel model = new RuleProviderExecutionStatisticsService(graphContext) .create(); model.setRuleIndex(ruleIndex); model.setRuleProviderID(ruleProvider.getMetadata().getID()); model.setTimeTaken(timeTaken); timeTakenByProvider.put(ruleProvider, model.getElement().id()); } else { RuleProviderExecutionStatisticsService service = new RuleProviderExecutionStatisticsService(graphContext); RuleProviderExecutionStatisticsModel model = service.getById(timeTakenByProvider.get(ruleProvider)); int prevTimeTaken = model.getTimeTaken(); model.setTimeTaken(prevTimeTaken + timeTaken); } logTimeTakenByPhase(graphContext, ruleProvider.getMetadata().getPhase(), timeTaken); }
java
private void logTimeTakenByRuleProvider(GraphContext graphContext, Context context, int ruleIndex, int timeTaken) { AbstractRuleProvider ruleProvider = (AbstractRuleProvider) context.get(RuleMetadataType.RULE_PROVIDER); if (ruleProvider == null) return; if (!timeTakenByProvider.containsKey(ruleProvider)) { RuleProviderExecutionStatisticsModel model = new RuleProviderExecutionStatisticsService(graphContext) .create(); model.setRuleIndex(ruleIndex); model.setRuleProviderID(ruleProvider.getMetadata().getID()); model.setTimeTaken(timeTaken); timeTakenByProvider.put(ruleProvider, model.getElement().id()); } else { RuleProviderExecutionStatisticsService service = new RuleProviderExecutionStatisticsService(graphContext); RuleProviderExecutionStatisticsModel model = service.getById(timeTakenByProvider.get(ruleProvider)); int prevTimeTaken = model.getTimeTaken(); model.setTimeTaken(prevTimeTaken + timeTaken); } logTimeTakenByPhase(graphContext, ruleProvider.getMetadata().getPhase(), timeTaken); }
[ "private", "void", "logTimeTakenByRuleProvider", "(", "GraphContext", "graphContext", ",", "Context", "context", ",", "int", "ruleIndex", ",", "int", "timeTaken", ")", "{", "AbstractRuleProvider", "ruleProvider", "=", "(", "AbstractRuleProvider", ")", "context", ".", "get", "(", "RuleMetadataType", ".", "RULE_PROVIDER", ")", ";", "if", "(", "ruleProvider", "==", "null", ")", "return", ";", "if", "(", "!", "timeTakenByProvider", ".", "containsKey", "(", "ruleProvider", ")", ")", "{", "RuleProviderExecutionStatisticsModel", "model", "=", "new", "RuleProviderExecutionStatisticsService", "(", "graphContext", ")", ".", "create", "(", ")", ";", "model", ".", "setRuleIndex", "(", "ruleIndex", ")", ";", "model", ".", "setRuleProviderID", "(", "ruleProvider", ".", "getMetadata", "(", ")", ".", "getID", "(", ")", ")", ";", "model", ".", "setTimeTaken", "(", "timeTaken", ")", ";", "timeTakenByProvider", ".", "put", "(", "ruleProvider", ",", "model", ".", "getElement", "(", ")", ".", "id", "(", ")", ")", ";", "}", "else", "{", "RuleProviderExecutionStatisticsService", "service", "=", "new", "RuleProviderExecutionStatisticsService", "(", "graphContext", ")", ";", "RuleProviderExecutionStatisticsModel", "model", "=", "service", ".", "getById", "(", "timeTakenByProvider", ".", "get", "(", "ruleProvider", ")", ")", ";", "int", "prevTimeTaken", "=", "model", ".", "getTimeTaken", "(", ")", ";", "model", ".", "setTimeTaken", "(", "prevTimeTaken", "+", "timeTaken", ")", ";", "}", "logTimeTakenByPhase", "(", "graphContext", ",", "ruleProvider", ".", "getMetadata", "(", ")", ".", "getPhase", "(", ")", ",", "timeTaken", ")", ";", "}" ]
Logs the time taken by this rule, and attaches this to the total for the RuleProvider
[ "Logs", "the", "time", "taken", "by", "this", "rule", "and", "attaches", "this", "to", "the", "total", "for", "the", "RuleProvider" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/RuleSubset.java#L138-L162
159,748
windup/windup
config/api/src/main/java/org/jboss/windup/config/RuleSubset.java
RuleSubset.logTimeTakenByPhase
private void logTimeTakenByPhase(GraphContext graphContext, Class<? extends RulePhase> phase, int timeTaken) { if (!timeTakenByPhase.containsKey(phase)) { RulePhaseExecutionStatisticsModel model = new GraphService<>(graphContext, RulePhaseExecutionStatisticsModel.class).create(); model.setRulePhase(phase.toString()); model.setTimeTaken(timeTaken); model.setOrderExecuted(timeTakenByPhase.size()); timeTakenByPhase.put(phase, model.getElement().id()); } else { GraphService<RulePhaseExecutionStatisticsModel> service = new GraphService<>(graphContext, RulePhaseExecutionStatisticsModel.class); RulePhaseExecutionStatisticsModel model = service.getById(timeTakenByPhase.get(phase)); int prevTimeTaken = model.getTimeTaken(); model.setTimeTaken(prevTimeTaken + timeTaken); } }
java
private void logTimeTakenByPhase(GraphContext graphContext, Class<? extends RulePhase> phase, int timeTaken) { if (!timeTakenByPhase.containsKey(phase)) { RulePhaseExecutionStatisticsModel model = new GraphService<>(graphContext, RulePhaseExecutionStatisticsModel.class).create(); model.setRulePhase(phase.toString()); model.setTimeTaken(timeTaken); model.setOrderExecuted(timeTakenByPhase.size()); timeTakenByPhase.put(phase, model.getElement().id()); } else { GraphService<RulePhaseExecutionStatisticsModel> service = new GraphService<>(graphContext, RulePhaseExecutionStatisticsModel.class); RulePhaseExecutionStatisticsModel model = service.getById(timeTakenByPhase.get(phase)); int prevTimeTaken = model.getTimeTaken(); model.setTimeTaken(prevTimeTaken + timeTaken); } }
[ "private", "void", "logTimeTakenByPhase", "(", "GraphContext", "graphContext", ",", "Class", "<", "?", "extends", "RulePhase", ">", "phase", ",", "int", "timeTaken", ")", "{", "if", "(", "!", "timeTakenByPhase", ".", "containsKey", "(", "phase", ")", ")", "{", "RulePhaseExecutionStatisticsModel", "model", "=", "new", "GraphService", "<>", "(", "graphContext", ",", "RulePhaseExecutionStatisticsModel", ".", "class", ")", ".", "create", "(", ")", ";", "model", ".", "setRulePhase", "(", "phase", ".", "toString", "(", ")", ")", ";", "model", ".", "setTimeTaken", "(", "timeTaken", ")", ";", "model", ".", "setOrderExecuted", "(", "timeTakenByPhase", ".", "size", "(", ")", ")", ";", "timeTakenByPhase", ".", "put", "(", "phase", ",", "model", ".", "getElement", "(", ")", ".", "id", "(", ")", ")", ";", "}", "else", "{", "GraphService", "<", "RulePhaseExecutionStatisticsModel", ">", "service", "=", "new", "GraphService", "<>", "(", "graphContext", ",", "RulePhaseExecutionStatisticsModel", ".", "class", ")", ";", "RulePhaseExecutionStatisticsModel", "model", "=", "service", ".", "getById", "(", "timeTakenByPhase", ".", "get", "(", "phase", ")", ")", ";", "int", "prevTimeTaken", "=", "model", ".", "getTimeTaken", "(", ")", ";", "model", ".", "setTimeTaken", "(", "prevTimeTaken", "+", "timeTaken", ")", ";", "}", "}" ]
Logs the time taken by this rule and adds this to the total time taken for this phase
[ "Logs", "the", "time", "taken", "by", "this", "rule", "and", "adds", "this", "to", "the", "total", "time", "taken", "for", "this", "phase" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/RuleSubset.java#L167-L186
159,749
windup/windup
rules-xml/api/src/main/java/org/jboss/windup/rules/apps/xml/condition/XmlFileXPathTransformer.java
XmlFileXPathTransformer.transformXPath
public static String transformXPath(String originalXPath) { // use a list to maintain the multiple joined xqueries (if there are multiple queries joined with the "|" operator) List<StringBuilder> compiledXPaths = new ArrayList<>(1); int frameIdx = -1; boolean inQuote = false; int conditionLevel = 0; char startQuoteChar = 0; StringBuilder currentXPath = new StringBuilder(); compiledXPaths.add(currentXPath); for (int i = 0; i < originalXPath.length(); i++) { char curChar = originalXPath.charAt(i); if (!inQuote && curChar == '[') { frameIdx++; conditionLevel++; currentXPath.append("[windup:startFrame(").append(frameIdx).append(") and windup:evaluate(").append(frameIdx).append(", "); } else if (!inQuote && curChar == ']') { conditionLevel--; currentXPath.append(")]"); } else if (!inQuote && conditionLevel == 0 && curChar == '|') { // joining multiple xqueries currentXPath = new StringBuilder(); compiledXPaths.add(currentXPath); } else { if (inQuote && curChar == startQuoteChar) { inQuote = false; startQuoteChar = 0; } else if (curChar == '"' || curChar == '\'') { inQuote = true; startQuoteChar = curChar; } if (!inQuote && originalXPath.startsWith(WINDUP_MATCHES_FUNCTION_PREFIX, i)) { i += (WINDUP_MATCHES_FUNCTION_PREFIX.length() - 1); currentXPath.append("windup:matches(").append(frameIdx).append(", "); } else { currentXPath.append(curChar); } } } Pattern leadingAndTrailingWhitespace = Pattern.compile("(\\s*)(.*?)(\\s*)"); StringBuilder finalResult = new StringBuilder(); for (StringBuilder compiledXPath : compiledXPaths) { if (StringUtils.isNotBlank(compiledXPath)) { Matcher whitespaceMatcher = leadingAndTrailingWhitespace.matcher(compiledXPath); if (!whitespaceMatcher.matches()) continue; compiledXPath = new StringBuilder(); compiledXPath.append(whitespaceMatcher.group(1)); compiledXPath.append(whitespaceMatcher.group(2)); compiledXPath.append("/self::node()[windup:persist(").append(frameIdx).append(", ").append(".)]"); compiledXPath.append(whitespaceMatcher.group(3)); if (StringUtils.isNotBlank(finalResult)) finalResult.append("|"); finalResult.append(compiledXPath); } } return finalResult.toString(); }
java
public static String transformXPath(String originalXPath) { // use a list to maintain the multiple joined xqueries (if there are multiple queries joined with the "|" operator) List<StringBuilder> compiledXPaths = new ArrayList<>(1); int frameIdx = -1; boolean inQuote = false; int conditionLevel = 0; char startQuoteChar = 0; StringBuilder currentXPath = new StringBuilder(); compiledXPaths.add(currentXPath); for (int i = 0; i < originalXPath.length(); i++) { char curChar = originalXPath.charAt(i); if (!inQuote && curChar == '[') { frameIdx++; conditionLevel++; currentXPath.append("[windup:startFrame(").append(frameIdx).append(") and windup:evaluate(").append(frameIdx).append(", "); } else if (!inQuote && curChar == ']') { conditionLevel--; currentXPath.append(")]"); } else if (!inQuote && conditionLevel == 0 && curChar == '|') { // joining multiple xqueries currentXPath = new StringBuilder(); compiledXPaths.add(currentXPath); } else { if (inQuote && curChar == startQuoteChar) { inQuote = false; startQuoteChar = 0; } else if (curChar == '"' || curChar == '\'') { inQuote = true; startQuoteChar = curChar; } if (!inQuote && originalXPath.startsWith(WINDUP_MATCHES_FUNCTION_PREFIX, i)) { i += (WINDUP_MATCHES_FUNCTION_PREFIX.length() - 1); currentXPath.append("windup:matches(").append(frameIdx).append(", "); } else { currentXPath.append(curChar); } } } Pattern leadingAndTrailingWhitespace = Pattern.compile("(\\s*)(.*?)(\\s*)"); StringBuilder finalResult = new StringBuilder(); for (StringBuilder compiledXPath : compiledXPaths) { if (StringUtils.isNotBlank(compiledXPath)) { Matcher whitespaceMatcher = leadingAndTrailingWhitespace.matcher(compiledXPath); if (!whitespaceMatcher.matches()) continue; compiledXPath = new StringBuilder(); compiledXPath.append(whitespaceMatcher.group(1)); compiledXPath.append(whitespaceMatcher.group(2)); compiledXPath.append("/self::node()[windup:persist(").append(frameIdx).append(", ").append(".)]"); compiledXPath.append(whitespaceMatcher.group(3)); if (StringUtils.isNotBlank(finalResult)) finalResult.append("|"); finalResult.append(compiledXPath); } } return finalResult.toString(); }
[ "public", "static", "String", "transformXPath", "(", "String", "originalXPath", ")", "{", "// use a list to maintain the multiple joined xqueries (if there are multiple queries joined with the \"|\" operator)", "List", "<", "StringBuilder", ">", "compiledXPaths", "=", "new", "ArrayList", "<>", "(", "1", ")", ";", "int", "frameIdx", "=", "-", "1", ";", "boolean", "inQuote", "=", "false", ";", "int", "conditionLevel", "=", "0", ";", "char", "startQuoteChar", "=", "0", ";", "StringBuilder", "currentXPath", "=", "new", "StringBuilder", "(", ")", ";", "compiledXPaths", ".", "add", "(", "currentXPath", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "originalXPath", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "curChar", "=", "originalXPath", ".", "charAt", "(", "i", ")", ";", "if", "(", "!", "inQuote", "&&", "curChar", "==", "'", "'", ")", "{", "frameIdx", "++", ";", "conditionLevel", "++", ";", "currentXPath", ".", "append", "(", "\"[windup:startFrame(\"", ")", ".", "append", "(", "frameIdx", ")", ".", "append", "(", "\") and windup:evaluate(\"", ")", ".", "append", "(", "frameIdx", ")", ".", "append", "(", "\", \"", ")", ";", "}", "else", "if", "(", "!", "inQuote", "&&", "curChar", "==", "'", "'", ")", "{", "conditionLevel", "--", ";", "currentXPath", ".", "append", "(", "\")]\"", ")", ";", "}", "else", "if", "(", "!", "inQuote", "&&", "conditionLevel", "==", "0", "&&", "curChar", "==", "'", "'", ")", "{", "// joining multiple xqueries", "currentXPath", "=", "new", "StringBuilder", "(", ")", ";", "compiledXPaths", ".", "add", "(", "currentXPath", ")", ";", "}", "else", "{", "if", "(", "inQuote", "&&", "curChar", "==", "startQuoteChar", ")", "{", "inQuote", "=", "false", ";", "startQuoteChar", "=", "0", ";", "}", "else", "if", "(", "curChar", "==", "'", "'", "||", "curChar", "==", "'", "'", ")", "{", "inQuote", "=", "true", ";", "startQuoteChar", "=", "curChar", ";", "}", "if", "(", "!", "inQuote", "&&", "originalXPath", ".", "startsWith", "(", "WINDUP_MATCHES_FUNCTION_PREFIX", ",", "i", ")", ")", "{", "i", "+=", "(", "WINDUP_MATCHES_FUNCTION_PREFIX", ".", "length", "(", ")", "-", "1", ")", ";", "currentXPath", ".", "append", "(", "\"windup:matches(\"", ")", ".", "append", "(", "frameIdx", ")", ".", "append", "(", "\", \"", ")", ";", "}", "else", "{", "currentXPath", ".", "append", "(", "curChar", ")", ";", "}", "}", "}", "Pattern", "leadingAndTrailingWhitespace", "=", "Pattern", ".", "compile", "(", "\"(\\\\s*)(.*?)(\\\\s*)\"", ")", ";", "StringBuilder", "finalResult", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "StringBuilder", "compiledXPath", ":", "compiledXPaths", ")", "{", "if", "(", "StringUtils", ".", "isNotBlank", "(", "compiledXPath", ")", ")", "{", "Matcher", "whitespaceMatcher", "=", "leadingAndTrailingWhitespace", ".", "matcher", "(", "compiledXPath", ")", ";", "if", "(", "!", "whitespaceMatcher", ".", "matches", "(", ")", ")", "continue", ";", "compiledXPath", "=", "new", "StringBuilder", "(", ")", ";", "compiledXPath", ".", "append", "(", "whitespaceMatcher", ".", "group", "(", "1", ")", ")", ";", "compiledXPath", ".", "append", "(", "whitespaceMatcher", ".", "group", "(", "2", ")", ")", ";", "compiledXPath", ".", "append", "(", "\"/self::node()[windup:persist(\"", ")", ".", "append", "(", "frameIdx", ")", ".", "append", "(", "\", \"", ")", ".", "append", "(", "\".)]\"", ")", ";", "compiledXPath", ".", "append", "(", "whitespaceMatcher", ".", "group", "(", "3", ")", ")", ";", "if", "(", "StringUtils", ".", "isNotBlank", "(", "finalResult", ")", ")", "finalResult", ".", "append", "(", "\"|\"", ")", ";", "finalResult", ".", "append", "(", "compiledXPath", ")", ";", "}", "}", "return", "finalResult", ".", "toString", "(", ")", ";", "}" ]
Performs the conversion from standard XPath to xpath with parameterization support.
[ "Performs", "the", "conversion", "from", "standard", "XPath", "to", "xpath", "with", "parameterization", "support", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-xml/api/src/main/java/org/jboss/windup/rules/apps/xml/condition/XmlFileXPathTransformer.java#L20-L98
159,750
windup/windup
forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java
Compiler.accept
@Override public void accept(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) { if (this.options.verbose) { this.out.println( Messages.bind(Messages.compilation_loadBinary, new String(binaryType.getName()))); // new Exception("TRACE BINARY").printStackTrace(System.out); // System.out.println(); } LookupEnvironment env = packageBinding.environment; env.createBinaryTypeFrom(binaryType, packageBinding, accessRestriction); }
java
@Override public void accept(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) { if (this.options.verbose) { this.out.println( Messages.bind(Messages.compilation_loadBinary, new String(binaryType.getName()))); // new Exception("TRACE BINARY").printStackTrace(System.out); // System.out.println(); } LookupEnvironment env = packageBinding.environment; env.createBinaryTypeFrom(binaryType, packageBinding, accessRestriction); }
[ "@", "Override", "public", "void", "accept", "(", "IBinaryType", "binaryType", ",", "PackageBinding", "packageBinding", ",", "AccessRestriction", "accessRestriction", ")", "{", "if", "(", "this", ".", "options", ".", "verbose", ")", "{", "this", ".", "out", ".", "println", "(", "Messages", ".", "bind", "(", "Messages", ".", "compilation_loadBinary", ",", "new", "String", "(", "binaryType", ".", "getName", "(", ")", ")", ")", ")", ";", "//\t\t\tnew Exception(\"TRACE BINARY\").printStackTrace(System.out);", "//\t\t System.out.println();", "}", "LookupEnvironment", "env", "=", "packageBinding", ".", "environment", ";", "env", ".", "createBinaryTypeFrom", "(", "binaryType", ",", "packageBinding", ",", "accessRestriction", ")", ";", "}" ]
Add an additional binary type
[ "Add", "an", "additional", "binary", "type" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java#L313-L323
159,751
windup/windup
forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java
Compiler.accept
@Override public void accept(ICompilationUnit sourceUnit, AccessRestriction accessRestriction) { // Switch the current policy and compilation result for this unit to the requested one. CompilationResult unitResult = new CompilationResult(sourceUnit, this.totalUnits, this.totalUnits, this.options.maxProblemsPerUnit); unitResult.checkSecondaryTypes = true; try { if (this.options.verbose) { String count = String.valueOf(this.totalUnits + 1); this.out.println( Messages.bind(Messages.compilation_request, new String[] { count, count, new String(sourceUnit.getFileName()) })); } // diet parsing for large collection of unit CompilationUnitDeclaration parsedUnit; if (this.totalUnits < this.parseThreshold) { parsedUnit = this.parser.parse(sourceUnit, unitResult); } else { parsedUnit = this.parser.dietParse(sourceUnit, unitResult); } // initial type binding creation this.lookupEnvironment.buildTypeBindings(parsedUnit, accessRestriction); addCompilationUnit(sourceUnit, parsedUnit); // binding resolution this.lookupEnvironment.completeTypeBindings(parsedUnit); } catch (AbortCompilationUnit e) { // at this point, currentCompilationUnitResult may not be sourceUnit, but some other // one requested further along to resolve sourceUnit. if (unitResult.compilationUnit == sourceUnit) { // only report once this.requestor.acceptResult(unitResult.tagAsAccepted()); } else { throw e; // want to abort enclosing request to compile } } }
java
@Override public void accept(ICompilationUnit sourceUnit, AccessRestriction accessRestriction) { // Switch the current policy and compilation result for this unit to the requested one. CompilationResult unitResult = new CompilationResult(sourceUnit, this.totalUnits, this.totalUnits, this.options.maxProblemsPerUnit); unitResult.checkSecondaryTypes = true; try { if (this.options.verbose) { String count = String.valueOf(this.totalUnits + 1); this.out.println( Messages.bind(Messages.compilation_request, new String[] { count, count, new String(sourceUnit.getFileName()) })); } // diet parsing for large collection of unit CompilationUnitDeclaration parsedUnit; if (this.totalUnits < this.parseThreshold) { parsedUnit = this.parser.parse(sourceUnit, unitResult); } else { parsedUnit = this.parser.dietParse(sourceUnit, unitResult); } // initial type binding creation this.lookupEnvironment.buildTypeBindings(parsedUnit, accessRestriction); addCompilationUnit(sourceUnit, parsedUnit); // binding resolution this.lookupEnvironment.completeTypeBindings(parsedUnit); } catch (AbortCompilationUnit e) { // at this point, currentCompilationUnitResult may not be sourceUnit, but some other // one requested further along to resolve sourceUnit. if (unitResult.compilationUnit == sourceUnit) { // only report once this.requestor.acceptResult(unitResult.tagAsAccepted()); } else { throw e; // want to abort enclosing request to compile } } }
[ "@", "Override", "public", "void", "accept", "(", "ICompilationUnit", "sourceUnit", ",", "AccessRestriction", "accessRestriction", ")", "{", "// Switch the current policy and compilation result for this unit to the requested one.", "CompilationResult", "unitResult", "=", "new", "CompilationResult", "(", "sourceUnit", ",", "this", ".", "totalUnits", ",", "this", ".", "totalUnits", ",", "this", ".", "options", ".", "maxProblemsPerUnit", ")", ";", "unitResult", ".", "checkSecondaryTypes", "=", "true", ";", "try", "{", "if", "(", "this", ".", "options", ".", "verbose", ")", "{", "String", "count", "=", "String", ".", "valueOf", "(", "this", ".", "totalUnits", "+", "1", ")", ";", "this", ".", "out", ".", "println", "(", "Messages", ".", "bind", "(", "Messages", ".", "compilation_request", ",", "new", "String", "[", "]", "{", "count", ",", "count", ",", "new", "String", "(", "sourceUnit", ".", "getFileName", "(", ")", ")", "}", ")", ")", ";", "}", "// diet parsing for large collection of unit", "CompilationUnitDeclaration", "parsedUnit", ";", "if", "(", "this", ".", "totalUnits", "<", "this", ".", "parseThreshold", ")", "{", "parsedUnit", "=", "this", ".", "parser", ".", "parse", "(", "sourceUnit", ",", "unitResult", ")", ";", "}", "else", "{", "parsedUnit", "=", "this", ".", "parser", ".", "dietParse", "(", "sourceUnit", ",", "unitResult", ")", ";", "}", "// initial type binding creation", "this", ".", "lookupEnvironment", ".", "buildTypeBindings", "(", "parsedUnit", ",", "accessRestriction", ")", ";", "addCompilationUnit", "(", "sourceUnit", ",", "parsedUnit", ")", ";", "// binding resolution", "this", ".", "lookupEnvironment", ".", "completeTypeBindings", "(", "parsedUnit", ")", ";", "}", "catch", "(", "AbortCompilationUnit", "e", ")", "{", "// at this point, currentCompilationUnitResult may not be sourceUnit, but some other", "// one requested further along to resolve sourceUnit.", "if", "(", "unitResult", ".", "compilationUnit", "==", "sourceUnit", ")", "{", "// only report once", "this", ".", "requestor", ".", "acceptResult", "(", "unitResult", ".", "tagAsAccepted", "(", ")", ")", ";", "}", "else", "{", "throw", "e", ";", "// want to abort enclosing request to compile", "}", "}", "}" ]
Add an additional compilation unit into the loop -> build compilation unit declarations, their bindings and record their results.
[ "Add", "an", "additional", "compilation", "unit", "into", "the", "loop", "-", ">", "build", "compilation", "unit", "declarations", "their", "bindings", "and", "record", "their", "results", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java#L329-L368
159,752
windup/windup
forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java
Compiler.accept
@Override public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding, AccessRestriction accessRestriction) { this.problemReporter.abortDueToInternalError( Messages.bind(Messages.abort_againstSourceModel, new String[] { String.valueOf(sourceTypes[0].getName()), String.valueOf(sourceTypes[0].getFileName()) })); }
java
@Override public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding, AccessRestriction accessRestriction) { this.problemReporter.abortDueToInternalError( Messages.bind(Messages.abort_againstSourceModel, new String[] { String.valueOf(sourceTypes[0].getName()), String.valueOf(sourceTypes[0].getFileName()) })); }
[ "@", "Override", "public", "void", "accept", "(", "ISourceType", "[", "]", "sourceTypes", ",", "PackageBinding", "packageBinding", ",", "AccessRestriction", "accessRestriction", ")", "{", "this", ".", "problemReporter", ".", "abortDueToInternalError", "(", "Messages", ".", "bind", "(", "Messages", ".", "abort_againstSourceModel", ",", "new", "String", "[", "]", "{", "String", ".", "valueOf", "(", "sourceTypes", "[", "0", "]", ".", "getName", "(", ")", ")", ",", "String", ".", "valueOf", "(", "sourceTypes", "[", "0", "]", ".", "getFileName", "(", ")", ")", "}", ")", ")", ";", "}" ]
Add additional source types
[ "Add", "additional", "source", "types" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java#L373-L377
159,753
windup/windup
forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java
Compiler.reportProgress
protected void reportProgress(String taskDecription) { if (this.progress != null) { if (this.progress.isCanceled()) { // Only AbortCompilation can stop the compiler cleanly. // We check cancellation again following the call to compile. throw new AbortCompilation(true, null); } this.progress.setTaskName(taskDecription); } }
java
protected void reportProgress(String taskDecription) { if (this.progress != null) { if (this.progress.isCanceled()) { // Only AbortCompilation can stop the compiler cleanly. // We check cancellation again following the call to compile. throw new AbortCompilation(true, null); } this.progress.setTaskName(taskDecription); } }
[ "protected", "void", "reportProgress", "(", "String", "taskDecription", ")", "{", "if", "(", "this", ".", "progress", "!=", "null", ")", "{", "if", "(", "this", ".", "progress", ".", "isCanceled", "(", ")", ")", "{", "// Only AbortCompilation can stop the compiler cleanly.", "// We check cancellation again following the call to compile.", "throw", "new", "AbortCompilation", "(", "true", ",", "null", ")", ";", "}", "this", ".", "progress", ".", "setTaskName", "(", "taskDecription", ")", ";", "}", "}" ]
Checks whether the compilation has been canceled and reports the given progress to the compiler progress.
[ "Checks", "whether", "the", "compilation", "has", "been", "canceled", "and", "reports", "the", "given", "progress", "to", "the", "compiler", "progress", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java#L414-L423
159,754
windup/windup
forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java
Compiler.reportWorked
protected void reportWorked(int workIncrement, int currentUnitIndex) { if (this.progress != null) { if (this.progress.isCanceled()) { // Only AbortCompilation can stop the compiler cleanly. // We check cancellation again following the call to compile. throw new AbortCompilation(true, null); } this.progress.worked(workIncrement, (this.totalUnits* this.remainingIterations) - currentUnitIndex - 1); } }
java
protected void reportWorked(int workIncrement, int currentUnitIndex) { if (this.progress != null) { if (this.progress.isCanceled()) { // Only AbortCompilation can stop the compiler cleanly. // We check cancellation again following the call to compile. throw new AbortCompilation(true, null); } this.progress.worked(workIncrement, (this.totalUnits* this.remainingIterations) - currentUnitIndex - 1); } }
[ "protected", "void", "reportWorked", "(", "int", "workIncrement", ",", "int", "currentUnitIndex", ")", "{", "if", "(", "this", ".", "progress", "!=", "null", ")", "{", "if", "(", "this", ".", "progress", ".", "isCanceled", "(", ")", ")", "{", "// Only AbortCompilation can stop the compiler cleanly.", "// We check cancellation again following the call to compile.", "throw", "new", "AbortCompilation", "(", "true", ",", "null", ")", ";", "}", "this", ".", "progress", ".", "worked", "(", "workIncrement", ",", "(", "this", ".", "totalUnits", "*", "this", ".", "remainingIterations", ")", "-", "currentUnitIndex", "-", "1", ")", ";", "}", "}" ]
Checks whether the compilation has been canceled and reports the given work increment to the compiler progress.
[ "Checks", "whether", "the", "compilation", "has", "been", "canceled", "and", "reports", "the", "given", "work", "increment", "to", "the", "compiler", "progress", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java#L428-L437
159,755
windup/windup
forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java
Compiler.compile
private void compile(ICompilationUnit[] sourceUnits, boolean lastRound) { this.stats.startTime = System.currentTimeMillis(); try { // build and record parsed units reportProgress(Messages.compilation_beginningToCompile); if (this.options.complianceLevel >= ClassFileConstants.JDK9) { // in Java 9 the compiler must never ask the oracle for a module that is contained in the input units: sortModuleDeclarationsFirst(sourceUnits); } if (this.annotationProcessorManager == null) { beginToCompile(sourceUnits); } else { ICompilationUnit[] originalUnits = sourceUnits.clone(); // remember source units in case a source type collision occurs try { beginToCompile(sourceUnits); if (!lastRound) { processAnnotations(); } if (!this.options.generateClassFiles) { // -proc:only was set on the command line return; } } catch (SourceTypeCollisionException e) { backupAptProblems(); reset(); // a generated type was referenced before it was created // the compiler either created a MissingType or found a BinaryType for it // so add the processor's generated files & start over, // but remember to only pass the generated files to the annotation processor int originalLength = originalUnits.length; int newProcessedLength = e.newAnnotationProcessorUnits.length; ICompilationUnit[] combinedUnits = new ICompilationUnit[originalLength + newProcessedLength]; System.arraycopy(originalUnits, 0, combinedUnits, 0, originalLength); System.arraycopy(e.newAnnotationProcessorUnits, 0, combinedUnits, originalLength, newProcessedLength); this.annotationProcessorStartIndex = originalLength; compile(combinedUnits, e.isLastRound); return; } } // Restore the problems before the results are processed and cleaned up. restoreAptProblems(); processCompiledUnits(0, lastRound); } catch (AbortCompilation e) { this.handleInternalException(e, null); } if (this.options.verbose) { if (this.totalUnits > 1) { this.out.println( Messages.bind(Messages.compilation_units, String.valueOf(this.totalUnits))); } else { this.out.println( Messages.bind(Messages.compilation_unit, String.valueOf(this.totalUnits))); } } }
java
private void compile(ICompilationUnit[] sourceUnits, boolean lastRound) { this.stats.startTime = System.currentTimeMillis(); try { // build and record parsed units reportProgress(Messages.compilation_beginningToCompile); if (this.options.complianceLevel >= ClassFileConstants.JDK9) { // in Java 9 the compiler must never ask the oracle for a module that is contained in the input units: sortModuleDeclarationsFirst(sourceUnits); } if (this.annotationProcessorManager == null) { beginToCompile(sourceUnits); } else { ICompilationUnit[] originalUnits = sourceUnits.clone(); // remember source units in case a source type collision occurs try { beginToCompile(sourceUnits); if (!lastRound) { processAnnotations(); } if (!this.options.generateClassFiles) { // -proc:only was set on the command line return; } } catch (SourceTypeCollisionException e) { backupAptProblems(); reset(); // a generated type was referenced before it was created // the compiler either created a MissingType or found a BinaryType for it // so add the processor's generated files & start over, // but remember to only pass the generated files to the annotation processor int originalLength = originalUnits.length; int newProcessedLength = e.newAnnotationProcessorUnits.length; ICompilationUnit[] combinedUnits = new ICompilationUnit[originalLength + newProcessedLength]; System.arraycopy(originalUnits, 0, combinedUnits, 0, originalLength); System.arraycopy(e.newAnnotationProcessorUnits, 0, combinedUnits, originalLength, newProcessedLength); this.annotationProcessorStartIndex = originalLength; compile(combinedUnits, e.isLastRound); return; } } // Restore the problems before the results are processed and cleaned up. restoreAptProblems(); processCompiledUnits(0, lastRound); } catch (AbortCompilation e) { this.handleInternalException(e, null); } if (this.options.verbose) { if (this.totalUnits > 1) { this.out.println( Messages.bind(Messages.compilation_units, String.valueOf(this.totalUnits))); } else { this.out.println( Messages.bind(Messages.compilation_unit, String.valueOf(this.totalUnits))); } } }
[ "private", "void", "compile", "(", "ICompilationUnit", "[", "]", "sourceUnits", ",", "boolean", "lastRound", ")", "{", "this", ".", "stats", ".", "startTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "try", "{", "// build and record parsed units", "reportProgress", "(", "Messages", ".", "compilation_beginningToCompile", ")", ";", "if", "(", "this", ".", "options", ".", "complianceLevel", ">=", "ClassFileConstants", ".", "JDK9", ")", "{", "// in Java 9 the compiler must never ask the oracle for a module that is contained in the input units:", "sortModuleDeclarationsFirst", "(", "sourceUnits", ")", ";", "}", "if", "(", "this", ".", "annotationProcessorManager", "==", "null", ")", "{", "beginToCompile", "(", "sourceUnits", ")", ";", "}", "else", "{", "ICompilationUnit", "[", "]", "originalUnits", "=", "sourceUnits", ".", "clone", "(", ")", ";", "// remember source units in case a source type collision occurs", "try", "{", "beginToCompile", "(", "sourceUnits", ")", ";", "if", "(", "!", "lastRound", ")", "{", "processAnnotations", "(", ")", ";", "}", "if", "(", "!", "this", ".", "options", ".", "generateClassFiles", ")", "{", "// -proc:only was set on the command line", "return", ";", "}", "}", "catch", "(", "SourceTypeCollisionException", "e", ")", "{", "backupAptProblems", "(", ")", ";", "reset", "(", ")", ";", "// a generated type was referenced before it was created", "// the compiler either created a MissingType or found a BinaryType for it", "// so add the processor's generated files & start over,", "// but remember to only pass the generated files to the annotation processor", "int", "originalLength", "=", "originalUnits", ".", "length", ";", "int", "newProcessedLength", "=", "e", ".", "newAnnotationProcessorUnits", ".", "length", ";", "ICompilationUnit", "[", "]", "combinedUnits", "=", "new", "ICompilationUnit", "[", "originalLength", "+", "newProcessedLength", "]", ";", "System", ".", "arraycopy", "(", "originalUnits", ",", "0", ",", "combinedUnits", ",", "0", ",", "originalLength", ")", ";", "System", ".", "arraycopy", "(", "e", ".", "newAnnotationProcessorUnits", ",", "0", ",", "combinedUnits", ",", "originalLength", ",", "newProcessedLength", ")", ";", "this", ".", "annotationProcessorStartIndex", "=", "originalLength", ";", "compile", "(", "combinedUnits", ",", "e", ".", "isLastRound", ")", ";", "return", ";", "}", "}", "// Restore the problems before the results are processed and cleaned up.", "restoreAptProblems", "(", ")", ";", "processCompiledUnits", "(", "0", ",", "lastRound", ")", ";", "}", "catch", "(", "AbortCompilation", "e", ")", "{", "this", ".", "handleInternalException", "(", "e", ",", "null", ")", ";", "}", "if", "(", "this", ".", "options", ".", "verbose", ")", "{", "if", "(", "this", ".", "totalUnits", ">", "1", ")", "{", "this", ".", "out", ".", "println", "(", "Messages", ".", "bind", "(", "Messages", ".", "compilation_units", ",", "String", ".", "valueOf", "(", "this", ".", "totalUnits", ")", ")", ")", ";", "}", "else", "{", "this", ".", "out", ".", "println", "(", "Messages", ".", "bind", "(", "Messages", ".", "compilation_unit", ",", "String", ".", "valueOf", "(", "this", ".", "totalUnits", ")", ")", ")", ";", "}", "}", "}" ]
General API -> compile each of supplied files -> recompile any required types for which we have an incomplete principle structure
[ "General", "API", "-", ">", "compile", "each", "of", "supplied", "files", "-", ">", "recompile", "any", "required", "types", "for", "which", "we", "have", "an", "incomplete", "principle", "structure" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java#L447-L502
159,756
windup/windup
forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java
Compiler.process
public void process(CompilationUnitDeclaration unit, int i) { this.lookupEnvironment.unitBeingCompleted = unit; long parseStart = System.currentTimeMillis(); this.parser.getMethodBodies(unit); long resolveStart = System.currentTimeMillis(); this.stats.parseTime += resolveStart - parseStart; // fault in fields & methods if (unit.scope != null) unit.scope.faultInTypes(); // verify inherited methods if (unit.scope != null) unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier()); // type checking unit.resolve(); long analyzeStart = System.currentTimeMillis(); this.stats.resolveTime += analyzeStart - resolveStart; //No need of analysis or generation of code if statements are not required if (!this.options.ignoreMethodBodies) unit.analyseCode(); // flow analysis long generateStart = System.currentTimeMillis(); this.stats.analyzeTime += generateStart - analyzeStart; if (!this.options.ignoreMethodBodies) unit.generateCode(); // code generation // reference info if (this.options.produceReferenceInfo && unit.scope != null) unit.scope.storeDependencyInfo(); // finalize problems (suppressWarnings) unit.finalizeProblems(); this.stats.generateTime += System.currentTimeMillis() - generateStart; // refresh the total number of units known at this stage unit.compilationResult.totalUnitsKnown = this.totalUnits; this.lookupEnvironment.unitBeingCompleted = null; }
java
public void process(CompilationUnitDeclaration unit, int i) { this.lookupEnvironment.unitBeingCompleted = unit; long parseStart = System.currentTimeMillis(); this.parser.getMethodBodies(unit); long resolveStart = System.currentTimeMillis(); this.stats.parseTime += resolveStart - parseStart; // fault in fields & methods if (unit.scope != null) unit.scope.faultInTypes(); // verify inherited methods if (unit.scope != null) unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier()); // type checking unit.resolve(); long analyzeStart = System.currentTimeMillis(); this.stats.resolveTime += analyzeStart - resolveStart; //No need of analysis or generation of code if statements are not required if (!this.options.ignoreMethodBodies) unit.analyseCode(); // flow analysis long generateStart = System.currentTimeMillis(); this.stats.analyzeTime += generateStart - analyzeStart; if (!this.options.ignoreMethodBodies) unit.generateCode(); // code generation // reference info if (this.options.produceReferenceInfo && unit.scope != null) unit.scope.storeDependencyInfo(); // finalize problems (suppressWarnings) unit.finalizeProblems(); this.stats.generateTime += System.currentTimeMillis() - generateStart; // refresh the total number of units known at this stage unit.compilationResult.totalUnitsKnown = this.totalUnits; this.lookupEnvironment.unitBeingCompleted = null; }
[ "public", "void", "process", "(", "CompilationUnitDeclaration", "unit", ",", "int", "i", ")", "{", "this", ".", "lookupEnvironment", ".", "unitBeingCompleted", "=", "unit", ";", "long", "parseStart", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "this", ".", "parser", ".", "getMethodBodies", "(", "unit", ")", ";", "long", "resolveStart", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "this", ".", "stats", ".", "parseTime", "+=", "resolveStart", "-", "parseStart", ";", "// fault in fields & methods", "if", "(", "unit", ".", "scope", "!=", "null", ")", "unit", ".", "scope", ".", "faultInTypes", "(", ")", ";", "// verify inherited methods", "if", "(", "unit", ".", "scope", "!=", "null", ")", "unit", ".", "scope", ".", "verifyMethods", "(", "this", ".", "lookupEnvironment", ".", "methodVerifier", "(", ")", ")", ";", "// type checking", "unit", ".", "resolve", "(", ")", ";", "long", "analyzeStart", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "this", ".", "stats", ".", "resolveTime", "+=", "analyzeStart", "-", "resolveStart", ";", "//No need of analysis or generation of code if statements are not required", "if", "(", "!", "this", ".", "options", ".", "ignoreMethodBodies", ")", "unit", ".", "analyseCode", "(", ")", ";", "// flow analysis", "long", "generateStart", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "this", ".", "stats", ".", "analyzeTime", "+=", "generateStart", "-", "analyzeStart", ";", "if", "(", "!", "this", ".", "options", ".", "ignoreMethodBodies", ")", "unit", ".", "generateCode", "(", ")", ";", "// code generation", "// reference info", "if", "(", "this", ".", "options", ".", "produceReferenceInfo", "&&", "unit", ".", "scope", "!=", "null", ")", "unit", ".", "scope", ".", "storeDependencyInfo", "(", ")", ";", "// finalize problems (suppressWarnings)", "unit", ".", "finalizeProblems", "(", ")", ";", "this", ".", "stats", ".", "generateTime", "+=", "System", ".", "currentTimeMillis", "(", ")", "-", "generateStart", ";", "// refresh the total number of units known at this stage", "unit", ".", "compilationResult", ".", "totalUnitsKnown", "=", "this", ".", "totalUnits", ";", "this", ".", "lookupEnvironment", ".", "unitBeingCompleted", "=", "null", ";", "}" ]
Process a compilation unit already parsed and build.
[ "Process", "a", "compilation", "unit", "already", "parsed", "and", "build", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java#L888-L932
159,757
windup/windup
config/api/src/main/java/org/jboss/windup/config/tags/TagServiceHolder.java
TagServiceHolder.loadTagDefinitions
@PostConstruct public void loadTagDefinitions() { Map<Addon, List<URL>> addonToResourcesMap = scanner.scanForAddonMap(new FileExtensionFilter("tags.xml")); for (Map.Entry<Addon, List<URL>> entry : addonToResourcesMap.entrySet()) { for (URL resource : entry.getValue()) { log.info("Reading tags definitions from: " + resource.toString() + " from addon " + entry.getKey().getId()); try(InputStream is = resource.openStream()) { tagService.readTags(is); } catch( Exception ex ) { throw new WindupException("Failed reading tags definition: " + resource.toString() + " from addon " + entry.getKey().getId() + ":\n" + ex.getMessage(), ex); } } } }
java
@PostConstruct public void loadTagDefinitions() { Map<Addon, List<URL>> addonToResourcesMap = scanner.scanForAddonMap(new FileExtensionFilter("tags.xml")); for (Map.Entry<Addon, List<URL>> entry : addonToResourcesMap.entrySet()) { for (URL resource : entry.getValue()) { log.info("Reading tags definitions from: " + resource.toString() + " from addon " + entry.getKey().getId()); try(InputStream is = resource.openStream()) { tagService.readTags(is); } catch( Exception ex ) { throw new WindupException("Failed reading tags definition: " + resource.toString() + " from addon " + entry.getKey().getId() + ":\n" + ex.getMessage(), ex); } } } }
[ "@", "PostConstruct", "public", "void", "loadTagDefinitions", "(", ")", "{", "Map", "<", "Addon", ",", "List", "<", "URL", ">", ">", "addonToResourcesMap", "=", "scanner", ".", "scanForAddonMap", "(", "new", "FileExtensionFilter", "(", "\"tags.xml\"", ")", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Addon", ",", "List", "<", "URL", ">", ">", "entry", ":", "addonToResourcesMap", ".", "entrySet", "(", ")", ")", "{", "for", "(", "URL", "resource", ":", "entry", ".", "getValue", "(", ")", ")", "{", "log", ".", "info", "(", "\"Reading tags definitions from: \"", "+", "resource", ".", "toString", "(", ")", "+", "\" from addon \"", "+", "entry", ".", "getKey", "(", ")", ".", "getId", "(", ")", ")", ";", "try", "(", "InputStream", "is", "=", "resource", ".", "openStream", "(", ")", ")", "{", "tagService", ".", "readTags", "(", "is", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "WindupException", "(", "\"Failed reading tags definition: \"", "+", "resource", ".", "toString", "(", ")", "+", "\" from addon \"", "+", "entry", ".", "getKey", "(", ")", ".", "getId", "(", ")", "+", "\":\\n\"", "+", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "}", "}", "}", "}" ]
Loads the tag definitions from the files with a ".tags.xml" suffix from the addons.
[ "Loads", "the", "tag", "definitions", "from", "the", "files", "with", "a", ".", "tags", ".", "xml", "suffix", "from", "the", "addons", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/tags/TagServiceHolder.java#L44-L63
159,758
windup/windup
java-ast/addon/src/main/java/org/jboss/windup/ast/java/BatchASTProcessor.java
BatchASTProcessor.analyze
public static BatchASTFuture analyze(final BatchASTListener listener, final WildcardImportResolver importResolver, final Set<String> libraryPaths, final Set<String> sourcePaths, Set<Path> sourceFiles) { final String[] encodings = null; final String[] bindingKeys = new String[0]; final ExecutorService executor = WindupExecutors.newFixedThreadPool(WindupExecutors.getDefaultThreadCount()); final FileASTRequestor requestor = new FileASTRequestor() { @Override public void acceptAST(String sourcePath, CompilationUnit ast) { try { /* * This super() call doesn't do anything, but we call it just to be nice, in case that ever changes. */ super.acceptAST(sourcePath, ast); ReferenceResolvingVisitor visitor = new ReferenceResolvingVisitor(importResolver, ast, sourcePath); ast.accept(visitor); listener.processed(Paths.get(sourcePath), visitor.getJavaClassReferences()); } catch (WindupStopException ex) { throw ex; } catch (Throwable t) { listener.failed(Paths.get(sourcePath), t); } } }; List<List<String>> batches = createBatches(sourceFiles); for (final List<String> batch : batches) { executor.submit(new Callable<Void>() { @Override public Void call() throws Exception { ASTParser parser = ASTParser.newParser(AST.JLS8); parser.setBindingsRecovery(false); parser.setResolveBindings(true); Map<String, String> options = JavaCore.getOptions(); JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options); // these options seem to slightly reduce the number of times that JDT aborts on compilation errors options.put(JavaCore.CORE_INCOMPLETE_CLASSPATH, "warning"); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, "warning"); options.put(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, "warning"); options.put(JavaCore.CORE_CIRCULAR_CLASSPATH, "warning"); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, "warning"); options.put(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION, "warning"); options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, "ignore"); options.put(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT, "warning"); options.put(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, "warning"); options.put(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, "warning"); parser.setCompilerOptions(options); parser.setEnvironment(libraryPaths.toArray(new String[libraryPaths.size()]), sourcePaths.toArray(new String[sourcePaths.size()]), null, true); parser.createASTs(batch.toArray(new String[batch.size()]), encodings, bindingKeys, requestor, null); return null; } }); } executor.shutdown(); return new BatchASTFuture() { @Override public boolean isDone() { return executor.isTerminated(); } }; }
java
public static BatchASTFuture analyze(final BatchASTListener listener, final WildcardImportResolver importResolver, final Set<String> libraryPaths, final Set<String> sourcePaths, Set<Path> sourceFiles) { final String[] encodings = null; final String[] bindingKeys = new String[0]; final ExecutorService executor = WindupExecutors.newFixedThreadPool(WindupExecutors.getDefaultThreadCount()); final FileASTRequestor requestor = new FileASTRequestor() { @Override public void acceptAST(String sourcePath, CompilationUnit ast) { try { /* * This super() call doesn't do anything, but we call it just to be nice, in case that ever changes. */ super.acceptAST(sourcePath, ast); ReferenceResolvingVisitor visitor = new ReferenceResolvingVisitor(importResolver, ast, sourcePath); ast.accept(visitor); listener.processed(Paths.get(sourcePath), visitor.getJavaClassReferences()); } catch (WindupStopException ex) { throw ex; } catch (Throwable t) { listener.failed(Paths.get(sourcePath), t); } } }; List<List<String>> batches = createBatches(sourceFiles); for (final List<String> batch : batches) { executor.submit(new Callable<Void>() { @Override public Void call() throws Exception { ASTParser parser = ASTParser.newParser(AST.JLS8); parser.setBindingsRecovery(false); parser.setResolveBindings(true); Map<String, String> options = JavaCore.getOptions(); JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options); // these options seem to slightly reduce the number of times that JDT aborts on compilation errors options.put(JavaCore.CORE_INCOMPLETE_CLASSPATH, "warning"); options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, "warning"); options.put(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, "warning"); options.put(JavaCore.CORE_CIRCULAR_CLASSPATH, "warning"); options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, "warning"); options.put(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION, "warning"); options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, "ignore"); options.put(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT, "warning"); options.put(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, "warning"); options.put(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, "warning"); parser.setCompilerOptions(options); parser.setEnvironment(libraryPaths.toArray(new String[libraryPaths.size()]), sourcePaths.toArray(new String[sourcePaths.size()]), null, true); parser.createASTs(batch.toArray(new String[batch.size()]), encodings, bindingKeys, requestor, null); return null; } }); } executor.shutdown(); return new BatchASTFuture() { @Override public boolean isDone() { return executor.isTerminated(); } }; }
[ "public", "static", "BatchASTFuture", "analyze", "(", "final", "BatchASTListener", "listener", ",", "final", "WildcardImportResolver", "importResolver", ",", "final", "Set", "<", "String", ">", "libraryPaths", ",", "final", "Set", "<", "String", ">", "sourcePaths", ",", "Set", "<", "Path", ">", "sourceFiles", ")", "{", "final", "String", "[", "]", "encodings", "=", "null", ";", "final", "String", "[", "]", "bindingKeys", "=", "new", "String", "[", "0", "]", ";", "final", "ExecutorService", "executor", "=", "WindupExecutors", ".", "newFixedThreadPool", "(", "WindupExecutors", ".", "getDefaultThreadCount", "(", ")", ")", ";", "final", "FileASTRequestor", "requestor", "=", "new", "FileASTRequestor", "(", ")", "{", "@", "Override", "public", "void", "acceptAST", "(", "String", "sourcePath", ",", "CompilationUnit", "ast", ")", "{", "try", "{", "/*\n * This super() call doesn't do anything, but we call it just to be nice, in case that ever changes.\n */", "super", ".", "acceptAST", "(", "sourcePath", ",", "ast", ")", ";", "ReferenceResolvingVisitor", "visitor", "=", "new", "ReferenceResolvingVisitor", "(", "importResolver", ",", "ast", ",", "sourcePath", ")", ";", "ast", ".", "accept", "(", "visitor", ")", ";", "listener", ".", "processed", "(", "Paths", ".", "get", "(", "sourcePath", ")", ",", "visitor", ".", "getJavaClassReferences", "(", ")", ")", ";", "}", "catch", "(", "WindupStopException", "ex", ")", "{", "throw", "ex", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "listener", ".", "failed", "(", "Paths", ".", "get", "(", "sourcePath", ")", ",", "t", ")", ";", "}", "}", "}", ";", "List", "<", "List", "<", "String", ">", ">", "batches", "=", "createBatches", "(", "sourceFiles", ")", ";", "for", "(", "final", "List", "<", "String", ">", "batch", ":", "batches", ")", "{", "executor", ".", "submit", "(", "new", "Callable", "<", "Void", ">", "(", ")", "{", "@", "Override", "public", "Void", "call", "(", ")", "throws", "Exception", "{", "ASTParser", "parser", "=", "ASTParser", ".", "newParser", "(", "AST", ".", "JLS8", ")", ";", "parser", ".", "setBindingsRecovery", "(", "false", ")", ";", "parser", ".", "setResolveBindings", "(", "true", ")", ";", "Map", "<", "String", ",", "String", ">", "options", "=", "JavaCore", ".", "getOptions", "(", ")", ";", "JavaCore", ".", "setComplianceOptions", "(", "JavaCore", ".", "VERSION_1_8", ",", "options", ")", ";", "// these options seem to slightly reduce the number of times that JDT aborts on compilation errors", "options", ".", "put", "(", "JavaCore", ".", "CORE_INCOMPLETE_CLASSPATH", ",", "\"warning\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_PB_ENUM_IDENTIFIER", ",", "\"warning\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_PB_FORBIDDEN_REFERENCE", ",", "\"warning\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "CORE_CIRCULAR_CLASSPATH", ",", "\"warning\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_PB_ASSERT_IDENTIFIER", ",", "\"warning\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_PB_NULL_SPECIFICATION_VIOLATION", ",", "\"warning\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "CORE_JAVA_BUILD_INVALID_CLASSPATH", ",", "\"ignore\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT", ",", "\"warning\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE", ",", "\"warning\"", ")", ";", "options", ".", "put", "(", "JavaCore", ".", "CORE_JAVA_BUILD_DUPLICATE_RESOURCE", ",", "\"warning\"", ")", ";", "parser", ".", "setCompilerOptions", "(", "options", ")", ";", "parser", ".", "setEnvironment", "(", "libraryPaths", ".", "toArray", "(", "new", "String", "[", "libraryPaths", ".", "size", "(", ")", "]", ")", ",", "sourcePaths", ".", "toArray", "(", "new", "String", "[", "sourcePaths", ".", "size", "(", ")", "]", ")", ",", "null", ",", "true", ")", ";", "parser", ".", "createASTs", "(", "batch", ".", "toArray", "(", "new", "String", "[", "batch", ".", "size", "(", ")", "]", ")", ",", "encodings", ",", "bindingKeys", ",", "requestor", ",", "null", ")", ";", "return", "null", ";", "}", "}", ")", ";", "}", "executor", ".", "shutdown", "(", ")", ";", "return", "new", "BatchASTFuture", "(", ")", "{", "@", "Override", "public", "boolean", "isDone", "(", ")", "{", "return", "executor", ".", "isTerminated", "(", ")", ";", "}", "}", ";", "}" ]
Process the given batch of files and pass the results back to the listener as each file is processed.
[ "Process", "the", "given", "batch", "of", "files", "and", "pass", "the", "results", "back", "to", "the", "listener", "as", "each", "file", "is", "processed", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/java-ast/addon/src/main/java/org/jboss/windup/ast/java/BatchASTProcessor.java#L34-L116
159,759
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/condition/annotation/AnnotationTypeCondition.java
AnnotationTypeCondition.addCondition
public AnnotationTypeCondition addCondition(String element, AnnotationCondition condition) { this.conditions.put(element, condition); return this; }
java
public AnnotationTypeCondition addCondition(String element, AnnotationCondition condition) { this.conditions.put(element, condition); return this; }
[ "public", "AnnotationTypeCondition", "addCondition", "(", "String", "element", ",", "AnnotationCondition", "condition", ")", "{", "this", ".", "conditions", ".", "put", "(", "element", ",", "condition", ")", ";", "return", "this", ";", "}" ]
Adds another condition for an element within this annotation.
[ "Adds", "another", "condition", "for", "an", "element", "within", "this", "annotation", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/condition/annotation/AnnotationTypeCondition.java#L36-L40
159,760
windup/windup
decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java
ProcyonDecompiler.decompileClassFile
@Override public DecompilationResult decompileClassFile(Path rootDir, Path classFilePath, Path outputDir) throws DecompilationException { Checks.checkDirectoryToBeRead(rootDir.toFile(), "Classes root dir"); File classFile = classFilePath.toFile(); Checks.checkFileToBeRead(classFile, "Class file"); Checks.checkDirectoryToBeFilled(outputDir.toFile(), "Output directory"); log.info("Decompiling .class '" + classFilePath + "' to '" + outputDir + "' from: '" + rootDir + "'"); String name = classFilePath.normalize().toAbsolutePath().toString().substring(rootDir.toAbsolutePath().toString().length() + 1); final String typeName = StringUtils.removeEnd(name, ".class");// .replace('/', '.'); DecompilationResult result = new DecompilationResult(); try { DecompilerSettings settings = getDefaultSettings(outputDir.toFile()); this.procyonConf.setDecompilerSettings(settings); // TODO: This is horrible mess. final ITypeLoader typeLoader = new CompositeTypeLoader(new WindupClasspathTypeLoader(rootDir.toString()), new ClasspathTypeLoader()); WindupMetadataSystem metadataSystem = new WindupMetadataSystem(typeLoader); File outputFile = this.decompileType(settings, metadataSystem, typeName); result.addDecompiled(Collections.singletonList(classFilePath.toString()), outputFile.getAbsolutePath()); } catch (Throwable e) { DecompilationFailure failure = new DecompilationFailure("Error during decompilation of " + classFilePath.toString() + ":\n " + e.getMessage(), Collections.singletonList(name), e); log.severe(failure.getMessage()); result.addFailure(failure); } return result; }
java
@Override public DecompilationResult decompileClassFile(Path rootDir, Path classFilePath, Path outputDir) throws DecompilationException { Checks.checkDirectoryToBeRead(rootDir.toFile(), "Classes root dir"); File classFile = classFilePath.toFile(); Checks.checkFileToBeRead(classFile, "Class file"); Checks.checkDirectoryToBeFilled(outputDir.toFile(), "Output directory"); log.info("Decompiling .class '" + classFilePath + "' to '" + outputDir + "' from: '" + rootDir + "'"); String name = classFilePath.normalize().toAbsolutePath().toString().substring(rootDir.toAbsolutePath().toString().length() + 1); final String typeName = StringUtils.removeEnd(name, ".class");// .replace('/', '.'); DecompilationResult result = new DecompilationResult(); try { DecompilerSettings settings = getDefaultSettings(outputDir.toFile()); this.procyonConf.setDecompilerSettings(settings); // TODO: This is horrible mess. final ITypeLoader typeLoader = new CompositeTypeLoader(new WindupClasspathTypeLoader(rootDir.toString()), new ClasspathTypeLoader()); WindupMetadataSystem metadataSystem = new WindupMetadataSystem(typeLoader); File outputFile = this.decompileType(settings, metadataSystem, typeName); result.addDecompiled(Collections.singletonList(classFilePath.toString()), outputFile.getAbsolutePath()); } catch (Throwable e) { DecompilationFailure failure = new DecompilationFailure("Error during decompilation of " + classFilePath.toString() + ":\n " + e.getMessage(), Collections.singletonList(name), e); log.severe(failure.getMessage()); result.addFailure(failure); } return result; }
[ "@", "Override", "public", "DecompilationResult", "decompileClassFile", "(", "Path", "rootDir", ",", "Path", "classFilePath", ",", "Path", "outputDir", ")", "throws", "DecompilationException", "{", "Checks", ".", "checkDirectoryToBeRead", "(", "rootDir", ".", "toFile", "(", ")", ",", "\"Classes root dir\"", ")", ";", "File", "classFile", "=", "classFilePath", ".", "toFile", "(", ")", ";", "Checks", ".", "checkFileToBeRead", "(", "classFile", ",", "\"Class file\"", ")", ";", "Checks", ".", "checkDirectoryToBeFilled", "(", "outputDir", ".", "toFile", "(", ")", ",", "\"Output directory\"", ")", ";", "log", ".", "info", "(", "\"Decompiling .class '\"", "+", "classFilePath", "+", "\"' to '\"", "+", "outputDir", "+", "\"' from: '\"", "+", "rootDir", "+", "\"'\"", ")", ";", "String", "name", "=", "classFilePath", ".", "normalize", "(", ")", ".", "toAbsolutePath", "(", ")", ".", "toString", "(", ")", ".", "substring", "(", "rootDir", ".", "toAbsolutePath", "(", ")", ".", "toString", "(", ")", ".", "length", "(", ")", "+", "1", ")", ";", "final", "String", "typeName", "=", "StringUtils", ".", "removeEnd", "(", "name", ",", "\".class\"", ")", ";", "// .replace('/', '.');", "DecompilationResult", "result", "=", "new", "DecompilationResult", "(", ")", ";", "try", "{", "DecompilerSettings", "settings", "=", "getDefaultSettings", "(", "outputDir", ".", "toFile", "(", ")", ")", ";", "this", ".", "procyonConf", ".", "setDecompilerSettings", "(", "settings", ")", ";", "// TODO: This is horrible mess.", "final", "ITypeLoader", "typeLoader", "=", "new", "CompositeTypeLoader", "(", "new", "WindupClasspathTypeLoader", "(", "rootDir", ".", "toString", "(", ")", ")", ",", "new", "ClasspathTypeLoader", "(", ")", ")", ";", "WindupMetadataSystem", "metadataSystem", "=", "new", "WindupMetadataSystem", "(", "typeLoader", ")", ";", "File", "outputFile", "=", "this", ".", "decompileType", "(", "settings", ",", "metadataSystem", ",", "typeName", ")", ";", "result", ".", "addDecompiled", "(", "Collections", ".", "singletonList", "(", "classFilePath", ".", "toString", "(", ")", ")", ",", "outputFile", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "DecompilationFailure", "failure", "=", "new", "DecompilationFailure", "(", "\"Error during decompilation of \"", "+", "classFilePath", ".", "toString", "(", ")", "+", "\":\\n \"", "+", "e", ".", "getMessage", "(", ")", ",", "Collections", ".", "singletonList", "(", "name", ")", ",", "e", ")", ";", "log", ".", "severe", "(", "failure", ".", "getMessage", "(", ")", ")", ";", "result", ".", "addFailure", "(", "failure", ")", ";", "}", "return", "result", ";", "}" ]
Decompiles the given .class file and creates the specified output source file. @param classFilePath the .class file to be decompiled. @param outputDir The directory where decompiled .java files will be placed.
[ "Decompiles", "the", "given", ".", "class", "file", "and", "creates", "the", "specified", "output", "source", "file", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java#L225-L259
159,761
windup/windup
decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java
ProcyonDecompiler.refreshMetadataCache
private void refreshMetadataCache(final Queue<WindupMetadataSystem> metadataSystemCache, final DecompilerSettings settings) { metadataSystemCache.clear(); for (int i = 0; i < this.getNumberOfThreads(); i++) { metadataSystemCache.add(new NoRetryMetadataSystem(settings.getTypeLoader())); } }
java
private void refreshMetadataCache(final Queue<WindupMetadataSystem> metadataSystemCache, final DecompilerSettings settings) { metadataSystemCache.clear(); for (int i = 0; i < this.getNumberOfThreads(); i++) { metadataSystemCache.add(new NoRetryMetadataSystem(settings.getTypeLoader())); } }
[ "private", "void", "refreshMetadataCache", "(", "final", "Queue", "<", "WindupMetadataSystem", ">", "metadataSystemCache", ",", "final", "DecompilerSettings", "settings", ")", "{", "metadataSystemCache", ".", "clear", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "getNumberOfThreads", "(", ")", ";", "i", "++", ")", "{", "metadataSystemCache", ".", "add", "(", "new", "NoRetryMetadataSystem", "(", "settings", ".", "getTypeLoader", "(", ")", ")", ")", ";", "}", "}" ]
The metadata cache can become huge over time. This simply flushes it periodically.
[ "The", "metadata", "cache", "can", "become", "huge", "over", "time", ".", "This", "simply", "flushes", "it", "periodically", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java#L522-L529
159,762
windup/windup
decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java
ProcyonDecompiler.decompileType
private File decompileType(final DecompilerSettings settings, final WindupMetadataSystem metadataSystem, final String typeName) throws IOException { log.fine("Decompiling " + typeName); final TypeReference type; // Hack to get around classes whose descriptors clash with primitive types. if (typeName.length() == 1) { final MetadataParser parser = new MetadataParser(IMetadataResolver.EMPTY); final TypeReference reference = parser.parseTypeDescriptor(typeName); type = metadataSystem.resolve(reference); } else type = metadataSystem.lookupType(typeName); if (type == null) { log.severe("Failed to load class: " + typeName); return null; } final TypeDefinition resolvedType = type.resolve(); if (resolvedType == null) { log.severe("Failed to resolve type: " + typeName); return null; } boolean nested = resolvedType.isNested() || resolvedType.isAnonymous() || resolvedType.isSynthetic(); if (!this.procyonConf.isIncludeNested() && nested) return null; settings.setJavaFormattingOptions(new JavaFormattingOptions()); final FileOutputWriter writer = createFileWriter(resolvedType, settings); final PlainTextOutput output; output = new PlainTextOutput(writer); output.setUnicodeOutputEnabled(settings.isUnicodeOutputEnabled()); if (settings.getLanguage() instanceof BytecodeLanguage) output.setIndentToken(" "); DecompilationOptions options = new DecompilationOptions(); options.setSettings(settings); // I'm missing why these two classes are split. // --------- DECOMPILE --------- final TypeDecompilationResults results = settings.getLanguage().decompileType(resolvedType, output, options); writer.flush(); writer.close(); // If we're writing to a file and we were asked to include line numbers in any way, // then reformat the file to include that line number information. final List<LineNumberPosition> lineNumberPositions = results.getLineNumberPositions(); if (!this.procyonConf.getLineNumberOptions().isEmpty()) { final LineNumberFormatter lineFormatter = new LineNumberFormatter(writer.getFile(), lineNumberPositions, this.procyonConf.getLineNumberOptions()); lineFormatter.reformatFile(); } return writer.getFile(); }
java
private File decompileType(final DecompilerSettings settings, final WindupMetadataSystem metadataSystem, final String typeName) throws IOException { log.fine("Decompiling " + typeName); final TypeReference type; // Hack to get around classes whose descriptors clash with primitive types. if (typeName.length() == 1) { final MetadataParser parser = new MetadataParser(IMetadataResolver.EMPTY); final TypeReference reference = parser.parseTypeDescriptor(typeName); type = metadataSystem.resolve(reference); } else type = metadataSystem.lookupType(typeName); if (type == null) { log.severe("Failed to load class: " + typeName); return null; } final TypeDefinition resolvedType = type.resolve(); if (resolvedType == null) { log.severe("Failed to resolve type: " + typeName); return null; } boolean nested = resolvedType.isNested() || resolvedType.isAnonymous() || resolvedType.isSynthetic(); if (!this.procyonConf.isIncludeNested() && nested) return null; settings.setJavaFormattingOptions(new JavaFormattingOptions()); final FileOutputWriter writer = createFileWriter(resolvedType, settings); final PlainTextOutput output; output = new PlainTextOutput(writer); output.setUnicodeOutputEnabled(settings.isUnicodeOutputEnabled()); if (settings.getLanguage() instanceof BytecodeLanguage) output.setIndentToken(" "); DecompilationOptions options = new DecompilationOptions(); options.setSettings(settings); // I'm missing why these two classes are split. // --------- DECOMPILE --------- final TypeDecompilationResults results = settings.getLanguage().decompileType(resolvedType, output, options); writer.flush(); writer.close(); // If we're writing to a file and we were asked to include line numbers in any way, // then reformat the file to include that line number information. final List<LineNumberPosition> lineNumberPositions = results.getLineNumberPositions(); if (!this.procyonConf.getLineNumberOptions().isEmpty()) { final LineNumberFormatter lineFormatter = new LineNumberFormatter(writer.getFile(), lineNumberPositions, this.procyonConf.getLineNumberOptions()); lineFormatter.reformatFile(); } return writer.getFile(); }
[ "private", "File", "decompileType", "(", "final", "DecompilerSettings", "settings", ",", "final", "WindupMetadataSystem", "metadataSystem", ",", "final", "String", "typeName", ")", "throws", "IOException", "{", "log", ".", "fine", "(", "\"Decompiling \"", "+", "typeName", ")", ";", "final", "TypeReference", "type", ";", "// Hack to get around classes whose descriptors clash with primitive types.", "if", "(", "typeName", ".", "length", "(", ")", "==", "1", ")", "{", "final", "MetadataParser", "parser", "=", "new", "MetadataParser", "(", "IMetadataResolver", ".", "EMPTY", ")", ";", "final", "TypeReference", "reference", "=", "parser", ".", "parseTypeDescriptor", "(", "typeName", ")", ";", "type", "=", "metadataSystem", ".", "resolve", "(", "reference", ")", ";", "}", "else", "type", "=", "metadataSystem", ".", "lookupType", "(", "typeName", ")", ";", "if", "(", "type", "==", "null", ")", "{", "log", ".", "severe", "(", "\"Failed to load class: \"", "+", "typeName", ")", ";", "return", "null", ";", "}", "final", "TypeDefinition", "resolvedType", "=", "type", ".", "resolve", "(", ")", ";", "if", "(", "resolvedType", "==", "null", ")", "{", "log", ".", "severe", "(", "\"Failed to resolve type: \"", "+", "typeName", ")", ";", "return", "null", ";", "}", "boolean", "nested", "=", "resolvedType", ".", "isNested", "(", ")", "||", "resolvedType", ".", "isAnonymous", "(", ")", "||", "resolvedType", ".", "isSynthetic", "(", ")", ";", "if", "(", "!", "this", ".", "procyonConf", ".", "isIncludeNested", "(", ")", "&&", "nested", ")", "return", "null", ";", "settings", ".", "setJavaFormattingOptions", "(", "new", "JavaFormattingOptions", "(", ")", ")", ";", "final", "FileOutputWriter", "writer", "=", "createFileWriter", "(", "resolvedType", ",", "settings", ")", ";", "final", "PlainTextOutput", "output", ";", "output", "=", "new", "PlainTextOutput", "(", "writer", ")", ";", "output", ".", "setUnicodeOutputEnabled", "(", "settings", ".", "isUnicodeOutputEnabled", "(", ")", ")", ";", "if", "(", "settings", ".", "getLanguage", "(", ")", "instanceof", "BytecodeLanguage", ")", "output", ".", "setIndentToken", "(", "\" \"", ")", ";", "DecompilationOptions", "options", "=", "new", "DecompilationOptions", "(", ")", ";", "options", ".", "setSettings", "(", "settings", ")", ";", "// I'm missing why these two classes are split.", "// --------- DECOMPILE ---------", "final", "TypeDecompilationResults", "results", "=", "settings", ".", "getLanguage", "(", ")", ".", "decompileType", "(", "resolvedType", ",", "output", ",", "options", ")", ";", "writer", ".", "flush", "(", ")", ";", "writer", ".", "close", "(", ")", ";", "// If we're writing to a file and we were asked to include line numbers in any way,", "// then reformat the file to include that line number information.", "final", "List", "<", "LineNumberPosition", ">", "lineNumberPositions", "=", "results", ".", "getLineNumberPositions", "(", ")", ";", "if", "(", "!", "this", ".", "procyonConf", ".", "getLineNumberOptions", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "final", "LineNumberFormatter", "lineFormatter", "=", "new", "LineNumberFormatter", "(", "writer", ".", "getFile", "(", ")", ",", "lineNumberPositions", ",", "this", ".", "procyonConf", ".", "getLineNumberOptions", "(", ")", ")", ";", "lineFormatter", ".", "reformatFile", "(", ")", ";", "}", "return", "writer", ".", "getFile", "(", ")", ";", "}" ]
Decompiles a single type. @param metadataSystem @param typeName @return @throws IOException
[ "Decompiles", "a", "single", "type", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java#L598-L663
159,763
windup/windup
decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java
ProcyonDecompiler.getDefaultSettings
private DecompilerSettings getDefaultSettings(File outputDir) { DecompilerSettings settings = new DecompilerSettings(); procyonConf.setDecompilerSettings(settings); settings.setOutputDirectory(outputDir.getPath()); settings.setShowSyntheticMembers(false); settings.setForceExplicitImports(true); if (settings.getTypeLoader() == null) settings.setTypeLoader(new ClasspathTypeLoader()); return settings; }
java
private DecompilerSettings getDefaultSettings(File outputDir) { DecompilerSettings settings = new DecompilerSettings(); procyonConf.setDecompilerSettings(settings); settings.setOutputDirectory(outputDir.getPath()); settings.setShowSyntheticMembers(false); settings.setForceExplicitImports(true); if (settings.getTypeLoader() == null) settings.setTypeLoader(new ClasspathTypeLoader()); return settings; }
[ "private", "DecompilerSettings", "getDefaultSettings", "(", "File", "outputDir", ")", "{", "DecompilerSettings", "settings", "=", "new", "DecompilerSettings", "(", ")", ";", "procyonConf", ".", "setDecompilerSettings", "(", "settings", ")", ";", "settings", ".", "setOutputDirectory", "(", "outputDir", ".", "getPath", "(", ")", ")", ";", "settings", ".", "setShowSyntheticMembers", "(", "false", ")", ";", "settings", ".", "setForceExplicitImports", "(", "true", ")", ";", "if", "(", "settings", ".", "getTypeLoader", "(", ")", "==", "null", ")", "settings", ".", "setTypeLoader", "(", "new", "ClasspathTypeLoader", "(", ")", ")", ";", "return", "settings", ";", "}" ]
Default settings set type loader to ClasspathTypeLoader if not set before.
[ "Default", "settings", "set", "type", "loader", "to", "ClasspathTypeLoader", "if", "not", "set", "before", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java#L668-L679
159,764
windup/windup
decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java
ProcyonDecompiler.loadJar
private JarFile loadJar(File archive) throws DecompilationException { try { return new JarFile(archive); } catch (IOException ex) { throw new DecompilationException("Can't load .jar: " + archive.getPath(), ex); } }
java
private JarFile loadJar(File archive) throws DecompilationException { try { return new JarFile(archive); } catch (IOException ex) { throw new DecompilationException("Can't load .jar: " + archive.getPath(), ex); } }
[ "private", "JarFile", "loadJar", "(", "File", "archive", ")", "throws", "DecompilationException", "{", "try", "{", "return", "new", "JarFile", "(", "archive", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "DecompilationException", "(", "\"Can't load .jar: \"", "+", "archive", ".", "getPath", "(", ")", ",", "ex", ")", ";", "}", "}" ]
Opens the jar, wraps any IOException.
[ "Opens", "the", "jar", "wraps", "any", "IOException", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java#L684-L694
159,765
windup/windup
decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java
ProcyonDecompiler.createFileWriter
private static synchronized FileOutputWriter createFileWriter(final TypeDefinition type, final DecompilerSettings settings) throws IOException { final String outputDirectory = settings.getOutputDirectory(); final String fileName = type.getName() + settings.getLanguage().getFileExtension(); final String packageName = type.getPackageName(); // foo.Bar -> foo/Bar.java final String subDir = StringUtils.defaultIfEmpty(packageName, "").replace('.', File.separatorChar); final String outputPath = PathHelper.combine(outputDirectory, subDir, fileName); final File outputFile = new File(outputPath); final File parentDir = outputFile.getParentFile(); if (parentDir != null && !parentDir.exists() && !parentDir.mkdirs()) { throw new IllegalStateException("Could not create directory:" + parentDir); } if (!outputFile.exists() && !outputFile.createNewFile()) { throw new IllegalStateException("Could not create output file: " + outputPath); } return new FileOutputWriter(outputFile, settings); }
java
private static synchronized FileOutputWriter createFileWriter(final TypeDefinition type, final DecompilerSettings settings) throws IOException { final String outputDirectory = settings.getOutputDirectory(); final String fileName = type.getName() + settings.getLanguage().getFileExtension(); final String packageName = type.getPackageName(); // foo.Bar -> foo/Bar.java final String subDir = StringUtils.defaultIfEmpty(packageName, "").replace('.', File.separatorChar); final String outputPath = PathHelper.combine(outputDirectory, subDir, fileName); final File outputFile = new File(outputPath); final File parentDir = outputFile.getParentFile(); if (parentDir != null && !parentDir.exists() && !parentDir.mkdirs()) { throw new IllegalStateException("Could not create directory:" + parentDir); } if (!outputFile.exists() && !outputFile.createNewFile()) { throw new IllegalStateException("Could not create output file: " + outputPath); } return new FileOutputWriter(outputFile, settings); }
[ "private", "static", "synchronized", "FileOutputWriter", "createFileWriter", "(", "final", "TypeDefinition", "type", ",", "final", "DecompilerSettings", "settings", ")", "throws", "IOException", "{", "final", "String", "outputDirectory", "=", "settings", ".", "getOutputDirectory", "(", ")", ";", "final", "String", "fileName", "=", "type", ".", "getName", "(", ")", "+", "settings", ".", "getLanguage", "(", ")", ".", "getFileExtension", "(", ")", ";", "final", "String", "packageName", "=", "type", ".", "getPackageName", "(", ")", ";", "// foo.Bar -> foo/Bar.java", "final", "String", "subDir", "=", "StringUtils", ".", "defaultIfEmpty", "(", "packageName", ",", "\"\"", ")", ".", "replace", "(", "'", "'", ",", "File", ".", "separatorChar", ")", ";", "final", "String", "outputPath", "=", "PathHelper", ".", "combine", "(", "outputDirectory", ",", "subDir", ",", "fileName", ")", ";", "final", "File", "outputFile", "=", "new", "File", "(", "outputPath", ")", ";", "final", "File", "parentDir", "=", "outputFile", ".", "getParentFile", "(", ")", ";", "if", "(", "parentDir", "!=", "null", "&&", "!", "parentDir", ".", "exists", "(", ")", "&&", "!", "parentDir", ".", "mkdirs", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Could not create directory:\"", "+", "parentDir", ")", ";", "}", "if", "(", "!", "outputFile", ".", "exists", "(", ")", "&&", "!", "outputFile", ".", "createNewFile", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Could not create output file: \"", "+", "outputPath", ")", ";", "}", "return", "new", "FileOutputWriter", "(", "outputFile", ",", "settings", ")", ";", "}" ]
Constructs the path from FQCN, validates writability, and creates a writer.
[ "Constructs", "the", "path", "from", "FQCN", "validates", "writability", "and", "creates", "a", "writer", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/decompiler/impl-procyon/src/main/java/org/jboss/windup/decompiler/procyon/ProcyonDecompiler.java#L699-L725
159,766
windup/windup
bootstrap/src/main/java/org/jboss/windup/bootstrap/commands/AbstractListCommandWithoutFurnace.java
AbstractListCommandWithoutFurnace.printValuesSorted
protected static void printValuesSorted(String message, Set<String> values) { System.out.println(); System.out.println(message + ":"); List<String> sorted = new ArrayList<>(values); Collections.sort(sorted); for (String value : sorted) { System.out.println("\t" + value); } }
java
protected static void printValuesSorted(String message, Set<String> values) { System.out.println(); System.out.println(message + ":"); List<String> sorted = new ArrayList<>(values); Collections.sort(sorted); for (String value : sorted) { System.out.println("\t" + value); } }
[ "protected", "static", "void", "printValuesSorted", "(", "String", "message", ",", "Set", "<", "String", ">", "values", ")", "{", "System", ".", "out", ".", "println", "(", ")", ";", "System", ".", "out", ".", "println", "(", "message", "+", "\":\"", ")", ";", "List", "<", "String", ">", "sorted", "=", "new", "ArrayList", "<>", "(", "values", ")", ";", "Collections", ".", "sort", "(", "sorted", ")", ";", "for", "(", "String", "value", ":", "sorted", ")", "{", "System", ".", "out", ".", "println", "(", "\"\\t\"", "+", "value", ")", ";", "}", "}" ]
Print the given values after displaying the provided message.
[ "Print", "the", "given", "values", "after", "displaying", "the", "provided", "message", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/bootstrap/src/main/java/org/jboss/windup/bootstrap/commands/AbstractListCommandWithoutFurnace.java#L16-L26
159,767
windup/windup
graph/api/src/main/java/org/jboss/windup/graph/GraphTypeManager.java
GraphTypeManager.getTypeValue
public static String getTypeValue(Class<? extends WindupFrame> clazz) { TypeValue typeValueAnnotation = clazz.getAnnotation(TypeValue.class); if (typeValueAnnotation == null) throw new IllegalArgumentException("Class " + clazz.getCanonicalName() + " lacks a @TypeValue annotation"); return typeValueAnnotation.value(); }
java
public static String getTypeValue(Class<? extends WindupFrame> clazz) { TypeValue typeValueAnnotation = clazz.getAnnotation(TypeValue.class); if (typeValueAnnotation == null) throw new IllegalArgumentException("Class " + clazz.getCanonicalName() + " lacks a @TypeValue annotation"); return typeValueAnnotation.value(); }
[ "public", "static", "String", "getTypeValue", "(", "Class", "<", "?", "extends", "WindupFrame", ">", "clazz", ")", "{", "TypeValue", "typeValueAnnotation", "=", "clazz", ".", "getAnnotation", "(", "TypeValue", ".", "class", ")", ";", "if", "(", "typeValueAnnotation", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Class \"", "+", "clazz", ".", "getCanonicalName", "(", ")", "+", "\" lacks a @TypeValue annotation\"", ")", ";", "return", "typeValueAnnotation", ".", "value", "(", ")", ";", "}" ]
Returns the type discriminator value for given Frames model class, extracted from the @TypeValue annotation.
[ "Returns", "the", "type", "discriminator", "value", "for", "given", "Frames", "model", "class", "extracted", "from", "the" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/graph/api/src/main/java/org/jboss/windup/graph/GraphTypeManager.java#L59-L66
159,768
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/freemarker/FreeMarkerUtil.java
FreeMarkerUtil.getDefaultFreemarkerConfiguration
public static Configuration getDefaultFreemarkerConfiguration() { freemarker.template.Configuration configuration = new freemarker.template.Configuration(Configuration.VERSION_2_3_26); DefaultObjectWrapperBuilder objectWrapperBuilder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_26); objectWrapperBuilder.setUseAdaptersForContainers(true); objectWrapperBuilder.setIterableSupport(true); configuration.setObjectWrapper(objectWrapperBuilder.build()); configuration.setAPIBuiltinEnabled(true); configuration.setTemplateLoader(new FurnaceFreeMarkerTemplateLoader()); configuration.setTemplateUpdateDelayMilliseconds(3600); return configuration; }
java
public static Configuration getDefaultFreemarkerConfiguration() { freemarker.template.Configuration configuration = new freemarker.template.Configuration(Configuration.VERSION_2_3_26); DefaultObjectWrapperBuilder objectWrapperBuilder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_26); objectWrapperBuilder.setUseAdaptersForContainers(true); objectWrapperBuilder.setIterableSupport(true); configuration.setObjectWrapper(objectWrapperBuilder.build()); configuration.setAPIBuiltinEnabled(true); configuration.setTemplateLoader(new FurnaceFreeMarkerTemplateLoader()); configuration.setTemplateUpdateDelayMilliseconds(3600); return configuration; }
[ "public", "static", "Configuration", "getDefaultFreemarkerConfiguration", "(", ")", "{", "freemarker", ".", "template", ".", "Configuration", "configuration", "=", "new", "freemarker", ".", "template", ".", "Configuration", "(", "Configuration", ".", "VERSION_2_3_26", ")", ";", "DefaultObjectWrapperBuilder", "objectWrapperBuilder", "=", "new", "DefaultObjectWrapperBuilder", "(", "Configuration", ".", "VERSION_2_3_26", ")", ";", "objectWrapperBuilder", ".", "setUseAdaptersForContainers", "(", "true", ")", ";", "objectWrapperBuilder", ".", "setIterableSupport", "(", "true", ")", ";", "configuration", ".", "setObjectWrapper", "(", "objectWrapperBuilder", ".", "build", "(", ")", ")", ";", "configuration", ".", "setAPIBuiltinEnabled", "(", "true", ")", ";", "configuration", ".", "setTemplateLoader", "(", "new", "FurnaceFreeMarkerTemplateLoader", "(", ")", ")", ";", "configuration", ".", "setTemplateUpdateDelayMilliseconds", "(", "3600", ")", ";", "return", "configuration", ";", "}" ]
Gets the default configuration for Freemarker within Windup.
[ "Gets", "the", "default", "configuration", "for", "Freemarker", "within", "Windup", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/freemarker/FreeMarkerUtil.java#L34-L46
159,769
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/freemarker/FreeMarkerUtil.java
FreeMarkerUtil.findFreeMarkerContextVariables
public static Map<String, Object> findFreeMarkerContextVariables(Variables variables, String... varNames) { Map<String, Object> results = new HashMap<>(); for (String varName : varNames) { WindupVertexFrame payload = null; try { payload = Iteration.getCurrentPayload(variables, null, varName); } catch (IllegalStateException | IllegalArgumentException e) { // oh well } if (payload != null) { results.put(varName, payload); } else { Iterable<? extends WindupVertexFrame> var = variables.findVariable(varName); if (var != null) { results.put(varName, var); } } } return results; }
java
public static Map<String, Object> findFreeMarkerContextVariables(Variables variables, String... varNames) { Map<String, Object> results = new HashMap<>(); for (String varName : varNames) { WindupVertexFrame payload = null; try { payload = Iteration.getCurrentPayload(variables, null, varName); } catch (IllegalStateException | IllegalArgumentException e) { // oh well } if (payload != null) { results.put(varName, payload); } else { Iterable<? extends WindupVertexFrame> var = variables.findVariable(varName); if (var != null) { results.put(varName, var); } } } return results; }
[ "public", "static", "Map", "<", "String", ",", "Object", ">", "findFreeMarkerContextVariables", "(", "Variables", "variables", ",", "String", "...", "varNames", ")", "{", "Map", "<", "String", ",", "Object", ">", "results", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "String", "varName", ":", "varNames", ")", "{", "WindupVertexFrame", "payload", "=", "null", ";", "try", "{", "payload", "=", "Iteration", ".", "getCurrentPayload", "(", "variables", ",", "null", ",", "varName", ")", ";", "}", "catch", "(", "IllegalStateException", "|", "IllegalArgumentException", "e", ")", "{", "// oh well", "}", "if", "(", "payload", "!=", "null", ")", "{", "results", ".", "put", "(", "varName", ",", "payload", ")", ";", "}", "else", "{", "Iterable", "<", "?", "extends", "WindupVertexFrame", ">", "var", "=", "variables", ".", "findVariable", "(", "varName", ")", ";", "if", "(", "var", "!=", "null", ")", "{", "results", ".", "put", "(", "varName", ",", "var", ")", ";", "}", "}", "}", "return", "results", ";", "}" ]
Finds all variables in the context with the given names, and also attaches all WindupFreeMarkerMethods from all addons into the map. This allows external addons to extend the capabilities in the freemarker reporting system.
[ "Finds", "all", "variables", "in", "the", "context", "with", "the", "given", "names", "and", "also", "attaches", "all", "WindupFreeMarkerMethods", "from", "all", "addons", "into", "the", "map", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/freemarker/FreeMarkerUtil.java#L121-L151
159,770
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/service/ClassificationService.java
ClassificationService.attachLink
public ClassificationModel attachLink(ClassificationModel classificationModel, LinkModel linkModel) { for (LinkModel existing : classificationModel.getLinks()) { if (StringUtils.equals(existing.getLink(), linkModel.getLink())) { return classificationModel; } } classificationModel.addLink(linkModel); return classificationModel; }
java
public ClassificationModel attachLink(ClassificationModel classificationModel, LinkModel linkModel) { for (LinkModel existing : classificationModel.getLinks()) { if (StringUtils.equals(existing.getLink(), linkModel.getLink())) { return classificationModel; } } classificationModel.addLink(linkModel); return classificationModel; }
[ "public", "ClassificationModel", "attachLink", "(", "ClassificationModel", "classificationModel", ",", "LinkModel", "linkModel", ")", "{", "for", "(", "LinkModel", "existing", ":", "classificationModel", ".", "getLinks", "(", ")", ")", "{", "if", "(", "StringUtils", ".", "equals", "(", "existing", ".", "getLink", "(", ")", ",", "linkModel", ".", "getLink", "(", ")", ")", ")", "{", "return", "classificationModel", ";", "}", "}", "classificationModel", ".", "addLink", "(", "linkModel", ")", ";", "return", "classificationModel", ";", "}" ]
Attach the given link to the classification, while checking for duplicates.
[ "Attach", "the", "given", "link", "to", "the", "classification", "while", "checking", "for", "duplicates", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/ClassificationService.java#L317-L328
159,771
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/scan/provider/DiscoverMavenProjectsRuleProvider.java
DiscoverMavenProjectsRuleProvider.getMavenStubProject
private MavenProjectModel getMavenStubProject(MavenProjectService mavenProjectService, String groupId, String artifactId, String version) { Iterable<MavenProjectModel> mavenProjectModels = mavenProjectService.findByGroupArtifactVersion(groupId, artifactId, version); if (!mavenProjectModels.iterator().hasNext()) { return null; } for (MavenProjectModel mavenProjectModel : mavenProjectModels) { if (mavenProjectModel.getRootFileModel() == null) { // this is a stub... we can fill it in with details return mavenProjectModel; } } return null; }
java
private MavenProjectModel getMavenStubProject(MavenProjectService mavenProjectService, String groupId, String artifactId, String version) { Iterable<MavenProjectModel> mavenProjectModels = mavenProjectService.findByGroupArtifactVersion(groupId, artifactId, version); if (!mavenProjectModels.iterator().hasNext()) { return null; } for (MavenProjectModel mavenProjectModel : mavenProjectModels) { if (mavenProjectModel.getRootFileModel() == null) { // this is a stub... we can fill it in with details return mavenProjectModel; } } return null; }
[ "private", "MavenProjectModel", "getMavenStubProject", "(", "MavenProjectService", "mavenProjectService", ",", "String", "groupId", ",", "String", "artifactId", ",", "String", "version", ")", "{", "Iterable", "<", "MavenProjectModel", ">", "mavenProjectModels", "=", "mavenProjectService", ".", "findByGroupArtifactVersion", "(", "groupId", ",", "artifactId", ",", "version", ")", ";", "if", "(", "!", "mavenProjectModels", ".", "iterator", "(", ")", ".", "hasNext", "(", ")", ")", "{", "return", "null", ";", "}", "for", "(", "MavenProjectModel", "mavenProjectModel", ":", "mavenProjectModels", ")", "{", "if", "(", "mavenProjectModel", ".", "getRootFileModel", "(", ")", "==", "null", ")", "{", "// this is a stub... we can fill it in with details", "return", "mavenProjectModel", ";", "}", "}", "return", "null", ";", "}" ]
A Maven stub is a Maven Project for which we have found information, but the project has not yet been located within the input application. If we have found an application of the same GAV within the input app, we should fill out this stub instead of creating a new one.
[ "A", "Maven", "stub", "is", "a", "Maven", "Project", "for", "which", "we", "have", "found", "information", "but", "the", "project", "has", "not", "yet", "been", "located", "within", "the", "input", "application", ".", "If", "we", "have", "found", "an", "application", "of", "the", "same", "GAV", "within", "the", "input", "app", "we", "should", "fill", "out", "this", "stub", "instead", "of", "creating", "a", "new", "one", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/java/scan/provider/DiscoverMavenProjectsRuleProvider.java#L401-L417
159,772
windup/windup
utils/src/main/java/org/jboss/windup/util/PathUtil.java
PathUtil.getRootFolderForSource
public static Path getRootFolderForSource(Path sourceFilePath, String packageName) { if (packageName == null || packageName.trim().isEmpty()) { return sourceFilePath.getParent(); } String[] packageNameComponents = packageName.split("\\."); Path currentPath = sourceFilePath.getParent(); for (int i = packageNameComponents.length; i > 0; i--) { String packageComponent = packageNameComponents[i - 1]; if (!StringUtils.equals(packageComponent, currentPath.getFileName().toString())) { return null; } currentPath = currentPath.getParent(); } return currentPath; }
java
public static Path getRootFolderForSource(Path sourceFilePath, String packageName) { if (packageName == null || packageName.trim().isEmpty()) { return sourceFilePath.getParent(); } String[] packageNameComponents = packageName.split("\\."); Path currentPath = sourceFilePath.getParent(); for (int i = packageNameComponents.length; i > 0; i--) { String packageComponent = packageNameComponents[i - 1]; if (!StringUtils.equals(packageComponent, currentPath.getFileName().toString())) { return null; } currentPath = currentPath.getParent(); } return currentPath; }
[ "public", "static", "Path", "getRootFolderForSource", "(", "Path", "sourceFilePath", ",", "String", "packageName", ")", "{", "if", "(", "packageName", "==", "null", "||", "packageName", ".", "trim", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "sourceFilePath", ".", "getParent", "(", ")", ";", "}", "String", "[", "]", "packageNameComponents", "=", "packageName", ".", "split", "(", "\"\\\\.\"", ")", ";", "Path", "currentPath", "=", "sourceFilePath", ".", "getParent", "(", ")", ";", "for", "(", "int", "i", "=", "packageNameComponents", ".", "length", ";", "i", ">", "0", ";", "i", "--", ")", "{", "String", "packageComponent", "=", "packageNameComponents", "[", "i", "-", "1", "]", ";", "if", "(", "!", "StringUtils", ".", "equals", "(", "packageComponent", ",", "currentPath", ".", "getFileName", "(", ")", ".", "toString", "(", ")", ")", ")", "{", "return", "null", ";", "}", "currentPath", "=", "currentPath", ".", "getParent", "(", ")", ";", "}", "return", "currentPath", ";", "}" ]
Returns the root path for this source file, based upon the package name. For example, if path is "/project/src/main/java/org/example/Foo.java" and the package is "org.example", then this should return "/project/src/main/java". Returns null if the folder structure does not match the package name.
[ "Returns", "the", "root", "path", "for", "this", "source", "file", "based", "upon", "the", "package", "name", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/PathUtil.java#L213-L231
159,773
windup/windup
utils/src/main/java/org/jboss/windup/util/PathUtil.java
PathUtil.isInSubDirectory
public static boolean isInSubDirectory(File dir, File file) { if (file == null) return false; if (file.equals(dir)) return true; return isInSubDirectory(dir, file.getParentFile()); }
java
public static boolean isInSubDirectory(File dir, File file) { if (file == null) return false; if (file.equals(dir)) return true; return isInSubDirectory(dir, file.getParentFile()); }
[ "public", "static", "boolean", "isInSubDirectory", "(", "File", "dir", ",", "File", "file", ")", "{", "if", "(", "file", "==", "null", ")", "return", "false", ";", "if", "(", "file", ".", "equals", "(", "dir", ")", ")", "return", "true", ";", "return", "isInSubDirectory", "(", "dir", ",", "file", ".", "getParentFile", "(", ")", ")", ";", "}" ]
Returns true if "file" is a subfile or subdirectory of "dir". For example with the directory /path/to/a, the following return values would occur: /path/to/a/foo.txt - true /path/to/a/bar/zoo/boo/team.txt - true /path/to/b/foo.txt - false
[ "Returns", "true", "if", "file", "is", "a", "subfile", "or", "subdirectory", "of", "dir", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/PathUtil.java#L241-L250
159,774
windup/windup
utils/src/main/java/org/jboss/windup/util/PathUtil.java
PathUtil.createDirectory
public static void createDirectory(Path dir, String dirDesc) { try { Files.createDirectories(dir); } catch (IOException ex) { throw new WindupException("Error creating " + dirDesc + " folder: " + dir.toString() + " due to: " + ex.getMessage(), ex); } }
java
public static void createDirectory(Path dir, String dirDesc) { try { Files.createDirectories(dir); } catch (IOException ex) { throw new WindupException("Error creating " + dirDesc + " folder: " + dir.toString() + " due to: " + ex.getMessage(), ex); } }
[ "public", "static", "void", "createDirectory", "(", "Path", "dir", ",", "String", "dirDesc", ")", "{", "try", "{", "Files", ".", "createDirectories", "(", "dir", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "WindupException", "(", "\"Error creating \"", "+", "dirDesc", "+", "\" folder: \"", "+", "dir", ".", "toString", "(", ")", "+", "\" due to: \"", "+", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "}", "}" ]
Creates the given directory. Fails if it already exists.
[ "Creates", "the", "given", "directory", ".", "Fails", "if", "it", "already", "exists", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/utils/src/main/java/org/jboss/windup/util/PathUtil.java#L264-L274
159,775
windup/windup
java-ast/addon/src/main/java/org/jboss/windup/ast/java/ReferenceResolvingVisitor.java
ReferenceResolvingVisitor.processType
private ClassReference processType(Type type, TypeReferenceLocation typeReferenceLocation, int lineNumber, int columnNumber, int length, String line) { if (type == null) return null; ITypeBinding resolveBinding = type.resolveBinding(); if (resolveBinding == null) { ResolveClassnameResult resolvedResult = resolveClassname(type.toString()); ResolutionStatus status = resolvedResult.found ? ResolutionStatus.RECOVERED : ResolutionStatus.UNRESOLVED; PackageAndClassName packageAndClassName = PackageAndClassName.parseFromQualifiedName(resolvedResult.result); return processTypeAsString(resolvedResult.result, packageAndClassName.packageName, packageAndClassName.className, status, typeReferenceLocation, lineNumber, columnNumber, length, line); } else { return processTypeBinding(type.resolveBinding(), ResolutionStatus.RESOLVED, typeReferenceLocation, lineNumber, columnNumber, length, line); } }
java
private ClassReference processType(Type type, TypeReferenceLocation typeReferenceLocation, int lineNumber, int columnNumber, int length, String line) { if (type == null) return null; ITypeBinding resolveBinding = type.resolveBinding(); if (resolveBinding == null) { ResolveClassnameResult resolvedResult = resolveClassname(type.toString()); ResolutionStatus status = resolvedResult.found ? ResolutionStatus.RECOVERED : ResolutionStatus.UNRESOLVED; PackageAndClassName packageAndClassName = PackageAndClassName.parseFromQualifiedName(resolvedResult.result); return processTypeAsString(resolvedResult.result, packageAndClassName.packageName, packageAndClassName.className, status, typeReferenceLocation, lineNumber, columnNumber, length, line); } else { return processTypeBinding(type.resolveBinding(), ResolutionStatus.RESOLVED, typeReferenceLocation, lineNumber, columnNumber, length, line); } }
[ "private", "ClassReference", "processType", "(", "Type", "type", ",", "TypeReferenceLocation", "typeReferenceLocation", ",", "int", "lineNumber", ",", "int", "columnNumber", ",", "int", "length", ",", "String", "line", ")", "{", "if", "(", "type", "==", "null", ")", "return", "null", ";", "ITypeBinding", "resolveBinding", "=", "type", ".", "resolveBinding", "(", ")", ";", "if", "(", "resolveBinding", "==", "null", ")", "{", "ResolveClassnameResult", "resolvedResult", "=", "resolveClassname", "(", "type", ".", "toString", "(", ")", ")", ";", "ResolutionStatus", "status", "=", "resolvedResult", ".", "found", "?", "ResolutionStatus", ".", "RECOVERED", ":", "ResolutionStatus", ".", "UNRESOLVED", ";", "PackageAndClassName", "packageAndClassName", "=", "PackageAndClassName", ".", "parseFromQualifiedName", "(", "resolvedResult", ".", "result", ")", ";", "return", "processTypeAsString", "(", "resolvedResult", ".", "result", ",", "packageAndClassName", ".", "packageName", ",", "packageAndClassName", ".", "className", ",", "status", ",", "typeReferenceLocation", ",", "lineNumber", ",", "columnNumber", ",", "length", ",", "line", ")", ";", "}", "else", "{", "return", "processTypeBinding", "(", "type", ".", "resolveBinding", "(", ")", ",", "ResolutionStatus", ".", "RESOLVED", ",", "typeReferenceLocation", ",", "lineNumber", ",", "columnNumber", ",", "length", ",", "line", ")", ";", "}", "}" ]
The method determines if the type can be resolved and if not, will try to guess the qualified name using the information from the imports.
[ "The", "method", "determines", "if", "the", "type", "can", "be", "resolved", "and", "if", "not", "will", "try", "to", "guess", "the", "qualified", "name", "using", "the", "information", "from", "the", "imports", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/java-ast/addon/src/main/java/org/jboss/windup/ast/java/ReferenceResolvingVisitor.java#L299-L322
159,776
windup/windup
java-ast/addon/src/main/java/org/jboss/windup/ast/java/ReferenceResolvingVisitor.java
ReferenceResolvingVisitor.addAnnotationValues
private void addAnnotationValues(ClassReference annotatedReference, AnnotationClassReference typeRef, Annotation node) { Map<String, AnnotationValue> annotationValueMap = new HashMap<>(); if (node instanceof SingleMemberAnnotation) { SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) node; AnnotationValue value = getAnnotationValueForExpression(annotatedReference, singleMemberAnnotation.getValue()); annotationValueMap.put("value", value); } else if (node instanceof NormalAnnotation) { @SuppressWarnings("unchecked") List<MemberValuePair> annotationValues = ((NormalAnnotation) node).values(); for (MemberValuePair annotationValue : annotationValues) { String key = annotationValue.getName().toString(); Expression expression = annotationValue.getValue(); AnnotationValue value = getAnnotationValueForExpression(annotatedReference, expression); annotationValueMap.put(key, value); } } typeRef.setAnnotationValues(annotationValueMap); }
java
private void addAnnotationValues(ClassReference annotatedReference, AnnotationClassReference typeRef, Annotation node) { Map<String, AnnotationValue> annotationValueMap = new HashMap<>(); if (node instanceof SingleMemberAnnotation) { SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) node; AnnotationValue value = getAnnotationValueForExpression(annotatedReference, singleMemberAnnotation.getValue()); annotationValueMap.put("value", value); } else if (node instanceof NormalAnnotation) { @SuppressWarnings("unchecked") List<MemberValuePair> annotationValues = ((NormalAnnotation) node).values(); for (MemberValuePair annotationValue : annotationValues) { String key = annotationValue.getName().toString(); Expression expression = annotationValue.getValue(); AnnotationValue value = getAnnotationValueForExpression(annotatedReference, expression); annotationValueMap.put(key, value); } } typeRef.setAnnotationValues(annotationValueMap); }
[ "private", "void", "addAnnotationValues", "(", "ClassReference", "annotatedReference", ",", "AnnotationClassReference", "typeRef", ",", "Annotation", "node", ")", "{", "Map", "<", "String", ",", "AnnotationValue", ">", "annotationValueMap", "=", "new", "HashMap", "<>", "(", ")", ";", "if", "(", "node", "instanceof", "SingleMemberAnnotation", ")", "{", "SingleMemberAnnotation", "singleMemberAnnotation", "=", "(", "SingleMemberAnnotation", ")", "node", ";", "AnnotationValue", "value", "=", "getAnnotationValueForExpression", "(", "annotatedReference", ",", "singleMemberAnnotation", ".", "getValue", "(", ")", ")", ";", "annotationValueMap", ".", "put", "(", "\"value\"", ",", "value", ")", ";", "}", "else", "if", "(", "node", "instanceof", "NormalAnnotation", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "MemberValuePair", ">", "annotationValues", "=", "(", "(", "NormalAnnotation", ")", "node", ")", ".", "values", "(", ")", ";", "for", "(", "MemberValuePair", "annotationValue", ":", "annotationValues", ")", "{", "String", "key", "=", "annotationValue", ".", "getName", "(", ")", ".", "toString", "(", ")", ";", "Expression", "expression", "=", "annotationValue", ".", "getValue", "(", ")", ";", "AnnotationValue", "value", "=", "getAnnotationValueForExpression", "(", "annotatedReference", ",", "expression", ")", ";", "annotationValueMap", ".", "put", "(", "key", ",", "value", ")", ";", "}", "}", "typeRef", ".", "setAnnotationValues", "(", "annotationValueMap", ")", ";", "}" ]
Adds parameters contained in the annotation into the annotation type reference @param typeRef @param node
[ "Adds", "parameters", "contained", "in", "the", "annotation", "into", "the", "annotation", "type", "reference" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/java-ast/addon/src/main/java/org/jboss/windup/ast/java/ReferenceResolvingVisitor.java#L668-L690
159,777
windup/windup
java-ast/addon/src/main/java/org/jboss/windup/ast/java/ReferenceResolvingVisitor.java
ReferenceResolvingVisitor.visit
@Override public boolean visit(VariableDeclarationStatement node) { for (int i = 0; i < node.fragments().size(); ++i) { String nodeType = node.getType().toString(); VariableDeclarationFragment frag = (VariableDeclarationFragment) node.fragments().get(i); state.getNames().add(frag.getName().getIdentifier()); state.getNameInstance().put(frag.getName().toString(), nodeType.toString()); } processType(node.getType(), TypeReferenceLocation.VARIABLE_DECLARATION, compilationUnit.getLineNumber(node.getStartPosition()), compilationUnit.getColumnNumber(node.getStartPosition()), node.getLength(), node.toString()); return super.visit(node); }
java
@Override public boolean visit(VariableDeclarationStatement node) { for (int i = 0; i < node.fragments().size(); ++i) { String nodeType = node.getType().toString(); VariableDeclarationFragment frag = (VariableDeclarationFragment) node.fragments().get(i); state.getNames().add(frag.getName().getIdentifier()); state.getNameInstance().put(frag.getName().toString(), nodeType.toString()); } processType(node.getType(), TypeReferenceLocation.VARIABLE_DECLARATION, compilationUnit.getLineNumber(node.getStartPosition()), compilationUnit.getColumnNumber(node.getStartPosition()), node.getLength(), node.toString()); return super.visit(node); }
[ "@", "Override", "public", "boolean", "visit", "(", "VariableDeclarationStatement", "node", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "node", ".", "fragments", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "String", "nodeType", "=", "node", ".", "getType", "(", ")", ".", "toString", "(", ")", ";", "VariableDeclarationFragment", "frag", "=", "(", "VariableDeclarationFragment", ")", "node", ".", "fragments", "(", ")", ".", "get", "(", "i", ")", ";", "state", ".", "getNames", "(", ")", ".", "add", "(", "frag", ".", "getName", "(", ")", ".", "getIdentifier", "(", ")", ")", ";", "state", ".", "getNameInstance", "(", ")", ".", "put", "(", "frag", ".", "getName", "(", ")", ".", "toString", "(", ")", ",", "nodeType", ".", "toString", "(", ")", ")", ";", "}", "processType", "(", "node", ".", "getType", "(", ")", ",", "TypeReferenceLocation", ".", "VARIABLE_DECLARATION", ",", "compilationUnit", ".", "getLineNumber", "(", "node", ".", "getStartPosition", "(", ")", ")", ",", "compilationUnit", ".", "getColumnNumber", "(", "node", ".", "getStartPosition", "(", ")", ")", ",", "node", ".", "getLength", "(", ")", ",", "node", ".", "toString", "(", ")", ")", ";", "return", "super", ".", "visit", "(", "node", ")", ";", "}" ]
Declaration of the variable within a block
[ "Declaration", "of", "the", "variable", "within", "a", "block" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/java-ast/addon/src/main/java/org/jboss/windup/ast/java/ReferenceResolvingVisitor.java#L925-L940
159,778
windup/windup
config/api/src/main/java/org/jboss/windup/config/query/Query.java
Query.excludingType
@Override public QueryBuilderFind excludingType(final Class<? extends WindupVertexFrame> type) { pipelineCriteria.add(new QueryGremlinCriterion() { @Override public void query(GraphRewrite event, GraphTraversal<?, Vertex> pipeline) { pipeline.filter(it -> !GraphTypeManager.hasType(type, it.get())); } }); return this; }
java
@Override public QueryBuilderFind excludingType(final Class<? extends WindupVertexFrame> type) { pipelineCriteria.add(new QueryGremlinCriterion() { @Override public void query(GraphRewrite event, GraphTraversal<?, Vertex> pipeline) { pipeline.filter(it -> !GraphTypeManager.hasType(type, it.get())); } }); return this; }
[ "@", "Override", "public", "QueryBuilderFind", "excludingType", "(", "final", "Class", "<", "?", "extends", "WindupVertexFrame", ">", "type", ")", "{", "pipelineCriteria", ".", "add", "(", "new", "QueryGremlinCriterion", "(", ")", "{", "@", "Override", "public", "void", "query", "(", "GraphRewrite", "event", ",", "GraphTraversal", "<", "?", ",", "Vertex", ">", "pipeline", ")", "{", "pipeline", ".", "filter", "(", "it", "->", "!", "GraphTypeManager", ".", "hasType", "(", "type", ",", "it", ".", "get", "(", ")", ")", ")", ";", "}", "}", ")", ";", "return", "this", ";", "}" ]
Excludes Vertices that are of the provided type.
[ "Excludes", "Vertices", "that", "are", "of", "the", "provided", "type", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/query/Query.java#L71-L83
159,779
windup/windup
reporting/impl/src/main/java/org/jboss/windup/reporting/rules/rendering/CssJsResourceRenderingRuleProvider.java
CssJsResourceRenderingRuleProvider.addonDependsOnReporting
private boolean addonDependsOnReporting(Addon addon) { for (AddonDependency dep : addon.getDependencies()) { if (dep.getDependency().equals(this.addon)) { return true; } boolean subDep = addonDependsOnReporting(dep.getDependency()); if (subDep) { return true; } } return false; }
java
private boolean addonDependsOnReporting(Addon addon) { for (AddonDependency dep : addon.getDependencies()) { if (dep.getDependency().equals(this.addon)) { return true; } boolean subDep = addonDependsOnReporting(dep.getDependency()); if (subDep) { return true; } } return false; }
[ "private", "boolean", "addonDependsOnReporting", "(", "Addon", "addon", ")", "{", "for", "(", "AddonDependency", "dep", ":", "addon", ".", "getDependencies", "(", ")", ")", "{", "if", "(", "dep", ".", "getDependency", "(", ")", ".", "equals", "(", "this", ".", "addon", ")", ")", "{", "return", "true", ";", "}", "boolean", "subDep", "=", "addonDependsOnReporting", "(", "dep", ".", "getDependency", "(", ")", ")", ";", "if", "(", "subDep", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if the addon depends on reporting.
[ "Returns", "true", "if", "the", "addon", "depends", "on", "reporting", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/impl/src/main/java/org/jboss/windup/reporting/rules/rendering/CssJsResourceRenderingRuleProvider.java#L163-L178
159,780
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/service/TagGraphService.java
TagGraphService.getSingleParent
public static TagModel getSingleParent(TagModel tag) { final Iterator<TagModel> parents = tag.getDesignatedByTags().iterator(); if (!parents.hasNext()) throw new WindupException("Tag is not designated by any tags: " + tag); final TagModel maybeOnlyParent = parents.next(); if (parents.hasNext()) { StringBuilder sb = new StringBuilder(); tag.getDesignatedByTags().iterator().forEachRemaining(x -> sb.append(x).append(", ")); throw new WindupException(String.format("Tag %s is designated by multiple tags: %s", tag, sb.toString())); } return maybeOnlyParent; }
java
public static TagModel getSingleParent(TagModel tag) { final Iterator<TagModel> parents = tag.getDesignatedByTags().iterator(); if (!parents.hasNext()) throw new WindupException("Tag is not designated by any tags: " + tag); final TagModel maybeOnlyParent = parents.next(); if (parents.hasNext()) { StringBuilder sb = new StringBuilder(); tag.getDesignatedByTags().iterator().forEachRemaining(x -> sb.append(x).append(", ")); throw new WindupException(String.format("Tag %s is designated by multiple tags: %s", tag, sb.toString())); } return maybeOnlyParent; }
[ "public", "static", "TagModel", "getSingleParent", "(", "TagModel", "tag", ")", "{", "final", "Iterator", "<", "TagModel", ">", "parents", "=", "tag", ".", "getDesignatedByTags", "(", ")", ".", "iterator", "(", ")", ";", "if", "(", "!", "parents", ".", "hasNext", "(", ")", ")", "throw", "new", "WindupException", "(", "\"Tag is not designated by any tags: \"", "+", "tag", ")", ";", "final", "TagModel", "maybeOnlyParent", "=", "parents", ".", "next", "(", ")", ";", "if", "(", "parents", ".", "hasNext", "(", ")", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "tag", ".", "getDesignatedByTags", "(", ")", ".", "iterator", "(", ")", ".", "forEachRemaining", "(", "x", "->", "sb", ".", "append", "(", "x", ")", ".", "append", "(", "\", \"", ")", ")", ";", "throw", "new", "WindupException", "(", "String", ".", "format", "(", "\"Tag %s is designated by multiple tags: %s\"", ",", "tag", ",", "sb", ".", "toString", "(", ")", ")", ")", ";", "}", "return", "maybeOnlyParent", ";", "}" ]
Returns a single parent of the given tag. If there are multiple parents, throws a WindupException.
[ "Returns", "a", "single", "parent", "of", "the", "given", "tag", ".", "If", "there", "are", "multiple", "parents", "throws", "a", "WindupException", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/TagGraphService.java#L168-L183
159,781
windup/windup
config/api/src/main/java/org/jboss/windup/config/query/QueryTypeCriterion.java
QueryTypeCriterion.addPipeFor
public static GraphTraversal<Vertex, Vertex> addPipeFor(GraphTraversal<Vertex, Vertex> pipeline, Class<? extends WindupVertexFrame> clazz) { pipeline.has(WindupVertexFrame.TYPE_PROP, GraphTypeManager.getTypeValue(clazz)); return pipeline; }
java
public static GraphTraversal<Vertex, Vertex> addPipeFor(GraphTraversal<Vertex, Vertex> pipeline, Class<? extends WindupVertexFrame> clazz) { pipeline.has(WindupVertexFrame.TYPE_PROP, GraphTypeManager.getTypeValue(clazz)); return pipeline; }
[ "public", "static", "GraphTraversal", "<", "Vertex", ",", "Vertex", ">", "addPipeFor", "(", "GraphTraversal", "<", "Vertex", ",", "Vertex", ">", "pipeline", ",", "Class", "<", "?", "extends", "WindupVertexFrame", ">", "clazz", ")", "{", "pipeline", ".", "has", "(", "WindupVertexFrame", ".", "TYPE_PROP", ",", "GraphTypeManager", ".", "getTypeValue", "(", "clazz", ")", ")", ";", "return", "pipeline", ";", "}" ]
Adds a criterion to given pipeline which filters out vertices representing given WindupVertexFrame.
[ "Adds", "a", "criterion", "to", "given", "pipeline", "which", "filters", "out", "vertices", "representing", "given", "WindupVertexFrame", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/query/QueryTypeCriterion.java#L35-L40
159,782
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/TagUtil.java
TagUtil.strictCheckMatchingTags
public static boolean strictCheckMatchingTags(Collection<String> tags, Set<String> includeTags, Set<String> excludeTags) { boolean includeTagsEnabled = !includeTags.isEmpty(); for (String tag : tags) { boolean isIncluded = includeTags.contains(tag); boolean isExcluded = excludeTags.contains(tag); if ((includeTagsEnabled && isIncluded) || (!includeTagsEnabled && !isExcluded)) { return true; } } return false; }
java
public static boolean strictCheckMatchingTags(Collection<String> tags, Set<String> includeTags, Set<String> excludeTags) { boolean includeTagsEnabled = !includeTags.isEmpty(); for (String tag : tags) { boolean isIncluded = includeTags.contains(tag); boolean isExcluded = excludeTags.contains(tag); if ((includeTagsEnabled && isIncluded) || (!includeTagsEnabled && !isExcluded)) { return true; } } return false; }
[ "public", "static", "boolean", "strictCheckMatchingTags", "(", "Collection", "<", "String", ">", "tags", ",", "Set", "<", "String", ">", "includeTags", ",", "Set", "<", "String", ">", "excludeTags", ")", "{", "boolean", "includeTagsEnabled", "=", "!", "includeTags", ".", "isEmpty", "(", ")", ";", "for", "(", "String", "tag", ":", "tags", ")", "{", "boolean", "isIncluded", "=", "includeTags", ".", "contains", "(", "tag", ")", ";", "boolean", "isExcluded", "=", "excludeTags", ".", "contains", "(", "tag", ")", ";", "if", "(", "(", "includeTagsEnabled", "&&", "isIncluded", ")", "||", "(", "!", "includeTagsEnabled", "&&", "!", "isExcluded", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if - includeTags is not empty and tag is in includeTags - includeTags is empty and tag is not in excludeTags @param tags Hint tags @param includeTags Include tags @param excludeTags Exclude tags @return has tag match
[ "Returns", "true", "if", "-", "includeTags", "is", "not", "empty", "and", "tag", "is", "in", "includeTags", "-", "includeTags", "is", "empty", "and", "tag", "is", "not", "in", "excludeTags" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/TagUtil.java#L35-L51
159,783
windup/windup
bootstrap/src/main/java/org/jboss/windup/bootstrap/commands/windup/RunWindupCommand.java
RunWindupCommand.expandMultiAppInputDirs
private static List<Path> expandMultiAppInputDirs(List<Path> input) { List<Path> expanded = new LinkedList<>(); for (Path path : input) { if (Files.isRegularFile(path)) { expanded.add(path); continue; } if (!Files.isDirectory(path)) { String pathString = (path == null) ? "" : path.toString(); log.warning("Neither a file or directory found in input: " + pathString); continue; } try { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) { for (Path subpath : directoryStream) { if (isJavaArchive(subpath)) { expanded.add(subpath); } } } } catch (IOException e) { throw new WindupException("Failed to read directory contents of: " + path); } } return expanded; }
java
private static List<Path> expandMultiAppInputDirs(List<Path> input) { List<Path> expanded = new LinkedList<>(); for (Path path : input) { if (Files.isRegularFile(path)) { expanded.add(path); continue; } if (!Files.isDirectory(path)) { String pathString = (path == null) ? "" : path.toString(); log.warning("Neither a file or directory found in input: " + pathString); continue; } try { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) { for (Path subpath : directoryStream) { if (isJavaArchive(subpath)) { expanded.add(subpath); } } } } catch (IOException e) { throw new WindupException("Failed to read directory contents of: " + path); } } return expanded; }
[ "private", "static", "List", "<", "Path", ">", "expandMultiAppInputDirs", "(", "List", "<", "Path", ">", "input", ")", "{", "List", "<", "Path", ">", "expanded", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "Path", "path", ":", "input", ")", "{", "if", "(", "Files", ".", "isRegularFile", "(", "path", ")", ")", "{", "expanded", ".", "add", "(", "path", ")", ";", "continue", ";", "}", "if", "(", "!", "Files", ".", "isDirectory", "(", "path", ")", ")", "{", "String", "pathString", "=", "(", "path", "==", "null", ")", "?", "\"\"", ":", "path", ".", "toString", "(", ")", ";", "log", ".", "warning", "(", "\"Neither a file or directory found in input: \"", "+", "pathString", ")", ";", "continue", ";", "}", "try", "{", "try", "(", "DirectoryStream", "<", "Path", ">", "directoryStream", "=", "Files", ".", "newDirectoryStream", "(", "path", ")", ")", "{", "for", "(", "Path", "subpath", ":", "directoryStream", ")", "{", "if", "(", "isJavaArchive", "(", "subpath", ")", ")", "{", "expanded", ".", "add", "(", "subpath", ")", ";", "}", "}", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "WindupException", "(", "\"Failed to read directory contents of: \"", "+", "path", ")", ";", "}", "}", "return", "expanded", ";", "}" ]
Expands the directories from the given list and and returns a list of subfiles. Files from the original list are kept as is.
[ "Expands", "the", "directories", "from", "the", "given", "list", "and", "and", "returns", "a", "list", "of", "subfiles", ".", "Files", "from", "the", "original", "list", "are", "kept", "as", "is", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/bootstrap/src/main/java/org/jboss/windup/bootstrap/commands/windup/RunWindupCommand.java#L485-L522
159,784
windup/windup
config/api/src/main/java/org/jboss/windup/config/RuleUtils.java
RuleUtils.ruleToRuleContentsString
public static String ruleToRuleContentsString(Rule originalRule, int indentLevel) { if (originalRule instanceof Context && ((Context) originalRule).containsKey(RuleMetadataType.RULE_XML)) { return (String) ((Context) originalRule).get(RuleMetadataType.RULE_XML); } if (!(originalRule instanceof RuleBuilder)) { return wrap(originalRule.toString(), MAX_WIDTH, indentLevel); } final RuleBuilder rule = (RuleBuilder) originalRule; StringBuilder result = new StringBuilder(); if (indentLevel == 0) result.append("addRule()"); for (Condition condition : rule.getConditions()) { String conditionToString = conditionToString(condition, indentLevel + 1); if (!conditionToString.isEmpty()) { result.append(System.lineSeparator()); insertPadding(result, indentLevel + 1); result.append(".when(").append(wrap(conditionToString, MAX_WIDTH, indentLevel + 2)).append(")"); } } for (Operation operation : rule.getOperations()) { String operationToString = operationToString(operation, indentLevel + 1); if (!operationToString.isEmpty()) { result.append(System.lineSeparator()); insertPadding(result, indentLevel + 1); result.append(".perform(").append(wrap(operationToString, MAX_WIDTH, indentLevel + 2)).append(")"); } } if (rule.getId() != null && !rule.getId().isEmpty()) { result.append(System.lineSeparator()); insertPadding(result, indentLevel); result.append("withId(\"").append(rule.getId()).append("\")"); } if (rule.priority() != 0) { result.append(System.lineSeparator()); insertPadding(result, indentLevel); result.append(".withPriority(").append(rule.priority()).append(")"); } return result.toString(); }
java
public static String ruleToRuleContentsString(Rule originalRule, int indentLevel) { if (originalRule instanceof Context && ((Context) originalRule).containsKey(RuleMetadataType.RULE_XML)) { return (String) ((Context) originalRule).get(RuleMetadataType.RULE_XML); } if (!(originalRule instanceof RuleBuilder)) { return wrap(originalRule.toString(), MAX_WIDTH, indentLevel); } final RuleBuilder rule = (RuleBuilder) originalRule; StringBuilder result = new StringBuilder(); if (indentLevel == 0) result.append("addRule()"); for (Condition condition : rule.getConditions()) { String conditionToString = conditionToString(condition, indentLevel + 1); if (!conditionToString.isEmpty()) { result.append(System.lineSeparator()); insertPadding(result, indentLevel + 1); result.append(".when(").append(wrap(conditionToString, MAX_WIDTH, indentLevel + 2)).append(")"); } } for (Operation operation : rule.getOperations()) { String operationToString = operationToString(operation, indentLevel + 1); if (!operationToString.isEmpty()) { result.append(System.lineSeparator()); insertPadding(result, indentLevel + 1); result.append(".perform(").append(wrap(operationToString, MAX_WIDTH, indentLevel + 2)).append(")"); } } if (rule.getId() != null && !rule.getId().isEmpty()) { result.append(System.lineSeparator()); insertPadding(result, indentLevel); result.append("withId(\"").append(rule.getId()).append("\")"); } if (rule.priority() != 0) { result.append(System.lineSeparator()); insertPadding(result, indentLevel); result.append(".withPriority(").append(rule.priority()).append(")"); } return result.toString(); }
[ "public", "static", "String", "ruleToRuleContentsString", "(", "Rule", "originalRule", ",", "int", "indentLevel", ")", "{", "if", "(", "originalRule", "instanceof", "Context", "&&", "(", "(", "Context", ")", "originalRule", ")", ".", "containsKey", "(", "RuleMetadataType", ".", "RULE_XML", ")", ")", "{", "return", "(", "String", ")", "(", "(", "Context", ")", "originalRule", ")", ".", "get", "(", "RuleMetadataType", ".", "RULE_XML", ")", ";", "}", "if", "(", "!", "(", "originalRule", "instanceof", "RuleBuilder", ")", ")", "{", "return", "wrap", "(", "originalRule", ".", "toString", "(", ")", ",", "MAX_WIDTH", ",", "indentLevel", ")", ";", "}", "final", "RuleBuilder", "rule", "=", "(", "RuleBuilder", ")", "originalRule", ";", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "indentLevel", "==", "0", ")", "result", ".", "append", "(", "\"addRule()\"", ")", ";", "for", "(", "Condition", "condition", ":", "rule", ".", "getConditions", "(", ")", ")", "{", "String", "conditionToString", "=", "conditionToString", "(", "condition", ",", "indentLevel", "+", "1", ")", ";", "if", "(", "!", "conditionToString", ".", "isEmpty", "(", ")", ")", "{", "result", ".", "append", "(", "System", ".", "lineSeparator", "(", ")", ")", ";", "insertPadding", "(", "result", ",", "indentLevel", "+", "1", ")", ";", "result", ".", "append", "(", "\".when(\"", ")", ".", "append", "(", "wrap", "(", "conditionToString", ",", "MAX_WIDTH", ",", "indentLevel", "+", "2", ")", ")", ".", "append", "(", "\")\"", ")", ";", "}", "}", "for", "(", "Operation", "operation", ":", "rule", ".", "getOperations", "(", ")", ")", "{", "String", "operationToString", "=", "operationToString", "(", "operation", ",", "indentLevel", "+", "1", ")", ";", "if", "(", "!", "operationToString", ".", "isEmpty", "(", ")", ")", "{", "result", ".", "append", "(", "System", ".", "lineSeparator", "(", ")", ")", ";", "insertPadding", "(", "result", ",", "indentLevel", "+", "1", ")", ";", "result", ".", "append", "(", "\".perform(\"", ")", ".", "append", "(", "wrap", "(", "operationToString", ",", "MAX_WIDTH", ",", "indentLevel", "+", "2", ")", ")", ".", "append", "(", "\")\"", ")", ";", "}", "}", "if", "(", "rule", ".", "getId", "(", ")", "!=", "null", "&&", "!", "rule", ".", "getId", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "result", ".", "append", "(", "System", ".", "lineSeparator", "(", ")", ")", ";", "insertPadding", "(", "result", ",", "indentLevel", ")", ";", "result", ".", "append", "(", "\"withId(\\\"\"", ")", ".", "append", "(", "rule", ".", "getId", "(", ")", ")", ".", "append", "(", "\"\\\")\"", ")", ";", "}", "if", "(", "rule", ".", "priority", "(", ")", "!=", "0", ")", "{", "result", ".", "append", "(", "System", ".", "lineSeparator", "(", ")", ")", ";", "insertPadding", "(", "result", ",", "indentLevel", ")", ";", "result", ".", "append", "(", "\".withPriority(\"", ")", ".", "append", "(", "rule", ".", "priority", "(", ")", ")", ".", "append", "(", "\")\"", ")", ";", "}", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Attempts to create a human-readable String representation of the provided rule.
[ "Attempts", "to", "create", "a", "human", "-", "readable", "String", "representation", "of", "the", "provided", "rule", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/RuleUtils.java#L54-L106
159,785
windup/windup
graph/impl/src/main/java/org/jboss/windup/graph/SetInPropertiesHandler.java
SetInPropertiesHandler.processMethod
@Override public <E> DynamicType.Builder<E> processMethod(final DynamicType.Builder<E> builder, final Method method, final Annotation annotation) { String methodName = method.getName(); if (ReflectionUtility.isGetMethod(method)) return createInterceptor(builder, method); else if (ReflectionUtility.isSetMethod(method)) return createInterceptor(builder, method); else if (methodName.startsWith("addAll")) return createInterceptor(builder, method); else if (methodName.startsWith("add")) return createInterceptor(builder, method); else throw new WindupException("Only get*, set*, add*, and addAll* method names are supported for @" + SetInProperties.class.getSimpleName() + ", found at: " + method.getName()); }
java
@Override public <E> DynamicType.Builder<E> processMethod(final DynamicType.Builder<E> builder, final Method method, final Annotation annotation) { String methodName = method.getName(); if (ReflectionUtility.isGetMethod(method)) return createInterceptor(builder, method); else if (ReflectionUtility.isSetMethod(method)) return createInterceptor(builder, method); else if (methodName.startsWith("addAll")) return createInterceptor(builder, method); else if (methodName.startsWith("add")) return createInterceptor(builder, method); else throw new WindupException("Only get*, set*, add*, and addAll* method names are supported for @" + SetInProperties.class.getSimpleName() + ", found at: " + method.getName()); }
[ "@", "Override", "public", "<", "E", ">", "DynamicType", ".", "Builder", "<", "E", ">", "processMethod", "(", "final", "DynamicType", ".", "Builder", "<", "E", ">", "builder", ",", "final", "Method", "method", ",", "final", "Annotation", "annotation", ")", "{", "String", "methodName", "=", "method", ".", "getName", "(", ")", ";", "if", "(", "ReflectionUtility", ".", "isGetMethod", "(", "method", ")", ")", "return", "createInterceptor", "(", "builder", ",", "method", ")", ";", "else", "if", "(", "ReflectionUtility", ".", "isSetMethod", "(", "method", ")", ")", "return", "createInterceptor", "(", "builder", ",", "method", ")", ";", "else", "if", "(", "methodName", ".", "startsWith", "(", "\"addAll\"", ")", ")", "return", "createInterceptor", "(", "builder", ",", "method", ")", ";", "else", "if", "(", "methodName", ".", "startsWith", "(", "\"add\"", ")", ")", "return", "createInterceptor", "(", "builder", ",", "method", ")", ";", "else", "throw", "new", "WindupException", "(", "\"Only get*, set*, add*, and addAll* method names are supported for @\"", "+", "SetInProperties", ".", "class", ".", "getSimpleName", "(", ")", "+", "\", found at: \"", "+", "method", ".", "getName", "(", ")", ")", ";", "}" ]
The handling method.
[ "The", "handling", "method", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/graph/impl/src/main/java/org/jboss/windup/graph/SetInPropertiesHandler.java#L46-L61
159,786
windup/windup
rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/JNDIResourceService.java
JNDIResourceService.associateTypeJndiResource
public void associateTypeJndiResource(JNDIResourceModel resource, String type) { if (type == null || resource == null) { return; } if (StringUtils.equals(type, "javax.sql.DataSource") && !(resource instanceof DataSourceModel)) { DataSourceModel ds = GraphService.addTypeToModel(this.getGraphContext(), resource, DataSourceModel.class); } else if (StringUtils.equals(type, "javax.jms.Queue") && !(resource instanceof JmsDestinationModel)) { JmsDestinationModel jms = GraphService.addTypeToModel(this.getGraphContext(), resource, JmsDestinationModel.class); jms.setDestinationType(JmsDestinationType.QUEUE); } else if (StringUtils.equals(type, "javax.jms.QueueConnectionFactory") && !(resource instanceof JmsConnectionFactoryModel)) { JmsConnectionFactoryModel jms = GraphService.addTypeToModel(this.getGraphContext(), resource, JmsConnectionFactoryModel.class); jms.setConnectionFactoryType(JmsDestinationType.QUEUE); } else if (StringUtils.equals(type, "javax.jms.Topic") && !(resource instanceof JmsDestinationModel)) { JmsDestinationModel jms = GraphService.addTypeToModel(this.getGraphContext(), resource, JmsDestinationModel.class); jms.setDestinationType(JmsDestinationType.TOPIC); } else if (StringUtils.equals(type, "javax.jms.TopicConnectionFactory") && !(resource instanceof JmsConnectionFactoryModel)) { JmsConnectionFactoryModel jms = GraphService.addTypeToModel(this.getGraphContext(), resource, JmsConnectionFactoryModel.class); jms.setConnectionFactoryType(JmsDestinationType.TOPIC); } }
java
public void associateTypeJndiResource(JNDIResourceModel resource, String type) { if (type == null || resource == null) { return; } if (StringUtils.equals(type, "javax.sql.DataSource") && !(resource instanceof DataSourceModel)) { DataSourceModel ds = GraphService.addTypeToModel(this.getGraphContext(), resource, DataSourceModel.class); } else if (StringUtils.equals(type, "javax.jms.Queue") && !(resource instanceof JmsDestinationModel)) { JmsDestinationModel jms = GraphService.addTypeToModel(this.getGraphContext(), resource, JmsDestinationModel.class); jms.setDestinationType(JmsDestinationType.QUEUE); } else if (StringUtils.equals(type, "javax.jms.QueueConnectionFactory") && !(resource instanceof JmsConnectionFactoryModel)) { JmsConnectionFactoryModel jms = GraphService.addTypeToModel(this.getGraphContext(), resource, JmsConnectionFactoryModel.class); jms.setConnectionFactoryType(JmsDestinationType.QUEUE); } else if (StringUtils.equals(type, "javax.jms.Topic") && !(resource instanceof JmsDestinationModel)) { JmsDestinationModel jms = GraphService.addTypeToModel(this.getGraphContext(), resource, JmsDestinationModel.class); jms.setDestinationType(JmsDestinationType.TOPIC); } else if (StringUtils.equals(type, "javax.jms.TopicConnectionFactory") && !(resource instanceof JmsConnectionFactoryModel)) { JmsConnectionFactoryModel jms = GraphService.addTypeToModel(this.getGraphContext(), resource, JmsConnectionFactoryModel.class); jms.setConnectionFactoryType(JmsDestinationType.TOPIC); } }
[ "public", "void", "associateTypeJndiResource", "(", "JNDIResourceModel", "resource", ",", "String", "type", ")", "{", "if", "(", "type", "==", "null", "||", "resource", "==", "null", ")", "{", "return", ";", "}", "if", "(", "StringUtils", ".", "equals", "(", "type", ",", "\"javax.sql.DataSource\"", ")", "&&", "!", "(", "resource", "instanceof", "DataSourceModel", ")", ")", "{", "DataSourceModel", "ds", "=", "GraphService", ".", "addTypeToModel", "(", "this", ".", "getGraphContext", "(", ")", ",", "resource", ",", "DataSourceModel", ".", "class", ")", ";", "}", "else", "if", "(", "StringUtils", ".", "equals", "(", "type", ",", "\"javax.jms.Queue\"", ")", "&&", "!", "(", "resource", "instanceof", "JmsDestinationModel", ")", ")", "{", "JmsDestinationModel", "jms", "=", "GraphService", ".", "addTypeToModel", "(", "this", ".", "getGraphContext", "(", ")", ",", "resource", ",", "JmsDestinationModel", ".", "class", ")", ";", "jms", ".", "setDestinationType", "(", "JmsDestinationType", ".", "QUEUE", ")", ";", "}", "else", "if", "(", "StringUtils", ".", "equals", "(", "type", ",", "\"javax.jms.QueueConnectionFactory\"", ")", "&&", "!", "(", "resource", "instanceof", "JmsConnectionFactoryModel", ")", ")", "{", "JmsConnectionFactoryModel", "jms", "=", "GraphService", ".", "addTypeToModel", "(", "this", ".", "getGraphContext", "(", ")", ",", "resource", ",", "JmsConnectionFactoryModel", ".", "class", ")", ";", "jms", ".", "setConnectionFactoryType", "(", "JmsDestinationType", ".", "QUEUE", ")", ";", "}", "else", "if", "(", "StringUtils", ".", "equals", "(", "type", ",", "\"javax.jms.Topic\"", ")", "&&", "!", "(", "resource", "instanceof", "JmsDestinationModel", ")", ")", "{", "JmsDestinationModel", "jms", "=", "GraphService", ".", "addTypeToModel", "(", "this", ".", "getGraphContext", "(", ")", ",", "resource", ",", "JmsDestinationModel", ".", "class", ")", ";", "jms", ".", "setDestinationType", "(", "JmsDestinationType", ".", "TOPIC", ")", ";", "}", "else", "if", "(", "StringUtils", ".", "equals", "(", "type", ",", "\"javax.jms.TopicConnectionFactory\"", ")", "&&", "!", "(", "resource", "instanceof", "JmsConnectionFactoryModel", ")", ")", "{", "JmsConnectionFactoryModel", "jms", "=", "GraphService", ".", "addTypeToModel", "(", "this", ".", "getGraphContext", "(", ")", ",", "resource", ",", "JmsConnectionFactoryModel", ".", "class", ")", ";", "jms", ".", "setConnectionFactoryType", "(", "JmsDestinationType", ".", "TOPIC", ")", ";", "}", "}" ]
Associate a type with the given resource model.
[ "Associate", "a", "type", "with", "the", "given", "resource", "model", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/JNDIResourceService.java#L54-L85
159,787
windup/windup
rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/FeatureBasedApiDependenciesDeducer.java
FeatureBasedApiDependenciesDeducer.addDeploymentTypeBasedDependencies
private boolean addDeploymentTypeBasedDependencies(ProjectModel projectModel, Pom modulePom) { if (projectModel.getProjectType() == null) return true; switch (projectModel.getProjectType()){ case "ear": break; case "war": modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_SERVLET_31)); break; case "ejb": modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_EJB_32)); modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_CDI)); modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_JAVAX_ANN)); break; case "ejb-client": modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_EJB_CLIENT)); break; } return false; }
java
private boolean addDeploymentTypeBasedDependencies(ProjectModel projectModel, Pom modulePom) { if (projectModel.getProjectType() == null) return true; switch (projectModel.getProjectType()){ case "ear": break; case "war": modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_SERVLET_31)); break; case "ejb": modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_EJB_32)); modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_CDI)); modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_JAVAX_ANN)); break; case "ejb-client": modulePom.getDependencies().add(new SimpleDependency(Dependency.Role.API, ApiDependenciesData.DEP_API_EJB_CLIENT)); break; } return false; }
[ "private", "boolean", "addDeploymentTypeBasedDependencies", "(", "ProjectModel", "projectModel", ",", "Pom", "modulePom", ")", "{", "if", "(", "projectModel", ".", "getProjectType", "(", ")", "==", "null", ")", "return", "true", ";", "switch", "(", "projectModel", ".", "getProjectType", "(", ")", ")", "{", "case", "\"ear\"", ":", "break", ";", "case", "\"war\"", ":", "modulePom", ".", "getDependencies", "(", ")", ".", "add", "(", "new", "SimpleDependency", "(", "Dependency", ".", "Role", ".", "API", ",", "ApiDependenciesData", ".", "DEP_API_SERVLET_31", ")", ")", ";", "break", ";", "case", "\"ejb\"", ":", "modulePom", ".", "getDependencies", "(", ")", ".", "add", "(", "new", "SimpleDependency", "(", "Dependency", ".", "Role", ".", "API", ",", "ApiDependenciesData", ".", "DEP_API_EJB_32", ")", ")", ";", "modulePom", ".", "getDependencies", "(", ")", ".", "add", "(", "new", "SimpleDependency", "(", "Dependency", ".", "Role", ".", "API", ",", "ApiDependenciesData", ".", "DEP_API_CDI", ")", ")", ";", "modulePom", ".", "getDependencies", "(", ")", ".", "add", "(", "new", "SimpleDependency", "(", "Dependency", ".", "Role", ".", "API", ",", "ApiDependenciesData", ".", "DEP_API_JAVAX_ANN", ")", ")", ";", "break", ";", "case", "\"ejb-client\"", ":", "modulePom", ".", "getDependencies", "(", ")", ".", "add", "(", "new", "SimpleDependency", "(", "Dependency", ".", "Role", ".", "API", ",", "ApiDependenciesData", ".", "DEP_API_EJB_CLIENT", ")", ")", ";", "break", ";", "}", "return", "false", ";", "}" ]
Adds the dependencies typical for particular deployment types. This is not accurate and doesn't cover the real needs of the project. Basically it's just to have "something" for the initial implementation.
[ "Adds", "the", "dependencies", "typical", "for", "particular", "deployment", "types", ".", "This", "is", "not", "accurate", "and", "doesn", "t", "cover", "the", "real", "needs", "of", "the", "project", ".", "Basically", "it", "s", "just", "to", "have", "something", "for", "the", "initial", "implementation", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/FeatureBasedApiDependenciesDeducer.java#L52-L72
159,788
windup/windup
config/api/src/main/java/org/jboss/windup/config/tags/TagService.java
TagService.readTags
public void readTags(InputStream tagsXML) { SAXParserFactory factory = SAXParserFactory.newInstance(); try { SAXParser saxParser = factory.newSAXParser(); saxParser.parse(tagsXML, new TagsSaxHandler(this)); } catch (ParserConfigurationException | SAXException | IOException ex) { throw new RuntimeException("Failed parsing the tags definition: " + ex.getMessage(), ex); } }
java
public void readTags(InputStream tagsXML) { SAXParserFactory factory = SAXParserFactory.newInstance(); try { SAXParser saxParser = factory.newSAXParser(); saxParser.parse(tagsXML, new TagsSaxHandler(this)); } catch (ParserConfigurationException | SAXException | IOException ex) { throw new RuntimeException("Failed parsing the tags definition: " + ex.getMessage(), ex); } }
[ "public", "void", "readTags", "(", "InputStream", "tagsXML", ")", "{", "SAXParserFactory", "factory", "=", "SAXParserFactory", ".", "newInstance", "(", ")", ";", "try", "{", "SAXParser", "saxParser", "=", "factory", ".", "newSAXParser", "(", ")", ";", "saxParser", ".", "parse", "(", "tagsXML", ",", "new", "TagsSaxHandler", "(", "this", ")", ")", ";", "}", "catch", "(", "ParserConfigurationException", "|", "SAXException", "|", "IOException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed parsing the tags definition: \"", "+", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "}", "}" ]
Read the tag structure from the provided stream.
[ "Read", "the", "tag", "structure", "from", "the", "provided", "stream", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/tags/TagService.java#L37-L49
159,789
windup/windup
config/api/src/main/java/org/jboss/windup/config/tags/TagService.java
TagService.getPrimeTags
public List<Tag> getPrimeTags() { return this.definedTags.values().stream() .filter(Tag::isPrime) .collect(Collectors.toList()); }
java
public List<Tag> getPrimeTags() { return this.definedTags.values().stream() .filter(Tag::isPrime) .collect(Collectors.toList()); }
[ "public", "List", "<", "Tag", ">", "getPrimeTags", "(", ")", "{", "return", "this", ".", "definedTags", ".", "values", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "Tag", "::", "isPrime", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "}" ]
Gets all tags that are "prime" tags.
[ "Gets", "all", "tags", "that", "are", "prime", "tags", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/tags/TagService.java#L54-L59
159,790
windup/windup
config/api/src/main/java/org/jboss/windup/config/tags/TagService.java
TagService.getRootTags
public List<Tag> getRootTags() { return this.definedTags.values().stream() .filter(Tag::isRoot) .collect(Collectors.toList()); }
java
public List<Tag> getRootTags() { return this.definedTags.values().stream() .filter(Tag::isRoot) .collect(Collectors.toList()); }
[ "public", "List", "<", "Tag", ">", "getRootTags", "(", ")", "{", "return", "this", ".", "definedTags", ".", "values", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "Tag", "::", "isRoot", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "}" ]
Returns the tags that were root in the definition files. These serve as entry point shortcuts when browsing the graph. We could reduce this to just fewer as the root tags may be connected through parents="...".
[ "Returns", "the", "tags", "that", "were", "root", "in", "the", "definition", "files", ".", "These", "serve", "as", "entry", "point", "shortcuts", "when", "browsing", "the", "graph", ".", "We", "could", "reduce", "this", "to", "just", "fewer", "as", "the", "root", "tags", "may", "be", "connected", "through", "parents", "=", "...", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/tags/TagService.java#L65-L70
159,791
windup/windup
config/api/src/main/java/org/jboss/windup/config/tags/TagService.java
TagService.getAncestorTags
public Set<Tag> getAncestorTags(Tag tag) { Set<Tag> ancestors = new HashSet<>(); getAncestorTags(tag, ancestors); return ancestors; }
java
public Set<Tag> getAncestorTags(Tag tag) { Set<Tag> ancestors = new HashSet<>(); getAncestorTags(tag, ancestors); return ancestors; }
[ "public", "Set", "<", "Tag", ">", "getAncestorTags", "(", "Tag", "tag", ")", "{", "Set", "<", "Tag", ">", "ancestors", "=", "new", "HashSet", "<>", "(", ")", ";", "getAncestorTags", "(", "tag", ",", "ancestors", ")", ";", "return", "ancestors", ";", "}" ]
Returns all tags that designate this tag. E.g., for "tesla-model3", this would return "car", "vehicle", "vendor-tesla" etc.
[ "Returns", "all", "tags", "that", "designate", "this", "tag", ".", "E", ".", "g", ".", "for", "tesla", "-", "model3", "this", "would", "return", "car", "vehicle", "vendor", "-", "tesla", "etc", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/tags/TagService.java#L117-L122
159,792
windup/windup
config/api/src/main/java/org/jboss/windup/config/tags/TagService.java
TagService.writeTagsToJavaScript
public void writeTagsToJavaScript(Writer writer) throws IOException { writer.append("function fillTagService(tagService) {\n"); writer.append("\t// (name, isPrime, isPseudo, color), [parent tags]\n"); for (Tag tag : definedTags.values()) { writer.append("\ttagService.registerTag(new Tag("); escapeOrNull(tag.getName(), writer); writer.append(", "); escapeOrNull(tag.getTitle(), writer); writer.append(", ").append("" + tag.isPrime()) .append(", ").append("" + tag.isPseudo()) .append(", "); escapeOrNull(tag.getColor(), writer); writer.append(")").append(", ["); // We only have strings, not references, so we're letting registerTag() getOrCreate() the tag. for (Tag parentTag : tag.getParentTags()) { writer.append("'").append(StringEscapeUtils.escapeEcmaScript(parentTag.getName())).append("',"); } writer.append("]);\n"); } writer.append("}\n"); }
java
public void writeTagsToJavaScript(Writer writer) throws IOException { writer.append("function fillTagService(tagService) {\n"); writer.append("\t// (name, isPrime, isPseudo, color), [parent tags]\n"); for (Tag tag : definedTags.values()) { writer.append("\ttagService.registerTag(new Tag("); escapeOrNull(tag.getName(), writer); writer.append(", "); escapeOrNull(tag.getTitle(), writer); writer.append(", ").append("" + tag.isPrime()) .append(", ").append("" + tag.isPseudo()) .append(", "); escapeOrNull(tag.getColor(), writer); writer.append(")").append(", ["); // We only have strings, not references, so we're letting registerTag() getOrCreate() the tag. for (Tag parentTag : tag.getParentTags()) { writer.append("'").append(StringEscapeUtils.escapeEcmaScript(parentTag.getName())).append("',"); } writer.append("]);\n"); } writer.append("}\n"); }
[ "public", "void", "writeTagsToJavaScript", "(", "Writer", "writer", ")", "throws", "IOException", "{", "writer", ".", "append", "(", "\"function fillTagService(tagService) {\\n\"", ")", ";", "writer", ".", "append", "(", "\"\\t// (name, isPrime, isPseudo, color), [parent tags]\\n\"", ")", ";", "for", "(", "Tag", "tag", ":", "definedTags", ".", "values", "(", ")", ")", "{", "writer", ".", "append", "(", "\"\\ttagService.registerTag(new Tag(\"", ")", ";", "escapeOrNull", "(", "tag", ".", "getName", "(", ")", ",", "writer", ")", ";", "writer", ".", "append", "(", "\", \"", ")", ";", "escapeOrNull", "(", "tag", ".", "getTitle", "(", ")", ",", "writer", ")", ";", "writer", ".", "append", "(", "\", \"", ")", ".", "append", "(", "\"\"", "+", "tag", ".", "isPrime", "(", ")", ")", ".", "append", "(", "\", \"", ")", ".", "append", "(", "\"\"", "+", "tag", ".", "isPseudo", "(", ")", ")", ".", "append", "(", "\", \"", ")", ";", "escapeOrNull", "(", "tag", ".", "getColor", "(", ")", ",", "writer", ")", ";", "writer", ".", "append", "(", "\")\"", ")", ".", "append", "(", "\", [\"", ")", ";", "// We only have strings, not references, so we're letting registerTag() getOrCreate() the tag.", "for", "(", "Tag", "parentTag", ":", "tag", ".", "getParentTags", "(", ")", ")", "{", "writer", ".", "append", "(", "\"'\"", ")", ".", "append", "(", "StringEscapeUtils", ".", "escapeEcmaScript", "(", "parentTag", ".", "getName", "(", ")", ")", ")", ".", "append", "(", "\"',\"", ")", ";", "}", "writer", ".", "append", "(", "\"]);\\n\"", ")", ";", "}", "writer", ".", "append", "(", "\"}\\n\"", ")", ";", "}" ]
Writes the JavaScript code describing the tags as Tag classes to given writer.
[ "Writes", "the", "JavaScript", "code", "describing", "the", "tags", "as", "Tag", "classes", "to", "given", "writer", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/tags/TagService.java#L223-L247
159,793
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/service/ReportService.java
ReportService.getReportDirectory
public Path getReportDirectory() { WindupConfigurationModel cfg = WindupConfigurationService.getConfigurationModel(getGraphContext()); Path path = cfg.getOutputPath().asFile().toPath().resolve(REPORTS_DIR); createDirectoryIfNeeded(path); return path.toAbsolutePath(); }
java
public Path getReportDirectory() { WindupConfigurationModel cfg = WindupConfigurationService.getConfigurationModel(getGraphContext()); Path path = cfg.getOutputPath().asFile().toPath().resolve(REPORTS_DIR); createDirectoryIfNeeded(path); return path.toAbsolutePath(); }
[ "public", "Path", "getReportDirectory", "(", ")", "{", "WindupConfigurationModel", "cfg", "=", "WindupConfigurationService", ".", "getConfigurationModel", "(", "getGraphContext", "(", ")", ")", ";", "Path", "path", "=", "cfg", ".", "getOutputPath", "(", ")", ".", "asFile", "(", ")", ".", "toPath", "(", ")", ".", "resolve", "(", "REPORTS_DIR", ")", ";", "createDirectoryIfNeeded", "(", "path", ")", ";", "return", "path", ".", "toAbsolutePath", "(", ")", ";", "}" ]
Returns the output directory for reporting.
[ "Returns", "the", "output", "directory", "for", "reporting", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/ReportService.java#L52-L58
159,794
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/service/ReportService.java
ReportService.getReportByName
@SuppressWarnings("unchecked") public <T extends ReportModel> T getReportByName(String name, Class<T> clazz) { WindupVertexFrame model = this.getUniqueByProperty(ReportModel.REPORT_NAME, name); try { return (T) model; } catch (ClassCastException ex) { throw new WindupException("The vertex is not of expected frame type " + clazz.getName() + ": " + model.toPrettyString()); } }
java
@SuppressWarnings("unchecked") public <T extends ReportModel> T getReportByName(String name, Class<T> clazz) { WindupVertexFrame model = this.getUniqueByProperty(ReportModel.REPORT_NAME, name); try { return (T) model; } catch (ClassCastException ex) { throw new WindupException("The vertex is not of expected frame type " + clazz.getName() + ": " + model.toPrettyString()); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", "extends", "ReportModel", ">", "T", "getReportByName", "(", "String", "name", ",", "Class", "<", "T", ">", "clazz", ")", "{", "WindupVertexFrame", "model", "=", "this", ".", "getUniqueByProperty", "(", "ReportModel", ".", "REPORT_NAME", ",", "name", ")", ";", "try", "{", "return", "(", "T", ")", "model", ";", "}", "catch", "(", "ClassCastException", "ex", ")", "{", "throw", "new", "WindupException", "(", "\"The vertex is not of expected frame type \"", "+", "clazz", ".", "getName", "(", ")", "+", "\": \"", "+", "model", ".", "toPrettyString", "(", ")", ")", ";", "}", "}" ]
Returns the ReportModel with given name.
[ "Returns", "the", "ReportModel", "with", "given", "name", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/ReportService.java#L79-L91
159,795
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/service/ReportService.java
ReportService.getUniqueFilename
public String getUniqueFilename(String baseFileName, String extension, boolean cleanBaseFileName, String... ancestorFolders) { if (cleanBaseFileName) { baseFileName = PathUtil.cleanFileName(baseFileName); } if (ancestorFolders != null) { Path pathToFile = Paths.get("", Stream.of(ancestorFolders).map(ancestor -> PathUtil.cleanFileName(ancestor)).toArray(String[]::new)).resolve(baseFileName); baseFileName = pathToFile.toString(); } String filename = baseFileName + "." + extension; // FIXME this looks nasty while (usedFilenames.contains(filename)) { filename = baseFileName + "." + index.getAndIncrement() + "." + extension; } usedFilenames.add(filename); return filename; }
java
public String getUniqueFilename(String baseFileName, String extension, boolean cleanBaseFileName, String... ancestorFolders) { if (cleanBaseFileName) { baseFileName = PathUtil.cleanFileName(baseFileName); } if (ancestorFolders != null) { Path pathToFile = Paths.get("", Stream.of(ancestorFolders).map(ancestor -> PathUtil.cleanFileName(ancestor)).toArray(String[]::new)).resolve(baseFileName); baseFileName = pathToFile.toString(); } String filename = baseFileName + "." + extension; // FIXME this looks nasty while (usedFilenames.contains(filename)) { filename = baseFileName + "." + index.getAndIncrement() + "." + extension; } usedFilenames.add(filename); return filename; }
[ "public", "String", "getUniqueFilename", "(", "String", "baseFileName", ",", "String", "extension", ",", "boolean", "cleanBaseFileName", ",", "String", "...", "ancestorFolders", ")", "{", "if", "(", "cleanBaseFileName", ")", "{", "baseFileName", "=", "PathUtil", ".", "cleanFileName", "(", "baseFileName", ")", ";", "}", "if", "(", "ancestorFolders", "!=", "null", ")", "{", "Path", "pathToFile", "=", "Paths", ".", "get", "(", "\"\"", ",", "Stream", ".", "of", "(", "ancestorFolders", ")", ".", "map", "(", "ancestor", "->", "PathUtil", ".", "cleanFileName", "(", "ancestor", ")", ")", ".", "toArray", "(", "String", "[", "]", "::", "new", ")", ")", ".", "resolve", "(", "baseFileName", ")", ";", "baseFileName", "=", "pathToFile", ".", "toString", "(", ")", ";", "}", "String", "filename", "=", "baseFileName", "+", "\".\"", "+", "extension", ";", "// FIXME this looks nasty", "while", "(", "usedFilenames", ".", "contains", "(", "filename", ")", ")", "{", "filename", "=", "baseFileName", "+", "\".\"", "+", "index", ".", "getAndIncrement", "(", ")", "+", "\".\"", "+", "extension", ";", "}", "usedFilenames", ".", "add", "(", "filename", ")", ";", "return", "filename", ";", "}" ]
Returns a unique file name @param baseFileName the requested base name for the file @param extension the requested extension for the file @param cleanBaseFileName specify if the <code>baseFileName</code> has to be cleaned before being used (i.e. 'jboss-web' should not be cleaned to avoid '-' to become '_') @param ancestorFolders specify the ancestor folders for the file (if there's no ancestor folder, just pass 'null' value) @return a String representing the unique file generated
[ "Returns", "a", "unique", "file", "name" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/ReportService.java#L109-L131
159,796
windup/windup
reporting/api/src/main/java/org/jboss/windup/reporting/service/TagSetService.java
TagSetService.getOrCreate
public TagSetModel getOrCreate(GraphRewrite event, Set<String> tags) { Map<Set<String>, Vertex> cache = getCache(event); Vertex vertex = cache.get(tags); if (vertex == null) { TagSetModel model = create(); model.setTags(tags); cache.put(tags, model.getElement()); return model; } else { return frame(vertex); } }
java
public TagSetModel getOrCreate(GraphRewrite event, Set<String> tags) { Map<Set<String>, Vertex> cache = getCache(event); Vertex vertex = cache.get(tags); if (vertex == null) { TagSetModel model = create(); model.setTags(tags); cache.put(tags, model.getElement()); return model; } else { return frame(vertex); } }
[ "public", "TagSetModel", "getOrCreate", "(", "GraphRewrite", "event", ",", "Set", "<", "String", ">", "tags", ")", "{", "Map", "<", "Set", "<", "String", ">", ",", "Vertex", ">", "cache", "=", "getCache", "(", "event", ")", ";", "Vertex", "vertex", "=", "cache", ".", "get", "(", "tags", ")", ";", "if", "(", "vertex", "==", "null", ")", "{", "TagSetModel", "model", "=", "create", "(", ")", ";", "model", ".", "setTags", "(", "tags", ")", ";", "cache", ".", "put", "(", "tags", ",", "model", ".", "getElement", "(", ")", ")", ";", "return", "model", ";", "}", "else", "{", "return", "frame", "(", "vertex", ")", ";", "}", "}" ]
This essentially ensures that we only store a single Vertex for each unique "Set" of tags.
[ "This", "essentially", "ensures", "that", "we", "only", "store", "a", "single", "Vertex", "for", "each", "unique", "Set", "of", "tags", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/TagSetService.java#L43-L58
159,797
windup/windup
reporting/impl/src/main/java/org/jboss/windup/reporting/rules/generation/techreport/GetTechReportPunchCardStatsMethod.java
GetTechReportPunchCardStatsMethod.getAllApplications
private static Set<ProjectModel> getAllApplications(GraphContext graphContext) { Set<ProjectModel> apps = new HashSet<>(); Iterable<ProjectModel> appProjects = graphContext.findAll(ProjectModel.class); for (ProjectModel appProject : appProjects) apps.add(appProject); return apps; }
java
private static Set<ProjectModel> getAllApplications(GraphContext graphContext) { Set<ProjectModel> apps = new HashSet<>(); Iterable<ProjectModel> appProjects = graphContext.findAll(ProjectModel.class); for (ProjectModel appProject : appProjects) apps.add(appProject); return apps; }
[ "private", "static", "Set", "<", "ProjectModel", ">", "getAllApplications", "(", "GraphContext", "graphContext", ")", "{", "Set", "<", "ProjectModel", ">", "apps", "=", "new", "HashSet", "<>", "(", ")", ";", "Iterable", "<", "ProjectModel", ">", "appProjects", "=", "graphContext", ".", "findAll", "(", "ProjectModel", ".", "class", ")", ";", "for", "(", "ProjectModel", "appProject", ":", "appProjects", ")", "apps", ".", "(", "appProject", ")", ";", "return", "apps", ";", "}" ]
Returns all ApplicationProjectModels.
[ "Returns", "all", "ApplicationProjectModels", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/impl/src/main/java/org/jboss/windup/reporting/rules/generation/techreport/GetTechReportPunchCardStatsMethod.java#L191-L198
159,798
windup/windup
reporting/impl/src/main/java/org/jboss/windup/reporting/rules/generation/techreport/TechReportService.java
TechReportService.processPlaceLabels
private static TechReportPlacement processPlaceLabels(GraphContext graphContext, Set<String> tagNames) { TagGraphService tagService = new TagGraphService(graphContext); if (tagNames.size() < 3) throw new WindupException("There should always be exactly 3 placement labels - row, sector, column/box. It was: " + tagNames); if (tagNames.size() > 3) LOG.severe("There should always be exactly 3 placement labels - row, sector, column/box. It was: " + tagNames); TechReportPlacement placement = new TechReportPlacement(); final TagModel placeSectorsTag = tagService.getTagByName("techReport:placeSectors"); final TagModel placeBoxesTag = tagService.getTagByName("techReport:placeBoxes"); final TagModel placeRowsTag = tagService.getTagByName("techReport:placeRows"); Set<String> unknownTags = new HashSet<>(); for (String name : tagNames) { final TagModel tag = tagService.getTagByName(name); if (null == tag) continue; if (TagGraphService.isTagUnderTagOrSame(tag, placeSectorsTag)) { placement.sector = tag; } else if (TagGraphService.isTagUnderTagOrSame(tag, placeBoxesTag)) { placement.box = tag; } else if (TagGraphService.isTagUnderTagOrSame(tag, placeRowsTag)) { placement.row = tag; } else { unknownTags.add(name); } } placement.unknown = unknownTags; LOG.fine(String.format("\t\tLabels %s identified as: sector: %s, box: %s, row: %s", tagNames, placement.sector, placement.box, placement.row)); if (placement.box == null || placement.row == null) { LOG.severe(String.format( "There should always be exactly 3 placement labels - row, sector, column/box. Found: %s, of which box: %s, row: %s", tagNames, placement.box, placement.row)); } return placement; }
java
private static TechReportPlacement processPlaceLabels(GraphContext graphContext, Set<String> tagNames) { TagGraphService tagService = new TagGraphService(graphContext); if (tagNames.size() < 3) throw new WindupException("There should always be exactly 3 placement labels - row, sector, column/box. It was: " + tagNames); if (tagNames.size() > 3) LOG.severe("There should always be exactly 3 placement labels - row, sector, column/box. It was: " + tagNames); TechReportPlacement placement = new TechReportPlacement(); final TagModel placeSectorsTag = tagService.getTagByName("techReport:placeSectors"); final TagModel placeBoxesTag = tagService.getTagByName("techReport:placeBoxes"); final TagModel placeRowsTag = tagService.getTagByName("techReport:placeRows"); Set<String> unknownTags = new HashSet<>(); for (String name : tagNames) { final TagModel tag = tagService.getTagByName(name); if (null == tag) continue; if (TagGraphService.isTagUnderTagOrSame(tag, placeSectorsTag)) { placement.sector = tag; } else if (TagGraphService.isTagUnderTagOrSame(tag, placeBoxesTag)) { placement.box = tag; } else if (TagGraphService.isTagUnderTagOrSame(tag, placeRowsTag)) { placement.row = tag; } else { unknownTags.add(name); } } placement.unknown = unknownTags; LOG.fine(String.format("\t\tLabels %s identified as: sector: %s, box: %s, row: %s", tagNames, placement.sector, placement.box, placement.row)); if (placement.box == null || placement.row == null) { LOG.severe(String.format( "There should always be exactly 3 placement labels - row, sector, column/box. Found: %s, of which box: %s, row: %s", tagNames, placement.box, placement.row)); } return placement; }
[ "private", "static", "TechReportPlacement", "processPlaceLabels", "(", "GraphContext", "graphContext", ",", "Set", "<", "String", ">", "tagNames", ")", "{", "TagGraphService", "tagService", "=", "new", "TagGraphService", "(", "graphContext", ")", ";", "if", "(", "tagNames", ".", "size", "(", ")", "<", "3", ")", "throw", "new", "WindupException", "(", "\"There should always be exactly 3 placement labels - row, sector, column/box. It was: \"", "+", "tagNames", ")", ";", "if", "(", "tagNames", ".", "size", "(", ")", ">", "3", ")", "LOG", ".", "severe", "(", "\"There should always be exactly 3 placement labels - row, sector, column/box. It was: \"", "+", "tagNames", ")", ";", "TechReportPlacement", "placement", "=", "new", "TechReportPlacement", "(", ")", ";", "final", "TagModel", "placeSectorsTag", "=", "tagService", ".", "getTagByName", "(", "\"techReport:placeSectors\"", ")", ";", "final", "TagModel", "placeBoxesTag", "=", "tagService", ".", "getTagByName", "(", "\"techReport:placeBoxes\"", ")", ";", "final", "TagModel", "placeRowsTag", "=", "tagService", ".", "getTagByName", "(", "\"techReport:placeRows\"", ")", ";", "Set", "<", "String", ">", "unknownTags", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "String", "name", ":", "tagNames", ")", "{", "final", "TagModel", "tag", "=", "tagService", ".", "getTagByName", "(", "name", ")", ";", "if", "(", "null", "==", "tag", ")", "continue", ";", "if", "(", "TagGraphService", ".", "isTagUnderTagOrSame", "(", "tag", ",", "placeSectorsTag", ")", ")", "{", "placement", ".", "sector", "=", "tag", ";", "}", "else", "if", "(", "TagGraphService", ".", "isTagUnderTagOrSame", "(", "tag", ",", "placeBoxesTag", ")", ")", "{", "placement", ".", "box", "=", "tag", ";", "}", "else", "if", "(", "TagGraphService", ".", "isTagUnderTagOrSame", "(", "tag", ",", "placeRowsTag", ")", ")", "{", "placement", ".", "row", "=", "tag", ";", "}", "else", "{", "unknownTags", ".", "add", "(", "name", ")", ";", "}", "}", "placement", ".", "unknown", "=", "unknownTags", ";", "LOG", ".", "fine", "(", "String", ".", "format", "(", "\"\\t\\tLabels %s identified as: sector: %s, box: %s, row: %s\"", ",", "tagNames", ",", "placement", ".", "sector", ",", "placement", ".", "box", ",", "placement", ".", "row", ")", ")", ";", "if", "(", "placement", ".", "box", "==", "null", "||", "placement", ".", "row", "==", "null", ")", "{", "LOG", ".", "severe", "(", "String", ".", "format", "(", "\"There should always be exactly 3 placement labels - row, sector, column/box. Found: %s, of which box: %s, row: %s\"", ",", "tagNames", ",", "placement", ".", "box", ",", "placement", ".", "row", ")", ")", ";", "}", "return", "placement", ";", "}" ]
From three tagNames, if one is under sectorTag and one under rowTag, returns the remaining one, which is supposedly the a box label. Otherwise, returns null.
[ "From", "three", "tagNames", "if", "one", "is", "under", "sectorTag", "and", "one", "under", "rowTag", "returns", "the", "remaining", "one", "which", "is", "supposedly", "the", "a", "box", "label", ".", "Otherwise", "returns", "null", "." ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/impl/src/main/java/org/jboss/windup/reporting/rules/generation/techreport/TechReportService.java#L74-L124
159,799
windup/windup
rules-java-project/addon/src/main/java/org/jboss/windup/project/condition/Artifact.java
Artifact.withVersion
public static Artifact withVersion(Version v) { Artifact artifact = new Artifact(); artifact.version = v; return artifact; }
java
public static Artifact withVersion(Version v) { Artifact artifact = new Artifact(); artifact.version = v; return artifact; }
[ "public", "static", "Artifact", "withVersion", "(", "Version", "v", ")", "{", "Artifact", "artifact", "=", "new", "Artifact", "(", ")", ";", "artifact", ".", "version", "=", "v", ";", "return", "artifact", ";", "}" ]
Start with specifying the artifact version
[ "Start", "with", "specifying", "the", "artifact", "version" ]
6668f09e7f012d24a0b4212ada8809417225b2ad
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java-project/addon/src/main/java/org/jboss/windup/project/condition/Artifact.java#L28-L33