Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
541aa04f
Commit
541aa04f
authored
15 years ago
by
Mirco Dotta
Browse files
Options
Downloads
Patches
Plain Diff
removing files (will be added back soon in scalacheck package
parent
bd700507
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/funcheck/FilterGeneratorAnnotations.scala
+0
-60
0 additions, 60 deletions
src/funcheck/FilterGeneratorAnnotations.scala
src/funcheck/ForallInjection.scala
+0
-30
0 additions, 30 deletions
src/funcheck/ForallInjection.scala
with
0 additions
and
90 deletions
src/funcheck/FilterGeneratorAnnotations.scala
deleted
100644 → 0
+
0
−
60
View file @
bd700507
package
funcheck
/**
* A tree traverser which filter the trees elements that contain the
* <code>@generator</code> annotation, defined in <code>funcheck.lib.Specs</code>
* module.
*
* Note: For the moment this is working only for <code>ClassDef</code> and
* <code>DefDef</code> tree elements.
*
* This trait is meant to be used with the <code>FilterTreeTraverser</code>
* class, available in the <code>scala.tools.nsc.ast.Trees</code> trait.
*
*
* Usage Example:
*
* new FilterTreeTraverser(filterTreesWithGeneratorAnnotation(unit))
*
* where <code>unit</code> is the current Compilation Unit.
*/
trait
FilterGeneratorAnnotations
{
self
:
AnalysisComponent
=>
// [[INFO]] "hasAttribute" is "hasAnnotation" in future compiler release 2.8
import
global._
/** Funcheck <code>@generator</code> annotation. */
private
lazy
val
generator
:
Symbol
=
definitions
.
getClass
(
"funcheck.lib.Specs.generator"
)
/**
* Check for <code>@generator</code> annotation only for class and method
* definitions. A class is considered to be annotated if either the class itself
* has the annotation, or if the class inherit from an annotated abstract class.
*/
def
filterTreesWithGeneratorAnnotation
(
Unit
:
CompilationUnit
)(
tree
:
Tree
)
:
Boolean
=
{
lazy
val
sym
=
tree
.
symbol
tree
match
{
case
cd
:
ClassDef
=>
sym
.
hasAttribute
(
generator
)
||
abstractSuperClassHasGeneratorAnnotation
(
sym
.
superClass
)
case
d
:
DefDef
=>
sym
.
hasAttribute
(
generator
)
case
_
=>
false
}
}
/** Return true if the class (or superclass) symbol is flagged as being ABSTRACT and contains
* the <code>@generator</code> annotation.*/
private
def
abstractSuperClassHasGeneratorAnnotation
(
superclass
:
Symbol
)
:
Boolean
=
{
//require(superclass.isInstanceOf[ClassSymbol], "expected ClassSymbol, found "+superclass)
superclass
match
{
case
NoSymbol
=>
false
case
cs
:
ClassSymbol
=>
(
cs
.
hasFlag
(
scala
.
tools
.
nsc
.
symtab
.
Flags
.
ABSTRACT
)
&&
cs
.
hasAttribute
(
generator
))
||
abstractSuperClassHasGeneratorAnnotation
(
cs
.
superClass
)
case
_
=>
assert
(
false
,
"expected ClassSymbol, found "
+
superclass
)
false
}
}
}
This diff is collapsed.
Click to expand it.
src/funcheck/ForallInjection.scala
deleted
100644 → 0
+
0
−
30
View file @
bd700507
package
funcheck
trait
ForallInjection
{
self
:
AnalysisComponent
=>
import
global._
def
mircoTraverser
(
unit
:
CompilationUnit
)(
tree
:
Tree
)
:
Unit
=
{
lazy
val
genAnnot
:
Symbol
=
definitions
.
getClass
(
"funcheck.lib.Specs.generator"
)
tree
match
{
case
d
@
DefDef
(
mods
,
name
,
_
,
_
,
_
,
_
)
=>
{
/** Looking for contracts on the current method definition */
mods
.
annotations
.
foreach
((
ann
:
Annotation
)
=>
{
ann
.
constr
match
{
/** Looks for the "signature" of the desired annotations */
case
Apply
(
Select
(
New
(
i
:
Select
),
_
),
Nil
)
=>
{
i
.
symbol
match
{
case
s
if
s
==
genAnnot
=>
println
(
"Found a generator annotation in: "
+
name
.
toString
)
case
_
=>
;
}
}
case
_
=>
;
}
})
}
case
_
=>
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment