use of org.eclipse.titan.designer.AST.ASN1.ASN1Assignment in project titan.EclipsePlug-ins by eclipse.
the class AssignmentHandlerAFTRerences method visit.
@Override
public int visit(final IVisitableNode node) {
if (node instanceof ASN1Assignment) {
final ASN1Assignment assignment = (ASN1Assignment) node;
if (assignment.getAssPard() != null) {
return V_SKIP;
}
}
if (node instanceof StatementBlock) {
final ReferenceCollector referenceCollector = new ReferenceCollector();
node.accept(referenceCollector);
// TODO: broken if reference does not point anywhere
final Set<Reference> references = referenceCollector.getReferences();
addNonContagiousReferences(computeReferences(references));
if (containsErroneousReference(references)) {
setIsInfected(true);
}
return V_SKIP;
}
if (node instanceof Reference) {
final Identifier identifier = ((Reference) node).getId();
if (identifier != null) {
addContagiousReference(identifier.getDisplayName());
}
if (((Reference) node).getIsErroneous(CompilationTimeStamp.getBaseTimestamp())) {
setIsInfected(true);
setIsContagious(true);
return V_CONTINUE;
}
final Assignment assignment = ((Reference) node).getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false, null);
if (assignment == null || assignment.getIdentifier() == null || !assignment.getIdentifier().equals(identifier)) {
setIsInfected(true);
setIsContagious(true);
return V_CONTINUE;
}
}
return V_CONTINUE;
}
use of org.eclipse.titan.designer.AST.ASN1.ASN1Assignment in project titan.EclipsePlug-ins by eclipse.
the class Reference method refersToSettingType.
/**
* Checks if the reference is actually refering to a setting of the
* provided type, or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param settingType
* the setting type to check the reference against.
* @param referenceChain
* a referencechain to detect cyclic references.
*
* @return true if the reference refers to a setting of the provided
* kind, false otherwise.
*/
public boolean refersToSettingType(final CompilationTimeStamp timestamp, final Setting_type settingType, final IReferenceChain referenceChain) {
if (myScope == null) {
return Setting_type.S_ERROR.equals(settingType);
}
final Assignment assignment = getRefdAssignment(timestamp, true);
if (assignment == null) {
return false;
}
if (!(assignment instanceof ASN1Assignment)) {
getLocation().reportSemanticError(ASN1SETTINGEXPECTED);
setIsErroneous(true);
return false;
}
final ASN1Assignment asnAssignment = (ASN1Assignment) assignment;
switch(settingType) {
case S_OC:
return asnAssignment.isAssignmentType(timestamp, Assignment_type.A_OC, referenceChain);
case S_T:
return asnAssignment.isAssignmentType(timestamp, Assignment_type.A_TYPE, referenceChain);
case S_O:
return asnAssignment.isAssignmentType(timestamp, Assignment_type.A_OBJECT, referenceChain);
case S_V:
return asnAssignment.isAssignmentType(timestamp, Assignment_type.A_CONST, referenceChain);
case S_OS:
return asnAssignment.isAssignmentType(timestamp, Assignment_type.A_OS, referenceChain);
case S_VS:
return asnAssignment.isAssignmentType(timestamp, Assignment_type.A_VS, referenceChain);
case S_ERROR:
return asnAssignment.getIsErroneous();
default:
// FATAL_ERROR
return false;
}
}
use of org.eclipse.titan.designer.AST.ASN1.ASN1Assignment in project titan.EclipsePlug-ins by eclipse.
the class SpecialASN1Module method createSpecAsss.
/**
* Creates the special assignments by parsing the strings as if they
* were coming from an internal file and creating a module around them.
*
* @return the module of the special assignments created.
*/
private static ASN1Module createSpecAsss() {
if (null != specialAssignmentsModule) {
return specialAssignmentsModule;
}
final ASN1Assignments parsedAssignments = new ASN1Assignments();
ASN1Assignment actualAssignment;
for (String[] assignment : INTERNAL_ASSIGNMENTS) {
actualAssignment = SpecialASN1Module.parseSpecialInternalAssignment(assignment[1], new Identifier(Identifier_type.ID_ASN, assignment[0]));
parsedAssignments.addAssignment(actualAssignment);
}
// null as a project might not be a good idea
specialAssignmentsModule = new ASN1Module(new Identifier(Identifier_type.ID_ASN, INTERNAL_MODULE), null, Tag_types.AUTOMATIC_TAGS, false);
specialAssignmentsModule.setExports(new Exports(true));
specialAssignmentsModule.setImports(new Imports());
specialAssignmentsModule.setAssignments(parsedAssignments);
specialAssignmentsModule.setLocation(NULL_Location.INSTANCE);
specialAssignmentsModule.setScopeName(INTERNAL_MODULE);
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
final ModuleImportationChain referenceChain = new ModuleImportationChain(ModuleImportationChain.CIRCULARREFERENCE, false);
specialAssignmentsModule.checkImports(timestamp, referenceChain, new ArrayList<Module>());
specialAssignmentsModule.check(timestamp);
return specialAssignmentsModule;
}
use of org.eclipse.titan.designer.AST.ASN1.ASN1Assignment in project titan.EclipsePlug-ins by eclipse.
the class SpecialASN1Module method parseSpecialInternalAssignment.
/**
* Parses the special internal assignments to build their semantic
* representation.
*
* @param inputCode
* the code to parse.
* @param identifier
* the identifier for the assignment to be created.
*
* @return the parsed assignment.
*/
public static ASN1Assignment parseSpecialInternalAssignment(final String inputCode, final Identifier identifier) {
ASN1Assignment assignment = null;
final StringReader reader = new StringReader(inputCode);
final CharStream charStream = new UnbufferedCharStream(reader);
final Asn1Lexer lexer = new Asn1Lexer(charStream);
lexer.setTokenFactory(new TokenWithIndexAndSubTokensFactory(true));
final ASN1Listener lexerListener = new ASN1Listener();
// remove ConsoleErrorListener
lexer.removeErrorListeners();
lexer.addErrorListener(lexerListener);
final ModuleLevelTokenStreamTracker tracker = new ModuleLevelTokenStreamTracker(lexer);
tracker.discard(Asn1Lexer.WS);
tracker.discard(Asn1Lexer.MULTILINECOMMENT);
tracker.discard(Asn1Lexer.SINGLELINECOMMENT);
final Asn1Parser parser = new Asn1Parser(tracker);
parser.setBuildParseTree(false);
final ASN1Listener parserListener = new ASN1Listener(parser);
// remove ConsoleErrorListener
parser.removeErrorListeners();
parser.addErrorListener(parserListener);
assignment = parser.pr_TITAN_special_Assignment(identifier).assignment;
if (!parser.getErrorStorage().isEmpty()) {
ErrorReporter.INTERNAL_ERROR(PARSINGFAILED);
for (SyntacticErrorStorage temp : parser.getErrorStorage()) {
ErrorReporter.logError(temp.message);
}
}
return assignment;
}
use of org.eclipse.titan.designer.AST.ASN1.ASN1Assignment 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