public void setOffset(int i) { offset=i;}
+
}
}
extraAttributeList.add(
- new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine)));
+ new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine, this.sourceStart())));
}
}
}
extraAttributeList.add(
- new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine)));
+ new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine, this.sourceStart())));
}
}
return new EclipseSourceLocation(result, position.getStart(), position.getEnd());
}
- public ISourceLocation makeSourceLocation(int line) {
+ public ISourceLocation makeSourceLocation(int line, int offset) {
SourceLocation sl = new SourceLocation(getSourceFile(), line);
- // compute the offset
- //TODO AV - should we do it lazily?
- int[] offsets = result.lineSeparatorPositions;
- int likelyOffset = 0;
- if (line > 0 && line < offsets.length) {
- //1st char of given line is next char after previous end of line
- likelyOffset = offsets[line-1];
+ if (offset > 0) {
+ sl.setOffset(offset);
+ } else {
+ // compute the offset
+ //TODO AV - should we do it lazily?
+ int[] offsets = result.lineSeparatorPositions;
+ int likelyOffset = 0;
+ if (line > 0 && line < offsets.length) {
+ //1st char of given line is next char after previous end of line
+ likelyOffset = offsets[line-1];//FIXME may be need -2
+ }
+ sl.setOffset(likelyOffset);
}
- sl.setOffset(likelyOffset);
return sl;
}
public void testSingletonAspectBindings() {
//Note AV: uncomment setReporting to get it in modules/tests folder
- //org.aspectj.asm.AsmManager.setReporting("debug.txt",true,true,true,true);
+ org.aspectj.asm.AsmManager.setReporting("debug.txt",true,true,true,true);
runTest("singletonAspectBindings");
// same stuff with AJ
//org.aspectj.asm.AsmManager.setReporting("debug-aj.txt",true,true,true,true);
- runTest("singletonAspectBindings2");
+ //runTest("singletonAspectBindings2");
}
}
private int lineNumber;
-
- public MethodDeclarationLineNumberAttribute(int line) {
+
+ // AV: added in 1.5 M3 thus handling cases where we don't have that information
+ private int offset;
+
+ public MethodDeclarationLineNumberAttribute(int line, int offset) {
this.lineNumber = line;
+ this.offset = offset;
}
public int getLineNumber() { return lineNumber; }
-
+
+ public int getOffset() { return offset; }
+
public void write(DataOutputStream s) throws IOException {
s.writeInt(lineNumber);
+ s.writeInt(offset);
}
public static MethodDeclarationLineNumberAttribute read(VersionedDataInputStream s) throws IOException {
- return new MethodDeclarationLineNumberAttribute(s.readInt());
+ int line = s.readInt();
+ int offset = 0;
+ if (s.available()>0) {
+ offset = s.readInt();
+ }
+ return new MethodDeclarationLineNumberAttribute(line, offset);
}
public String toString() {
- return AttributeName + ": " + lineNumber;
+ return AttributeName + ": " + lineNumber + ":" + offset;
}
}
public interface ISourceContext {
public ISourceLocation makeSourceLocation(IHasPosition position);
- public ISourceLocation makeSourceLocation(int line);
+ public ISourceLocation makeSourceLocation(int line, int offset);
public int getOffset();
}
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(
new AjAttribute.AdviceAttribute(
AdviceKind.Before,
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(
new AjAttribute.AdviceAttribute(
AdviceKind.After,
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(
new AjAttribute.AdviceAttribute(
AdviceKind.AfterReturning,
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(
new AjAttribute.AdviceAttribute(
AdviceKind.AfterThrowing,
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(
new AjAttribute.AdviceAttribute(
AdviceKind.Around,
return -1;
}
}
-
+
+ public int getDeclarationOffset() {
+ if (declarationLineNumber != null) {
+ return declarationLineNumber.getOffset();
+ } else {
+ return -1;
+ }
+ }
+
public ISourceLocation getSourceLocation() {
ISourceLocation ret = super.getSourceLocation();
if ((ret == null || ret.getLine()==0) && hasDeclarationLineNumberInfo()) {
// lets see if we can do better
ISourceContext isc = getSourceContext();
- if (isc !=null) ret = isc.makeSourceLocation(getDeclarationLineNumber());
+ if (isc !=null) ret = isc.makeSourceLocation(getDeclarationLineNumber(), getDeclarationOffset());
else ret = new SourceLocation(null,getDeclarationLineNumber());
}
return ret;
}
public ISourceLocation getSourceLocation() {
- return getResolvedTypeX().getSourceContext().makeSourceLocation(0); //FIXME ??? we can do better than this
+ return getResolvedTypeX().getSourceContext().makeSourceLocation(0, 0); //FIXME ??? we can do better than this
}
public AjAttribute.WeaverVersionInfo getWeaverVersionAttribute() {
if (getKind()==Shadow.StaticInitialization && getEnclosingClass().getType().getSourceLocation().getOffset()!=0)
return getEnclosingClass().getType().getSourceLocation();
else
- return getEnclosingClass().getType().getSourceContext().makeSourceLocation(sourceLine);
+ return getEnclosingClass().getType().getSourceContext().makeSourceLocation(sourceLine, 0);
}
}
}
}
- public ISourceLocation makeSourceLocation(int line) {
+ public ISourceLocation makeSourceLocation(int line, int offset) {
if (line < 0) line = 0;
SourceLocation sl = new SourceLocation(getSourceFile(), line);
- if (lineBreaks != null) {
- int likelyOffset = 0;
- if (line > 0 && line < lineBreaks.length) {
- //1st char of given line is next char after previous end of line
- likelyOffset = lineBreaks[line-1] + 1;
+ if (offset > 0) {
+ sl.setOffset(offset);
+ } else {
+ if (lineBreaks != null) {
+ int likelyOffset = 0;
+ if (line > 0 && line < lineBreaks.length) {
+ //1st char of given line is next char after previous end of line
+ likelyOffset = lineBreaks[line-1] + 1;
+ }
+ sl.setOffset(likelyOffset);
}
- sl.setOffset(likelyOffset);
}
return sl;
}
public void write(DataOutputStream s) throws IOException {
s.writeByte(Pointcut.IF);
- testMethod.write(s);//TODO Adrian, do something if this one happens to be null for @style if() from JDT stuff
+ testMethod.write(s);//FIXME Adrian, do something if this one happens to be null for @style if() from JDT stuff
s.writeByte(extraParameterFlags);
writeLocation(s);
}
public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException {
- //TODO Adrian, read may failt if testMethod happens to be null for @style if() from JDT stuff
+ //FIXME Adrian, read may failt if testMethod happens to be null for @style if() from JDT stuff
IfPointcut ret = new IfPointcut(ResolvedMember.readResolvedMember(s, context), s.readByte());
ret.readLocation(context, s);
return ret;