Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Jastadd2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container 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
JastAdd
Jastadd2
Commits
8f1e4709
Commit
8f1e4709
authored
5 years ago
by
Jesper
Browse files
Options
Downloads
Patches
Plain Diff
[cleanup] Remove unnecessary class InterTypeObject
parent
faf36d22
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/jastadd/ast/Attributes.jrag
+10
-11
10 additions, 11 deletions
src/jastadd/ast/Attributes.jrag
src/java/org/jastadd/JastAdd.java
+16
-12
16 additions, 12 deletions
src/java/org/jastadd/JastAdd.java
with
26 additions
and
23 deletions
src/jastadd/ast/Attributes.jrag
+
10
−
11
View file @
8f1e4709
...
...
@@ -28,7 +28,9 @@
import org.jastadd.ast.AST.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
...
...
@@ -402,29 +404,26 @@ public aspect Attributes {
}
}
public class InterTypeObject {
public String className;
public ClassBodyObject classBodyObject;
public Map<String, Collection<ClassBodyObject>> Grammar.interTypeDecls
= new HashMap<String, Collection<ClassBodyObject>>();
public
InterType
Obj
ec
t
(String
n
ame, ClassBodyObject
obj
) {
this.
className
= name;
this.c
lassBodyObject
= obj
;
protected void Grammar.add
InterType
D
ec
l
(String
classN
ame, ClassBodyObject
decl
) {
if (!interTypeDecls.containsKey(
className
)) {
interTypeDecls.put(className, new ArrayList<C
lassBodyObject
>())
;
}
interTypeDecls.get(className).add(decl);
}
public Collection<InterTypeObject> Grammar.interTypeObjects = new LinkedList<InterTypeObject>();
public void Grammar.addClassBodyDecl(org.jastadd.jrag.AST.SimpleNode n,
String className, String fileName, String aspectName) {
interTypeObjects.add(new InterTypeObject(className, new ClassBodyObject(n,
fileName, n.firstToken.beginLine, aspectName)));
addInterTypeDecl(className, new ClassBodyObject(n, fileName, n.firstToken.beginLine, aspectName));
}
public void Grammar.addClassBodyDecl(org.jastadd.jrag.AST.SimpleNode n,
String className, String fileName, String modifiers, String aspectName) {
ClassBodyObject obj = new ClassBodyObject(n, fileName, n.firstToken.beginLine, aspectName);
obj.modifiers = modifiers;
interTypeObjects.add(new
InterType
Obj
ec
t
(className, obj)
)
;
add
InterType
D
ec
l
(className, obj);
}
public Collection<ClassBodyObject> TypeDecl.classBodyDecls = new LinkedHashSet<ClassBodyObject>();
...
...
This diff is collapsed.
Click to expand it.
src/java/org/jastadd/JastAdd.java
+
16
−
12
View file @
8f1e4709
...
...
@@ -40,6 +40,7 @@ import java.io.StringReader;
import
java.io.StringWriter
;
import
java.util.Collection
;
import
java.util.LinkedList
;
import
java.util.Map
;
import
java.util.MissingResourceException
;
import
java.util.ResourceBundle
;
import
java.util.Scanner
;
...
...
@@ -51,12 +52,12 @@ import org.jastadd.ast.AST.Component;
import
org.jastadd.ast.AST.Grammar
;
import
org.jastadd.ast.AST.InhDecl
;
import
org.jastadd.ast.AST.InhEq
;
import
org.jastadd.ast.AST.InterTypeObject
;
import
org.jastadd.ast.AST.List
;
import
org.jastadd.ast.AST.SynDecl
;
import
org.jastadd.ast.AST.SynEq
;
import
org.jastadd.ast.AST.TokenComponent
;
import
org.jastadd.ast.AST.TypeDecl
;
import
org.jastadd.jrag.ClassBodyObject
;
import
org.jastadd.jrag.AST.ASTCompilationUnit
;
import
org.jastadd.jrag.AST.JragParser
;
import
org.jastadd.jrag.AST.TokenMgrError
;
...
...
@@ -297,20 +298,23 @@ public class JastAdd {
protected
static
Collection
<
Problem
>
weaveInterTypeObjects
(
Grammar
grammar
)
{
Collection
<
Problem
>
problems
=
new
LinkedList
<
Problem
>();
for
(
InterTypeObject
object
:
grammar
.
interTypeObjects
)
{
TypeDecl
clazz
=
grammar
.
lookup
(
object
.
className
);
if
(
clazz
!=
null
)
{
clazz
.
classBodyDecls
.
add
(
object
.
classBodyObject
);
}
else
{
problems
.
add
(
Problem
.
builder
()
.
message
(
"can not add member to unknown class %s"
,
object
.
className
)
.
sourceFile
(
object
.
classBodyObject
.
fileName
)
.
sourceLine
(
object
.
classBodyObject
.
line
)
.
buildError
());
for
(
Map
.
Entry
<
String
,
Collection
<
ClassBodyObject
>>
entry
:
grammar
.
interTypeDecls
.
entrySet
())
{
String
className
=
entry
.
getKey
();
TypeDecl
clazz
=
grammar
.
lookup
(
className
);
for
(
ClassBodyObject
decl
:
entry
.
getValue
())
{
if
(
clazz
!=
null
)
{
clazz
.
classBodyDecls
.
add
(
decl
);
}
else
{
problems
.
add
(
Problem
.
builder
()
.
message
(
"can not add member to unknown class %s"
,
className
)
.
sourceFile
(
decl
.
fileName
)
.
sourceLine
(
decl
.
line
)
.
buildError
());
}
}
}
// TODO(jesper): Remove the below line.
grammar
.
interType
Obj
ec
t
s
.
clear
();
// Reset to avoid double weaving.
grammar
.
interType
D
ec
l
s
.
clear
();
// Reset to avoid double weaving.
return
problems
;
}
...
...
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