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

Added doc comment support for constants


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 21d763c2
......@@ -115,6 +115,8 @@ public final class ContentAssistProcessor implements IContentAssistProcessor {
oldRef.setMyScope(scope);
oldRef.detectModid();
}
} else {
return null;
}
final IPreferencesService prefs = Platform.getPreferencesService();
......
......@@ -22,11 +22,13 @@ import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.titan.designer.AST.Assignment;
import org.eclipse.titan.designer.AST.DocumentComment;
import org.eclipse.titan.designer.AST.IType;
import org.eclipse.titan.designer.AST.Identifier;
import org.eclipse.titan.designer.AST.Identifier.Identifier_type;
import org.eclipse.titan.designer.AST.Module;
import org.eclipse.titan.designer.AST.Reference;
import org.eclipse.titan.designer.AST.Scope;
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.Definition;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter;
......@@ -75,7 +77,7 @@ public final class TextHover extends BaseTextHover implements ITextHoverExtensio
* @param hoverRegion
* @return
*/
// @Override
@Override
public String getHoverInfo(final ITextViewer textViewer, final IRegion hoverRegion) {
IDocument doc = textViewer.getDocument();
final IFile file = editor.getEditorInput().getAdapter(IFile.class);
......@@ -103,7 +105,9 @@ public final class TextHover extends BaseTextHover implements ITextHoverExtensio
if (assignment instanceof Def_Function) {
functionHover(tooltip, dc, assignment);
}
if (assignment instanceof Def_Const) {
constantHover(tooltip, dc, assignment, timestamp);
}
tooltip.append("</html>");
return tooltip.toString();
}
......@@ -200,12 +204,25 @@ public final class TextHover extends BaseTextHover implements ITextHoverExtensio
for (int i = 0; i < fp.getNofParameters(); i++) {
final FormalParameter param = fp.getParameterByIndex(i);
String paramType = getFormalParamType(param);
sb.append("<div><i>" + param.getIdentifier().getName() + " </i>" + paramType + "</div>");
sb.append("<div><b><i>" + param.getIdentifier().getName() + " (</i>" + paramType + ")</b></div>");
}
}
}
}
private void constantHover(StringBuilder sb, DocumentComment dc, Assignment ass, CompilationTimeStamp timestamp) {
final IType constType = ass.getType(timestamp);
String typeName = null;
if (constType != null) {
typeName = "<i>" + constType.getTypename() + " </i>";
}
sb.append("constant <b>" + typeName + ((Definition)ass).getIdentifier().getName() + "</b>");
if (dc != null) {
addDescs(sb, dc);
addAuthors(sb, dc);
}
}
private String getFormalParamType(FormalParameter fp) {
String paramType;
......
......@@ -1945,7 +1945,10 @@ pr_PortElement[Reference portTypeReference]
}
};
pr_ConstDef returns[List<Definition> array, Type type]:
pr_ConstDef returns[List<Definition> array, Type type]
@init {
DocumentComment docComment = getDocumentComment();
}:
( col = pr_ConstKeyword
t = pr_Type { $type = $t.type; }
a = pr_ConstList[ $t.type ] { $array = $a.array; }
......@@ -1959,6 +1962,9 @@ pr_ConstDef returns[List<Definition> array, Type type]:
loc.setOffset( offset + $col.start.getStartIndex() );
}
}
if (docComment != null) {
temp.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