Code Monkey home page Code Monkey logo

abapquickfix's Introduction

ABAP Quick Fix plugin for ADT

Installation from Marketplace https://marketplace.eclipse.org/content/abap-quick-fix

Eclipse Marketplace Stats

Eclipse Marketplace Downloads

Direct installation from https://fidley.github.io/ADTPluginsUpdateSite/UpdateSite/

ABAP Quick Fix Functions so far:

  • Remove all comments (do not delete pseudo comments and ADT comments)
  • Remove all comments in selection (do not delete pseudo comments and ADT comments)
  • Replace icon literals with constant
  • Translate comments into English
  • Replace READ TABLE with ASSIGN
  • Replace READ TABLE with REF #( )
  • Replace READ TABLE with Table Expression
  • Replace CALL METHOD with direct call
  • Replace MOVE with direct assignment
  • Combine statements: DATA, TYPES, CONSTANTS, FIELD-SYMBOLS, CHECK, CLEAR, REFRESH, FREE, PARAMETERS, SELECT-OPTIONS, METHODS, CLASS-METHODS
  • Change APPEND TO to APPEND VALUE #( ) TO
  • Change INSERT INTO to INSERT VALUE #( ) INTO
  • Split combined(chained) statements
  • Remove Line Break at end of statement
  • Replace CREATE OBJECT with NEW
  • Omit EXPORTING in method call
  • Omit RECEIVING in method call
  • Change APPEND TO to INSERT VALUE #( ) INTO
  • Replace GET REFERENCE with REF #
  • Replace READ TABLE TRANSPORTING NO FIELDS with LINE_EXISTS
  • Remove full line comments from statement
  • Omit self reference ME->
  • Replace operators EQ,NE,GT,GE,LT,LE with =,<>,>,>=,<,<=

EQ QuickFix

  • Align operators (in selected code)

    QuickFixAlignOperators

  • Replace Full Line Comment with In-line comment

  • Align TYPEs(and LIKE) in variable definitions) alignTypes

Additional information

Cover image

YourKit supports this open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications. YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler, and YourKit YouMonitor.

abapquickfix's People

Contributors

fidley avatar g-back avatar larshp avatar lc-leuc avatar lukas-mb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

abapquickfix's Issues

Replace all Operators

We have the already great fixes to replace single instances of EQ, GE, LE etc. - would be cool if we could replace ALL instances of these operators in a file.

Will try to take a crack at this myself, when I find the time 🙂

Split doesn't work with line comments

Hi,
When I split the following instruction:

constants: foo type c value '0',  "foo
           bar type c value '1'.  "bar

I get the following result:

constants foo type c value '0'.
constants   "foobar type c value '1'.  "bar

Tested on Eclipse 2022-12 with Quick fix installed from Eclipse Marketplace. Not sure about the version since I got the release notes from 1.3 but when I look at the Eclipse MArketplace in the tab Installed, it's 1.0.16.

Quick fixes not showing up

Hi,

I've installed the extension, but cannot seem to figure out how to enable it. Ctrl + 1 does not seem to show any of the supported actions/quick fixes mentioned in the README. Am I missing some pre-requisite?
image
image
image

data sort qf removes all data statements

I'm creating an old school wizard, so we have a function group, function module, top include, the usual suspects.
The top include had concatenated data statements, so first I applied the the split qf which worked ok.
Saved, activated (not really necesssary, just mentioning it).

Next I tried the "sort" qf: all the data statements are gone and the status line has this message: Quelltext nicht formatierbar. Modularisierungseinheit nicht gefunden (I'm logged in in German, a rough translation should be "Source text cannot be formatted. Modularization unit not found")

I'm fine with reverting the changes immediately if I notice the qf went awry, but I wonder if it could be made to work in this context or at least blocked if the fix is not possible.

Create Help of plugin

To show all capabilities of plugin it would be good to have a help, that would contain all info

Discussion: How to activate all Inactives

Hi Fdiley,
I really appreciate your work, which inspired me to develop an Eclipse Plugin. However, I've encountered an issue:

I need to activate all inactive objects without using the command com.sap.adt.activation.ui.command.multiActivation because it requires additional input.

Here's what I'm trying:

factory = AdtActivationPlugin.getDefault().getActivationServiceFactory();
activationService = factory.createActivationService(project.getName());
newInactiveCtsObjectList = activationService.getInactiveCtsObjects(new NullProgressMonitor());

Despite this, I'm unable to activate newInactiveCtsObjectList. Could you provide guidance on how to proceed?

Replace full line comment with in-line comment

Replace comments that start with * at the start of the line with inline-comments "
Unlike Full-Line Comments, Inline-comments are automatically indented, making them (imo) a lot easier to read.

Single Line or whole file (whole file: setting to be enabled)
Should be done easily with Regex since * has to be first character of line.

Will try this myself (if you give the ok)

Create Help of plugin

To show all capabilities of plugin it would be good to have a help, that would contain all info

Replace Operators

Idea for new quick fix: replace operators "EQ" "NE" with their "proper" counterparts.
I'd try this myself but there's a couple of traps:

  • should not replace when in string literals or string templates
  • should not replace in comments
  • not in identifiers or keywords (obviously)

My regex abilities are unfortunately not good enough to handle those traps...

Idea: Align equal signs (of selected rows)

Simple example:

    poheaderx = VALUE bapimepoheaderx(
        comp_code = abap_true
        doc_type = abap_true
        item_intvl = abap_true
        vendor = abap_true
        purch_org = abap_true
        pur_group = abap_true
        currency = abap_true
    ).
    poheaderx = VALUE bapimepoheaderx(
        comp_code  = abap_true
        doc_type   = abap_true
        item_intvl = abap_true
        vendor     = abap_true
        purch_org  = abap_true
        pur_group  = abap_true
        currency   = abap_true
    ).

Notes/Naive Approach/Ideas:

  • only first equal sign of row is looked at (in case someone decides to use multiple per line, e.g for method calls)
  • find "rightmost" equal sign in selected range, fill other rows with whitespace to align

Installation not possible

Hi,

when I open the link for the direct installtion in the readme, I get an HTTP 403, from your server. This happens on my work notebook as well as on my private smartphone - so it doesn't seem to be a problem with the company firewall.
2022-06-09 14_13_39-403 Forbidden und 1 weitere Seite - Profil 1 – Microsoft​ Edge

When trying to install via drag&drop from the marketplace, the URL seems to be wrong.
2022-06-09 14_10_53-Eclipse Marketplace

If I continue anyways, I get the following error message.
2022-06-09 14_12_12-Problem Occurred

Any advice?

Regards,
Jörg

QuickFix invocation causes BadLocationException in Report - no Proposals shown (or not all)

Observation

In Reports and also in FM Quickfix proposals are not shown.
In debug mode a BadLocationException can be observed in AbapStatement initialization.

Apparently endOfStatement is negative and causes substring(.) to fail.

How to reproduce

Several small test reports show this behavior.
For example see this example report (minial). Place curson on data and press Ctrl-1.

report z_test.
   data(temp) = 1.

@FD1899 has reported this odd behavior in ABAPQuickFixS4Conversion/#6 for other reports.
The problem occurs with the ABAPQuickFixS4Conversion plugin installes as well as without the plugin.

Versions

  • Eclippse: 2024-03 (4.31)
  • ABAPQuickFix 1.16

Stacktrace

org.eclipse.jface.text.BadLocationException
	at org.eclipse.jface.text.AbstractDocument.getChar(AbstractDocument.java:774)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getChar(SynchronizableDocument.java:141)
	at com.abapblog.adt.quickfix.assist.syntax.codeParser.AbapStatement.<init>(AbapStatement.java:25)
	at com.abapblog.adt.quickfix.assist.syntax.codeParser.AbapCodeReader.createStatement(AbapCodeReader.java:46)
	at com.abapblog.adt.quickfix.assist.syntax.codeParser.AbapCodeReader.<init>(AbapCodeReader.java:34)
	at com.abapblog.adt.quickfix.assist.syntax.codeParser.AbapCodeReader.getInstance(AbapCodeReader.java:55)
	at com.abapblog.adt.quickfix.assist.syntax.statements.StatementsAssistProcessor.computeQuickAssistProposals(StatementsAssistProcessor.java:130)
	at com.sap.adt.tools.abapsource.ui.sources.QuickAssistProcessorManager.computeQuickAssistProposals(QuickAssistProcessorManager.java:58)
	at org.eclipse.jface.text.quickassist.QuickAssistAssistant$ContentAssistProcessor.computeCompletionProposals(QuickAssistAssistant.java:71)
	at org.eclipse.jface.text.contentassist.ContentAssistant$2.lambda$0(ContentAssistant.java:2064)
	at java.base/java.util.Collections$SingletonSet.forEach(Collections.java:5125)
	at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:2063)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:2060)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:577)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.lambda$0(CompletionProposalPopup.java:507)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:502)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1874)
	at org.eclipse.jface.text.quickassist.QuickAssistAssistant.showPossibleQuickAssists(QuickAssistAssistant.java:113)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:1005)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1468)
	at com.sap.adt.tools.abapsource.ui.sources.editors.AdtProjectionViewer.doOperation(AdtProjectionViewer.java:243)
	at com.sap.adt.refactoring.ui.internal.quickfix.AbapQuickfixProcessor$AsyncQuickfixCalculatorJob.retriggerContentAssist(AbapQuickfixProcessor.java:754)
	at com.sap.adt.util.ui.contentassist.AsyncContentAssistProposalCalculatorJob.lambda$0(AsyncContentAssistProposalCalculatorJob.java:74)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4047)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3663)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:152)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:639)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:546)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1459)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1432)
Range [1, 0) out of bounds for length 41

Bug for quick fixing data statements

When using quick fix to combine/split data statements for variables that are referencing a type defined in a class(for example a type of a gateway entity) - the combine data statements suggestion is missing:

    DATA ls_entityset1 TYPE zcl_testapp_mpc=>ts_entity1.
    DATA ls_entityset2 TYPE zcl_testapp_mpc=>ts_entity1.
    DATA lv_matnr1     TYPE matnr.
    DATA lv_matnr2     TYPE matnr.
    DATA lv_matnr3     TYPE matnr.

If i just select the last 3 statements it works fine - i assume its due to a missing escaping of the special characters in this case?

Thanks in advance for checking!

Greetings
Marian

New QuickFix : Uncombine statements

Hi,

In order to implement CleanCode rule Do not chain up-front declarations, I would like to suggest a new quick fix for uncombining (or unchaining) statements.

Basically, it would be the exact opposite of the following rule: "Combine statements: DATA, TYPES, CONSTANTS, FIELD-SYMBOLS, CHECK, CLEAR, REFRESH, FREE, PARAMETERS, SELECT-OPTIONS, METHODS, CLASS-METHODS"

Thanks & Regards,
Alexandre

"Remove all comments" - Setting

Hi,
thanks for this plugin, very useful!
A suggestion: add a setting to enable/disable the "Remove all comments" function (same as with the translation function). What do you think?

New Quick Fix: Sort Declarations

Hi, what do you think about a new quick fix for sorting data declarations? Sometimes, I encounter code with many declarations without any structure. There could also be an ordering mechanism based on user preferences. For example:

  1. Objects (go_ , lo_)
  2. Tables (gt_ , lt_)
  3. Structures (gs_, ls_)
  4. Data elements (gv_, lv_)

In the initial phase, we can use variable names for sorting, which is a simpler step. Later on, we could also implement a backend that searches for types in the dictionary, regardless of the variable name.

If I find some time in the upcoming weeks, I would try to start this myself.

Read Table

  • Read Table .. Assigning To .. Index
  • Read Table .. Index .. Assigning To
  • Read Table .. . Assigning To .. With Key...
  • Read Table .. . With Key... Assigning To
  • Read Table .. . With Key... Reference Into
  • Read Table .. . Reference Into ... With Key

More variants to check

Feature: QuickFix to create OO event handler

Hi,

I have asked in SAP Community if there was a way to easily create event handlers. I'll try to work on a proposal, but maybe you'd be interested or have ideas, so I post the idea here:

Every time I have to define a event handler, I do it completely manually, by typing the following lines, without assistance from Eclipse ADT to propose the available events of the object type I choose:

METHODS on_event FOR EVENT eventname OF objecttype IMPORTING ...

somewhere else, I enter:

SET HANDLER on_event FOR object.

Hopefully, there is one QuickFix to propose the possible parameters of the event, and another one to create the empty method implementation.

But I find it quite cumbersome to have to go to the object type, list its events, copy/paste them, then type the text around.

Is it possible to create one QuickFix to accelerate the typing of the event handlers?

Thank you.

Sandra

NB: the context how I use it is that I defined a dynpro application with view classes (MVC) with one event per user action (i.e. many events), and the controller class handles each event.
NB2: I guess that quick fix would imply to work with two repository objects at the same time, the class containing the event handlers (where to add code) and the object type containing the event definitions. Eventually there should be a dialog to select for which events handlers are to be added.

Replace read table to new syntax

Hi,

first, thanks for this great tool. I discovered a bug in eclipse 2021-09 when I want to replace an old read table. Here is a short video

read_table.mp4

comma at begin of new line in combined declaration breaks the split fix

Trying to fix this:

  DATA:
    lr_tabdescr TYPE REF TO cl_abap_structdescr
  , lr_data     TYPE REF TO data
  , lt_dfies    TYPE ddfields
  , ls_dfies    TYPE dfies
  , ls_fieldcat TYPE lvc_s_fcat
  .

leads to:

  DATA lr_tabdescr TYPE REF TO cl_abap_structdescr
DATA .
  lr_data     type ref to data
data .
  lt_dfies    type ddfields
data .
  ls_dfies    type dfies
data .
  ls_fieldcat type lvc_s_fcat.

Problems with Eclipse 2021-06 (4.20.0)

Hi Łukasz,

I'm not able to start quick Fixes via "CTRL+SHIFT+1" in ADT on Eclipse 2021-06 (4.20.0).
The popup just don't appear.

Is this a known bug you are working on?

KR
Alex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.