/* BSD 2-Clause License - see OPAL/LICENSE for details. */
package org.opalj
package da
import scala.xml.Node
/**
* @author Michael Eichberg
* @author Wael Alkhatib
* @author Isbel Isbel
* @author Noorulla Sharief
* @author Andre Pacak
*/
case class Signature_attribute(
attribute_name_index: Constant_Pool_Index,
signature_index: Constant_Pool_Index
) extends Attribute {
/**
* The value of the attribute_length item is fixed; it is always 2.
*/
final override def attribute_length = 2
def signature(implicit cp: Constant_Pool): String = cp(signature_index).toString
def signatureSpan(implicit cp: Constant_Pool): Node = {
{ cp(signature_index).toString }
}
// Primarily implemented to handle the case if the signature attribute is not
// found in an expected case.
override def toXHTML(implicit cp: Constant_Pool): Node = {
Signature
{ signature }
}
}
/* Functionality, which may be useful when creating a better representation of type signatures.
+ def decipher(sig: String): Node = {
+ val fts = SignatureParser.parseFieldTypeSignature(sig)
Add a comment to this line
+ typeSigToXHTML(fts)
+ }
+
+ def typeSigToXHTML(ts: TypeSignature): Node = ts match {
+ case _: BooleanType =>
+ boolean
+ case _: ByteType =>
+ byte
+ case _: CharType =>
+ char
+ case _: DoubleType =>
+ double
+ case _: FloatType =>
+ float
+ case _: IntegerType =>
+ int
+ case _: LongType =>
+ long
+ case _: ShortType =>
+ short
+
+ case scts: SimpleClassTypeSignature =>
+
+ { scts.simpleName }
+ <{ scts.typeArguments.map(typeArgToXHTML) }
+ >
+
+ case ats: ArrayTypeSignature =>
+ [{ typeSigToXHTML(ats.typeSignature) }
+ case tvs: TypeVariableSignature =>
+ T{ tvs.identifier };
+ case cts: ClassTypeSignature =>
+
+ L
+ {
+ if (cts.packageIdentifier.isDefined)
+
+ { cts.packageIdentifier.get + cts.simpleClassTypeSignature.simpleName }
+
+ else
+
+ { cts.simpleClassTypeSignature.simpleName }
+
+ }
+ <
+ { cts.simpleClassTypeSignature.typeArguments.map { typeArgToXHTML(_) } }
+ >
+ {
+ cts.classTypeSignatureSuffix.map {
+ e => e.simpleName + e.typeArguments.map { typeArgToXHTML(_) }
+ }
+ }
+ ;
+
+ case _ => { ts.toJVMSignature }
+ }
+
+ def typeArgToXHTML(ta: TypeArgument): Node = {
+ ta match {
+ case w: Wildcard =>
+ *
+ case prop: ProperTypeArgument =>
+
+ { if (prop.varianceIndicator.isDefined) prop.varianceIndicator.get.toJVMSignature }
+ { typeSigToXHTML(prop.fieldTypeSignature) }
+
+ case _ =>
+ // this is a complete list of TypeArugments at the time of writing
+ throw new IllegalArgumentException("unknown TypeArugment")
+ }
+ }
*/