Comments (10)
That would be a nice feature. I'm marking that as enhancement. Thanks for the idea, I'll keep you posted.
from intellij-plugin-save-actions.
+1.
That would be the last thing missing for convincing everybody in my team to switch from eclipse to intellij.
from intellij-plugin-save-actions.
I tried to call some methods and it seems to work quite well...
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
new WriteCommandAction.Simple(project) {
@Override
protected void run() throws Throwable {
InspectionManager inspectionManager = InspectionManager.getInstance(project);
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
Document document = psiDocumentManager.getDocument(psiFile);
psiDocumentManager.commitDocument(document);
GlobalInspectionContext context = inspectionManager.createNewGlobalContext(false);
LocalCanBeFinal tool = new LocalCanBeFinal();
InspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(tool);
List<ProblemDescriptor> problemDescriptors = InspectionEngine.runInspectionOnFile(psiFile,
toolWrapper, context);
for (ProblemDescriptor problemDescriptor : problemDescriptors) {
QuickFix[] fixes = problemDescriptor.getFixes();
if (fixes != null) {
for (QuickFix fix : fixes) {
if (fix != null) {
fix.applyFix(project, problemDescriptor);
}
}
}
}
psiDocumentManager.commitDocument(document);
}
}.execute();
}
})
from intellij-plugin-save-actions.
Very nice @krasa, I'll try your code ASAP.
The best way to configure that would be to duplicate the "Settings > Editor > Inspections" option table in the save actions options, to enable / disable specific inspections on save... Then reuse your code by looping on the activated inspections and applying them.
from intellij-plugin-save-actions.
Yep, that would be ideal.
from intellij-plugin-save-actions.
+1 for this enhancement. but applying quick fixes after inspections should be opt-in in settings for various reasons.
from intellij-plugin-save-actions.
I'm currently implementing that one. I'm doing a simple version with only some inspections, so if you want to vote for the one you want, go ahead (there are so many !).
from intellij-plugin-save-actions.
Some inspection IDs I find useful:
- localCanBeFinal
- explicitTypeCanBeDiamond
- unqualifiedFieldAccess
- suppressAnnotation
- finalPrivateMethod
- unnecessarySemicolon
- fieldCanBeFinal
from intellij-plugin-save-actions.
+1
I really miss the "Use 'this' qualifier for field/method access" from Eclipse Save Actions! So I'd vote for:
- unqualifiedFieldAccess
- unqualifiedMethodAccess
from intellij-plugin-save-actions.
Added in 0.5. Open another issue if you want more inspections, I'll add them incrementally.
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.