mirror of
https://github.com/openjdk/jdk.git
synced 2026-08-04 07:05:31 +00:00
Add end position for variables coming from variableDeclaratorId().
This commit is contained in:
parent
4fcc61269b
commit
e235228708
@ -3944,7 +3944,9 @@ public class JavacParser implements Parser {
|
||||
log.error(token.pos, Errors.WrongReceiver);
|
||||
}
|
||||
}
|
||||
return toP(F.at(pos).ReceiverVarDef(mods, pn, type));
|
||||
JCVariableDecl result = toP(F.at(pos).ReceiverVarDef(mods, pn, type));
|
||||
storeEnd(result, S.prevToken().endPos);
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
/** if it is a lambda parameter and the token kind is not an identifier,
|
||||
@ -3969,8 +3971,10 @@ public class JavacParser implements Parser {
|
||||
name = names.empty;
|
||||
}
|
||||
|
||||
return toP(F.at(pos).VarDef(mods, name, type, null,
|
||||
JCVariableDecl result = toP(F.at(pos).VarDef(mods, name, type, null,
|
||||
type != null && type.hasTag(IDENT) && ((JCIdent)type).name == names.var));
|
||||
storeEnd(result, S.prevToken().endPos);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Resources = Resource { ";" Resources }
|
||||
|
||||
@ -87,37 +87,33 @@ public class DeclarationEndPositions {
|
||||
|
||||
// JCModuleDecl
|
||||
checkEndPosition(JCModuleDecl.class,
|
||||
// 0 1 2 3 4 5
|
||||
// 012345678901234567890123456789012345678901234567890123456789
|
||||
"/* comment */ module fred { /* comment */ } /* comment */",
|
||||
" ^ ");
|
||||
|
||||
// JCPackageDecl
|
||||
checkEndPosition(JCPackageDecl.class,
|
||||
// 0 1 2 3 4 5
|
||||
// 012345678901234567890123456789012345678901234567890123456789
|
||||
"/* comment */ package fred; /* comment */",
|
||||
" ^ ");
|
||||
|
||||
// JCClassDecl
|
||||
checkEndPosition(JCClassDecl.class,
|
||||
// 0 1 2 3 4 5
|
||||
// 012345678901234567890123456789012345678901234567890123456789
|
||||
"/* comment */ class Fred { /* comment */ } /* comment */",
|
||||
" ^ ");
|
||||
|
||||
// JCMethodDecl
|
||||
checkEndPosition(JCMethodDecl.class,
|
||||
// 0 1 2 3 4 5
|
||||
// 012345678901234567890123456789012345678901234567890123456789
|
||||
"/* comment */ class Fred { void m() { /* comment */ } } /* comment */",
|
||||
" ^ ");
|
||||
|
||||
// JCVariableDecl
|
||||
checkEndPosition(JCVariableDecl.class,
|
||||
// 0 1 2 3 4 5
|
||||
// 012345678901234567890123456789012345678901234567890123456789
|
||||
"/* comment */ class Fred { int x; } /* comment */",
|
||||
" ^ ");
|
||||
checkEndPosition(JCVariableDecl.class,
|
||||
"/* comment */ class Fred { int x = 123; } /* comment */",
|
||||
" ^ ");
|
||||
checkEndPosition(JCVariableDecl.class,
|
||||
"/* comment */ class A { try {} catch (Error err) {} } /* comment */",
|
||||
" ^ ");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user