Skip to content

Commit

Permalink
changes for review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Arun Venmany <[email protected]>
  • Loading branch information
arunvenmany-ibm committed Dec 17, 2024
1 parent 4d037ac commit b96280f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,15 @@ public void testInvalidVariableDiagnosticWithCodeAction() throws IOException, Ba
.get(0).getLeft().getTextDocument()
.setUri(serverXmlFile.toURI().toString());
}

XMLAssert.testCodeActionsFor(serverXML, serverXmlFile.toURI().toString(), invalid1, codeActions.get(0));
TextEdit texted = te(8, 9,
8, 9, " ");

CodeAction invalidCodeAction = ca(invalid1, texted);
invalidCodeAction.getEdit()
.getDocumentChanges()
.get(0).getLeft().getTextDocument()
.setUri(serverXmlFile.toURI().toString());
codeActions.add(invalidCodeAction);
XMLAssert.testCodeActionsFor(serverXML, serverXmlFile.toURI().toString(), invalid1, codeActions.get(0),codeActions.get(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Hover onAttributeValue(IHoverRequest request, CancelChecker cancelChecker
stringBuilder.append(String.format("%s = %s", variable.getValue(), variableMap.get(variable.getValue())));
}
if (varIter.hasNext()) {
stringBuilder.append(System.lineSeparator());
stringBuilder.append("<br />");
}
}
if (!stringBuilder.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import org.eclipse.lemminx.dom.DOMDocument;
import org.eclipse.lemminx.services.extensions.codeaction.ICodeActionParticipant;
import org.eclipse.lemminx.services.extensions.codeaction.ICodeActionRequest;
import org.eclipse.lemminx.utils.XMLPositionUtility;
import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.jsonrpc.CancelChecker;

import java.util.List;
Expand Down Expand Up @@ -64,10 +66,12 @@ public void doCodeAction(ICodeActionRequest request, List<CodeAction> codeAction
String variableInDoc = String.format("${%s}", nextVariable.getKey().toString());
codeActions.add(CodeActionFactory.replace(title, diagnostic.getRange(), variableInDoc, document.getTextDocument(), diagnostic));
}
/*for (Map.Entry<Object, Object> nextVariable : existingVariables.entrySet()) {
String title = "Replace Variable with " + nextVariable.getKey() + " with value = " + nextVariable.getValue();
codeActions.add(CodeActionFactory.replace(title, diagnostic.getRange(), nextVariable.getKey().toString(), document.getTextDocument(), diagnostic));
}*/
// use special code action to reload variable diagnostics
Range range = XMLPositionUtility.createRange(document.getDocumentElement().getEndTagCloseOffset(), document.getDocumentElement().getEndTagCloseOffset()+1,
document);
String title = "Reload Diagnostics";
codeActions.add(CodeActionFactory.insert(title, range.getEnd(), " ",
document.getTextDocument(), diagnostic));
}
} catch (Exception e) {
// BadLocationException not expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,16 @@ public void testInvalidVariableDiagnosticWithCodeAction() throws BadLocationExce
.get(0).getLeft().getTextDocument()
.setUri(serverXMLURI);
}

XMLAssert.testCodeActionsFor(serverXML, serverXMLURI, invalid1, codeActions.get(0));
TextEdit texted = te(8, 9,
8, 9, " ");

CodeAction invalidCodeAction = ca(invalid1, texted);
invalidCodeAction.getEdit()
.getDocumentChanges()
.get(0).getLeft().getTextDocument()
.setUri(serverXMLURI);
codeActions.add(invalidCodeAction);
XMLAssert.testCodeActionsFor(serverXML, serverXMLURI, invalid1, codeActions.get(0),codeActions.get(1));
}


Expand Down

0 comments on commit b96280f

Please sign in to comment.