@Override
    public List<CompletionItem> getCompletionItems(EventCompletionContext context) {
        if (!(context.document instanceof SchemaDocument)) return List.of();
        if (!match(context)) return List.of();

        int beforeDotDelta = previousBeforeDot(context.document.getCurrentContent(), context.position);

        if (beforeDotDelta != -1) {
            Node prevSymbol = CSTUtils.getSymbolAtPosition(context.document.getRootNode(), new Position(context.position.getLine(), context.position.getCharacter() - beforeDotDelta));
            if (prevSymbol == null) return List.of();

            Optional<Symbol> prevSymbolDefinition = context.schemaIndex.getSymbolDefinition(prevSymbol.getSymbol());

            if (prevSymbolDefinition.isEmpty()) return List.of();

            List<Symbol> fieldSymbols = context.schemaIndex.listSymbolsInScope(prevSymbolDefinition.get(), EnumSet.of(SymbolType.FIELD, SymbolType.MAP_KEY, SymbolType.MAP_VALUE));

            Optional<Symbol> structDefinition = context.schemaIndex.fieldIndex().findFieldStructDefinition(prevSymbolDefinition.get());

            if (structDefinition.isPresent()) {
                fieldSymbols.addAll(context.schemaIndex.listSymbolsInScope(structDefinition.get(), SymbolType.FIELD));
            }

            List<CompletionItem> ret = new ArrayList<>();
            Set<String> addedIdentifiers = new HashSet<>();

            for (Symbol symbol : fieldSymbols) {
                if (addedIdentifiers.contains(symbol.getShortIdentifier()))continue;
                addedIdentifiers.add(symbol.getShortIdentifier());

                ret.add(CompletionUtils.constructBasic(symbol.getShortIdentifier(), symbol.getLongIdentifier()));
            }
            return ret;
        } else {
            Optional<Symbol> scope = context.schemaIndex.findSymbol(null, SymbolType.DOCUMENT, ((SchemaDocument)context.document).getSchemaIdentifier());

            if (scope.isEmpty()) return List.of();

            List<Symbol> fieldSymbols = context.schemaIndex.listSymbolsInScope(scope.get(), SymbolType.FIELD);

            return fieldSymbols.stream()
                               .map(symbol -> CompletionUtils.constructBasic(symbol.getPrettyIdentifier()))
                               .toList();
        }
	}
FieldsCompletionProvider
For completing user defined fields in a fieldset.
integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/lsp/schema/completion/provider/FieldsCompletion.java