list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

Strictness Directive

The strictness directive is used to control certain messages that the Umple compiler may issue. It has five subdirectives that are specified by a second keyword following 'strictness':

The first two are 'modelOnly' or 'noExtraCode'. These are used when the programmer or modeller intends not to include base language code, and wants a warning to appear if base language code is found. Base language code is code in a language like Java or PhP that is discovered by Umple but not interpreted in any way. One example is the code in the bodies of methods; however, when parsing a class, any time Umple can't parse what it finds, it assumes it must be base language code. It just emits the base language code for the base language compiler to deal with. However there are circumstances when the developer does not want this: The developer may be creating a pure model or may want that the only base language code would be in the body of methods. It is advantageous therefore to tell the compiler to raise a warning if it thinks it has found base language code in some other context, since otherwise, an ordinary Umple syntax error may go undetected, until the base language compiler is run on the code.

  • strictness modelOnly; means be very strict and issue a warning if base language code is found.
  • strictness noExtraCode; means that base language code is allowed in method bodies, but if found anywhere else to issue a warning.

The second set of subdirectives are 'expect', 'allow' and 'disallow'. These are used to control the effect of certain messages. They are followed by a message number.

  • strictness expect n declares that message number n should occur; it is an error if the message does not. This is used in testing to create example cases of message n; an error would be triggered if message n does not appear.
  • strictness allow n is used in the case of errors, to tell the compiler to not actually 'fail', but to report that error as if it was a warning. In the case of n being a warning, the warning is not emitted. This is also used in testing to include cases that give message n, without the compiler reporting that it has failed.
  • strictness disallow n, where n is a warning, tells the compiler to treat n as if it was an error, and fail the compilation.
Some of the above are still under development.

The strictness directives take effect on the entire system being built. The code of all Ump files of that system will be subject to the strictness subdirectives.

Example

// Tell the compiler that error 25
// will appear (and fail if it does not)
strictness expect 25;

// Tell the compiler that if error 22
// occurs, not to fail the compile.
// However, this does not mean that
// code can be generated
strictness allow 22;

// UNDER DEVELOPMENT: The following
// is not operational yet
// Tell the compiler that  base language
// code should not appear
strictness modelOnly;

// Tell the compiler that the only base
// language code could be in method bodies
// Any other unparsable 'extra code' in classes
// will be rejected.
strictness noExtraCode;


      

Load the above code into UmpleOnline

 

Syntax


// A high level of strictness will cause warnings to be issued when base language code
// is found, where it might not have been intended. Strictness can also be used
// To either suppress certain messages, or to declare that they should be present.
// NOTE: This is currently under development
strictness- : strictness ( [=strictness:modelOnly|noExtraCode|none]
    | [[strictnessMessage]]
    | [[strictnessDisableAuto]] ) ;

strictnessMessage : [=message:allow|ignore|expect|disallow] [messageNumber]

strictnessDisableAuto : disable [**expression]