Permalink
Browse files

Small refactorings.

  • Loading branch information...
1 parent 5364fff commit 23f386b9351c792dbd4176c42c9e87cb3a409ef0 @cderoove committed Feb 4, 2013
Showing with 33 additions and 28 deletions.
  1. +33 −28 EkekoPlugin/src/damp/ekeko/jdt/reification.clj
@@ -288,19 +288,6 @@
(ast :Type ?type) ;above trick is not necessary as Type is an actual super class
(ast ?key ?type)))
-(defn
- ast-name-of-parameter
- "Like ast/2, but ensures ?name is the SimpleName
- of a formal parameter declaration."
- [?keyw ?name]
- (fresh [?nameBinding ?parent]
- (== ?keyw :SimpleName)
- (ast ?keyw ?name)
- (equals ?nameBinding (.resolveBinding ^SimpleName ?name))
- (succeeds (.isParameter ^IVariableBinding ?nameBinding))
- (ast-parent ?name ?parent)
- (ast :SingleVariableDeclaration ?parent)))
-
(defn
ast-resolveable-declaration
@@ -336,17 +323,7 @@
]))
-(defn
- ast-expression-typebinding
- "Relation between an Expression instance ?ast,
- the keyword ?key representing its kind,
- and the ITypeBinding ?binding for its type."
- [?key ?ast ?binding]
- (all
- (ast :Expression ?ast)
- (equals ?binding (.resolveTypeBinding ^Expression ?ast))
- (!= nil ?binding)
- (ast ?key ?ast)))
+(declare ast-expression-typebinding)
(defn
ast-expression-reference
@@ -358,9 +335,36 @@
(succeeds (not (.isPrimitive ^ITypeBinding ?binding)))))
+(defn
+ ast-name-of-parameter
+ "Like ast/2, but ensures ?name is the SimpleName
+ of a formal parameter declaration."
+ [?keyw ?name]
+ (fresh [?nameBinding ?parent]
+ (== ?keyw :SimpleName)
+ (ast ?keyw ?name)
+ (equals ?nameBinding (.resolveBinding ^SimpleName ?name))
+ (succeeds (.isParameter ^IVariableBinding ?nameBinding))
+ (ast-parent ?name ?parent)
+ (ast :SingleVariableDeclaration ?parent)))
+
+
;; Bindings
;; --------
+(defn
+ ast-expression-typebinding
+ "Relation between an Expression instance ?ast,
+ the keyword ?key representing its kind,
+ and the ITypeBinding ?binding for its type."
+ [?key ?ast ?binding]
+ (all
+ (ast :Expression ?ast)
+ (equals ?binding (.resolveTypeBinding ^Expression ?ast))
+ (!= nil ?binding)
+ (ast ?key ?ast)))
+
+
(defn
ast-type-binding
"Relation between a type ASTNode ?type, the keyword ?key
@@ -385,9 +389,10 @@
See also:
API documentation of org.eclipse.jdt.core.dom.TypeDeclaration
and org.eclipse.jdt.core.dom.ITypeBinding"
- [?typeDeclaration ?binding]
+ [?key ?typeDeclaration ?binding]
(all
- (ast :TypeDeclaration ?typeDeclaration)
+ (== ?key :TypeDeclaration)
+ (ast ?key ?typeDeclaration)
(!= nil ?binding)
(equals ?binding (.resolveBinding ^TypeDeclaration ?typeDeclaration))))
@@ -427,9 +432,9 @@
Note that this relation is quite slow to compute.
See also:
- binary predicate ast-typedeclaration-binding/2
+ ternary predicate ast-typedeclaration-binding/3
which restricts ?n to TypeDeclaration instances"
- [?n ?key ?binding]
+ [?key ?n ?binding]
(all
(!= ?binding nil)
(!= ?n nil)

0 comments on commit 23f386b

Please sign in to comment.