Fix build after rebase

Signed-off-by: Thomas Mäder <tmader@redhat.com>
6.19.x
Thomas Mäder 2018-07-27 15:45:30 +02:00 committed by Thomas Mäder
parent 763bebb9d1
commit 90f4f3b607
5 changed files with 47 additions and 356 deletions

View File

@ -32,12 +32,6 @@ public class JdbLocation implements Location {
this(languageServer, stackFrame, new JdbMethod(stackFrame));
}
public JdbLocation(Location internal, Method method) {
this.method = method;
this.internal = internal;
this.jdiStackFrame = null;
}
/**
* Intends to create location when thread is not suspended. Information concerning thread and
* frame are not available.

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.languageserver.ide.service;
import org.eclipse.che.api.core.jsonrpc.commons.JsonRpcError;
import org.eclipse.che.api.core.jsonrpc.commons.JsonRpcException;
import org.eclipse.che.api.promises.client.PromiseError;
public class ServiceUtil {
private ServiceUtil() {}
public static PromiseError getPromiseError(JsonRpcError jsonRpcError) {
return new PromiseError() {
@Override
public String getMessage() {
return jsonRpcError.getMessage();
}
@Override
public Throwable getCause() {
return new JsonRpcException(jsonRpcError.getCode(), jsonRpcError.getMessage());
}
};
}
}

View File

@ -1,298 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.maven.server.core.reconcile;
/**
* ***************************************************************************** Copyright (c)
* 2012-2018 Red Hat, Inc. All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* <p>Contributors: Red Hat, Inc. - initial API and implementation
* *****************************************************************************
*/
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.lang.String.format;
import static java.nio.charset.Charset.defaultCharset;
import static org.eclipse.che.maven.data.MavenConstants.POM_FILE_NAME;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.annotation.PreDestroy;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.core.notification.EventSubscriber;
import org.eclipse.che.api.editor.server.impl.EditorWorkingCopy;
import org.eclipse.che.api.editor.server.impl.EditorWorkingCopyManager;
import org.eclipse.che.api.editor.server.impl.EditorWorkingCopyUpdatedEvent;
import org.eclipse.che.api.languageserver.service.LanguageServiceUtils;
import org.eclipse.che.api.project.shared.dto.EditorChangesDto;
import org.eclipse.che.commons.xml.XMLTreeException;
import org.eclipse.che.dto.server.DtoFactory;
import org.eclipse.che.ide.ext.java.shared.dto.Problem;
import org.eclipse.che.ide.maven.tools.Model;
import org.eclipse.che.maven.data.MavenProjectProblem;
import org.eclipse.che.plugin.maven.server.core.MavenProjectManager;
import org.eclipse.che.plugin.maven.server.core.project.MavenProject;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
import org.eclipse.lsp4j.MessageParams;
import org.eclipse.lsp4j.MessageType;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.PublishDiagnosticsParams;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.services.LanguageClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXParseException;
/**
* Handles reconcile operations for pom.xml file.
*
* @author Roman Nikitenko
*/
public class PomReconciler {
private static final Logger LOG = LoggerFactory.getLogger(PomReconciler.class);
private MavenProjectManager mavenProjectManager;
private EditorWorkingCopyManager editorWorkingCopyManager;
private EventService eventService;
private EventSubscriber<EditorWorkingCopyUpdatedEvent> editorContentUpdateEventSubscriber;
private LanguageClient client;
public PomReconciler(
MavenProjectManager mavenProjectManager,
EditorWorkingCopyManager editorWorkingCopyManager,
EventService eventService,
LanguageClient client) {
this.mavenProjectManager = mavenProjectManager;
this.editorWorkingCopyManager = editorWorkingCopyManager;
this.eventService = eventService;
this.client = client;
editorContentUpdateEventSubscriber =
new EventSubscriber<EditorWorkingCopyUpdatedEvent>() {
@Override
public void onEvent(EditorWorkingCopyUpdatedEvent event) {
onEditorContentUpdated(event);
}
};
eventService.subscribe(editorContentUpdateEventSubscriber);
}
@PreDestroy
private void unsubscribe() {
eventService.unsubscribe(editorContentUpdateEventSubscriber);
}
List<Problem> reconcile(String pomPath, String projectPath, String pomContent)
throws ServerException, NotFoundException {
List<Problem> result = new ArrayList<>();
if (isNullOrEmpty(pomContent)) {
Problem problem =
DtoFactory.newDto(Problem.class)
.withError(true)
.withMessage("Content of pom file is empty")
.withSourceStart(1)
.withSourceEnd(1);
result.add(problem);
return result;
}
try {
Model.readFrom(new ByteArrayInputStream(pomContent.getBytes(defaultCharset())));
if (isNullOrEmpty(projectPath)) {
return result;
}
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectPath);
MavenProject mavenProject = mavenProjectManager.findMavenProject(project);
if (mavenProject == null) {
return result;
}
List<MavenProjectProblem> problems = mavenProject.getProblems();
int start = pomContent.indexOf("<project ") + 1;
int end = start + "<project ".length();
List<Problem> problemList =
problems
.stream()
.map(
mavenProjectProblem ->
DtoFactory.newDto(Problem.class)
.withError(true)
.withSourceStart(start)
.withSourceEnd(end)
.withMessage(mavenProjectProblem.getDescription()))
.collect(Collectors.toList());
result.addAll(problemList);
} catch (XMLTreeException exception) {
Throwable cause = exception.getCause();
if (cause != null && cause instanceof SAXParseException) {
result.add(createProblem(pomContent, (SAXParseException) cause));
} else {
String error =
format(
"Couldn't reconcile pom file '%s', the reason is '%s'",
pomPath, exception.getLocalizedMessage());
LOG.error(error, exception);
throw new ServerException(error);
}
} catch (IOException e) {
String error =
format(
"Couldn't reconcile pom file '%s', the reason is '%s'",
pomPath, e.getLocalizedMessage());
LOG.error(error, e);
throw new ServerException(error);
}
return result;
}
private void onEditorContentUpdated(EditorWorkingCopyUpdatedEvent event) {
EditorChangesDto editorChanges = event.getChanges();
String fileLocation = editorChanges.getFileLocation();
String projectPath = editorChanges.getProjectPath();
reconcilePath(fileLocation, projectPath);
}
public void reconcilePath(String fileLocation, String projectPath) {
String fileName = new Path(fileLocation).lastSegment();
if (!POM_FILE_NAME.equals(fileName)) {
return;
}
EditorWorkingCopy workingCopy = editorWorkingCopyManager.getWorkingCopy(fileLocation);
if (workingCopy == null) {
return;
}
try {
String newPomContent = workingCopy.getContentAsString();
List<Problem> problems = reconcile(fileLocation, projectPath, newPomContent);
List<Diagnostic> diagnostics = convertProblems(newPomContent, problems);
client.publishDiagnostics(
new PublishDiagnosticsParams(LanguageServiceUtils.prefixURI(fileLocation), diagnostics));
} catch (ServerException | NotFoundException e) {
LOG.error(e.getMessage(), e);
client.showMessage(new MessageParams(MessageType.Error, "Error reconciling " + fileLocation));
}
}
private Problem createProblem(String pomContent, SAXParseException spe) {
Problem problem = DtoFactory.newDto(Problem.class);
problem.setError(true);
problem.setMessage(spe.getMessage());
if (pomContent != null) {
int lineNumber = spe.getLineNumber();
int columnNumber = spe.getColumnNumber();
try {
Document document = new Document(pomContent);
int lineOffset = document.getLineOffset(lineNumber - 1);
problem.setSourceStart(lineOffset + columnNumber - 1);
problem.setSourceEnd(lineOffset + columnNumber);
} catch (BadLocationException e) {
LOG.error(e.getMessage(), e);
}
}
return problem;
}
public void reconcileUri(String uri, String text) {
try {
String pomPath = LanguageServiceUtils.removePrefixUri(uri);
List<Problem> problems = reconcile(pomPath, new File(pomPath).getParent(), text);
List<Diagnostic> diagnostics = convertProblems(text, problems);
client.publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
} catch (ServerException | NotFoundException e) {
LOG.error("Error reconciling content: " + uri, e);
client.showMessage(new MessageParams(MessageType.Error, "Error reconciling " + uri));
}
}
private static List<Diagnostic> convertProblems(String text, List<Problem> problems) {
Map<Integer, Position> positions = mapPositions(text, problems);
List<Diagnostic> diagnostics =
problems
.stream()
.map((Problem p) -> convertProblem(positions, p))
.filter(o -> o != null)
.collect(Collectors.toList());
return diagnostics;
}
private static Map<Integer, Position> mapPositions(String text, List<Problem> problems) {
SortedSet<Integer> offsets = new TreeSet<>();
for (Problem problem : problems) {
offsets.add(problem.getSourceStart());
offsets.add(problem.getSourceEnd());
}
Map<Integer, Position> result = new HashMap<>();
int line = 0;
int character = 0;
int pos = 0;
for (int offset : offsets) {
while (pos < offset && pos < text.length()) {
char ch = text.charAt(pos++);
if (ch == '\r') {
if (text.charAt(pos) == '\n') {
pos++;
}
line++;
character = 0;
} else if (ch == '\n') {
line++;
character = 0;
} else {
character++;
}
}
result.put(offset, new Position(line, character));
}
;
return result;
}
private static Diagnostic convertProblem(Map<Integer, Position> positionMap, Problem problem) {
Diagnostic result = new Diagnostic();
Position start = positionMap.get(problem.getSourceStart());
Position end = positionMap.get(problem.getSourceEnd());
if (start == null || end == null) {
LOG.error("Could not map problem range: " + problem);
return null;
}
result.setRange(new Range(start, end));
result.setMessage(problem.getMessage());
result.setSeverity(problem.isError() ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning);
return result;
}
}

View File

@ -25,6 +25,7 @@ import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ACTIVE_
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ALL_TABS_XPATH;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ASSIST_CONTENT_CONTAINER;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.AUTOCOMPLETE_CONTAINER;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.AUTOCOMPLETE_PROPOSAL_DOC_ID;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.CONTEXT_MENU;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.DEBUGGER_BREAKPOINT_CONDITION;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.DEBUGGER_BREAKPOINT_DISABLED;
@ -40,6 +41,7 @@ import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.IMPLEME
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ITEM_TAB_LIST;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.JAVA_DOC_POPUP;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.LANGUAGE_SERVER_REFACTORING_RENAME_FIELD_CSS;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.LANGUAGE_SERVER_REFACTORING_RENAME_FIELD_CSS;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ORION_ACTIVE_EDITOR_CONTAINER_XPATH;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ORION_CONTENT_ACTIVE_EDITOR_XPATH;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.POSITION_CURSOR_NUMBER;
@ -90,7 +92,6 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import org.eclipse.che.commons.lang.Pair;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.action.ActionsFactory;
@ -347,8 +348,13 @@ public class CodenvyEditor {
@FindBy(xpath = HOVER_POPUP_XPATH)
private WebElement hoverPopup;
@FindBy(id = AUTOCOMPLETE_PROPOSAL_DOC_ID)
private WebElement proposalDoc;
@FindBy(css = LANGUAGE_SERVER_REFACTORING_RENAME_FIELD_CSS)
private WebElement languageServerRenameField;
/**
* Waits until specified {@code editorTab} is presented, selected, focused and editor activated.
*
@ -2277,47 +2283,6 @@ public class CodenvyEditor {
loader.waitOnClosed();
}
/**
* Get html code of java doc of autocomplete proposal.
*
* @return html code of JavaDoc of already opened autocomplete proposal by making request on 'src'
* attribute of iframe of JavaDoc popup.
*/
public String getAutocompleteProposalJavaDocHtml() throws IOException {
return getJavaDocPopupText();
}
/**
* Waits until specified {@code expectedText} is present in javadoc.
*
* @param expectedText text which should be present in javadoc
*/
public void waitContextMenuJavaDocText(String expectedText) {
webDriverWaitFactory
.get()
.until(
(ExpectedCondition<Boolean>)
driver -> {
String javaDocPopupHtmlText = "";
try {
javaDocPopupHtmlText = getJavaDocPopupText();
} catch (StaleElementReferenceException e) {
LOG.warn(
"Can not get java doc HTML text from autocomplete context menu in editor");
}
return javaDocPopupHtmlText.length() > 0
&& verifyJavaDoc(javaDocPopupHtmlText, expectedText);
});
}
private String getJavaDocPopupText() {
return seleniumWebDriverHelper.waitVisibilityAndGetText(autocompleteProposalJavaDocPopup);
}
private boolean verifyJavaDoc(String javaDocHtml, String regex) {
return Pattern.compile(regex, Pattern.DOTALL).matcher(javaDocHtml).matches();
}
private List<WebElement> getAllTabsWithProvidedName(String tabName) {
return seleniumWebDriverHelper.waitVisibilityOfAllElements(
By.xpath(
@ -2329,7 +2294,6 @@ public class CodenvyEditor {
By.xpath(format(Locators.TEXT_TO_MOVE_CURSOR_XPATH, text)));
}
<<<<<<< HEAD
public void checkProposalDocumentation(String expectedText) {
seleniumWebDriverHelper.waitTextContains(proposalDoc, expectedText);
}
@ -2354,8 +2318,6 @@ public class CodenvyEditor {
seleniumWebDriverHelper.pressEnter();
}
=======
>>>>>>> Readd removed code to fix build
/** Type the comment line in the file by keyboard */
public void launchCommentCodeFeature() {
actionsFactory

View File

@ -92,7 +92,7 @@ public class AutocompleteProposalJavaDocTest {
editor.selectAutocompleteProposal("concat(String part1, String part2, char divider) : String");
// then
editor.waitContextMenuJavaDocText(
editor.checkProposalDocumentation(
".*<p><b>Deprecated.</b> <i> As of version 1.0, use "
+ "<code><a href='.*/javadoc/get\\?.*projectpath=/multi-module-java-with-ext-libs/app&handle=%E2%98%82%3Dmulti-module-java-with-ext-libs.*org.apache.commons.lang.StringUtils%E2%98%82join%E2%98%82Object\\+%5B%5D%E2%98%82char'>org.apache.commons.lang.StringUtils.join\\(Object \\[\\], char\\)</a></code>"
+ "</i><p>Returns concatination of two strings into one divided by special symbol."
@ -114,7 +114,7 @@ public class AutocompleteProposalJavaDocTest {
editor.selectAutocompleteProposal("App()");
// then
editor.waitContextMenuJavaDocText(".*No documentation found.*");
editor.checkProposalDocumentation(".*No documentation found.*");
}
@Test
@ -127,7 +127,7 @@ public class AutocompleteProposalJavaDocTest {
editor.selectAutocompleteProposal("isEquals(Object o) : boolean ");
// then
editor.waitContextMenuJavaDocText(
editor.checkProposalDocumentation(
".*Returns <code>true</code> if the argument is equal to instance. otherwise <code>false</code>"
+ "<dl><dt>Parameters:</dt>"
+ "<dd><b>o</b> an object.</dd>"
@ -155,7 +155,7 @@ public class AutocompleteProposalJavaDocTest {
editor.selectAutocompleteProposal("BookImpl");
// then
editor.waitContextMenuJavaDocText(".*UPDATE. Implementation of Book interface..*");
editor.checkProposalDocumentation(".*UPDATE. Implementation of Book interface..*");
}
@Test
@ -168,7 +168,7 @@ public class AutocompleteProposalJavaDocTest {
editor.selectAutocompleteProposal("hashCode() : int");
// then
editor.waitContextMenuJavaDocText(
editor.checkProposalDocumentation(
".*Returns a hash code value for the object. "
+ "This method is supported for the benefit of hash tables such as those provided by "
+ "<code><a href='.*/javadoc/get\\?.*projectpath=/multi-module-java-with-ext-libs/app&handle=%E2%98%82%3Dmulti-module-java-with-ext-libs.*%3Cjava.lang%28Object.class%E2%98%83Object%7EhashCode%E2%98%82java.util.HashMap'>java.util.HashMap</a></code>.*");
@ -184,7 +184,7 @@ public class AutocompleteProposalJavaDocTest {
editor.selectAutocompleteProposal("info(String arg0) : void");
// then
editor.waitContextMenuJavaDocText(".*No documentation found.*");
editor.checkProposalDocumentation(".*No documentation found.*");
// when
editor.closeAutocomplete();
@ -202,7 +202,7 @@ public class AutocompleteProposalJavaDocTest {
editor.selectAutocompleteProposal("info(String msg) : void");
// then
editor.waitContextMenuJavaDocText(
editor.checkProposalDocumentation(
".*Log a message at the .* level."
+ "<dl><dt>Parameters:</dt>"
+ "<dd><b>msg</b>"