Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pieter Koopman
Personal Prof public repository
Commits
f9304ec8
Commit
f9304ec8
authored
May 08, 2020
by
Rick van der Wal
Browse files
Adapted previous changes to be less "hacky"
parent
d2cd71d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/AssignmentSnakeRules.rsc
View file @
f9304ec8
...
@@ -31,11 +31,11 @@ set[Message] aSnake_view_separated(M3 model)
...
@@ -31,11 +31,11 @@ set[Message] aSnake_view_separated(M3 model)
, javafxSceneShapeArc
, javafxSceneShapeArc
};
};
set[loc] permittedClasses = { findClass(model, "SnakeGame") };
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)
return { error("<getName(model, shapeClass)>: only SnakeGame should use shapes", class)
| class <- classes(model) -
p
ermittedClasses
| class <- classes(model) -
allP
ermittedClasses
, shapeClass <- shapeClasses
, shapeClass <- shapeClasses
, (shapeClass in model.extends[class] || shapeClass in allTypeDependenciesLoc(model, class))
, (shapeClass in model.extends[class] || shapeClass in allTypeDependenciesLoc(model, class))
&& {1 | permitted <- permittedClasses, class in model.containment[permitted]} == {}
};
};
}
}
catch e:error(_,_):
catch e:error(_,_):
...
@@ -57,11 +57,11 @@ set[Message] aSnake_controller_separated(M3 model)
...
@@ -57,11 +57,11 @@ set[Message] aSnake_controller_separated(M3 model)
{ findClass(model, "Main")
{ findClass(model, "Main")
, findClass(model, "InputHandler")
, findClass(model, "InputHandler")
};
};
set[loc] allPermittedClasses = { *(model.containment*)[permitted] | permitted <- permittedClasses};
return { error("<getName(model, eventClass)>: only InputHandler should handle input events", class)
return { error("<getName(model, eventClass)>: only InputHandler should handle input events", class)
| class <- classes(model) -
p
ermittedClasses
| class <- classes(model) -
allP
ermittedClasses
, eventClass <- eventClasses
, eventClass <- eventClasses
, eventClass in allTypeDependenciesLoc(model, class)
, eventClass in allTypeDependenciesLoc(model, class)
&& {1 | permitted <- permittedClasses, class in model.containment[permitted]} == {}
};
};
}
}
catch e:error(_,_):
catch e:error(_,_):
...
...
src/CodingRules.rsc
View file @
f9304ec8
...
@@ -64,38 +64,34 @@ set[Message] ps_all_caps_constant_names(M3 model)
...
@@ -64,38 +64,34 @@ set[Message] ps_all_caps_constant_names(M3 model)
set[Message] ps_explicit_access_modifiers(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
return
{ error("Explicitly specify access modifiers: public, protected, or private", thing)
{ error("Explicitly specify access modifiers: public, protected, or private", thing)
| thing <- artifactsOfInterest
| thing <- artifactsOfInterest
// & is set intersection
// & is set intersection
, isEmpty(model.modifiers[thing] & {\public(), \protected(), \private()})
, 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[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
return
{ error("Private access modifiers for enum constructors are redundant", thing)
{ error("Private access modifiers for enum constructors are redundant", thing)
| thing <- artifactsOfInterest
| thing <- artifactsOfInterest
// & is set intersection
, \private() in model.modifiers[thing]
, !isEmpty(model.modifiers[thing] & {\private()})
&& {1 | enum <- enums(model), thing in constructors(model, enum)} != {}
};
};
}
}
set[Message] ps_no_interface_modifier(M3 model)
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
return
{ error("Public access modifiers for interface methods are redundant", thing)
{ error("Public access modifiers for interface methods are redundant", thing)
| thing <- artifactsOfInterest
| thing <- artifactsOfInterest
// & is set intersection
, \public() in model.modifiers[thing]
, !isEmpty(model.modifiers[thing] & {\public()})
&& {1 | interface <- interfaces(model), thing in methods(model, interface)} != {}
};
};
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment