Skip to content

Commit

Permalink
Fix test failures and unused variable warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohnstn committed Mar 7, 2024
1 parent 28c7598 commit 26b6ed3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static ConvertToMessageFormatFixCore createConvertToMessageFormatFix(Comp
NLSLine nlsLine= scanCurrentLine(cu, operand);
if (nlsLine != null) {
for (NLSElement element : nlsLine.getElements()) {
if (element.getPosition().getOffset() == operand.getStartPosition()) {
if (element.getPosition().getOffset() == compilationUnit.getColumnNumber(operand.getStartPosition())) {
if (element.hasTag()) {
if (seenNoTag) {
return null;
Expand Down Expand Up @@ -142,10 +142,11 @@ public static ConvertToMessageFormatFixCore createConvertToMessageFormatFix(Comp
private static NLSLine scanCurrentLine(ICompilationUnit cu, Expression exp) {
CompilationUnit cUnit= (CompilationUnit)exp.getRoot();
int startLine= cUnit.getLineNumber(exp.getStartPosition());
int startLinePos= cUnit.getPosition(startLine, 0);
int endOfLine= cUnit.getPosition(startLine + 1, 0);
NLSLine[] lines;
try {
lines= NLSScanner.scan(cu.getBuffer().getText(exp.getStartPosition(), endOfLine - exp.getStartPosition()));
lines= NLSScanner.scan(cu.getBuffer().getText(startLinePos, endOfLine - startLinePos));
if (lines.length > 0) {
return lines[0];
}
Expand Down Expand Up @@ -205,7 +206,7 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
NLSLine nlsLine= scanCurrentLine(cu, operand);
if (nlsLine != null) {
for (NLSElement element : nlsLine.getElements()) {
if (element.getPosition().getOffset() == operand.getStartPosition()) {
if (element.getPosition().getOffset() == root.getColumnNumber(operand.getStartPosition())) {
if (element.hasTag()) {
++tagsCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,13 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore

Statement lastAppend= insertAfter;
int tagsCount= 0;
CompilationUnit compilationUnit= (CompilationUnit)oldInfixExpression.getRoot();
for (Expression operand : operands) {
boolean tagged= false;
NLSLine nlsLine= scanCurrentLine(cu, operand);
if (nlsLine != null) {
for (NLSElement element : nlsLine.getElements()) {
if (element.getPosition().getOffset() == operand.getStartPosition()) {
if (element.getPosition().getOffset() == compilationUnit.getColumnNumber(operand.getStartPosition())) {
if (element.hasTag()) {
tagged= true;
++tagsCount;
Expand Down Expand Up @@ -326,10 +327,11 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
private static NLSLine scanCurrentLine(ICompilationUnit cu, Expression exp) {
CompilationUnit cUnit= (CompilationUnit)exp.getRoot();
int startLine= cUnit.getLineNumber(exp.getStartPosition());
int startLinePos= cUnit.getPosition(startLine, 0);
int endOfLine= cUnit.getPosition(startLine + 1, 0);
NLSLine[] lines;
try {
lines= NLSScanner.scan(cu.getBuffer().getText(exp.getStartPosition(), endOfLine - exp.getStartPosition()));
lines= NLSScanner.scan(cu.getBuffer().getText(startLinePos, endOfLine - startLinePos));
if (lines.length > 0) {
return lines[0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static ConvertToStringFormatFixCore createConvertToStringFormatFix(Compil
NLSLine nlsLine= scanCurrentLine(cu, operand);
if (nlsLine != null) {
for (NLSElement element : nlsLine.getElements()) {
if (element.getPosition().getOffset() == operand.getStartPosition()) {
if (element.getPosition().getOffset() == compilationUnit.getColumnNumber(operand.getStartPosition())) {
if (element.hasTag()) {
if (seenNoTag) {
return null;
Expand Down Expand Up @@ -142,10 +142,11 @@ public static ConvertToStringFormatFixCore createConvertToStringFormatFix(Compil
private static NLSLine scanCurrentLine(ICompilationUnit cu, Expression exp) {
CompilationUnit cUnit= (CompilationUnit)exp.getRoot();
int startLine= cUnit.getLineNumber(exp.getStartPosition());
int startLinePos= cUnit.getPosition(startLine, 0);
int endOfLine= cUnit.getPosition(startLine + 1, 0);
NLSLine[] lines;
try {
lines= NLSScanner.scan(cu.getBuffer().getText(exp.getStartPosition(), endOfLine - exp.getStartPosition()));
lines= NLSScanner.scan(cu.getBuffer().getText(startLinePos, endOfLine - startLinePos));
if (lines.length > 0) {
return lines[0];
}
Expand Down Expand Up @@ -197,7 +198,7 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
NLSLine nlsLine= scanCurrentLine(cu, operand);
if (nlsLine != null) {
for (NLSElement element : nlsLine.getElements()) {
if (element.getPosition().getOffset() == operand.getStartPosition()) {
if (element.getPosition().getOffset() == root.getColumnNumber(operand.getStartPosition())) {
if (element.hasTag()) {
++tagsCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private boolean hasNLS(List<Comment> trailingComments, ICompilationUnit cu) {
try {
buffer= cu.getBuffer();
for (Comment comment : trailingComments) {
if (comment instanceof LineComment lineComment) {
if (comment instanceof LineComment) {
if (buffer.getText(comment.getStartPosition(), comment.getLength()).contains("$NON-NLS")) { //$NON-NLS-1$
return true;
}
Expand Down

0 comments on commit 26b6ed3

Please sign in to comment.