private Issue createPostProcessingFailedError(N4JSResource res, Throwable th) { final String thKind = th instanceof Error ? "error" : (th instanceof Exception ? "exception" : "throwable"); final String thName = th.getClass().getSimpleName(); final String trace = "\n" + Stream.of(th.getStackTrace()) .map(ste -> ste.toString()) .collect(Collectors.joining("\n")); // cannot add indentation, because Xtext would reformat the message final String msg = IssueCodes.getMessageForPOST_PROCESSING_FAILED(thKind, thName, th.getMessage() + trace); final Issue.IssueImpl issue = new Issue.IssueImpl(); issue.setCode(IssueCodes.POST_PROCESSING_FAILED); issue.setSeverity(IssueCodes.getDefaultSeverity(IssueCodes.POST_PROCESSING_FAILED)); issue.setMessage(msg); issue.setUriToProblem(EcoreUtil.getURI(res.getScript())); issue.setType(CheckType.FAST); // using CheckType.FAST is important to get proper marker update behavior in ... // ... the editor between persisted and dirty states! issue.setOffset(0); issue.setLength(0); issue.setLineNumber(0); issue.setColumn(0); return issue; }
@Check(CheckType.FAST) public void checkUnusedEntry(final Entry entry) { if (entry.getParentRegion().getComposite() instanceof org.yakindu.sct.model.sgraph.State && entry.getIncomingTransitions().isEmpty()) { org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) entry.getParentRegion() .getComposite(); if (!STextValidationModelUtils.isDefault(entry)) { boolean hasIncomingTransition = false; Iterator<Transition> transitionIt = state.getIncomingTransitions().iterator(); while (transitionIt.hasNext() && !hasIncomingTransition) { Iterator<ReactionProperty> propertyIt = transitionIt.next().getProperties().iterator(); while (propertyIt.hasNext() && !hasIncomingTransition) { ReactionProperty property = propertyIt.next(); if (property instanceof EntryPointSpec) { hasIncomingTransition = entry.getName().equals(((EntryPointSpec) property).getEntrypoint()); } } } if (!hasIncomingTransition) { warning(ENTRY_UNUSED, entry, null, -1); } } } }
@Check(CheckType.FAST) public void checkValueOfNoEvent(EventValueReferenceExpression exp) { Expression eventExpr = exp.getValue(); EObject element = null; if (eventExpr instanceof ElementReferenceExpression) { element = ((ElementReferenceExpression) eventExpr).getReference(); } else if (eventExpr instanceof FeatureCall) { element = ((FeatureCall) eventExpr).getFeature(); } if (element != null && (!(element instanceof Event))) { String elementName = ""; if (element instanceof NamedElement) { elementName = "'" + ((NamedElement) element).getName() + "' "; } error(elementName + "is no event.", StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION__VALUE, 0, VALUE_OF_REQUIRES_EVENT); } }
@Check(CheckType.NORMAL) public void checkTopLeveEntryIsDefaultEntry(final Entry entry) { Region parentRegion = entry.getParentRegion(); // 1. check if is toplevel if (isTopLevelRegion(parentRegion)) { boolean isDefaultEntry = STextValidationModelUtils.isDefault(entry); // 2. check if is default entry if (!isDefaultEntry) { Map<Region, List<Entry>> regionsWithoutDefaultEntry = STextValidationModelUtils .getRegionsWithoutDefaultEntry(Lists.newArrayList(parentRegion)); List<Entry> list = regionsWithoutDefaultEntry.get(parentRegion); if (list != null) error(TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY, entry, SGraphPackage.Literals.ENTRY__KIND, -1); else warning(TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY, entry, SGraphPackage.Literals.ENTRY__KIND, -1); } } }
@Check(CheckType.FAST) public void checkAssignmentExpression(final AssignmentExpression exp) { final String name = getVariableName(exp); List<AssignmentExpression> contents = EcoreUtil2.eAllOfType(exp, AssignmentExpression.class); contents.remove(exp); Iterable<AssignmentExpression> filter = Iterables.filter(contents, new Predicate<AssignmentExpression>() { public boolean apply(final AssignmentExpression ex) { String variableName = getVariableName(ex); return variableName.equals(name); } }); if (Iterables.size(filter) > 0) { error(ASSIGNMENT_EXPRESSION, null); } }
@Check(CheckType.FAST) public void checkReactionTriggerRegularEvent(ReactionTrigger reactionTrigger) { for (int i = 0; i < reactionTrigger.getTriggers().size(); i++) { EventSpec eventSpec = reactionTrigger.getTriggers().get(i); if (eventSpec instanceof RegularEventSpec) { EObject element = unwrap(((RegularEventSpec) eventSpec).getEvent()); if (element != null && (!(element instanceof Event))) { String elementName = ""; if (element instanceof NamedElement) { elementName = "'" + ((NamedElement) element).getName() + "' "; } error("Trigger " + elementName + "is no event.", StextPackage.Literals.REACTION_TRIGGER__TRIGGERS, i, TRIGGER_IS_NO_EVENT); } } } }
/** * Only Expressions that produce an effect should be used as actions. * * @param effect */ @Check(CheckType.FAST) public void checkReactionEffectActions(ReactionEffect effect) { for (Expression exp : effect.getActions()) { if (!(exp instanceof AssignmentExpression) && !(exp instanceof EventRaisingExpression) && !(exp instanceof PostFixUnaryExpression)) { if (exp instanceof FeatureCall) { checkFeatureCallEffect((FeatureCall) exp); } else if (exp instanceof ElementReferenceExpression) { checkElementReferenceEffect((ElementReferenceExpression) exp); } else { error("Action has no effect.", StextPackage.Literals.REACTION_EFFECT__ACTIONS, effect.getActions().indexOf(exp), FEATURE_CALL_HAS_NO_EFFECT); } } } }
@Check(CheckType.FAST) public void checkAnnotationTarget(final AnnotatableElement element) { EList<Annotation> annotations = element.getAnnotations(); for (Annotation annotation : annotations) { EList<EObject> targets = annotation.getType().getTargets(); if(targets.isEmpty()) continue; boolean found = Iterables.any(targets, new Predicate<EObject>() { @Override public boolean apply(EObject input) { return ((EClass) input).isInstance(element); } }); if (!found) { error(String.format(ERROR_WRONG_ANNOTATION_TARGET_MSG, annotation.getType().getName(), element.eClass()), null, element.getAnnotations().indexOf(annotation), ERROR_WRONG_ANNOTATION_TARGET_CODE); } } }
@Check(CheckType.NORMAL) public void checkDesignNameUnique(Design design) { List<Design> designs = new ArrayList<Design>(); IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(design.eResource() .getURI()); List<IContainer> visiblecontainers = containermanager.getVisibleContainers(resourceDescription, resourceDescriptions); for (IContainer container : visiblecontainers) { for (IEObjectDescription eobjectDescription : container.getExportedObjects()) { EObject eObjectOrProxy = eobjectDescription.getEObjectOrProxy(); if (eObjectOrProxy instanceof Design) designs.add((Design) eObjectOrProxy); } } int count = 0; for (Design d : designs) { if (d.eIsProxy()) d = (Design) EcoreUtil.resolve(d, design); if (design.getName().equals(d.getName())) count++; } if (count > 1) error("Duplicate design in project.", PhdlPackage.Literals.DESIGN__NAME); }
@Check(CheckType.FAST) public void checkDevicePhysicalPinNames(Device d) { Map<String, Pin> pinMap = new HashMap<String, Pin>(); for (DeviceElement element : d.getElements()) { if (element instanceof Pin) { Pin p = (Pin) element; List<String> pinList = p.getPinNames(); for (int i = 0; i < (pinList.size()); i++) { String pinNum = pinList.get(i); if (pinMap.containsKey(pinNum)) { EStructuralFeature f = PhdlPackage.Literals.PIN__PIN_NAMES; error("Duplicate physical pin name.", p, f, i); Pin orig = pinMap.get(pinNum); error("Duplicate physical pin name.", orig, f, orig.getPinNames().indexOf(pinNum)); } else pinMap.put(pinNum, p); } } } }
@Check(CheckType.FAST) public void checkDevicePinDeclarations(Device d) { for (DeviceElement element : d.getElements()) { if (element instanceof Pin) { Pin p = (Pin) element; int index = d.getElements().indexOf(p); int width = (Math.abs(p.getVector().getMsb() - p.getVector().getLsb())) + 1; if (width != p.getPinNames().size()) error("Pin declaration width mismatch. Left=" + width + ", right=" + p.getPinNames().size() + ".", d, PhdlPackage.Literals.DEVICE__ELEMENTS, d.getElements().indexOf(element), IssueCodes.INVALID_PIN_DECLARATION, Integer.toString(index), Boolean.toString(p.getVector().isVector()), Integer.toString(width), Integer.toString(p.getPinNames().size())); } } }
@Check(CheckType.FAST) public void checkDeviceRequiredAttributes(Device d) { for (String reqAttr : reqAttrs) { boolean found = false; for (DeviceElement element : d.getElements()) { if (element instanceof Attr) { Attr a = (Attr) element; if (a.getName().equalsIgnoreCase(reqAttr)) { found = true; break; } } } if (!found) { error("Required attribute '" + reqAttr + "' missing.", d, PhdlPackage.Literals.DEVICE__NAME, -1, IssueCodes.REQUIRED_ATTRIBUTE_MISSING, reqAttr); } } }
@Check(CheckType.NORMAL) public void checkPackageNameUnique(Package pkg) { List<Package> packages = new ArrayList<Package>(); IResourceDescription resourceDescription = resourceDescriptions .getResourceDescription(pkg.eResource().getURI()); List<IContainer> visiblecontainers = containermanager.getVisibleContainers(resourceDescription, resourceDescriptions); for (IContainer container : visiblecontainers) { for (IEObjectDescription eobjectDescription : container.getExportedObjects()) { EObject eObjectOrProxy = eobjectDescription.getEObjectOrProxy(); if (eObjectOrProxy instanceof Package) packages.add((Package) eObjectOrProxy); } } int count = 0; for (Package p : packages) { if (p.eIsProxy()) p = (Package) EcoreUtil.resolve(p, pkg); if (pkg.getName().equals(p.getName())) count++; } if (count > 1) error("Duplicate package in project.", PhdlPackage.Literals.PACKAGE__NAME); }
@Check(CheckType.FAST) public void checkPinAssignQualifiers(PinAssign p) { Instance i = (Instance) p.eContainer(); if (i.getArray().isArray()) { if (p.getQualifier() != null) { if (p.getQualifier().getIndices().isArray()) { if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), p.getQualifier() .getIndices().getMsb())) invalidMsbError(p.getQualifier().getIndices(), PhdlPackage.Literals.INDICES__MSB); if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), p.getQualifier() .getIndices().getLsb())) invalidLsbError(p.getQualifier().getIndices(), PhdlPackage.Literals.INDICES__LSB); } else { for (Integer index : p.getQualifier().getIndices().getIndices()) if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), index)) invalidIndexError(p.getQualifier().getIndices(), p.getQualifier().getIndices().getIndices() .indexOf(index), PhdlPackage.Literals.INDICES__INDICES); } } } else { if (p.getQualifier() != null) qualifierNotAllowedError(p, PhdlPackage.Literals.PIN_ASSIGN__QUALIFIER); } }
@Check(CheckType.FAST) public void checkPortAssignQualifiers(PortAssign p) { Instance i = (Instance) p.eContainer(); if (i.getArray().isArray()) { if (p.getQualifier() != null) { if (p.getQualifier().getIndices().isArray()) { if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), p.getQualifier() .getIndices().getMsb())) invalidMsbError(p.getQualifier().getIndices(), PhdlPackage.Literals.INDICES__MSB); if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), p.getQualifier() .getIndices().getLsb())) invalidLsbError(p.getQualifier().getIndices(), PhdlPackage.Literals.INDICES__LSB); } else { for (Integer index : p.getQualifier().getIndices().getIndices()) if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), index)) invalidIndexError(p.getQualifier().getIndices(), p.getQualifier().getIndices().getIndices() .indexOf(index), PhdlPackage.Literals.INDICES__INDICES); } } } else { if (p.getQualifier() != null) qualifierNotAllowedError(p, PhdlPackage.Literals.PORT_ASSIGN__QUALIFIER); } }
@Check(CheckType.FAST) public void checkAppDoesNotContainsParentModel(UIApplication app) { Model[] models = (Model[]) app.getModels().toArray(); if (models.length > 1) { for (int i = 0; i < models.length - 1; i++) { for (int j = i + 1; j < models.length; j++) { if (this.containsModel(models[i], models[j])) { error("This Model is present in the Model " + models[i].getName(), app, MvcPackage.Literals.UI_APPLICATION__MODELS, j); } else if (this.containsModel(models[j], models[i])) { error("This Model is present in the Model " + models[j].getName(), app, MvcPackage.Literals.UI_APPLICATION__MODELS, i); } } } } }
@Check(CheckType.FAST) public void checkConnectionStatement(ConnectionStatement conn) { Classifier container = conn.getContainingClassifier(); if (container instanceof ComponentImplementation) { NamedElement aadlConn = conn.getConn(); if (aadlConn == null) { return; } if (!(aadlConn instanceof Connection)) { error(conn, "The connection label in the connection statement is not a connection"); return; } } else { error(conn, "Connection statements are only allowed in component implementations."); } }
@Check(CheckType.FAST) public void checkMNSynchStatement(MNSynchStatement sync) { if (sync.getMax().size() != sync.getMin().size() && sync.getMax().size() != sync.getComp1().size() && sync.getMax().size() != sync.getComp2().size()) { return; // this should throw a parser error } for (int i = 0; i < sync.getMax().size(); i++) { String maxStr = sync.getMax().get(i); String minStr = sync.getMin().get(i); int max = Integer.valueOf(maxStr); int min = Integer.valueOf(minStr); if (max < 1 || min < 1) { error(sync, "Quasi-synchronous values must be greater than zero"); } if (min > max) { error("Left hand side quasi-synchronous values must be greater than the right hand side"); } } }
@Check(CheckType.FAST) public void checkAssume(AssumeStatement assume) { Classifier comp = assume.getContainingClassifier(); if (!(comp instanceof ComponentType)) { error(assume, "Assume statements are only allowed in component types"); } //the expression could be null if a pattern is used Expr expr = assume.getExpr(); if (expr != null) { AgreeType exprType = getAgreeType(expr); if (!matches(BOOL, exprType)) { error(assume, "Expression for assume statement is of type '" + exprType.toString() + "' but must be of type 'bool'"); } } }
@Check(CheckType.FAST) public void checkLift(LiftStatement lift) { NestedDotID dotId = lift.getSubcomp(); if (dotId.getSub() != null) { error(lift, "Lift statements can only be applied to direct subcomponents." + "Place a lift statement in the subcomponents contract for heavy lifting"); } NamedElement namedEl = dotId.getBase(); if (namedEl != null) { if (!(namedEl instanceof SubcomponentImpl)) { error(lift, "Lift statements must apply to subcomponent implementations. '" + namedEl.getName() + "' is not a subcomponent."); } // } else { // SubcomponentImpl subImpl = (SubcomponentImpl) namedEl; // if (subImpl.getComponentImplementation() == null) { // error(lift, "Lift statements must apply to subcomponent implementations. '" // + namedEl.getName() // + "' is a subcomponent type, not a subcomponent implementation."); // } // } } }
@Check(CheckType.FAST) public void checkAssert(AssertStatement asser) { Classifier comp = asser.getContainingClassifier(); if (!(comp instanceof ComponentImplementation)) { error(asser, "Assert statements are only allowed in component implementations."); } //the expression could be null if a pattern is used Expr expr = asser.getExpr(); if (expr != null) { AgreeType exprType = getAgreeType(expr); if (!matches(BOOL, exprType)) { error(asser, "Expression for assert statement is of type '" + exprType.toString() + "' but must be of type 'bool'"); } } warning(asser, "We highly discourage the use of assert statements. " + "They can easily lead to inconsistent or unrealizable systems. " + "Note that our realizability check does not verify that component " + "assertions are realizable. It is likely that you can specify the " + "behavior you want by changing the subcomponent contracts or " + "by using assignment statements."); }
@Check(CheckType.FAST) public void checkAADLEnumerator(AADLEnumerator aadlEnum) { NestedDotID enumType = aadlEnum.getEnumType(); NamedElement enumTypeNamedElement = getFinalNestId(enumType); if (!AgreeAADLEnumerationUtils.isAADLEnumeration(enumTypeNamedElement)) { error(enumType, "AADL Enumerations must refer to a Data Type with \"Enum\" data representation " + "property and have an \"Enumerators\' property value list."); } else { String enumVal = aadlEnum.getValue(); List<String> enumerators = AgreeAADLEnumerationUtils .getEnumerators((ComponentClassifier) enumTypeNamedElement).stream() .map(pe -> ((org.osate.aadl2.StringLiteral) pe).getValue()).collect(Collectors.toList()); if (!enumerators.stream().anyMatch(ev -> ev.equalsIgnoreCase(enumVal))) { error(aadlEnum, "AADL Enumeration " + enumTypeNamedElement.getQualifiedName() + " does not have an enumeration value " + enumVal); } } }
@Check(CheckType.FAST) public void checkGuarantee(GuaranteeStatement guar) { Classifier comp = guar.getContainingClassifier(); if (!(comp instanceof ComponentType)) { error(guar, "Guarantee statements are only allowed in component types"); } //the expression could be null if a pattern is used Expr expr = guar.getExpr(); if (expr != null) { AgreeType exprType = getAgreeType(expr); if (!matches(BOOL, exprType)) { error(guar, "Expression for guarantee statement is of type '" + exprType.toString() + "' but must be of type 'bool'"); } } }
@Check(CheckType.FAST) public void checkWhenOccursStatment(WhenOccursStatment when){ Expr condition = when.getCondition(); Expr event = when.getEvent(); Expr times = when.getTimes(); checkExprIsIdentifier(condition); checkExprIsIdentifier(event); AgreeType type = getAgreeType(condition); if(!matches(BOOL, type)){ error(condition, "The condition of the 'when' statement is of type '" +type +"'" + " but must be of type 'bool'"); } type = getAgreeType(event); if(!matches(BOOL, type)){ error(event, "The effect of the 'when' statement is of type '" +type+"'" + " but must be of type 'bool'"); } type = getAgreeType(times); if(!matches(INT, type)){ error(event, "The 'times' of the 'when' statement is of type '" +type+"'" + " but must be of type 'int'"); } }
@Check(CheckType.FAST) public void checkWheneverOccursStatement(WheneverOccursStatement whenever){ Expr cause = whenever.getCause(); Expr effect = whenever.getEffect(); checkExprIsIdentifier(cause); checkExprIsIdentifier(effect); AgreeType type = getAgreeType(cause); if(!matches(BOOL, type)){ error(cause, "The cause of the 'whenever' statement is of type '"+type+"' " + "but must be of type 'bool'"); } type = getAgreeType(effect); if(!matches(BOOL, type)){ error(effect, "The effect of the 'whenever' statement is of type '"+type+"' " + "but must be of type 'bool'"); } }
@Check(CheckType.FAST) public void checkWheneverBecomesTrueStatement(WheneverBecomesTrueStatement whenever){ Expr cause = whenever.getCause(); Expr effect = whenever.getEffect(); checkExprIsIdentifier(cause); checkExprIsIdentifier(effect); AgreeType type = getAgreeType(cause); if(!matches(BOOL, type)){ error(cause, "The cause of the 'whenever' statement is of type '"+type+"' " + "but must be of type 'bool'"); } type = getAgreeType(effect); if(!matches(BOOL, type)){ error(effect, "The effect of the 'whenever' statement is of type '"+type+"' " + "but must be of type 'bool'"); } }
@Check(CheckType.FAST) public void checkWheneverHoldsStatement(WheneverHoldsStatement whenever) { Expr cause = whenever.getCause(); Expr effect = whenever.getEffect(); checkExprIsIdentifier(cause); checkExprIsIdentifier(effect); AgreeType type = getAgreeType(cause); if (!matches(BOOL, type)) { error(cause, "The cause of the 'whenever' statement is of type '" + type + "' " + "but must be of type 'bool'"); } type = getAgreeType(effect); if (!matches(BOOL, type)) { error(effect, "The effect of the 'whenever' statement is of type '" + type + "' " + "but must be of type 'bool'"); } }
@Check(CheckType.FAST) public void checkTimeInterval(TimeInterval interval){ Expr lower = interval.getLow(); Expr higher = interval.getHigh(); // AgreeType lowerType = getAgreeType(lower); // AgreeType higherType = getAgreeType(higher); if(!(lower instanceof RealLitExpr || isConst(lower))){ error(lower, "Lower interval must be a real valued literal"); } if(!(higher instanceof RealLitExpr || isConst(higher))){ error(higher, "higher interval must be a real valued literal"); } }
@Check(CheckType.FAST) public void checkLemma(LemmaStatement lemma) { Classifier comp = lemma.getContainingClassifier(); if (!(comp instanceof ComponentImplementation)) { error(lemma, "Lemma statements are only allowed in component implementations and nodes"); } Expr expr = lemma.getExpr(); if (expr != null) { AgreeType exprType = getAgreeType(expr); if (!matches(BOOL, exprType)) { error(lemma, "Expression for lemma statement is of type '" + exprType.toString() + "' but must be of type 'bool'"); } } }
@Check(CheckType.FAST) public void checkUnaryExpr(UnaryExpr unaryExpr) { AgreeType typeRight = getAgreeType(unaryExpr.getExpr()); String op = unaryExpr.getOp(); switch (op) { case "-": if (!matches(INT, typeRight) && !matches(REAL, typeRight)) { error(unaryExpr, "right side of unary expression '" + op + "' is of type '" + typeRight + "' but must be of type 'int' or 'real'"); } break; case "not": if (!matches(BOOL, typeRight)) { error(unaryExpr, "right side of unary expression '" + op + "' is of type '" + typeRight + "' but must be of type 'bool'"); } break; default: assert (false); } }
@Check(CheckType.FAST) public void checkLinearizationInterval(LinearizationInterval linInterval) { final String message = "Linearization interval endpoints must be constant expressions of real type"; Expr startExpr = linInterval.getStart(); Expr endExpr = linInterval.getEnd(); AgreeType startExprType = getAgreeType(startExpr); AgreeType endExprType = getAgreeType(endExpr); // The type of the interval start and end must be of real type if (!matches(startExprType, REAL)) { error(startExpr, message + ", found type " + startExprType + "."); } if (!matches(endExprType, REAL)) { error(endExpr, message + ", found type " + endExprType + "."); } // The interval start and end expressions must be constant if (!exprIsConst(startExpr)) { error(endExpr, message + ", found non-constant expression."); } if (!exprIsConst(startExpr)) { error(endExpr, message + ", found non-constant expression."); } }
@Check(CheckType.FAST) public void checkFnCallExpr(FnCallExpr fnCall) { NamedElement fn = getFinalNestId(fnCall.getFn()); if (isInLinearizationBody(fnCall)) { if (fn instanceof NodeDefExpr) { error(fnCall, "Node definitions cannot be applied in a linearization definition"); } } else { if (fn instanceof LibraryFnDefExpr) { if (fn.getElementRoot().getName().equalsIgnoreCase("dreal")) { warning(fnCall, "dReal library functions require the use of the dReal solver"); } else { error(fnCall, "Library functions cannot be called from the logic"); } } } checkInputsVsActuals(fnCall); }
@Check(CheckType.FAST) public void checkIfThenElseExpr(IfThenElseExpr expr) { if (isInLinearizationBody(expr)) { error(expr, "If-then-else expressions not allowed in linearization body expressions"); return; } AgreeType condType = getAgreeType(expr.getA()); AgreeType thenType = getAgreeType(expr.getB()); AgreeType elseType = getAgreeType(expr.getC()); if (!matches(BOOL, condType)) { error(expr, "The condition of the if statement is of type '" + condType + "' but must be of type 'bool'"); } if (!matches(elseType, thenType)) { error(expr, "The 'then' and 'else' expressions are of non-matching types '" + thenType + "' and '" + elseType + "'"); } }
/** * checkCatalogIsActiveGreeting. */ @Check(CheckType.FAST) public void checkCatalogIsActiveGreeting(final Greeting it) {// Issue diagnostic libraryChecksCatalog.accept(getMessageAcceptor(), // it, // context EObject null, // EStructuralFeature libraryChecksCatalog.getCheckCatalogIsActiveMessage(), // Message libraryChecksCatalog.getCheckCatalogIsActiveSeverityKind(it), // Severity ValidationMessageAcceptor.INSIGNIFICANT_INDEX, // Marker index LibraryChecksIssueCodes.CHECK_CATALOG_IS_ACTIVE // Issue code & data ); }
/** * cacheInjectionFailedGreeting. */ @Check(CheckType.FAST) public void cacheInjectionFailedGreeting(final Greeting g) { boolean _equals = Objects.equal(LibraryChecksCheckImpl.this.cache, null); if (_equals) {// Issue diagnostic libraryChecksCatalog.accept(getMessageAcceptor(), // g, // context EObject null, // EStructuralFeature libraryChecksCatalog.getCacheInjectionFailedMessage(), // Message libraryChecksCatalog.getCacheInjectionFailedSeverityKind(g), // Severity ValidationMessageAcceptor.INSIGNIFICANT_INDEX, // Marker index LibraryChecksIssueCodes.CACHE_INJECTION_FAILED // Issue code & data ); } }
/** * Checks that at least one issue expression exists in a context's constraints. * <p> * To be executed on save only as the error will otherwise be distracting. * </p> * * @param context * the context to be checked */ @Check(CheckType.NORMAL) public void checkIssueExpressionExists(final Context context) { if (context.getContextVariable() == null || context.getConstraint() == null) { return; } if (Iterables.isEmpty(generatorExtensions.issues(context))) { error(Messages.CheckJavaValidator_MISSING_ISSUE_EXPRESSION, context, CheckPackage.Literals.CONTEXT__CONSTRAINT, IssueCodes.MISSING_ISSUE_EXPRESSION); } }
/** * Check that a category name starts with an upper-case character. * * @param category * the category */ @Check(CheckType.FAST) public void checkCategoryFirstUpperName(final Category category) { if (!Character.isUpperCase(category.getName().charAt(0))) { error(NAME_SHOULD_START_WITH_A_CAPITAL, ValidPackage.Literals.CATEGORY__NAME, CATEGORY_FIRST_UPPER_NAME); } }
/** * Check that a rule name starts with an upper-case character. * * @param rule * the rule */ @Check(CheckType.FAST) public void checkRuleFirstUpperName(final Rule rule) { if (!Character.isUpperCase(rule.getName().charAt(0))) { error(NAME_SHOULD_START_WITH_A_CAPITAL, ValidPackage.Literals.RULE__NAME, RULE_FIRST_UPPER_NAME); } }
/** * Check that a quick fix name starts with an upper-case character. * * @param quickFix * the quick fix */ @Check(CheckType.FAST) public void checkQuickFixFirstUpperName(final QuickFix quickFix) { if (!Character.isUpperCase(quickFix.getName().charAt(0))) { error(NAME_SHOULD_START_WITH_A_CAPITAL, ValidPackage.Literals.QUICK_FIX__NAME, QUICK_FIX_FIRST_UPPER_NAME); } }