IDEA-CR-68537 Added nullable annotation to the getContentElementType method return value

GitOrigin-RevId: 941b1b49fee13fd6d74a76c1a82d3fb15c80f783
This commit is contained in:
Alexandr Evstigneev
2020-11-19 13:33:12 +03:00
committed by intellij-monorepo-bot
parent 80294250aa
commit 89bbc0b158
3 changed files with 10 additions and 34 deletions

View File

@@ -1,18 +1,4 @@
/*
* 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.psi.impl.source.tree.injected;
@@ -28,6 +14,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
@@ -149,7 +136,7 @@ class MultipleRootsInjectedFileViewProvider extends MultiplePsiFilesPerDocumentF
}
@Override
public IElementType getContentElementType(@NotNull Language language) {
public @Nullable IElementType getContentElementType(@NotNull Language language) {
return ((TemplateLanguageFileViewProvider)myOriginalProvider).getContentElementType(language);
}
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 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.
*/
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.psi.templateLanguages;
import com.intellij.lang.Language;
@@ -20,6 +6,7 @@ import com.intellij.psi.FileViewProvider;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author peter
@@ -44,11 +31,12 @@ public interface TemplateLanguageFileViewProvider extends FileViewProvider {
/**
* Should return content type that is used to override file content type for template data language.
* It is required for template language injections to override non-base language content type properly
*
* @param language for which we want to create a file
* @return content element type for non-base language, null otherwise
*/
@ApiStatus.Experimental
default IElementType getContentElementType(@NotNull Language language) {
default @Nullable IElementType getContentElementType(@NotNull Language language) {
return null;
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.rest;
import com.intellij.lang.Language;
@@ -13,6 +13,7 @@ import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
import com.intellij.psi.tree.IElementType;
import com.jetbrains.python.PythonLanguage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
import java.util.Set;
@@ -84,7 +85,7 @@ public class RestFileViewProvider extends MultiplePsiFilesPerDocumentFileViewPro
}
@Override
public IElementType getContentElementType(@NotNull Language language) {
public @Nullable IElementType getContentElementType(@NotNull Language language) {
if (language == getTemplateDataLanguage()) {
return RestPythonElementTypes.PYTHON_BLOCK_DATA;
}