Commit b3d1292d authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Added basic hover/doc comment for variables


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 5796e44d
......@@ -33,11 +33,13 @@ import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Definition;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList;
import org.eclipse.titan.designer.AST.TTCN3.types.ClassTypeBody;
import org.eclipse.titan.designer.AST.TTCN3.types.Class_Type;
import org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type;
import org.eclipse.titan.designer.editors.BaseTextHover;
import org.eclipse.titan.designer.editors.IReferenceParser;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
......@@ -116,6 +118,9 @@ public final class TextHover extends BaseTextHover implements ITextHoverExtensio
if (assignment instanceof Def_Const) {
constantHover(tooltip, dc, assignment, timestamp);
}
if (assignment instanceof Def_Var) {
varHover(tooltip, dc, assignment, timestamp);
}
if (assignment instanceof Def_Type) {
final Def_Type deftype = (Def_Type)assignment;
final Type type = deftype.getType(timestamp);
......@@ -228,6 +233,28 @@ public final class TextHover extends BaseTextHover implements ITextHoverExtensio
}
}
private void varHover(StringBuilder sb, DocumentComment dc, Assignment ass, CompilationTimeStamp timestamp) {
final IType varType = ass.getType(timestamp);
String typeName = null;
if (varType != null) {
typeName = "<i>" + varType.getTypename() + " </i>";
}
sb.append("var <b>" + typeName + ((Definition)ass).getIdentifier().getName() + "</b>");
if (varType instanceof Referenced_Type) {
final Referenced_Type refd = (Referenced_Type)varType;
if (refd.getTypeRefdLast(timestamp) instanceof Class_Type) {
sb.append("<br><br>");
final Class_Type ct = (Class_Type)refd.getTypeRefdLast(timestamp);
final Def_Type classType = (Def_Type)ct.getNameParent();
addClassMembers(sb, classType.getDocumentComment(), timestamp, ct.getClassBody());
}
}
if (dc != null) {
addDescs(sb, dc);
addAuthors(sb, dc);
}
}
private void constantHover(StringBuilder sb, DocumentComment dc, Assignment ass, CompilationTimeStamp timestamp) {
final IType constType = ass.getType(timestamp);
String typeName = null;
......@@ -246,6 +273,10 @@ public final class TextHover extends BaseTextHover implements ITextHoverExtensio
final Class_Type ct = (Class_Type)ass.getType(timestamp);
final ClassTypeBody body = ct.getClassBody();
sb.append("class <b>" + body.getIdentifier().getDisplayName() + "</b><br><br>");
addClassMembers(sb, dc, timestamp, body);
}
private void addClassMembers(StringBuilder sb, DocumentComment dc, CompilationTimeStamp timestamp, ClassTypeBody body) {
sb.append("<b>Members:</b><br>");
Map<String,String> members = null;
if (dc != null) {
......
......@@ -4615,6 +4615,7 @@ pr_VarInstance returns[List<Definition> definitions, Type type, boolean isAbstra
$isFinal = false;
$isDeterministic = false;
$isInternal = false;
DocumentComment docComment = getDocumentComment();
}:
( col = pr_VarKeyword
( tr = pr_TemplateOptRestricted { templateRestriction = $tr.templateRestriction; }
......@@ -4642,6 +4643,9 @@ pr_VarInstance returns[List<Definition> definitions, Type type, boolean isAbstra
def.getLocation().setLine( t.getLine() + line - 1);
Location loc = def.getLocation();
loc.setOffset( offset + t.getStartIndex() );
if (docComment != null) {
def.setDocumentComment(docComment);
}
}
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment