From 5880b3ac4ff24e19eb896766a06309174e3e87d4 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Tue, 10 Jan 2017 14:14:05 +0100 Subject: [PATCH] ant macro to detect make/rebuild --- .../ide/macro/CompilerContextMakeMacro.java | 41 +++++++++++++++++++ .../com/intellij/ide/macro/MacroManager.java | 1 + .../src/messages/IdeBundle.properties | 1 + .../application/options/PathMacrosImpl.java | 1 + .../config/impl/AntToolwindowRegistrar.java | 1 + 5 files changed, 45 insertions(+) create mode 100644 platform/lang-impl/src/com/intellij/ide/macro/CompilerContextMakeMacro.java diff --git a/platform/lang-impl/src/com/intellij/ide/macro/CompilerContextMakeMacro.java b/platform/lang-impl/src/com/intellij/ide/macro/CompilerContextMakeMacro.java new file mode 100644 index 000000000000..7965f3397842 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/ide/macro/CompilerContextMakeMacro.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.ide.macro; + +import com.intellij.ide.IdeBundle; +import com.intellij.openapi.actionSystem.DataContext; + +public final class CompilerContextMakeMacro extends Macro { + @Override + public String getName() { + return "IsMake"; + } + + @Override + public String getDescription() { + return IdeBundle.message("macro.compiler.context.is.make"); + } + + @Override + public String expand(DataContext dataContext) { + Object make = dataContext.getData("COMPILER_CONTEXT_MAKE"); + if (make instanceof Boolean) { + return make.toString(); + } + return null; + } +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java b/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java index ae18d2f07849..b4a659526436 100644 --- a/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java +++ b/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java @@ -76,6 +76,7 @@ public final class MacroManager { registerMacro(new ModuleFileDirMacro()); registerMacro(new ModuleNameMacro()); registerMacro(new AffectedModuleNamesMacro()); + registerMacro(new CompilerContextMakeMacro()); registerMacro(new ModulePathMacro()); registerMacro(new ModuleSdkPathMacro()); diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 8957ea461119..e7db490a2f0e 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -494,6 +494,7 @@ macro.module.file.directory=The directory of the module file macro.module.file.path=The path of the module file macro.module.file.name=The name of the module file without extension macro.affected.module.names=The names of the modules in the scope, comma separated +macro.compiler.context.is.make=Boolean value according to the performed compilation: true for make, false for force recompile macro.module.source.path=Module source path macro.output.path=Output path macro.project.file.directory=The directory of the project file diff --git a/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java b/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java index 067a2b7b95a3..d3a7f05b6f9d 100644 --- a/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java +++ b/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java @@ -107,6 +107,7 @@ public class PathMacrosImpl extends PathMacros implements PersistentStateCompone "ModuleFilePath", "ModuleName", "AffectedModuleNames", + "IsMake", "ModuleSourcePath", "ModuleSdkPath", "OutputPath", diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntToolwindowRegistrar.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntToolwindowRegistrar.java index a40ed71f3f55..0c6003295053 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntToolwindowRegistrar.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntToolwindowRegistrar.java @@ -98,6 +98,7 @@ public class AntToolwindowRegistrar extends AbstractProjectComponent { dataMap.put(LangDataKeys.MODULE.getName(), modules[0]); } dataMap.put(LangDataKeys.MODULE_CONTEXT_ARRAY.getName(), modules); + dataMap.put("COMPILER_CONTEXT_MAKE", context.isMake()); return SimpleDataContext.getSimpleContext(dataMap, null); }