Skip to content

Commit

Permalink
WIP Adding annotation processing support
Browse files Browse the repository at this point in the history
- adds m2e-apt to the server distro (requires CQ approval)
- ignores derived resources from didOpen/didChange/didSave calls, effectively removing diagnostics for those,
as, after the server generates those files, the client detects changes, so sends textedits to the server to
re-modify them, causing weird errors.

Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon committed Apr 25, 2018
1 parent 88af81d commit b4fad7c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion org.eclipse.jdt.ls.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IPreferencesChangeListener> preferencesChangeListeners;
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<unit id="org.eclipse.xtext.sdk.feature.group" version="2.13.0.v20171020-0920"/>
<repository location="http://download.eclipse.org/releases/photon/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.jboss.tools.maven.apt.feature.feature.group" version="1.5.0.201804060341"/>
<repository location="http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-apt/1.5.0-2018-04-06_03-47-50-H10"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
</target>

0 comments on commit b4fad7c

Please sign in to comment.