Azure / autorest.java

Extension for AutoRest (https://github.com/Azure/autorest) that generates Java code
MIT License
33 stars 82 forks source link

Surround manual code with Eclipse formatter off in partial update #2685

Closed alzimmermsft closed 5 months ago

alzimmermsft commented 5 months ago

Surround code that was manually written into a class supporting partial update with the comment tags that disable Eclipse code formatting. This ensures that the code format styles applied to generated code does not modify handwritten code, especially documentation.

haolingdong-msft commented 5 months ago

So I guess after we support partial-update on javadoc, code would be like this.

    // @formatter:off
    /**
     * <generated-javadoc-description-start>
     * javadoc
     * <generated-javadoc-description-end>
     *
     * <generated-javadoc-tags-start>
     * @param testProperty javadoc
     * <generated-javadoc-tags-end>
     */
    public void setTestProperty(String testProperty) {
        this.testProperty = testProperty;
    }
    }// @formatter:on
weidongxu-microsoft commented 5 months ago

So I guess after we support partial-update on javadoc, code would be like this.

    // @formatter:off
    /**
     * <generated-javadoc-description-start>
     * javadoc
     * <generated-javadoc-description-end>
     *
     * <generated-javadoc-tags-start>
     * @param testProperty javadoc
     * <generated-javadoc-tags-end>
     */
    public void setTestProperty(String testProperty) {
        this.testProperty = testProperty;
    }
    }// @formatter:on

Yours does not have @Generated, so no generated-javadoc should appear (even if they appears, codegen probably won't do anything, as without @Generated we'd assume dev own the whole method include Javadoc).

And if it is generated method, @formatter probably won't be added (it may be just replaced by new generated code -- not sure, but likely won't matter).

The @formatter here is only about formatting. Whether the code is generated or handwritten, at present formatter would format them all.

For handwritten code, we'd like option to skip formatting, as it could conflict with other tooling (currently the codesnippet tool)