use of org.eclipse.titan.designer.parsers.CompilationTimeStamp in project titan.EclipsePlug-ins by eclipse.
the class VerdictWithoutReason method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (!(node instanceof Setverdict_Statement)) {
return;
}
final Setverdict_Statement s = (Setverdict_Statement) node;
final Value verdictValue = s.getVerdictValue();
if (verdictValue == null) {
return;
}
final CompilationTimeStamp ct = CompilationTimeStamp.getBaseTimestamp();
final Type_type temp = verdictValue.getExpressionReturntype(ct, Expected_Value_type.EXPECTED_TEMPLATE);
if (Type_type.TYPE_VERDICT != temp) {
return;
}
final LogArguments verdictReason = s.getVerdictReason();
if (Value_type.VERDICT_VALUE.equals(verdictValue.getValuetype()) && !Verdict_type.PASS.equals(((Verdict_Value) verdictValue).getValue()) && verdictReason == null) {
final String msg = MessageFormat.format(WITHOUT_REASON, ((Verdict_Value) verdictValue).getValue());
problems.report(s.getLocation(), msg);
}
}
use of org.eclipse.titan.designer.parsers.CompilationTimeStamp in project titan.EclipsePlug-ins by eclipse.
the class UnnecessaryValueof method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof ValueofExpression) {
final ValueofExpression exp = (ValueofExpression) node;
final CompilationTimeStamp stamp = CompilationTimeStamp.getBaseTimestamp();
if (exp.getIsErroneous(stamp) || exp.isUnfoldable(stamp, null)) {
return;
}
final TemplateInstance inst = exp.getTemplateInstance();
if (inst != null && inst.getDerivedReference() == null && inst.getTemplateBody().isValue(stamp)) {
final String msg = MessageFormat.format(TEXT, inst.getTemplateBody().getValue().createStringRepresentation());
problems.report(exp.getLocation(), msg);
}
}
}
use of org.eclipse.titan.designer.parsers.CompilationTimeStamp in project titan.EclipsePlug-ins by eclipse.
the class ConsecutiveAssignments method process.
@Override
protected void process(final IVisitableNode node, final Problems problems) {
if (!(node instanceof StatementBlock)) {
return;
}
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
int count = 0;
boolean limitReached = false;
Location smellLoc = null;
Assignment_Statement lastAs = null;
Assignment toMatch = null;
final StatementBlock sb = (StatementBlock) node;
// iterate statements in block
for (int i = 0; i < sb.getSize(); i++) {
final Statement s = sb.getStatementByIndex(i);
if (!(s instanceof Assignment_Statement)) {
if (limitReached) {
smellLoc.setEndOffset(lastAs.getLocation().getEndOffset());
problems.report(smellLoc, ERROR_MESSAGE);
limitReached = false;
}
count = 0;
toMatch = null;
continue;
}
final Assignment_Statement as = (Assignment_Statement) s;
final Reference ref = as.getReference();
final Assignment a = ref.getRefdAssignment(timestamp, false);
if (a == null) {
if (limitReached) {
smellLoc.setEndOffset(lastAs.getLocation().getEndOffset());
problems.report(smellLoc, ERROR_MESSAGE);
limitReached = false;
}
count = 0;
toMatch = null;
continue;
}
// consecutive assignments: consecutive Assignment_Statements have the same definition
if (toMatch == null) {
toMatch = a;
} else if (toMatch != a) {
if (limitReached) {
smellLoc.setEndOffset(lastAs.getLocation().getEndOffset());
problems.report(smellLoc, ERROR_MESSAGE);
limitReached = false;
}
count = 0;
toMatch = a;
}
if (count == 0) {
smellLoc = new Location(as.getLocation());
}
lastAs = as;
count++;
if (count >= minCountToMark) {
limitReached = true;
}
}
if (limitReached) {
smellLoc.setEndOffset(lastAs.getLocation().getEndOffset());
problems.report(smellLoc, ERROR_MESSAGE);
}
}
Aggregations