Commit f9304ec8 authored by Rick van der Wal's avatar Rick van der Wal
Browse files

Adapted previous changes to be less "hacky"

parent d2cd71d1
......@@ -31,11 +31,11 @@ set[Message] aSnake_view_separated(M3 model)
, javafxSceneShapeArc
};
set[loc] permittedClasses = { findClass(model, "SnakeGame") };
set[loc] allPermittedClasses = { *(model.containment*)[permitted] | permitted <- permittedClasses};
return { error("<getName(model, shapeClass)>: only SnakeGame should use shapes", class)
| class <- classes(model) - permittedClasses
| class <- classes(model) - allPermittedClasses
, shapeClass <- shapeClasses
, (shapeClass in model.extends[class] || shapeClass in allTypeDependenciesLoc(model, class))
&& {1 | permitted <- permittedClasses, class in model.containment[permitted]} == {}
};
}
catch e:error(_,_):
......@@ -57,11 +57,11 @@ set[Message] aSnake_controller_separated(M3 model)
{ findClass(model, "Main")
, findClass(model, "InputHandler")
};
set[loc] allPermittedClasses = { *(model.containment*)[permitted] | permitted <- permittedClasses};
return { error("<getName(model, eventClass)>: only InputHandler should handle input events", class)
| class <- classes(model) - permittedClasses
| class <- classes(model) - allPermittedClasses
, eventClass <- eventClasses
, eventClass in allTypeDependenciesLoc(model, class)
&& {1 | permitted <- permittedClasses, class in model.containment[permitted]} == {}
};
}
catch e:error(_,_):
......
......@@ -64,38 +64,34 @@ set[Message] ps_all_caps_constant_names(M3 model)
set[Message] ps_explicit_access_modifiers(M3 model)
{
set[loc] artifactsOfInterest = range(declaredMethods(model)) + range(declaredFields(model));
set[loc] interfaceMethods = { method | interface <- interfaces(model), method <- methods(model, interface) };
set[loc] enumConstructors = { constructor | enum <- enums(model), constructor <- constructors(model, enum) };
set[loc] artifactsOfInterest = range(declaredMethods(model)) + range(declaredFields(model)) - interfaceMethods - enumConstructors;
return
{ error("Explicitly specify access modifiers: public, protected, or private", thing)
| thing <- artifactsOfInterest
// & is set intersection
, isEmpty(model.modifiers[thing] & {\public(), \protected(), \private()})
&& {1 | interface <- interfaces(model), thing in methods(model, interface)} == {}
&& {1 | enum <- enums(model), thing in constructors(model, enum)} == {}
};
}
set[Message] ps_no_enum_modifier(M3 model)
{
set[loc] artifactsOfInterest = range(declaredMethods(model));
set[loc] artifactsOfInterest = { constructor | enum <- enums(model), constructor <- constructors(model, enum) };
return
{ error("Private access modifiers for enum constructors are redundant", thing)
| thing <- artifactsOfInterest
// & is set intersection
, !isEmpty(model.modifiers[thing] & {\private()})
&& {1 | enum <- enums(model), thing in constructors(model, enum)} != {}
, \private() in model.modifiers[thing]
};
}
set[Message] ps_no_interface_modifier(M3 model)
{
set[loc] artifactsOfInterest = range(declaredMethods(model));
set[loc] artifactsOfInterest = { method | interface <- interfaces(model), method <- methods(model, interface) };
return
{ error("Public access modifiers for interface methods are redundant", thing)
| thing <- artifactsOfInterest
// & is set intersection
, !isEmpty(model.modifiers[thing] & {\public()})
&& {1 | interface <- interfaces(model), thing in methods(model, interface)} != {}
, \public() in model.modifiers[thing]
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment