mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 08:47:50 +08:00
code samples: @Nullable cleanup
This commit is contained in:
parent
dcfcb36a0d
commit
42c9ce8d1d
@ -25,9 +25,8 @@ public class DynamicActionGroup extends ActionGroup {
|
||||
* @return AnAction[] An instance of {@link AnAction}, in this case containing a single instance of the
|
||||
* {@link PopupDialogAction} class.
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(AnActionEvent e) {
|
||||
public AnAction @NotNull [] getChildren(AnActionEvent e) {
|
||||
return new AnAction[]{
|
||||
new PopupDialogAction("Action Added at Runtime", "Dynamic Action Demo", SdkIcons.Sdk_default_icon)
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.liveTemplates;
|
||||
|
||||
@ -21,7 +21,7 @@ public class TitleCaseMacro extends MacroBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) {
|
||||
protected Result calculateResult(Expression @NotNull [] params, ExpressionContext context, boolean quick) {
|
||||
// Retrieve the text from the macro or selection, if any is available.
|
||||
String text = getTextResult(params, context, true);
|
||||
if (text == null) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.module;
|
||||
|
||||
@ -48,11 +48,10 @@ public class DemoModuleType extends ModuleType<DemoModuleBuilder> {
|
||||
return SdkIcons.Sdk_default_icon;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext,
|
||||
@NotNull DemoModuleBuilder moduleBuilder,
|
||||
@NotNull ModulesProvider modulesProvider) {
|
||||
public ModuleWizardStep @NotNull [] createWizardSteps(@NotNull WizardContext wizardContext,
|
||||
@NotNull DemoModuleBuilder moduleBuilder,
|
||||
@NotNull ModulesProvider modulesProvider) {
|
||||
return super.createWizardSteps(wizardContext, moduleBuilder, modulesProvider);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package org.intellij.sdk.language.psi;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface SimpleProperty extends SimpleNamedElement {
|
||||
|
||||
@ -14,7 +13,7 @@ public interface SimpleProperty extends SimpleNamedElement {
|
||||
|
||||
String getName();
|
||||
|
||||
PsiElement setName(String newName);
|
||||
PsiElement setName(@NotNull String newName);
|
||||
|
||||
PsiElement getNameIdentifier();
|
||||
|
||||
|
@ -1,15 +1,13 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package org.intellij.sdk.language.psi.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import static org.intellij.sdk.language.psi.SimpleTypes.*;
|
||||
import org.intellij.sdk.language.psi.*;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import org.intellij.sdk.language.psi.SimpleProperty;
|
||||
import org.intellij.sdk.language.psi.SimpleVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimplePropertyImpl extends SimpleNamedElementImpl implements SimpleProperty {
|
||||
|
||||
@ -43,7 +41,7 @@ public class SimplePropertyImpl extends SimpleNamedElementImpl implements Simple
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(String newName) {
|
||||
public PsiElement setName(@NotNull String newName) {
|
||||
return SimplePsiImplUtil.setName(this, newName);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.language;
|
||||
|
||||
@ -13,9 +13,8 @@ import java.util.List;
|
||||
|
||||
public class SimpleChooseByNameContributor implements ChooseByNameContributor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getNames(Project project, boolean includeNonProjectItems) {
|
||||
public String @NotNull [] getNames(Project project, boolean includeNonProjectItems) {
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project);
|
||||
List<String> names = new ArrayList<>(properties.size());
|
||||
for (SimpleProperty property : properties) {
|
||||
@ -26,9 +25,8 @@ public class SimpleChooseByNameContributor implements ChooseByNameContributor {
|
||||
return names.toArray(new String[names.size()]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
|
||||
public NavigationItem @NotNull [] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
|
||||
// TODO: include non project items
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project, name);
|
||||
return properties.toArray(new NavigationItem[properties.size()]);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.language;
|
||||
|
||||
@ -19,7 +19,7 @@ public class SimpleColorSettingsPage implements ColorSettingsPage {
|
||||
new AttributesDescriptor("Key", SimpleSyntaxHighlighter.KEY),
|
||||
new AttributesDescriptor("Separator", SimpleSyntaxHighlighter.SEPARATOR),
|
||||
new AttributesDescriptor("Value", SimpleSyntaxHighlighter.VALUE),
|
||||
new AttributesDescriptor("Bad Value", SimpleSyntaxHighlighter.BAD_CHARACTER)
|
||||
new AttributesDescriptor("Bad value", SimpleSyntaxHighlighter.BAD_CHARACTER)
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@ -57,15 +57,13 @@ public class SimpleColorSettingsPage implements ColorSettingsPage {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AttributesDescriptor[] getAttributeDescriptors() {
|
||||
public AttributesDescriptor @NotNull [] getAttributeDescriptors() {
|
||||
return DESCRIPTORS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ColorDescriptor[] getColorDescriptors() {
|
||||
public ColorDescriptor @NotNull [] getColorDescriptors() {
|
||||
return ColorDescriptor.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.language;
|
||||
|
||||
@ -13,7 +13,7 @@ public class SimpleCompletionContributor extends CompletionContributor {
|
||||
|
||||
public SimpleCompletionContributor() {
|
||||
extend(CompletionType.BASIC, PlatformPatterns.psiElement(SimpleTypes.VALUE),
|
||||
new CompletionProvider<CompletionParameters>() {
|
||||
new CompletionProvider<>() {
|
||||
public void addCompletions(@NotNull CompletionParameters parameters,
|
||||
@NotNull ProcessingContext context,
|
||||
@NotNull CompletionResultSet resultSet) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.language;
|
||||
|
||||
@ -23,9 +23,8 @@ import java.util.List;
|
||||
|
||||
public class SimpleFoldingBuilder extends FoldingBuilderEx implements DumbAware {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
|
||||
public FoldingDescriptor @NotNull [] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
|
||||
// Initialize the group of folding regions that will expand/collapse together.
|
||||
FoldingGroup group = FoldingGroup.newGroup(SimpleAnnotator.SIMPLE_PREFIX_STR);
|
||||
// Initialize the list of folding regions
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.language;
|
||||
|
||||
@ -23,9 +23,8 @@ public class SimpleReference extends PsiReferenceBase<PsiElement> implements Psi
|
||||
key = element.getText().substring(textRange.getStartOffset(), textRange.getEndOffset());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ResolveResult[] multiResolve(boolean incompleteCode) {
|
||||
public ResolveResult @NotNull [] multiResolve(boolean incompleteCode) {
|
||||
Project project = myElement.getProject();
|
||||
final List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
|
||||
List<ResolveResult> results = new ArrayList<>();
|
||||
@ -42,9 +41,8 @@ public class SimpleReference extends PsiReferenceBase<PsiElement> implements Psi
|
||||
return resolveResults.length == 1 ? resolveResults[0].getElement() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] getVariants() {
|
||||
public Object @NotNull [] getVariants() {
|
||||
Project project = myElement.getProject();
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project);
|
||||
List<LookupElement> variants = new ArrayList<>();
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.language;
|
||||
|
||||
@ -17,10 +17,9 @@ public class SimpleReferenceContributor extends PsiReferenceContributor {
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class),
|
||||
new PsiReferenceProvider() {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
|
||||
@NotNull ProcessingContext context) {
|
||||
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element,
|
||||
@NotNull ProcessingContext context) {
|
||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
||||
String value = literalExpression.getValue() instanceof String ?
|
||||
(String) literalExpression.getValue() : null;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.language;
|
||||
|
||||
@ -59,9 +59,8 @@ public class SimpleStructureViewElement implements StructureViewTreeElement, Sor
|
||||
return presentation != null ? presentation : new PresentationData();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TreeElement[] getChildren() {
|
||||
public TreeElement @NotNull [] getChildren() {
|
||||
if (myElement instanceof SimpleFile) {
|
||||
List<SimpleProperty> properties = PsiTreeUtil.getChildrenOfTypeAsList(myElement, SimpleProperty.class);
|
||||
List<TreeElement> treeElements = new ArrayList<>(properties.size());
|
||||
|
@ -18,7 +18,7 @@ public class SimpleStructureViewModel extends StructureViewModelBase implements
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Sorter[] getSorters() {
|
||||
public Sorter @NotNull [] getSorters() {
|
||||
return new Sorter[]{Sorter.ALPHA_SORTER};
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.intellij.sdk.language;
|
||||
|
||||
@ -41,22 +41,24 @@ public class SimpleSyntaxHighlighter extends SyntaxHighlighterBase {
|
||||
return new SimpleLexerAdapter();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
|
||||
public TextAttributesKey @NotNull [] getTokenHighlights(IElementType tokenType) {
|
||||
if (tokenType.equals(SimpleTypes.SEPARATOR)) {
|
||||
return SEPARATOR_KEYS;
|
||||
} else if (tokenType.equals(SimpleTypes.KEY)) {
|
||||
return KEY_KEYS;
|
||||
} else if (tokenType.equals(SimpleTypes.VALUE)) {
|
||||
return VALUE_KEYS;
|
||||
} else if (tokenType.equals(SimpleTypes.COMMENT)) {
|
||||
return COMMENT_KEYS;
|
||||
} else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
|
||||
return BAD_CHAR_KEYS;
|
||||
} else {
|
||||
return EMPTY_KEYS;
|
||||
}
|
||||
if (tokenType.equals(SimpleTypes.KEY)) {
|
||||
return KEY_KEYS;
|
||||
}
|
||||
if (tokenType.equals(SimpleTypes.VALUE)) {
|
||||
return VALUE_KEYS;
|
||||
}
|
||||
if (tokenType.equals(SimpleTypes.COMMENT)) {
|
||||
return COMMENT_KEYS;
|
||||
}
|
||||
if (tokenType.equals(TokenType.BAD_CHARACTER)) {
|
||||
return BAD_CHAR_KEYS;
|
||||
}
|
||||
return EMPTY_KEYS;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user