Comments (2)
I updated the code a bit since then to fix an assertion exception that sometimes occurred:
private static void reformatAndCompile(
@NotNull final Project project,
@NotNull final Document document,
@NotNull final PsiFile psiFile) {
documentsToProcess.add(document);
if (storage.isEnabled(Action.compileFile) && isDocumentActive(project, document)) {
fileToCompile = isFileCompilable(project, psiFile.getVirtualFile());
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (documentsToProcess.contains(document)) {
documentsToProcess.remove(document);
if (storage.isEnabled(Action.optimizeImports)
|| storage.isEnabled(Action.reformatCode)) {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public void run() {
if (storage.isEnabled(Action.optimizeImports)) {
new OptimizeImportsProcessor(project, psiFile)
.run();
}
if (storage.isEnabled(Action.reformatCode)) {
new ReformatCodeProcessor(
project,
psiFile,
null,
ChangeListManager
.getInstance(project)
.getChange(psiFile.getVirtualFile()) != null)
.run();
}
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(psiFile);
}
});
}
});
}
}
if (fileToCompile.length > 0) {
if (documentsToProcess.isEmpty()) {
compileFile(project, fileToCompile);
fileToCompile = VirtualFile.EMPTY_ARRAY;
}
} else if (storage.isEnabled(Action.makeProject)) {
if (documentsToProcess.isEmpty()) {
makeProject(project);
}
} else {
saveFile(project, document, psiFile.getVirtualFile());
}
}
}, project.getDisposed());
}
from intellij-plugin-save-actions.
Added compile support in 0.8. Might add make support later
from intellij-plugin-save-actions.
Related Issues (20)
- StackOverlfow.
- CustomUnqualifiedStaticUsageInspection: display name should be overridden or configured via XML [Plugin: com.dubreuia] HOT 5
- bulk save action performance
- The specified parameters not match any of the following constructors: public com.dubreuia.model.Storage() HOT 1
- Exception in Save Actions 2.3.0 HOT 1
- Save Actions not working in WebStorm EAP version HOT 4
- Removal of required suppress warning annotation HOT 1
- Looking for gradle tasks integration option in save action plugin HOT 1
- Exception in IntelliJ 2023.1 HOT 1
- RuntimeException in IntelliJ 2023.1 HOT 21
- Cannot create configurable error on fresh plugin install HOT 7
- Cannot create configurable HOT 3
- Request: for "Reformat file" on save, please prevent it in case it changes logic or when the code has errors HOT 10
- Cannot save, launch, or commit changes, due to RuntimeException: Cannot invoke (class=SaveActionManager, method=beforeAllDocumentsSaving, topic=FileDocumentManagerListener) HOT 4
- Exception: Cannot create configurable HOT 2
- Can not commit git By idea2023.1 HOT 2
- Unexception: Save Actions occurs errors when starting tomcat server HOT 2
- com.intellij.diagnostic.PluginException: No display name is specified for configurable com.dubreuia.ui.Configuration in xml file HOT 2
- com.intellij.diagnostic.PluginException: No display name specified in plugin descriptor XML file for configurable com.dubreuia.ui.Configuration; specify it using 'displayName' or 'key' attribute to avoid necessity to load the configurable class when Settings dialog is opened [Plugin: com.dubreuia] HOT 3
- java.lang.RuntimeException: Cannot invoke (class=SaveActionManager, method=beforeAllDocumentsSaving, topic=FileDocumentManagerListener) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intellij-plugin-save-actions.