diff --git a/org.eclipse.jdt.ls.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.ls.core/META-INF/MANIFEST.MF index 4a25650935..236bd44a77 100644 --- a/org.eclipse.jdt.ls.core/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.ls.core/META-INF/MANIFEST.MF @@ -32,7 +32,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0", org.eclipse.lsp4j.jsonrpc, org.eclipse.xtend.lib, org.eclipse.xtext.xbase.lib, - org.eclipse.core.filesystem;bundle-version="1.7.0" + org.eclipse.core.filesystem;bundle-version="1.7.0", + org.eclipse.jdt.apt.pluggable.core;bundle-version="1.2.0", + org.jboss.tools.maven.apt.core;bundle-version="1.3.0" Export-Package: org.eclipse.jdt.ls.core.internal;x-friends:="org.eclipse.jdt.ls.tests", org.eclipse.jdt.ls.core.internal.commands;x-friends:="org.eclipse.jdt.ls.tests", org.eclipse.jdt.ls.core.internal.contentassist;x-friends:="org.eclipse.jdt.ls.tests", @@ -48,3 +50,4 @@ Bundle-ClassPath: lib/jsoup-1.9.2.jar, lib/remark-1.0.0.jar, . Bundle-Vendor: %Bundle-Vendor +Automatic-Module-Name: org.eclipse.jdt.ls.core diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/DocumentLifeCycleHandler.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/DocumentLifeCycleHandler.java index df8fb46c33..d0171c004d 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/DocumentLifeCycleHandler.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/DocumentLifeCycleHandler.java @@ -229,7 +229,7 @@ public void run(IProgressMonitor monitor) throws CoreException { public void handleOpen(DidOpenTextDocumentParams params) { String uri = params.getTextDocument().getUri(); ICompilationUnit unit = JDTUtils.resolveCompilationUnit(uri); - if (unit == null || unit.getResource() == null) { + if (unit == null || unit.getResource() == null || unit.getResource().isDerived()) { return; } try { @@ -291,7 +291,7 @@ public void handleOpen(DidOpenTextDocumentParams params) { public void handleChanged(DidChangeTextDocumentParams params) { ICompilationUnit unit = JDTUtils.resolveCompilationUnit(params.getTextDocument().getUri()); - if (unit == null || !unit.isWorkingCopy() || params.getContentChanges().isEmpty()) { + if (unit == null || !unit.isWorkingCopy() || params.getContentChanges().isEmpty() || unit.getResource().isDerived()) { return; } @@ -340,13 +340,14 @@ public void handleClosed(DidCloseTextDocumentParams params) { return; } try { - if (JDTUtils.isDefaultProject(unit) || !JDTUtils.isOnClassPath(unit)) { + if (JDTUtils.isDefaultProject(unit) || !JDTUtils.isOnClassPath(unit) || unit.getResource().isDerived()) { new DiagnosticsHandler(connection, unit).clearDiagnostics(); } if (unit.equals(sharedASTProvider.getActiveJavaElement())) { sharedASTProvider.disposeAST(); } unit.discardWorkingCopy(); + unit.getResource().refreshLocal(IResource.DEPTH_ZERO, null); } catch (CoreException e) { JavaLanguageServerPlugin.logException("Error while handling document close", e); } diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManager.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManager.java index 883fcc25a9..bfedd25e57 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManager.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManager.java @@ -44,6 +44,7 @@ public class PreferenceManager { private Preferences preferences ; + private static final String M2E_APT_ID = "org.jboss.tools.maven.apt"; private ClientPreferences clientPreferences; private IMavenConfiguration mavenConfig; private ListenerList preferencesChangeListeners; @@ -73,6 +74,11 @@ public void initialize() { defEclipsePrefs.put(CodeStyleConfiguration.ORGIMPORTS_IMPORTORDER, String.join(";", Preferences.JAVA_IMPORT_ORDER_DEFAULT)); defEclipsePrefs.put(CodeStyleConfiguration.ORGIMPORTS_ONDEMANDTHRESHOLD, "99"); defEclipsePrefs.put(CodeStyleConfiguration.ORGIMPORTS_STATIC_ONDEMANDTHRESHOLD, "99"); + + IEclipsePreferences m2eAptPrefs = DefaultScope.INSTANCE.getNode(M2E_APT_ID); + if (m2eAptPrefs != null) { + m2eAptPrefs.put(M2E_APT_ID + ".mode", "jdt_apt"); + } } public void update(Preferences preferences) { diff --git a/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target b/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target index de1bd4a128..f7749ac33d 100644 --- a/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target +++ b/org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target @@ -43,6 +43,10 @@ + + + +