use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class Anytype_Type method addProposal.
/**
* Searches and adds a completion proposal to the provided collector if a
* valid one is found.
* <p>
* In case of structural types, the member fields are checked if they could
* complete the proposal.
*
* @param propCollector the proposal collector to add the proposal to, and
* used to get more information
* @param i index, used to identify which element of the reference (used by
* the proposal collector) should be checked for completions.
*/
@Override
public /**
* {@inheritDoc}
*/
void addProposal(final ProposalCollector propCollector, final int i) {
final List<ISubReference> subreferences = propCollector.getReference().getSubreferences();
if (subreferences.size() <= i) {
return;
}
final ISubReference subreference = subreferences.get(i);
if (Subreference_type.fieldSubReference.equals(subreference.getReferenceType())) {
if (subreferences.size() > i + 1) {
// the reference might go on
final CompField compField = compFieldMap.getCompWithName(subreference.getId());
if (compField == null) {
return;
}
final IType type = compField.getType();
if (type != null) {
type.addProposal(propCollector, i + 1);
}
} else {
// final part of the reference
final List<CompField> compFields = compFieldMap.getComponentsWithPrefixCaseInsensitive(subreference.getId().getName());
for (final CompField compField : compFields) {
final String proposalKind = compField.getType().getProposalDescription(new StringBuilder()).toString();
propCollector.addProposal(compField.getIdentifier(), " - " + proposalKind, ImageCache.getImage(getOutlineIcon()), proposalKind);
}
}
}
}
use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class Array_Type method addProposal.
@Override
public /**
* {@inheritDoc}
*/
void addProposal(final ProposalCollector propCollector, final int i) {
final List<ISubReference> subreferences = propCollector.getReference().getSubreferences();
if (subreferences.size() < i) {
return;
} else if (subreferences.size() == i) {
final ISubReference subreference = subreferences.get(i - 1);
if (Subreference_type.fieldSubReference.equals(subreference.getReferenceType())) {
final String candidate = ((FieldSubReference) subreference).getId().getDisplayName();
propCollector.addTemplateProposal(candidate, new Template(candidate + "[index]", candidate + " with index", propCollector.getContextIdentifier(), candidate + "[${index}]", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
}
return;
}
final ISubReference subreference = subreferences.get(i);
if (Subreference_type.arraySubReference.equals(subreference.getReferenceType())) {
if (subreferences.size() > i + 1 && elementType != null) {
elementType.addProposal(propCollector, i + 1);
}
}
}
use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class BitString_Type method getFieldType.
@Override
public /**
* {@inheritDoc}
*/
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return this;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
if (subreferences.size() > actualSubReference + 1) {
subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
return null;
} else if (subreferences.size() == actualSubReference + 1) {
reference.setStringElementReferencing();
}
final Value indexValue = ((ArraySubReference) subreference).getValue();
checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
return this;
case fieldSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class Signature_Type method getFieldType.
@Override
public /**
* {@inheritDoc}
*/
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return this;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
return null;
case fieldSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Enumerated_Type method addDeclaration.
public void addDeclaration(final DeclarationCollector declarationCollector, final int i, final Location commentLocation) {
final List<ISubReference> subreferences = declarationCollector.getReference().getSubreferences();
if (i != 0 || subreferences.size() != 1 || declarationCollector.getReference().getModuleIdentifier() != null) {
return;
}
final ISubReference subreference = subreferences.get(i);
if (Subreference_type.fieldSubReference.equals(subreference.getReferenceType()) && items != null) {
if (commentLocation != null) {
items.addDeclaration(declarationCollector, i, commentLocation);
}
}
}
Aggregations