Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor actions (remove async) #207

Closed
dubreuia opened this issue Jan 11, 2019 · 4 comments
Closed

Refactor actions (remove async) #207

dubreuia opened this issue Jan 11, 2019 · 4 comments
Milestone

Comments

@dubreuia
Copy link
Owner

dubreuia commented Jan 11, 2019

There are currently a lot of issues that might come from the (unintentional) use of async:

Right now, we instantiate one com.dubreuia.processors.Processor per action (optimize, reformat, quick fix, etc.), and run them by calling #run, but some processor might not be finished when we run the next one (see com.dubreuia.processors.java.InspectionProcessor#run). By re-reading com.intellij.openapi.application.ModalityState, I realised that #invokeLater is frowned upon.

I'll refactor using the abstraction com.intellij.openapi.command.WriteCommandAction and use #invokeAndWait(Runnable, ModalityState.NON_MODAL) everywhere.

@dubreuia
Copy link
Owner Author

dubreuia commented Jan 11, 2019

I thought about #128: we need to compile all the elements at the same time, after the actions (actions might move the line number, make the compilation correct by removing a bad unused import). There's #90 also that should also trigger after the actions.

So we have:

  • Actions
    • General
      • RearrangeCode (move to last)
      • OptimizeImports
      • ReformatAllText
      • -Compile-
    • Java
      • FieldMayBeFinal
      • LocalCanBeFinal
      • MethodMayBeStatic
      • UnqualifiedFieldAccess
      • UnqualifiedMethodAccess
      • UnqualifiedStaticUsage
      • CustomUnqualifiedStaticUsage
      • override (TODO wrong id)
      • ControlFlowStatementWithoutBraces
      • serial (TODO wrong id)
      • UnnecessaryThis
      • FinalPrivateMethod
      • UnnecessaryFinalOnLocalVariableOrParameter
      • Convert2Diamond
      • SuppressionAnnotation
      • UnnecessarySemicolon
      • WeakerAccess
  • Build
  • Inspect
  • Save (if no exceptions)

There is com.dubreuia.core.component.SaveActionManager#beforeAllDocumentsSaving that triggers before the specific document saving. Combined with FileDocumentManager.getInstance().getUnsavedDocuments(); we might be able to pipeline correctly the actions.

@dubreuia
Copy link
Owner Author

@dubreuia
Copy link
Owner Author

The multiple spawn of save actions manager is probably a problem too: when com.dubreuia.core.component.java.SaveActionManager starts, it stops com.dubreuia.core.component.SaveActionManager. It it happens at the wrong moment it might stop the first in the middle of an action.

There should be two Component (global and java) and only one SaveActionManager.

@dubreuia
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant