use of org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment in project titan.EclipsePlug-ins by eclipse.
the class ReferenceFinder method detectAssignmentDataByOffset.
public boolean detectAssignmentDataByOffset(final Module module, final int offset, final IEditorPart targetEditor, final boolean reportErrors, final boolean reportDebugInformation) {
// detect the scope we are in
scope = module.getSmallestEnclosingScope(offset);
if (scope == null) {
if (reportErrors) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NORECOGNISABLESCOPE);
}
return false;
}
final IdentifierFinderVisitor visitor = new IdentifierFinderVisitor(offset);
module.accept(visitor);
final Declaration declaration = visitor.getReferencedDeclaration();
if (declaration == null) {
return false;
}
assignment = declaration.getAssignment();
if (assignment == null) {
if (reportErrors) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NORECOGNISABLEASSIGNMENT);
}
return false;
}
scope = detectSmallestScope(assignment);
// assignments which are created during SA
if (assignment instanceof Undefined_Assignment) {
assignment = ((Undefined_Assignment) assignment).getRealAssignment(CompilationTimeStamp.getBaseTimestamp());
if (assignment == null) {
if (reportErrors) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NORECOGNISABLEASSIGNMENT);
}
return false;
}
}
// in a field
if (assignment.getAssignmentType() == Assignment_type.A_TYPE) {
type = assignment.getType(CompilationTimeStamp.getBaseTimestamp());
if (type == null) {
if (reportErrors) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NOASSIGNMENTTYPE);
}
return false;
}
type.getEnclosingField(offset, this);
type = type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
}
if (reportDebugInformation) {
final MessageConsoleStream stream = TITANDebugConsole.getConsole().newMessageStream();
TITANDebugConsole.println("found scope: name=" + scope.getScopeName() + " type=" + scope.getClass().getName(), stream);
TITANDebugConsole.println("found assignment: name=" + assignment.getIdentifier().getDisplayName() + " type=" + assignment.getClass().getName(), stream);
if (type != null) {
TITANDebugConsole.println("found type: name=" + type.getTypename() + " type=" + type.getClass().getName(), stream);
}
if (fieldId != null) {
TITANDebugConsole.println("found field: name=" + fieldId.getDisplayName(), stream);
}
}
return true;
}
use of org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Type method getTypeRefd.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (refChain.add(this) && reference != null && !getIsErroneous(timestamp)) {
if (refd != null) {
return refd;
}
Assignment ass = reference.getRefdAssignment(timestamp, true, refChain);
if (ass != null && Assignment_type.A_UNDEF.semanticallyEquals(ass.getAssignmentType())) {
ass = ((Undefined_Assignment) ass).getRealAssignment(timestamp);
}
if (ass == null || ass.getIsErroneous()) {
// The referenced assignment was not found, or is erroneous
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
switch(ass.getAssignmentType()) {
case A_TYPE:
{
IType tempType = ass.getType(timestamp);
if (tempType != null) {
if (!tempType.getIsErroneous(timestamp)) {
tempType.check(timestamp);
tempType = tempType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, refChain, false);
if (tempType == null) {
setIsErroneous(true);
return this;
}
refd = tempType;
return refd;
}
}
break;
}
case A_VS:
{
final IType tempType = ass.getType(timestamp);
if (tempType == null) {
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
refd = tempType;
return refd;
}
case A_OC:
case A_OBJECT:
case A_OS:
final ISetting setting = reference.getRefdSetting(timestamp);
if (setting == null || setting.getIsErroneous(timestamp)) {
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
if (!Setting_type.S_T.equals(setting.getSettingtype())) {
reference.getLocation().reportSemanticError(MessageFormat.format(TYPEREFERENCEEXPECTED, reference.getDisplayName()));
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
refd = (Type) setting;
if (refd.getOwnertype() == TypeOwner_type.OT_UNKNOWN) {
refd.setOwnertype(TypeOwner_type.OT_REF, this);
}
return refd;
default:
reference.getLocation().reportSemanticError(MessageFormat.format(TYPEREFERENCEEXPECTED, reference.getDisplayName()));
break;
}
}
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
use of org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsViaReferences method getAssignmentsFrom.
public List<AssignmentHandler> getAssignmentsFrom(final Module module) {
final List<AssignmentHandler> assignmentHandlers = new ArrayList<AssignmentHandler>();
final Assignments assignments = module.getAssignments();
for (int d = 0; d < assignments.getNofAssignments(); ++d) {
final Assignment assignment = assignments.getAssignmentByIndex(d);
final AssignmentHandler assignmentHandler = AssignmentHandlerFactory.getDefinitionHandler(assignment);
if (assignment instanceof Undefined_Assignment) {
final ASN1Assignment realAssignment = ((Undefined_Assignment) assignment).getRealAssignment(CompilationTimeStamp.getBaseTimestamp());
if (realAssignment != null) {
realAssignment.accept(assignmentHandler);
} else {
// TODO: re-fine this branch
assignment.accept(assignmentHandler);
}
} else {
assignment.accept(assignmentHandler);
}
assignmentHandlers.add(assignmentHandler);
}
return assignmentHandlers;
}
Aggregations