From 99d607e446c6ed6a08283aa875fb0db51275b057 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 11 Mar 2015 17:29:38 +0300 Subject: [PATCH] allow to initialize class without Application (for upsource) --- .../codeinsight/JsonLiteralAnnotator.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/json/src/com/intellij/json/codeinsight/JsonLiteralAnnotator.java b/json/src/com/intellij/json/codeinsight/JsonLiteralAnnotator.java index 28f47c81ffb2..2854c8a7132e 100644 --- a/json/src/com/intellij/json/codeinsight/JsonLiteralAnnotator.java +++ b/json/src/com/intellij/json/codeinsight/JsonLiteralAnnotator.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2015 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.json.codeinsight; import com.intellij.json.JsonBundle; @@ -23,7 +38,9 @@ public class JsonLiteralAnnotator implements Annotator { private static final Pattern VALID_ESCAPE = Pattern.compile("\\\\([\"\\\\/bfnrt]|u[0-9a-fA-F]{4})"); private static final Pattern VALID_NUMBER_LITERAL = Pattern.compile("-?(0|[1-9][0-9]*)(\\.[0-9]+)?([eE][+-]?[0-9]+)?"); - private static final boolean DEBUG = ApplicationManager.getApplication().isUnitTestMode(); + private static class Holder { + private static final boolean DEBUG = ApplicationManager.getApplication().isUnitTestMode(); + } @Override public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { @@ -32,7 +49,7 @@ public class JsonLiteralAnnotator implements Annotator { final JsonStringLiteral stringLiteral = (JsonStringLiteral)element; final int elementOffset = element.getTextOffset(); if (JsonPsiUtil.isPropertyKey(element)) { - holder.createInfoAnnotation(element, DEBUG ? "property key" : null).setTextAttributes(JsonSyntaxHighlighterFactory.JSON_PROPERTY_KEY); + holder.createInfoAnnotation(element, Holder.DEBUG ? "property key" : null).setTextAttributes(JsonSyntaxHighlighterFactory.JSON_PROPERTY_KEY); } final int length = text.length();