Skip to content
Snippets Groups Projects

Implemented document comment generation

Merged Miklos Magyari requested to merge gendoccomment into main
4 files
+ 159
67
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -14,6 +14,7 @@ import org.eclipse.lsp4j.DocumentSymbol;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.SymbolKind;
import org.eclipse.titan.lsp.AST.ASTVisitor;
import org.eclipse.titan.lsp.AST.AstSemanticHighlighting;
import org.eclipse.titan.lsp.AST.DocumentComment;
import org.eclipse.titan.lsp.AST.IReferenceChain;
import org.eclipse.titan.lsp.AST.ISubReference;
@@ -31,6 +32,7 @@ import org.eclipse.titan.lsp.AST.ReferenceFinder;
import org.eclipse.titan.lsp.AST.ReferenceFinder.Hit;
import org.eclipse.titan.lsp.AST.Scope;
import org.eclipse.titan.lsp.AST.Type;
import org.eclipse.titan.lsp.AST.AstSemanticHighlighting.SemanticType;
import org.eclipse.titan.lsp.AST.TTCN3.attributes.AttributeSpecification;
import org.eclipse.titan.lsp.AST.TTCN3.attributes.ExtensionAttribute;
import org.eclipse.titan.lsp.AST.TTCN3.attributes.MultipleWithAttributes;
@@ -43,7 +45,10 @@ import org.eclipse.titan.lsp.AST.TTCN3.types.Address_Type;
import org.eclipse.titan.lsp.AST.TTCN3.types.Altstep_Type;
import org.eclipse.titan.lsp.AST.TTCN3.types.Class_Type;
import org.eclipse.titan.lsp.AST.TTCN3.types.Component_Type;
import org.eclipse.titan.lsp.AST.TTCN3.types.EnumItem;
import org.eclipse.titan.lsp.AST.TTCN3.types.Function_Type;
import org.eclipse.titan.lsp.AST.TTCN3.types.TTCN3_Enumerated_Type;
import org.eclipse.titan.lsp.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType;
import org.eclipse.titan.lsp.AST.TTCN3.types.Testcase_Type;
import org.eclipse.titan.lsp.hover.HoverContentType;
import org.eclipse.titan.lsp.hover.Ttcn3HoverContent;
@@ -270,7 +275,7 @@ public final class Def_Type extends Definition implements ICommentable {
default:
break;
}
// AstSyntaxHighlightTokens.addSyntaxDecoration(identifier.getLocation(), SyntaxDecoration.DefType);
//AstSemanticHighlighting.addSemanticToken(location, SemanticType.Type);
checkDocumentComment();
}
@@ -640,72 +645,72 @@ public final class Def_Type extends Definition implements ICommentable {
return hoverContent;
}
//
// @Override
// public String generateDocComment(final String indentation) {
// final CompilationTimeStamp timestamp = lastTimeChecked != null ? lastTimeChecked : CompilationTimeStamp.getBaseTimestamp();
// if (timestamp == null) {
// return "";
// }
// final IType assType = getType(timestamp);
//
// final String ind = indentation + ICommentable.LINE_START;
// final StringBuilder sb = new StringBuilder();
// sb.append(ICommentable.COMMENT_START)
// .append(ind).append(ICommentable.DESC_TAG).append('\n');
//
// switch (assType.getTypetype()) {
// case TYPE_CLASS:
// final Class_Type ct = (Class_Type)assType;
// for (final Definition def : ct.getDefinitions()) {
// boolean functionOverride = false;
// if (def instanceof Def_Function) {
// if (((Def_Function)def).isOverride()) {
// functionOverride = true;
// }
// }
// if (! def.isInherited() || functionOverride) {
// sb.append(ind).append(ICommentable.MEMBER_TAG).append(' ')
// .append(def.getIdentifier().getDisplayName())
// .append('\n');
// }
// }
// break;
// case TYPE_TTCN3_CHOICE:
// case TYPE_TTCN3_SEQUENCE:
// final TTCN3_Set_Seq_Choice_BaseType choice = (TTCN3_Set_Seq_Choice_BaseType)assType;
// for (int i = 0; i < choice.getNofComponents(); i++) {
// sb.append(ind).append(ICommentable.MEMBER_TAG).append(' ')
// .append(choice.getComponentByIndex(i).getIdentifier().getDisplayName())
// .append('\n');
// }
// break;
// case TYPE_COMPONENT:
// final Component_Type component = (Component_Type)assType;
// for (final Definition def : component.getComponentBody().getDefinitions()) {
// sb.append(ind).append(ICommentable.MEMBER_TAG).append(' ')
// .append(def.getIdentifier().getDisplayName())
// .append('\n');
// }
// break;
// case TYPE_TTCN3_ENUMERATED:
// final TTCN3_Enumerated_Type enumerated = (TTCN3_Enumerated_Type)assType;
// for (final EnumItem item : enumerated.getEnumItemsOrdered()) {
// sb.append(ind).append(ICommentable.MEMBER_TAG).append(' ')
// .append(item.getId().getDisplayName())
// .append('\n');
// }
// break;
// default:
// break;
// }
//
// sb.append(indentation).append(ICommentable.COMMENT_END).append(indentation);
// return sb.toString();
// }
@Override
public String generateDocComment(String indentation) {
// TODO Auto-generated method stub
return null;
public String generateDocComment(final String indentation) {
final CompilationTimeStamp timestamp = lastTimeChecked != null ? lastTimeChecked : CompilationTimeStamp.getBaseTimestamp();
if (timestamp == null) {
return "";
}
final IType assType = getType(timestamp);
final String ind = indentation + ICommentable.LINE_START;
final StringBuilder sb = new StringBuilder();
sb.append(ICommentable.COMMENT_START)
.append(ind).append(ICommentable.DESC_TAG).append('\n');
switch (assType.getTypetype()) {
case TYPE_CLASS:
final Class_Type ct = (Class_Type)assType;
for (final Definition def : ct.getDefinitions()) {
boolean functionOverride = false;
if (def instanceof Def_Function) {
if (((Def_Function)def).isOverride()) {
functionOverride = true;
}
}
if (! def.isInherited() || functionOverride) {
sb.append(ind).append(ICommentable.MEMBER_TAG).append(' ')
.append(def.getIdentifier().getDisplayName())
.append('\n');
}
}
break;
case TYPE_TTCN3_CHOICE:
case TYPE_TTCN3_SEQUENCE:
final TTCN3_Set_Seq_Choice_BaseType choice = (TTCN3_Set_Seq_Choice_BaseType)assType;
for (int i = 0; i < choice.getNofComponents(); i++) {
sb.append(ind).append(ICommentable.MEMBER_TAG).append(' ')
.append(choice.getComponentByIndex(i).getIdentifier().getDisplayName())
.append('\n');
}
break;
case TYPE_COMPONENT:
final Component_Type component = (Component_Type)assType;
for (final Definition def : component.getComponentBody().getDefinitions()) {
sb.append(ind).append(ICommentable.MEMBER_TAG).append(' ')
.append(def.getIdentifier().getDisplayName())
.append('\n');
}
break;
case TYPE_TTCN3_ENUMERATED:
final TTCN3_Enumerated_Type enumerated = (TTCN3_Enumerated_Type)assType;
for (final EnumItem item : enumerated.getEnumItemsOrdered()) {
sb.append(ind).append(ICommentable.MEMBER_TAG).append(' ')
.append(item.getId().getDisplayName())
.append('\n');
}
break;
default:
break;
}
sb.append(indentation).append(ICommentable.COMMENT_END).append(indentation);
return sb.toString();
}
// @Override
// public String generateDocComment(String indentation) {
// // TODO Auto-generated method stub
// return null;
// }
}
Loading