Skip to content

Commit 63a3687

Browse files
committed
Upgrade the project to IntelliJ 2018.1.6 (build 181.5540.7) and ignored a Runtime Exception from the Code Smell Detector if it is due to ‘cannot run under write acction’
1 parent f1a6e19 commit 63a3687

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

AEM IDE Tooling 4 IntelliJ.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<excludeFolder url="file://$MODULE_DIR$/eclipse.aem.tooling.generatedd.test.project" />
1212
<excludeFolder url="file://$MODULE_DIR$/src/main/java/com/headwire/aem/tooling/intellij/console/intellij" />
1313
</content>
14-
<orderEntry type="inheritedJdk" />
14+
<orderEntry type="jdk" jdkName="IntelliJ IDEA Community Edition IC-181.5540.7" jdkType="IDEA JDK" />
1515
<orderEntry type="sourceFolder" forTests="false" />
1616
<orderEntry type="library" name="org.apache.jackrabbit.vault:org.apache.jackrabbit.vault.rcp:3.1.38" level="project" />
1717
<orderEntry type="library" name="org.apache.jackrabbit.vault:org.apache.jackrabbit.vault:3.1.38" level="project" />

META-INF/plugin.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin version="2">
22
<id>com.headwire.aem.tooling.intellij</id>
33
<name>AEM IDE Tooling 4 IntelliJ</name>
4-
<version>1.0.3.4-beta1</version>
4+
<version>1.0.3.4-beta2</version>
55
<vendor email="aemintellijplugin@headwire.com" url="https://www.headwire.com/aemintellijplugin">headwire.com Inc</vendor>
66

77
<description><![CDATA[
@@ -16,12 +16,16 @@
1616

1717
<change-notes><![CDATA[
1818
<ul>
19-
<li>1.0.3.4-beta1:
19+
<li>1.0.3.4-beta2:
2020
<ol>
2121
<li>
2222
Added a fix of a threading issue inside the Import From action. IntelliJ does not permit (anymore)
2323
to write in an User Action.
2424
</li>
25+
<li>
26+
An exception during code change from the Code Smell Detector is ignored if it is based on
27+
the 'cannot run under write action' failure. There is not fix in sight from JetBrains or
28+
help on how to make this work so for now it is just ignored.
2529
</ol>
2630
</li>
2731
<li>1.0.3.3:

Readme.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ The **master** is the latest release code and it the same as the highest
4747

4848
#### Updates:
4949

50-
**1.0.3.4-beta1**:
50+
**1.0.3.4-beta2**:
5151
* A fix for the Import From User Action that fails because I cannot write from a
5252
User Action.
53-
53+
* An exception during code change from the Code Smell Detector is ignored if it is based on
54+
the 'cannot run under write action' failure. There is not fix in sight from JetBrains or
55+
help on how to make this work so for now it is just ignored.
56+
5457
**1.0.3.3**:
5558
* Working on issues with latest IntelliJ Releases.
5659
* All threading is centralized in single class and with it fixed some issues with threading

src/main/java/com/headwire/aem/tooling/intellij/communication/ContentResourceChangeListener.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.intellij.openapi.actionSystem.ActionManager;
3232
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
3333
import com.intellij.openapi.application.ApplicationManager;
34+
import com.intellij.openapi.application.ReadAction;
3435
import com.intellij.openapi.compiler.CompileContext;
3536
import com.intellij.openapi.compiler.CompileStatusNotification;
3637
import com.intellij.openapi.compiler.CompilerManager;
@@ -271,13 +272,8 @@ private void executeMake(final VirtualFileEvent event) {
271272
VirtualFile file = event.getFile();
272273
if("java".equalsIgnoreCase(file.getExtension())) {
273274
//AS TODO: In order to use the Code Snell Detector this needs to be invoked in a Read Only Thread but part of the Dispatcher Thread
274-
invokeAndWait(
275-
new InvokableRunner() {
276-
@Override
277-
public void run() {
278-
executeMakeInUIThread(event);
279-
}
280-
}
275+
ReadAction.run(() ->
276+
executeMakeInUIThread(event)
281277
);
282278
}
283279
}
@@ -293,12 +289,24 @@ private void executeMakeInUIThread(final VirtualFileEvent event) {
293289
CodeSmellDetector codeSmellDetector = CodeSmellDetector.getInstance(project);
294290
boolean isOk = true;
295291
if(codeSmellDetector != null) {
296-
List<CodeSmellInfo> codeSmellInfoList = codeSmellDetector.findCodeSmells(Arrays.asList(event.getFile()));
297-
for(CodeSmellInfo codeSmellInfo: codeSmellInfoList) {
298-
if(codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) {
299-
isOk = false;
300-
break;
292+
try {
293+
List<CodeSmellInfo> codeSmellInfoList = codeSmellDetector.findCodeSmells(Arrays.asList(event.getFile()));
294+
for (CodeSmellInfo codeSmellInfo : codeSmellInfoList) {
295+
if (codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) {
296+
isOk = false;
297+
break;
298+
}
299+
}
300+
} catch(RuntimeException e) {
301+
// Swallow the exception if this is due to the Cannot Run Under Write Action issue
302+
if(!e.getMessage().contains("run under write action")) {
303+
throw e;
301304
}
305+
else {
306+
Logger.getInstance(ContentResourceChangeListener.class).info(
307+
"Found 'cannot run under write action -> ignored"
308+
);
309+
}
302310
}
303311
}
304312
if(isOk) {

0 commit comments

Comments
 (0)