Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-11-02 15:32:52 +0000
committerDoug Schaefer2017-11-02 15:57:08 +0000
commiteed39fe4f8e6e8bd6a35170d69565ca1cf58ab17 (patch)
tree8adbf17e6d037d0149acb62fa20607c2d967182d /lsp4e-cpp/org.eclipse.lsp4e.cpp.language
parentbd88f34dde4388cbd09e03e626eaf0c2f78f8d50 (diff)
downloadorg.eclipse.cdt-eed39fe4f8e6e8bd6a35170d69565ca1cf58ab17.tar.gz
org.eclipse.cdt-eed39fe4f8e6e8bd6a35170d69565ca1cf58ab17.tar.xz
org.eclipse.cdt-eed39fe4f8e6e8bd6a35170d69565ca1cf58ab17.zip
Fix API error in lsp4e.cpp plugin.
Not sure we have the right dependency in the cdt target file but I get a compile error when I use it. Change-Id: Ie357ea76da82ac552b6c95662d725fb660434ff6
Diffstat (limited to 'lsp4e-cpp/org.eclipse.lsp4e.cpp.language')
-rw-r--r--lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/CPPResourceChangeListener.java234
1 files changed, 117 insertions, 117 deletions
diff --git a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/CPPResourceChangeListener.java b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/CPPResourceChangeListener.java
index 9d3d23f4d4d..18524e9fd62 100644
--- a/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/CPPResourceChangeListener.java
+++ b/lsp4e-cpp/org.eclipse.lsp4e.cpp.language/src/org/eclipse/lsp4e/cpp/language/CPPResourceChangeListener.java
@@ -1,118 +1,118 @@
-/*******************************************************************************
- * Copyright (c) 2017 Ericsson and others.
- * 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
- *******************************************************************************/
-
-package org.eclipse.lsp4e.cpp.language;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.lsp4e.LanguageServersRegistry;
-import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
-import org.eclipse.lsp4e.LanguageServiceAccessor;
-import org.eclipse.lsp4e.ProjectSpecificLanguageServerWrapper;
-import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
-import org.eclipse.lsp4j.FileChangeType;
-import org.eclipse.lsp4j.FileEvent;
-
-/**
- * A resource listener used to generate FileEvents, as part of the LSP. This
- * only listens to Added, Changed, Removed event on a specific project that as a
- * C/C++ language server started.
- */
-@SuppressWarnings("restriction")
-final class CPPResourceChangeListener implements IResourceChangeListener {
- private final IProject fProject;
-
- CPPResourceChangeListener(IProject project) {
- fProject = project;
- }
-
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- LanguageServerDefinition definition = LanguageServersRegistry.getInstance().getDefinition(CPPLanguageServer.ID);
- ProjectSpecificLanguageServerWrapper wrapper = getLanguageSeverWrapper(definition);
- if (event.getType() != IResourceChangeEvent.POST_CHANGE || !isRelevantDelta(event.getDelta())
- || wrapper == null) {
- return;
- }
-
- sendFileEvents(wrapper, createFileEventsFromResourceEvent(event));
- }
-
- private static void sendFileEvents(ProjectSpecificLanguageServerWrapper wrapper, List<FileEvent> fileEvents) {
- if (!fileEvents.isEmpty()) {
- DidChangeWatchedFilesParams params = new DidChangeWatchedFilesParams(fileEvents);
- wrapper.getServer().getWorkspaceService().didChangeWatchedFiles(params);
- }
- }
-
- private static List<FileEvent> createFileEventsFromResourceEvent(IResourceChangeEvent event) {
- List<FileEvent> fileEvents = new ArrayList<>();
- try {
- event.getDelta().accept((delta) -> {
- if (delta.getResource() instanceof IFile && isRelevantDelta(delta)) {
- FileEvent fileEvent = createFileEventFromDelta(delta);
- if (fileEvent != null) {
- fileEvents.add(fileEvent);
- }
- }
- return true;
- }, false);
- } catch (CoreException e) {
- // Do nothing
- }
- return fileEvents;
- }
-
- private ProjectSpecificLanguageServerWrapper getLanguageSeverWrapper(LanguageServerDefinition definition) {
- try {
- return LanguageServiceAccessor.getLSWrapperForConnection(fProject, definition, false);
- } catch (IOException e) {
- // Do nothing
- return null;
- }
- }
-
- private static boolean isRelevantDelta(IResourceDelta delta) {
- int kind = delta.getKind();
- int flags = delta.getFlags();
- if (delta.getResource() instanceof IFile && kind == IResourceDelta.CHANGED) {
- return (flags & IResourceDelta.CONTENT) != 0;
- }
-
- return kind == IResourceDelta.ADDED || kind == IResourceDelta.CHANGED || kind == IResourceDelta.REMOVED;
- }
-
- private static FileEvent createFileEventFromDelta(IResourceDelta delta) {
- URI locationURI = delta.getResource().getLocationURI();
- if (locationURI == null) {
- return null;
- }
-
- FileChangeType changeType = null;
- if (delta.getKind() == IResourceDelta.ADDED) {
- changeType = FileChangeType.Created;
- } else if (delta.getKind() == IResourceDelta.CHANGED) {
- changeType = FileChangeType.Changed;
- } else if (delta.getKind() == IResourceDelta.REMOVED) {
- changeType = FileChangeType.Deleted;
- } else {
- throw new IllegalStateException("Unsupported resource delta kind: " + delta.getKind()); //$NON-NLS-1$
- }
-
- return new FileEvent(locationURI.toString(), changeType);
- }
+/*******************************************************************************
+ * Copyright (c) 2017 Ericsson and others.
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.lsp4e.cpp.language;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.lsp4e.LanguageServersRegistry;
+import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
+import org.eclipse.lsp4e.LanguageServiceAccessor;
+import org.eclipse.lsp4e.ProjectSpecificLanguageServerWrapper;
+import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
+import org.eclipse.lsp4j.FileChangeType;
+import org.eclipse.lsp4j.FileEvent;
+
+/**
+ * A resource listener used to generate FileEvents, as part of the LSP. This
+ * only listens to Added, Changed, Removed event on a specific project that as a
+ * C/C++ language server started.
+ */
+@SuppressWarnings("restriction")
+final class CPPResourceChangeListener implements IResourceChangeListener {
+ private final IProject fProject;
+
+ CPPResourceChangeListener(IProject project) {
+ fProject = project;
+ }
+
+ @Override
+ public void resourceChanged(IResourceChangeEvent event) {
+ LanguageServerDefinition definition = LanguageServersRegistry.getInstance().getDefinition(CPPLanguageServer.ID);
+ ProjectSpecificLanguageServerWrapper wrapper = getLanguageSeverWrapper(definition);
+ if (event.getType() != IResourceChangeEvent.POST_CHANGE || !isRelevantDelta(event.getDelta())
+ || wrapper == null) {
+ return;
+ }
+
+ sendFileEvents(wrapper, createFileEventsFromResourceEvent(event));
+ }
+
+ private static void sendFileEvents(ProjectSpecificLanguageServerWrapper wrapper, List<FileEvent> fileEvents) {
+ if (!fileEvents.isEmpty()) {
+ DidChangeWatchedFilesParams params = new DidChangeWatchedFilesParams(fileEvents);
+ wrapper.getServer().getWorkspaceService().didChangeWatchedFiles(params);
+ }
+ }
+
+ private static List<FileEvent> createFileEventsFromResourceEvent(IResourceChangeEvent event) {
+ List<FileEvent> fileEvents = new ArrayList<>();
+ try {
+ event.getDelta().accept((delta) -> {
+ if (delta.getResource() instanceof IFile && isRelevantDelta(delta)) {
+ FileEvent fileEvent = createFileEventFromDelta(delta);
+ if (fileEvent != null) {
+ fileEvents.add(fileEvent);
+ }
+ }
+ return true;
+ }, false);
+ } catch (CoreException e) {
+ // Do nothing
+ }
+ return fileEvents;
+ }
+
+ private ProjectSpecificLanguageServerWrapper getLanguageSeverWrapper(LanguageServerDefinition definition) {
+ try {
+ return LanguageServiceAccessor.getLSWrapperForConnection(fProject, definition);
+ } catch (IOException e) {
+ // Do nothing
+ return null;
+ }
+ }
+
+ private static boolean isRelevantDelta(IResourceDelta delta) {
+ int kind = delta.getKind();
+ int flags = delta.getFlags();
+ if (delta.getResource() instanceof IFile && kind == IResourceDelta.CHANGED) {
+ return (flags & IResourceDelta.CONTENT) != 0;
+ }
+
+ return kind == IResourceDelta.ADDED || kind == IResourceDelta.CHANGED || kind == IResourceDelta.REMOVED;
+ }
+
+ private static FileEvent createFileEventFromDelta(IResourceDelta delta) {
+ URI locationURI = delta.getResource().getLocationURI();
+ if (locationURI == null) {
+ return null;
+ }
+
+ FileChangeType changeType = null;
+ if (delta.getKind() == IResourceDelta.ADDED) {
+ changeType = FileChangeType.Created;
+ } else if (delta.getKind() == IResourceDelta.CHANGED) {
+ changeType = FileChangeType.Changed;
+ } else if (delta.getKind() == IResourceDelta.REMOVED) {
+ changeType = FileChangeType.Deleted;
+ } else {
+ throw new IllegalStateException("Unsupported resource delta kind: " + delta.getKind()); //$NON-NLS-1$
+ }
+
+ return new FileEvent(locationURI.toString(), changeType);
+ }
} \ No newline at end of file

Back to the top