Skip to content

Commit

Permalink
Replacing Nonnull with NotNull
Browse files Browse the repository at this point in the history
  • Loading branch information
RAVEENSR committed Nov 21, 2017
1 parent 45b8ac8 commit d49d467
Show file tree
Hide file tree
Showing 168 changed files with 768 additions and 897 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ task copyPsiViewerPluginToSandBox(type: Copy) {

copyPsiViewerPluginToSandBox.dependsOn downloadPsiViewerPlugin
copyPsiViewerPluginToSandBox.mustRunAfter prepareSandbox
runIde.dependsOn copyPsiViewerPluginToSandBox
runIde.dependsOn copyPsiViewerPluginToSandBox,check
12 changes: 12 additions & 0 deletions config/findbugs/excludeFilter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,16 @@
<Class name="org.wso2.siddhi.plugins.idea.SiddhiModuleBuilder"/>
<Bug pattern="HE_INHERITS_EQUALS_USE_HASHCODE"/>
</Match>
<!--Added following exclusions because FindBugs doesn't allow to add NotNull annotation from jetbrains
(import org.jetbrains.annotations.NotNull) But it is recommended to write the plugin according to the jetbrains
standards.-->
<!-- TODO: Remove following exclusions once FindBugs allows NotNull annotation from jetbrains.-->
<Match>
<Package name="~org\.wso2\.siddhi\.plugins\.idea.*"/>
<Bug pattern="NP_NULL_ON_SOME_PATH,NP_NULL_PARAM_DEREF,
RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,NP_GUARANTEED_DEREF,
NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE,RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE,
RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"
/>
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
import com.intellij.psi.impl.source.tree.PsiCoreCommentImpl;
import com.intellij.psi.tree.IElementType;
import org.antlr.jetbrains.adaptor.lexer.TokenIElementType;
import org.jetbrains.annotations.NotNull;
import org.wso2.siddhi.plugins.idea.grammar.SiddhiQLLexer;
import org.wso2.siddhi.plugins.idea.psi.IdentifierPSINode;

import javax.annotation.Nonnull;

/**
* Defines how to create parse tree nodes (Jetbrains calls them AST nodes). Later
* non-leaf nodes are converted to PSI nodes by the {@link ParserDefinition}.
Expand All @@ -41,7 +40,7 @@ public class SiddhiASTFactory extends CoreASTFactory {
* The FileElement is a parse tree node, which is converted to a PsiFile
* by {@link ParserDefinition#createFile}.
*/
@Nonnull
@NotNull
@Override
public CompositeElement createComposite(IElementType type) {
return super.createComposite(type);
Expand All @@ -52,9 +51,9 @@ public CompositeElement createComposite(IElementType type) {
* Does not see whitespace tokens. Default impl makes {@link LeafPsiElement}
* or {@link PsiCoreCommentImpl} depending on {@link ParserDefinition#getCommentTokens()}.
*/
@Nonnull
@NotNull
@Override
public LeafElement createLeaf(@Nonnull IElementType type, @Nonnull CharSequence text) {
public LeafElement createLeaf(@NotNull IElementType type, @NotNull CharSequence text) {
if (type instanceof TokenIElementType &&
((TokenIElementType) type).getANTLRTokenType() == SiddhiQLLexer.ID) {
// found an ID node; here we do not distinguish between definitions and references
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package org.wso2.siddhi.plugins.idea;

import com.intellij.openapi.fileTypes.LanguageFileType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nonnull;
import javax.swing.Icon;

/**
Expand All @@ -33,19 +33,19 @@ private SiddhiFileType() {
super(SiddhiLanguage.INSTANCE);
}

@Nonnull
@NotNull
@Override
public String getName() {
return "Siddhi file";
}

@Nonnull
@NotNull
@Override
public String getDescription() {
return "Siddhi language file";
}

@Nonnull
@NotNull
@Override
public String getDefaultExtension() {
return "siddhi";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@

import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;

import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;

/**
* Creates file types associated with siddhi language.
*/
public class SiddhiFileTypeFactory extends FileTypeFactory {

@Override
public void createFileTypes(@Nonnull FileTypeConsumer fileTypeConsumer) {
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
fileTypeConsumer.consume(SiddhiFileType.INSTANCE, "siddhi");
}
}
6 changes: 3 additions & 3 deletions src/main/java/org/wso2/siddhi/plugins/idea/SiddhiIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.LayeredIcon;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import javax.swing.Icon;

/**
Expand All @@ -38,8 +38,8 @@ private SiddhiIcons() {

}

@Nonnull
private static LayeredIcon createIconWithShift(@Nonnull Icon base, Icon mark) {
@NotNull
private static LayeredIcon createIconWithShift(@NotNull Icon base, Icon mark) {
LayeredIcon icon = new LayeredIcon(2) {
@Override
public int getIconHeight() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.wso2.siddhi.plugins.idea.sdk.SiddhiSdkType;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;

/**
* Module builder for siddhi.
Expand All @@ -52,7 +52,7 @@ public List<Pair<String, String>> getSourcePaths() {
return paths;
}

@Nonnull
@NotNull
@Override
public ModuleType getModuleType() {
return SiddhiModuleType.getInstance();
Expand All @@ -64,7 +64,7 @@ public boolean isSuitableSdkType(SdkTypeId sdkType) {
}

@Override
public void moduleCreated(@Nonnull Module module) {
public void moduleCreated(@NotNull Module module) {
CompilerWorkspaceConfiguration.getInstance(module.getProject()).CLEAR_OUTPUT_DIRECTORY = false;
}
}
18 changes: 9 additions & 9 deletions src/main/java/org/wso2/siddhi/plugins/idea/SiddhiModuleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeManager;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.wso2.siddhi.plugins.idea.sdk.SiddhiSdkType;

import javax.annotation.Nonnull;
import javax.swing.Icon;

/**
Expand All @@ -37,24 +37,24 @@ public SiddhiModuleType() {
super(SiddhiConstants.MODULE_TYPE_ID);
}

@Nonnull
@NotNull
public static SiddhiModuleType getInstance() {
return (SiddhiModuleType) ModuleTypeManager.getInstance().findByID(SiddhiConstants.MODULE_TYPE_ID);
}

@Nonnull
@NotNull
@Override
public SiddhiModuleBuilder createModuleBuilder() {
return new SiddhiModuleBuilder();
}

@Nonnull
@NotNull
@Override
public String getName() {
return "Siddhi Module";
}

@Nonnull
@NotNull
@Override
public String getDescription() {
return "Siddhi modules are used for developing <b>Siddhi</b> applications.";
Expand All @@ -71,11 +71,11 @@ public Icon getNodeIcon(boolean isOpened) {
return SiddhiIcons.ICON;
}

@Nonnull
@NotNull
@Override
public ModuleWizardStep[] createWizardSteps(@Nonnull WizardContext wizardContext,
@Nonnull SiddhiModuleBuilder moduleBuilder,
@Nonnull ModulesProvider modulesProvider) {
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext,
@NotNull SiddhiModuleBuilder moduleBuilder,
@NotNull ModulesProvider modulesProvider) {
return new ModuleWizardStep[]{new ProjectJdkForModuleStep(wizardContext, SiddhiSdkType.getInstance()) {
@Override
public void updateDataModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.antlr.jetbrains.adaptor.psi.ANTLRPsiNode;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.jetbrains.annotations.NotNull;
import org.wso2.siddhi.plugins.idea.grammar.SiddhiQLLexer;
import org.wso2.siddhi.plugins.idea.grammar.SiddhiQLParser;
import org.wso2.siddhi.plugins.idea.psi.AggregationDefinitionNode;
Expand Down Expand Up @@ -113,8 +114,6 @@
import org.wso2.siddhi.plugins.idea.psi.WindowNode;
import org.wso2.siddhi.plugins.idea.psi.WithinTimeRangeNode;

import javax.annotation.Nonnull;

import static org.wso2.siddhi.plugins.idea.grammar.SiddhiQLParser.AGGREGATE;
import static org.wso2.siddhi.plugins.idea.grammar.SiddhiQLParser.AGGREGATION;
import static org.wso2.siddhi.plugins.idea.grammar.SiddhiQLParser.ALL;
Expand Down Expand Up @@ -303,14 +302,14 @@ public class SiddhiParserDefinition implements ParserDefinition {
public static final TokenSet SYMBOLS =
PSIElementTypeFactory.createTokenSet(SiddhiLanguage.INSTANCE, AT_SYMBOL, HASH);

@Nonnull
@NotNull
@Override
public Lexer createLexer(Project project) {
SiddhiQLLexer lexer = new SiddhiQLLexer(null);
return new ANTLRLexerAdaptor(SiddhiLanguage.INSTANCE, lexer);
}

@Nonnull
@NotNull
public PsiParser createParser(final Project project) {
final SiddhiQLParser parser = new SiddhiQLParser(null);
return new ANTLRParserAdaptor(SiddhiLanguage.INSTANCE, parser) {
Expand All @@ -326,17 +325,17 @@ protected ParseTree parse(Parser parser, IElementType root) {
/**
* Tokens of those types are automatically skipped by PsiBuilder.
*/
@Nonnull
@NotNull
public TokenSet getWhitespaceTokens() {
return WHITESPACE;
}

@Nonnull
@NotNull
public TokenSet getCommentTokens() {
return COMMENTS;
}

@Nonnull
@NotNull
public TokenSet getStringLiteralElements() {
return STRING_LITERALS;
}
Expand Down Expand Up @@ -386,7 +385,7 @@ public PsiFile createFile(FileViewProvider viewProvider) {
* sufficient to create a {@link ANTLRPsiNode} around
* the parse tree node
*/
@Nonnull
@NotNull
public PsiElement createElement(ASTNode node) {
IElementType elementType = node.getElementType();
if (elementType instanceof TokenIElementType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.wso2.siddhi.plugins.idea.SiddhiIcons;
import org.wso2.siddhi.plugins.idea.psi.SiddhiFile;

import java.util.Map;
import javax.annotation.Nonnull;

/**
* Defines 'creating a file' action in siddhi.
Expand All @@ -49,7 +49,7 @@ public SiddhiCreateFileAction() {

@Override
protected void buildDialog(Project project, PsiDirectory directory,
@Nonnull CreateFileFromTemplateDialog.Builder builder) {
@NotNull CreateFileFromTemplateDialog.Builder builder) {
builder.setTitle(NEW_SIDDHI_FILE).addKind("Siddhi Main", SiddhiIcons.ICON, MAIN_TEMPLATE_NAME);
}

Expand All @@ -59,7 +59,7 @@ protected String getDefaultTemplateProperty() {
return DEFAULT_SIDDHI_TEMPLATE_PROPERTY;
}

@Nonnull
@NotNull
@Override
protected String getActionName(PsiDirectory directory, String newName, String templateName) {
return NEW_SIDDHI_FILE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.source.tree.LeafPsiElement;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.wso2.siddhi.plugins.idea.SiddhiTypes;
import org.wso2.siddhi.plugins.idea.highlighter.SiddhiSyntaxHighlightingColors;
import org.wso2.siddhi.plugins.idea.psi.StreamIdNode;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;

/**
* Add annotations to files in siddhi language.
Expand All @@ -44,20 +44,20 @@ public class SiddhiAnnotator implements Annotator {
private static final Pattern INVALID_ESCAPE_CHAR_PATTERN = Pattern.compile(INVALID_ESCAPE_CHARACTERS);

@Override
public void annotate(@Nonnull PsiElement element, @Nonnull AnnotationHolder holder) {
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof StreamIdNode) {
annotateStreamIdNodes(element, holder);
} else if (element instanceof LeafPsiElement) {
annotateLeafPsiElementNodes(element, holder);
}
}

private void annotateStreamIdNodes(@Nonnull PsiElement element, @Nonnull AnnotationHolder holder) {
private void annotateStreamIdNodes(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
Annotation annotation = holder.createInfoAnnotation(element.getTextRange(), null);
annotation.setTextAttributes(SiddhiSyntaxHighlightingColors.STREAM_ID);
}

private void annotateLeafPsiElementNodes(@Nonnull PsiElement element, @Nonnull AnnotationHolder holder) {
private void annotateLeafPsiElementNodes(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
IElementType elementType = ((LeafPsiElement) element).getElementType();
if (elementType != SiddhiTypes.STRING_LITERAL) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.wso2.siddhi.plugins.idea.SiddhiFileType;
import org.wso2.siddhi.plugins.idea.SiddhiLanguage;
import org.wso2.siddhi.plugins.idea.sdk.SiddhiSdkService;
import org.wso2.siddhi.plugins.idea.sdk.SiddhiSdkType;

import javax.annotation.Nonnull;

/**
* Validates the sdk setup of the project.
*/
Expand All @@ -46,7 +45,7 @@ public class SiddhiProjectSdkSetupValidator implements ProjectSdkSetupValidator
public static final SiddhiProjectSdkSetupValidator INSTANCE = new SiddhiProjectSdkSetupValidator();

@Override
public boolean isApplicableFor(@Nonnull Project project, @Nonnull VirtualFile file) {
public boolean isApplicableFor(@NotNull Project project, @NotNull VirtualFile file) {
if (file.getFileType() == SiddhiFileType.INSTANCE) {
return true;
}
Expand All @@ -56,7 +55,7 @@ public boolean isApplicableFor(@Nonnull Project project, @Nonnull VirtualFile fi

@Nullable
@Override
public String getErrorMessage(@Nonnull Project project, @Nonnull VirtualFile file) {
public String getErrorMessage(@NotNull Project project, @NotNull VirtualFile file) {
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module == null || module.isDisposed()) {
return null;
Expand All @@ -79,7 +78,7 @@ public String getErrorMessage(@Nonnull Project project, @Nonnull VirtualFile fil
}

@Override
public void doFix(@Nonnull Project project, @Nonnull VirtualFile file) {
public void doFix(@NotNull Project project, @NotNull VirtualFile file) {
// Get the current project SDK.
Sdk currentProjectSDK = ProjectRootManager.getInstance(project).getProjectSdk();
if (currentProjectSDK != null) {
Expand Down
Loading

0 comments on commit d49d467

Please sign in to comment.