use of com.redhat.qute.commons.usertags.UserTagInfo in project quarkus-ls by redhat-developer.
the class QuarkusIntegrationForQute method collectUserTags.
/**
* Collect user tags for the given package fragment root.
*
* @param root the package fragment root.
* @param tags the user tags list to fill.
*
* @throws JavaModelException
* @throws CoreException
*/
private static void collectUserTags(IPackageFragmentRoot root, List<UserTagInfo> tags) throws JavaModelException, CoreException {
IJavaElement[] children = root.getChildren();
for (IJavaElement child : children) {
if (child instanceof IPackageFragment) {
IPackageFragment packageRoot = (IPackageFragment) child;
if (TEMPLATES_TAGS_ENTRY.equals(packageRoot.getElementName())) {
// 'templates.tags' entry exists, loop for all resources to build user tags
Object[] resources = packageRoot.getNonJavaResources();
if (resources != null) {
for (Object object : resources) {
if (object instanceof IJarEntryResource) {
// It's a HTML, etc file, build the user tag
IJarEntryResource templateFile = (IJarEntryResource) object;
String fileName = templateFile.getName();
String uri = toUri(templateFile);
String content = convertStreamToString(templateFile.getContents());
UserTagInfo tagInfo = new UserTagInfo();
tagInfo.setFileName(fileName);
tagInfo.setUri(uri);
tagInfo.setContent(content);
tags.add(tagInfo);
}
}
}
}
}
}
}
use of com.redhat.qute.commons.usertags.UserTagInfo in project quarkus-ls by redhat-developer.
the class QuarkusIntegrationForQute method getUserTags.
/**
* Collect user tags from the given Java project.
*
* @param javaProject the Java project.
* @param monitor the progress monitor
*
* @return user tags from the given Java project.
*
* @throws CoreException
*/
public static List<UserTagInfo> getUserTags(IJavaProject javaProject, IProgressMonitor monitor) throws CoreException {
List<UserTagInfo> tags = new ArrayList<UserTagInfo>();
// Loop for each JAR of the classpath and try to collect files from the
// 'templates.tags' entry
IClasspathEntry[] resolvedClasspath = ((JavaProject) javaProject).getResolvedClasspath();
for (IClasspathEntry entry : resolvedClasspath) {
if (entry.isTest()) {
continue;
}
switch(entry.getEntryKind()) {
case IClasspathEntry.CPE_LIBRARY:
String jarPath = entry.getPath().toOSString();
IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(jarPath);
if (root != null) {
collectUserTags(root, tags);
}
}
}
return tags;
}
Aggregations