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

[8.17] [Console] Add highlighting for painless language (#202695) #202952

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.17:

Questions ?

Please refer to the Backport tool documentation

Closes elastic#201672

## Summary

This PR adds existing painless rules to the console language so that the
painless scripts are correctly highlighted. We are adding a painless
starting rule that matches a string `"*_script"`, `"inline"`, or
`"source"`, followed by a triple quote, in order to prevent clashing
with the existing rules for triple-quote strings.

Example request with a script:

```
POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "script": {
          "description": "Extract 'tags' from 'env' field",
          "lang": "painless",
          "source": """
            String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);
            ArrayList tags = new ArrayList();
            tags.add(envSplit[params['position']].trim());
            ctx['tags'] = tags;
          """,
          "params": {
            "delimiter": "-",
            "position": 1
          }
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "env": "es01-prod"
      }
    }
  ]
}
```

<img width="1049" alt="Screenshot 2024-12-03 at 12 02 52"
src="https://github.com/user-attachments/assets/fb249953-a998-40c0-9775-3474e15b5de2">

(cherry picked from commit 2fcd323)
@kibanamachine kibanamachine merged commit 0e1927c into elastic:8.17 Dec 4, 2024
11 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
kbnUiSharedDeps-srcJs 3.4MB 3.4MB +671.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/monaco 4 5 +1

Total ESLint disabled count

id before after diff
@kbn/monaco 12 13 +1

cc @ElenaStoeva

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

Successfully merging this pull request may close these issues.

3 participants