Skip to content

Commit

Permalink
Format code.
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Oct 19, 2018
1 parent 326fa9e commit 9dd46ab
Showing 1 changed file with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,9 @@ public CompletionList doComplete(XMLDocument xmlDocument, Position position, Com
break;
case StartPrologOrPI: {
try {

boolean isFirstNode = xmlDocument.positionAt(scanner.getTokenOffset()).getLine() == 0;
if (isFirstNode && offset <= scanner.getTokenEnd()) {
collectPrologSuggestion(scanner.getTokenEnd(), "", completionRequest,
completionResponse);
collectPrologSuggestion(scanner.getTokenEnd(), "", completionRequest, completionResponse);
return completionResponse;
}
} catch (BadLocationException e) {
Expand All @@ -224,9 +222,9 @@ public CompletionList doComplete(XMLDocument xmlDocument, Position position, Com
boolean isFirstNode = xmlDocument.positionAt(scanner.getTokenOffset()).getLine() == 0;
if (isFirstNode && offset <= scanner.getTokenEnd()) {
String substringXML = "xml".substring(0, scanner.getTokenText().length());
if(scanner.getTokenText().equals(substringXML)) {
if (scanner.getTokenText().equals(substringXML)) {
collectPrologSuggestion(scanner.getTokenEnd(), scanner.getTokenText(), completionRequest,
completionResponse, true);
completionResponse, true);
return completionResponse;
}
}
Expand Down Expand Up @@ -407,35 +405,32 @@ private void collectPrologSuggestion(int startOffset, String tag, CompletionRequ
}

private void collectPrologSuggestion(int tokenEndOffset, String tag, CompletionRequest request,
CompletionResponse response, boolean inPIState) {
CompletionResponse response, boolean inPIState) {
XMLDocument document = request.getXMLDocument();
CompletionItem item = new CompletionItem();
item.setLabel("<?xml ... ?>");
item.setKind(CompletionItemKind.Property);
item.setFilterText("xml version=\"1.0\" encoding=\"UTF-8\"?>");
item.setInsertTextFormat(InsertTextFormat.Snippet);
int closingBracketOffset;
if(inPIState) {
closingBracketOffset= getOffsetFollowedBy(document.getText(), tokenEndOffset, ScannerState.WithinPI,
TokenType.PIEnd);
}
else {//prolog state
if (inPIState) {
closingBracketOffset = getOffsetFollowedBy(document.getText(), tokenEndOffset, ScannerState.WithinPI,
TokenType.PIEnd);
} else {// prolog state
closingBracketOffset = getOffsetFollowedBy(document.getText(), tokenEndOffset, ScannerState.WithinTag,
TokenType.PrologEnd);
TokenType.PrologEnd);
}

if(closingBracketOffset != -1) {
//Include '?>'
if (closingBracketOffset != -1) {
// Include '?>'
closingBracketOffset += 2;
}
else {
} else {
closingBracketOffset = getOffsetFollowedBy(document.getText(), tokenEndOffset, ScannerState.WithinTag,
TokenType.StartTagClose);
if(closingBracketOffset == -1) {
TokenType.StartTagClose);
if (closingBracketOffset == -1) {
closingBracketOffset = tokenEndOffset;
}
else {
closingBracketOffset ++;
} else {
closingBracketOffset++;
}
}
int startOffset = tokenEndOffset - tag.length();
Expand Down Expand Up @@ -696,8 +691,9 @@ private static boolean isFollowedBy(String s, int offset, ScannerState intialSta
}

/**
* Returns starting offset of 'expectedToken' if it the next non whitespace token after
* 'initialState'
* Returns starting offset of 'expectedToken' if it the next non whitespace
* token after 'initialState'
*
* @param s
* @param offset
* @param intialState
Expand Down

0 comments on commit 9dd46ab

Please sign in to comment.