Skip to content

Commit

Permalink
notnull
Browse files Browse the repository at this point in the history
  • Loading branch information
cdracm committed Oct 15, 2015
1 parent ada6698 commit 7e4dd8d
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
Expand Down Expand Up @@ -62,10 +62,10 @@ public boolean shouldRunHeavy() {
}

@Override
public void applyHeavyFilter(final Document copiedFragment,
public void applyHeavyFilter(@NotNull final Document copiedFragment,
final int startOffset,
int startLineNumber,
final Consumer<AdditionalHighlight> consumer) {
@NotNull final Consumer<AdditionalHighlight> consumer) {
Map<String, Trinity<TextRange, TextRange, TextRange>> visited = new THashMap<String, Trinity<TextRange, TextRange, TextRange>>();
final Trinity<TextRange, TextRange, TextRange> emptyInfo = Trinity.create(null, null, null);

Expand Down Expand Up @@ -110,6 +110,7 @@ public void applyHeavyFilter(final Document copiedFragment,
int off = startOffset + lineStartOffset;
final Color color = UIUtil.getInactiveTextColor();
consumer.consume(new AdditionalHighlight(off + info.first.getStartOffset(), off + info.second.getEndOffset()) {
@NotNull
@Override
public TextAttributes getTextAttributes(@Nullable TextAttributes source) {
return new TextAttributes(null, null, color, EffectType.BOLD_DOTTED_LINE, Font.PLAIN);
Expand All @@ -118,6 +119,7 @@ public TextAttributes getTextAttributes(@Nullable TextAttributes source) {
}
}

@NotNull
@Override
public String getUpdateMessage() {
return "Highlighting try blocks...";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
Expand Down Expand Up @@ -32,6 +32,7 @@
import com.intellij.openapi.ui.MultiLineLabelUI;
import com.intellij.util.Consumer;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
Expand All @@ -47,7 +48,7 @@
*/
public class ProjectJdkForModuleStep extends ModuleWizardStep {
private final JdkChooserPanel myJdkChooser;
private final JPanel myPanel;
@NotNull private final JPanel myPanel;
private final WizardContext myContext;
private final SdkType myType;
private boolean myInitialized = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void actionPerformed(ActionEvent e) {
});
}

protected boolean showTabForType(OrderRootType type) {
protected boolean showTabForType(@NotNull OrderRootType type) {
return ((SdkType) mySdk.getSdkType()).isRootTypeApplicable(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private void updateCache(VirtualFileEvent event) {
});
}

@NotNull
@Override
public String getPresentableName() {
return ProjectBundle.message("sdk.java.name");
Expand All @@ -116,6 +117,7 @@ public String getHelpTopic() {
return "reference.project.structure.sdk.java";
}

@NotNull
@Override
public Icon getIconForAddAction() {
return AllIcons.General.AddJdk;
Expand All @@ -141,7 +143,7 @@ public String getDefaultDocumentationUrl(@NotNull final Sdk sdk) {
}

@Override
public AdditionalDataConfigurable createAdditionalDataConfigurable(SdkModel sdkModel, SdkModificator sdkModificator) {
public AdditionalDataConfigurable createAdditionalDataConfigurable(@NotNull SdkModel sdkModel, @NotNull SdkModificator sdkModificator) {
return null;
}

Expand Down Expand Up @@ -280,6 +282,7 @@ public String fun(File file) {
}
}

@NotNull
@Override
public FileChooserDescriptor getHomeChooserDescriptor() {
final FileChooserDescriptor baseDescriptor = super.getHomeChooserDescriptor();
Expand All @@ -299,8 +302,9 @@ public void validateSelectedFiles(VirtualFile[] files) throws Exception {
return descriptor;
}

@NotNull
@Override
public String adjustSelectedSdkHome(String homePath) {
public String adjustSelectedSdkHome(@NotNull String homePath) {
if (SystemInfo.isMac) {
File home = new File(homePath, "/Home");
if (home.exists()) return home.getPath();
Expand Down Expand Up @@ -621,7 +625,7 @@ private static VirtualFile findDocs(File file, final String relativePath) {
}

@Override
public boolean isRootTypeApplicable(OrderRootType type) {
public boolean isRootTypeApplicable(@NotNull OrderRootType type) {
return type == OrderRootType.CLASSES ||
type == OrderRootType.SOURCES ||
type == JavadocOrderRootType.getInstance() ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
Expand Down Expand Up @@ -71,6 +71,7 @@ private MyAdditionalHighlight(int start, int end) {
super(start, end);
}

@NotNull
@Override
public TextAttributes getTextAttributes(@Nullable TextAttributes source) {
EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
Expand All @@ -93,10 +94,10 @@ public boolean shouldRunHeavy() {
}

@Override
public void applyHeavyFilter(final Document copiedFragment,
public void applyHeavyFilter(@NotNull final Document copiedFragment,
int startOffset,
int startLineNumber,
Consumer<AdditionalHighlight> consumer) {
@NotNull Consumer<AdditionalHighlight> consumer) {
VcsContentAnnotation vcsContentAnnotation = VcsContentAnnotationImpl.getInstance(myProject);
final LocalChangesCorrector localChangesCorrector = new LocalChangesCorrector(myProject);
Trinity<PsiClass, PsiFile, String> previousLineResult = null;
Expand Down Expand Up @@ -168,6 +169,7 @@ public void run() {
}
}

@NotNull
@Override
public String getUpdateMessage() {
return "Checking recent changes...";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
Expand All @@ -18,6 +18,7 @@
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
Expand All @@ -28,15 +29,16 @@
*/
public interface FilterMixin {
boolean shouldRunHeavy();
void applyHeavyFilter(Document copiedFragment, int startOffset, int startLineNumber, Consumer<AdditionalHighlight> consumer);
void applyHeavyFilter(@NotNull Document copiedFragment, int startOffset, int startLineNumber, @NotNull Consumer<AdditionalHighlight> consumer);

@NotNull
String getUpdateMessage();

abstract class AdditionalHighlight {
private final int myStart;
private final int myEnd;

public AdditionalHighlight(int start, int end) {
protected AdditionalHighlight(int start, int end) {
myStart = start;
myEnd = end;
}
Expand All @@ -49,6 +51,7 @@ public int getEnd() {
return myEnd;
}

@NotNull
public abstract TextAttributes getTextAttributes(@Nullable final TextAttributes source);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public Collection<String> suggestHomePaths() {
* @param homePath the path selected in the file chooser.
* @return the path to be used as the SDK home.
*/
public String adjustSelectedSdkHome(String homePath) {
@NotNull
public String adjustSelectedSdkHome(@NotNull String homePath) {
return homePath;
}

Expand All @@ -92,7 +93,7 @@ public String getVersionString(String sdkHome){

public void setupSdkPaths(@NotNull Sdk sdk) {}

public boolean setupSdkPaths(final Sdk sdk, final SdkModel sdkModel) {
public boolean setupSdkPaths(@NotNull Sdk sdk, @NotNull SdkModel sdkModel) {
setupSdkPaths(sdk);
return true;
}
Expand All @@ -101,7 +102,7 @@ public boolean setupSdkPaths(final Sdk sdk, final SdkModel sdkModel) {
* @return Configurable object for the sdk's additional data or null if not applicable
*/
@Nullable
public abstract AdditionalDataConfigurable createAdditionalDataConfigurable(SdkModel sdkModel, SdkModificator sdkModificator);
public abstract AdditionalDataConfigurable createAdditionalDataConfigurable(@NotNull SdkModel sdkModel, @NotNull SdkModificator sdkModificator);

@Nullable
public SdkAdditionalData loadAdditionalData(Element additional) {
Expand All @@ -120,6 +121,7 @@ public String getName() {
return myName;
}

@NotNull
public abstract String getPresentableName();

public Icon getIcon() {
Expand All @@ -131,6 +133,7 @@ public String getHelpTopic() {
return "preferences.jdks";
}

@NotNull
public Icon getIconForAddAction() {
return IconUtil.getAddIcon();
}
Expand All @@ -157,6 +160,7 @@ public String toString() {
return getName();
}

@NotNull
public FileChooserDescriptor getHomeChooserDescriptor() {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
Expand All @@ -181,6 +185,7 @@ public void validateSelectedFiles(VirtualFile[] files) throws Exception {
}


@NotNull
public String getHomeFieldLabel() {
return ProjectBundle.message("sdk.configure.type.home.path", getPresentableName());
}
Expand All @@ -190,14 +195,16 @@ public String getDefaultDocumentationUrl(@NotNull final Sdk sdk) {
return null;
}

@NotNull
public static SdkType[] getAllTypes() {
List<SdkType> allTypes = new ArrayList<SdkType>();
Collections.addAll(allTypes, ApplicationManager.getApplication().getComponents(SdkType.class));
Collections.addAll(allTypes, Extensions.getExtensions(EP_NAME));
return allTypes.toArray(new SdkType[allTypes.size()]);
}

public static <T extends SdkType> T findInstance(final Class<T> sdkTypeClass) {
@NotNull
public static <T extends SdkType> T findInstance(@NotNull Class<T> sdkTypeClass) {
for (SdkType sdkType : Extensions.getExtensions(EP_NAME)) {
if (sdkTypeClass.equals(sdkType.getClass())) {
//noinspection unchecked
Expand All @@ -208,7 +215,7 @@ public static <T extends SdkType> T findInstance(final Class<T> sdkTypeClass) {
return null;
}

public boolean isRootTypeApplicable(final OrderRootType type) {
public boolean isRootTypeApplicable(@NotNull OrderRootType type) {
return true;
}

Expand All @@ -232,7 +239,7 @@ public boolean supportsCustomCreateUI() {
* @param sdkCreatedCallback the callback to which the created SDK is passed.
* @since 12.0
*/
public void showCustomCreateUI(SdkModel sdkModel, JComponent parentComponent, Consumer<Sdk> sdkCreatedCallback) {
public void showCustomCreateUI(@NotNull SdkModel sdkModel, @NotNull JComponent parentComponent, @NotNull Consumer<Sdk> sdkCreatedCallback) {
}

/**
Expand All @@ -248,7 +255,7 @@ public boolean sdkHasValidPath(@NotNull Sdk sdk) {
return homeDir != null && homeDir.isValid();
}

public String sdkPath(VirtualFile homePath) {
public String sdkPath(@NotNull VirtualFile homePath) {
return homePath.getPath();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
Expand Down Expand Up @@ -45,13 +45,14 @@ public Sdk createJdk(final String jdkName, final String home) {
return jdk;
}

@NotNull
@Override
public String getPresentableName() {
return ProjectBundle.message("sdk.java.name");
}

@Override
public AdditionalDataConfigurable createAdditionalDataConfigurable(SdkModel sdkModel, SdkModificator sdkModificator) {
public AdditionalDataConfigurable createAdditionalDataConfigurable(@NotNull SdkModel sdkModel, @NotNull SdkModificator sdkModificator) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
Expand Down Expand Up @@ -71,7 +71,7 @@ public String suggestSdkName(String currentSdkName, String sdkHome) {
}

@Override
public AdditionalDataConfigurable createAdditionalDataConfigurable(SdkModel sdkModel, SdkModificator sdkModificator) {
public AdditionalDataConfigurable createAdditionalDataConfigurable(@NotNull SdkModel sdkModel, @NotNull SdkModificator sdkModificator) {
return null;
}

Expand All @@ -91,6 +91,7 @@ public String getVMExecutablePath(Sdk sdk) {
public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) {
}

@NotNull
@Override
public String getPresentableName() {
return ProjectBundle.message("sdk.unknown.name");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
Expand All @@ -24,6 +24,7 @@
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.util.Arrays;
Expand Down Expand Up @@ -60,7 +61,7 @@ public boolean supportsCustomCreateUI() {
}

@Override
public void showCustomCreateUI(final SdkModel sdkModel, JComponent parentComponent, final Consumer<Sdk> sdkCreatedCallback) {
public void showCustomCreateUI(@NotNull final SdkModel sdkModel, @NotNull JComponent parentComponent, @NotNull final Consumer<Sdk> sdkCreatedCallback) {
if (!checkDependency(sdkModel)) {
if (Messages.showOkCancelDialog(parentComponent, getUnsatisfiedDependencyMessage(), "Cannot Create SDK", Messages.getWarningIcon()) != Messages.OK) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ public void run() {
}

@Nullable
public static Sdk setupSdk(final Sdk[] allSdks,
final VirtualFile homeDir, final SdkType sdkType, final boolean silent,
public static Sdk setupSdk(@NotNull Sdk[] allSdks,
@NotNull VirtualFile homeDir,
final SdkType sdkType,
final boolean silent,
@Nullable final SdkAdditionalData additionalData,
@Nullable final String customSdkSuggestedName) {
final List<Sdk> sdksList = Arrays.asList(allSdks);
Expand Down
Loading

0 comments on commit 7e4dd8d

Please sign in to comment.