From 1e2ba40257ef1c24e6416ec2bf85ddaa71ee2c7e Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 26 Mar 2016 12:35:44 +0100 Subject: [PATCH] SSR: show script log var name as available variable in script editor --- .../structuralsearch/impl/matcher/predicates/ScriptLog.java | 4 +++- .../impl/matcher/predicates/ScriptSupport.java | 2 +- .../structuralsearch/plugin/ui/EditVarConstraintsDialog.java | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptLog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptLog.java index 60387cf2284a..701a6482647e 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptLog.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptLog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import com.intellij.structuralsearch.SSRBundle; */ public class ScriptLog { + public static final String SCRIPT_LOG_VAR_NAME = "__log__"; + private static final NotificationGroup myEventLog = NotificationGroup.logOnlyGroup(SSRBundle.message("structural.search.title")); private final Project myProject; diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptSupport.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptSupport.java index e7341bf4a4f0..5de3f33561d7 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptSupport.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptSupport.java @@ -84,7 +84,7 @@ public class ScriptSupport { public String evaluate(MatchResult result, PsiElement context) { try { final HashMap variableMap = new HashMap(); - variableMap.put("__log__", myScriptLog); + variableMap.put(ScriptLog.SCRIPT_LOG_VAR_NAME, myScriptLog); if (result != null) { buildVariableMap(result, variableMap); if (context == null) { diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java index 756c88b2c0a4..6eb94bd46340 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java @@ -28,6 +28,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFileFactory; import com.intellij.structuralsearch.*; import com.intellij.structuralsearch.impl.matcher.CompiledPattern; +import com.intellij.structuralsearch.impl.matcher.predicates.ScriptLog; import com.intellij.structuralsearch.impl.matcher.predicates.ScriptSupport; import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration; @@ -272,6 +273,7 @@ class EditVarConstraintsDialog extends DialogWrapper { customScriptCode.getButton().addActionListener(new ActionListener() { public void actionPerformed(@NotNull final ActionEvent e) { final List variableNames = ContainerUtil.newArrayList(myConfiguration.getMatchOptions().getVariableConstraintNames()); + variableNames.add(ScriptLog.SCRIPT_LOG_VAR_NAME); variableNames.remove(CompiledPattern.ALL_CLASS_UNMATCHED_CONTENT_VAR_ARTIFICIAL_NAME); final EditScriptDialog dialog = new EditScriptDialog(project, customScriptCode.getChildComponent().getText(), variableNames); dialog.show();