use of com.buschmais.jqassistant.core.report.api.model.source.FileLocation in project jqa-java-plugin by buschmais.
the class TypeSourceHelper method getSourceLocation.
static Optional<FileLocation> getSourceLocation(TypeDescriptor typeDescriptor, Optional<Integer> startLine, Optional<Integer> endLine) {
if (typeDescriptor instanceof ClassFileDescriptor) {
ClassFileDescriptor classFileDescriptor = (ClassFileDescriptor) typeDescriptor;
for (FileDescriptor parent : classFileDescriptor.getParents()) {
if (parent instanceof PackageDescriptor) {
// File location can only safely built if a parent package exists.
PackageDescriptor packageDescriptor = (PackageDescriptor) parent;
FileLocation.FileLocationBuilder fileLocationBuilder = FileLocation.builder();
fileLocationBuilder.parent(FileSourceHelper.getParentLocation(classFileDescriptor));
fileLocationBuilder.fileName(packageDescriptor.getFileName() + "/" + classFileDescriptor.getSourceFileName());
fileLocationBuilder.startLine(startLine);
fileLocationBuilder.endLine(endLine);
return of(fileLocationBuilder.build());
}
}
}
return empty();
}
use of com.buschmais.jqassistant.core.report.api.model.source.FileLocation in project jqa-core-framework by buschmais.
the class XmlReportPlugin method writeColumn.
/**
* Determines the language and language element of a descriptor from a result
* column.
*
* @param columnName
* The name of the column.
* @param value
* The value.
* @throws XMLStreamException
* If a problem occurs.
*/
private void writeColumn(String columnName, Object value) throws XMLStreamException {
xmlStreamWriter.writeStartElement("column");
xmlStreamWriter.writeAttribute("name", columnName);
String label = null;
if (value instanceof CompositeObject) {
CompositeObject descriptor = (CompositeObject) value;
LanguageElement elementValue = LanguageHelper.getLanguageElement(descriptor);
if (elementValue != null) {
xmlStreamWriter.writeStartElement("element");
xmlStreamWriter.writeAttribute("language", elementValue.getLanguage());
xmlStreamWriter.writeCharacters(elementValue.name());
// element
xmlStreamWriter.writeEndElement();
SourceProvider sourceProvider = elementValue.getSourceProvider();
label = sourceProvider.getName(descriptor);
Optional<FileLocation> sourceLocation = sourceProvider.getSourceLocation(descriptor);
if (sourceLocation.isPresent()) {
xmlStreamWriter.writeStartElement("source");
writeSourceLocation(sourceLocation.get());
// sourceFile
xmlStreamWriter.writeEndElement();
}
}
} else if (value != null) {
label = ReportHelper.getLabel(value);
}
writeElementWithCharacters("value", label);
// column
xmlStreamWriter.writeEndElement();
}
Aggregations