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