Bonjour,
Tout d’abord merci pour le tutoriel sur AspectJ il est très intéressant, et aide beaucoup.
Cependant un problème n’est pas souvent abordé : Celui des héritages de classes qu’on intercepte. Ca tombe mal c’est le mien..
Voici mon problème :
1 2 3 4 5 6 7 8 9 10 11 12 13
| public class InternalCartoParser extends AbstractInternalAntlrParser {
private GrammarAccess myGrammar;
public final EObject ruleLigneSdt() throws RecognitionException {
EObject current = null;
setCurrentLookahead();
resetLookahead();
return current; // Just as an example
}
} |
Les méthodes setCurrentLookahead(), resetLookahead sont des méthodes de la classe mère AbstractInternalAntlrParser et sont protected.
Voici mon aspect (j’intercepte donc la méthode ruleLigneSdt de la classe InternalCartoParser) Mon aspect est en privileged, j’ai donc accès à tout ce qui est privé dans la classe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| privileged aspect InternalParser {
declare parents: InternalCartoParser extends
AbstractInternalAntlrParser;
pointcut ruleLigneSdt(InternalCartoParser c):
execution(EObject
org.xtext.example.parser.antlr.internal.InternalCartoParser.ruleLigneSdt())
&& target(c) ;
EObject around(InternalCartoParser c): ruleLigneSdt(c) {
System.out.prinln("Start of Aspect class");
CartoGrammarAccess grammarAccessLocal = c.grammarAccess
EObject current = new EObject();
setCurrentLookahead(); // WARNING
resetLookahead(); // WARNING
System.out.prinln("End of Aspect class");
return current;
}
} |
J’obtiens un warning au niveau de mon setCurrenLookahead:
"this
affected type is not exposed to the weaver:
org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser (needed for
privileged access) [Xlint:typeNotExposedToWeaver]"
J’ai tenté la technique “declare parents”, pour l’héritage mais sans succès toujours ce problème. Je n’arrive pas à atteindre les méthodes de ma classe mère…
Si quelqu’un a une idée…
Merci d’avance
Partager