Commit 43d4131d authored by Miklos Magyari's avatar Miklos Magyari Committed by Adam Knapp
Browse files

Implemented IMemberInfo for supplying info from AST where no doc comment is present

parent ceb0f1ec
......@@ -42,9 +42,11 @@ import org.eclipse.titan.designer.AST.TTCN3.types.Address_Type;
import org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type;
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.CompField;
import org.eclipse.titan.designer.AST.TTCN3.types.Component_Type;
import org.eclipse.titan.designer.AST.TTCN3.types.EnumItem;
import org.eclipse.titan.designer.AST.TTCN3.types.Function_Type;
import org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type;
import org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type;
import org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType;
import org.eclipse.titan.designer.AST.TTCN3.types.Testcase_Type;
......@@ -623,6 +625,11 @@ public final class Def_Type extends Definition {
}
} else if (dc != null) {
dc.addMembersContent(hoverContent);
} else {
if (assType instanceof IMemberInfo) {
final IMemberInfo mInfo = (IMemberInfo)assType;
mInfo.addMembersContent(hoverContent);
}
}
if (dc != null) {
dc.addStatusContent(hoverContent);
......
/******************************************************************************
* Copyright (c) 2000-2022 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
******************************************************************************/
package org.eclipse.titan.designer.AST.TTCN3.definitions;
import org.eclipse.titan.designer.editors.controls.Ttcn3HoverContent;
/**
* This interface represents an element that can provide information about its members
*
* @author Miklos Magyari
*
*/
public interface IMemberInfo {
public void addMembersContent(Ttcn3HoverContent content);
}
......@@ -13,6 +13,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.titan.common.logging.ErrorReporter;
import org.eclipse.titan.designer.AST.Assignment;
import org.eclipse.titan.designer.AST.CachedReferenceChain;
......@@ -40,6 +41,7 @@ import org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct;
import org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_field_type;
import org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_fields;
import org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_taglist;
import org.eclipse.titan.designer.AST.TTCN3.definitions.IMemberInfo;
import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template;
import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Completeness_type;
import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Template_type;
......@@ -52,13 +54,15 @@ import org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value.Operation_ty
import org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct;
import org.eclipse.titan.designer.compiler.BuildTimestamp;
import org.eclipse.titan.designer.compiler.JavaGenData;
import org.eclipse.titan.designer.editors.controls.Ttcn3HoverContent;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
/**
* @author Kristof Szabados
* @author Arpad Lovassy
* @author Miklos Magyari
* */
public final class TTCN3_Choice_Type extends TTCN3_Set_Seq_Choice_BaseType {
public final class TTCN3_Choice_Type extends TTCN3_Set_Seq_Choice_BaseType implements IMemberInfo {
private static final String UNSUPPERTED_FIELDNAME =
"Sorry, but it is not supported for sequence types to have a field with a name (`{0}'') which exactly matches the name of the type definition.";
private static final String TEMPLATENOTALLOWED = "{0} cannot be used for union type `{1}''";
......@@ -1122,4 +1126,21 @@ public final class TTCN3_Choice_Type extends TTCN3_Set_Seq_Choice_BaseType {
return tempId;
}
@Override
public void addMembersContent(Ttcn3HoverContent content) {
if (getNofComponents() > 0) {
content.addTag("Members");
for (int i = 0; i < getNofComponents(); i++) {
final CompField field = getComponentByIndex(i);
final IType memberType = field.getType();
String memberTypeName = "";
if (memberType != null) {
memberTypeName = memberType.getTypename();
}
content.addStyledText(memberTypeName + " ", SWT.BOLD);
content.addStyledText(field.getIdentifier().getDisplayName(), SWT.ITALIC).addText("<br>");
}
}
}
}
......@@ -13,6 +13,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.titan.designer.AST.ASTVisitor;
import org.eclipse.titan.designer.AST.ArraySubReference;
import org.eclipse.titan.designer.AST.Assignment;
......@@ -41,6 +42,7 @@ import org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type;
import org.eclipse.titan.designer.AST.TTCN3.attributes.JsonAST;
import org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
import org.eclipse.titan.designer.AST.TTCN3.definitions.IMemberInfo;
import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template;
import org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template.Template_type;
import org.eclipse.titan.designer.AST.TTCN3.types.EnumeratedGenerator.Enum_Defs;
......@@ -68,7 +70,7 @@ import org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReparseUpdater;
* @author Kristof Szabados
* @author Arpad Lovassy
*/
public final class TTCN3_Enumerated_Type extends Type implements ITypeWithComponents {
public final class TTCN3_Enumerated_Type extends Type implements ITypeWithComponents, IMemberInfo {
public static final String COMPILE_TIME_VALUE_CHECK = "A value known at compile time was expected for enumeration `{0}''";
public static final String VALUE_TYPE_CHECK = "INTEGER or BITSTRING or OCTETSTRING or HEXSTRING value was expected for enumeration `{0}''";
public static final String DUPLICATEENUMERATIONIDENTIFIERFIRST = "Duplicate enumeration identifier `{0}'' was first declared here";
......@@ -971,4 +973,18 @@ public final class TTCN3_Enumerated_Type extends Type implements ITypeWithCompon
}
return null;
}
@Override
public void addMembersContent(Ttcn3HoverContent content) {
final List<EnumItem> enumItems = items.getItems();
final int nofItems = enumItems.size();
if (nofItems == 0) {
return;
}
content.addTag("Members");
for (int i = 0; i < nofItems; i++) {
final EnumItem item = enumItems.get(i);
content.addStyledText(item.getDeclaration().getIdentifier().getDisplayName(), SWT.ITALIC).addText("<br>");
}
}
}
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