blob: f445bb8c5f46b85ef768939387085462141f7d6f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*******************************************************************************
* Copyright (c) 2005, 2006 committers of openArchitectureWare and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* committers of openArchitectureWare - initial API and implementation
*******************************************************************************/
package org.eclipse.internal.xpand2.model;
import java.util.Set;
import org.eclipse.internal.xpand2.ast.Advice;
import org.eclipse.internal.xpand2.type.XpandDefinitionImpl;
import org.eclipse.internal.xtend.expression.ast.AbstractVisitor;
import org.eclipse.internal.xtend.expression.ast.DeclaredParameter;
import org.eclipse.xpand2.XpandExecutionContext;
import org.eclipse.xtend.expression.AnalysationIssue;
import org.eclipse.xtend.expression.ExecutionContext;
import org.eclipse.xtend.expression.Variable;
public class AdvicedDefinition implements XpandDefinition {
private XpandAdvice advice;
private XpandDefinition definition;
public AdvicedDefinition(final XpandAdvice adv, final XpandDefinition def) {
advice = adv;
definition = def;
}
public XpandResource getOwner() {
return definition.getOwner();
}
public DeclaredParameter[] getParams() {
return definition.getParams();
}
public String getTargetType() {
return definition.getTargetType();
}
public String getName() {
return "AROUND " + definition.getName();
}
public String getQualifiedName() {
return definition.getQualifiedName();
}
public String getParamString(boolean typesOnly) {
return definition.getParamString(typesOnly);
}
public void analyze(XpandExecutionContext ctx, Set<AnalysationIssue> issues) {
// not used, since a static analysis will never have AOP
}
public void evaluate(final XpandExecutionContext ctx) {
final XpandExecutionContext ctx1 = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(
Advice.DEF_VAR_NAME, new XpandDefinitionImpl(definition, ctx)));
advice.evaluate(ctx1);
}
public int getLine() {
return advice.getLine();
}
public int getEnd() {
return advice.getEnd();
}
public int getStart() {
return advice.getStart();
}
public String getFileName() {
return advice.getFileName();
}
public String getNameString(ExecutionContext context){
return advice.getNameString(context);
}
@Override
public String toString() {
return definition.toString() + " adviced by " + advice.toString();
}
public final Object accept(final AbstractVisitor visitor) {
return visitor.visit(this);
}
}
|