public static T addAnnotation()

in customization-base/src/main/java/com/azure/autorest/customization/implementation/Utils.java [282:308]


    public static <T extends CodeCustomization> T addAnnotation(String annotation, CodeCustomization customization,
        Supplier<T> refreshedCustomizationSupplier) {
        SymbolInformation symbol = customization.getSymbol();
        Editor editor = customization.getEditor();
        String fileName = customization.getFileName();
        String fileUri = customization.getFileUri();
        EclipseLanguageClient languageClient = customization.getLanguageClient();

        if (!annotation.startsWith("@")) {
            annotation = "@" + annotation;
        }

        if (editor.getContents().containsKey(fileName)) {
            int line = symbol.getLocation().getRange().getStart().getLine();
            Position position = editor.insertBlankLine(fileName, line, true);
            editor.replace(fileName, position, position, annotation);

            FileEvent fileEvent = new FileEvent();
            fileEvent.setUri(fileUri);
            fileEvent.setType(FileChangeType.Changed);
            languageClient.notifyWatchedFilesChanged(Collections.singletonList(fileEvent));

            organizeImportsOnRange(languageClient, editor, fileUri, symbol.getLocation().getRange());
        }

        return refreshedCustomizationSupplier.get();
    }