Skip to content

Commit

Permalink
added custom deprecation messages
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed Jun 30, 2016
1 parent 8ff7eec commit eab9ab5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Expand Up @@ -84,6 +84,7 @@ private void initStandardMacros() {
// BlockMacros
LatteMacro includeBlock = addStandardMacro("includeblock", UNPAIRED);
includeBlock.deprecated = true;
includeBlock.deprecatedMessage = "Macro includeblock is deprecated in Latte 2.4. Use import macro instead.";
addStandardMacro("import", UNPAIRED);
addStandardMacro("extends", UNPAIRED);
addStandardMacro("layout", UNPAIRED);
Expand Down
2 changes: 2 additions & 0 deletions src/com/jantvrdik/intellij/latte/config/LatteMacro.java
Expand Up @@ -13,6 +13,8 @@ public class LatteMacro {

public boolean deprecated = false;

public String deprecatedMessage;

public LatteMacro(String name, Type type) {
this.name = name;
this.type = type;
Expand Down
Expand Up @@ -39,7 +39,8 @@ public void visitElement(PsiElement element) {
String macroName = ((LatteMacroTag) element).getMacroName();
LatteMacro macro = LatteConfiguration.INSTANCE.getMacro(element.getProject(), macroName);
if (macro.deprecated) {
ProblemDescriptor problem = manager.createProblemDescriptor(element, "Macro " + macroName + " is deprecated", true, ProblemHighlightType.LIKE_DEPRECATED, isOnTheFly);
String description = macro.deprecatedMessage != null ? macro.deprecatedMessage : "Macro " + macroName + " is deprecated";
ProblemDescriptor problem = manager.createProblemDescriptor(element, description, true, ProblemHighlightType.LIKE_DEPRECATED, isOnTheFly);
problems.add(problem);

}
Expand Down

0 comments on commit eab9ab5

Please sign in to comment.