Skip to content

Commit

Permalink
notnull
Browse files Browse the repository at this point in the history
  • Loading branch information
cdracm committed Aug 28, 2013
1 parent dee081f commit 7d6de4f
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,25 @@ public AdditionalDataConfigurable createAdditionalDataConfigurable(SdkModel sdkM
}

@Override
public void saveAdditionalData(SdkAdditionalData additionalData, Element additional) {
public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) {
}

@Override
@SuppressWarnings({"HardCodedStringLiteral"})
public String getBinPath(Sdk sdk) {
public String getBinPath(@NotNull Sdk sdk) {
return getConvertedHomePath(sdk) + "bin";
}

@Override
@NonNls
public String getToolsPath(Sdk sdk) {
public String getToolsPath(@NotNull Sdk sdk) {
final String versionString = sdk.getVersionString();
final boolean isJdk1_x = versionString != null && (versionString.contains("1.0") || versionString.contains("1.1"));
return getConvertedHomePath(sdk) + "lib" + File.separator + (isJdk1_x? "classes.zip" : "tools.jar");
}

@Override
public String getVMExecutablePath(Sdk sdk) {
public String getVMExecutablePath(@NotNull Sdk sdk) {
/*
if ("64".equals(System.getProperty("sun.arch.data.model"))) {
return getBinPath(sdk) + File.separator + System.getProperty("os.arch") + File.separator + VM_EXE_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.io.File;

public abstract class JavaSdk extends SdkType implements JavaSdkType, ApplicationComponent {
public JavaSdk(@NonNls String name) {
public JavaSdk(@NotNull @NonNls String name) {
super(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String adjustSelectedSdkHome(String homePath) {

@Override
@Nullable
public String getVersionString(Sdk sdk) {
public String getVersionString(@NotNull Sdk sdk) {
return getVersionString(sdk.getHomePath());
}

Expand Down Expand Up @@ -99,15 +99,15 @@ public SdkAdditionalData loadAdditionalData(Element additional) {

@Override
@Nullable
public SdkAdditionalData loadAdditionalData(Sdk currentSdk, Element additional) {
public SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, Element additional) {
return loadAdditionalData(additional);
}


public SdkType(@NonNls String name) {
public SdkType(@NotNull @NonNls String name) {
myName = name;
}

@NotNull
@Override
public String getName() {
return myName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.intellij.openapi.projectRoots.impl.SdkVersionUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import java.io.File;

Expand Down Expand Up @@ -55,24 +56,24 @@ public AdditionalDataConfigurable createAdditionalDataConfigurable(SdkModel sdkM
}

@Override
public void saveAdditionalData(SdkAdditionalData additionalData, Element additional) {
public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) {
}

@Override
public String getBinPath(Sdk sdk) {
public String getBinPath(@NotNull Sdk sdk) {
return getConvertedHomePath(sdk) + "bin";
}

@Override
@NonNls
public String getToolsPath(Sdk sdk) {
public String getToolsPath(@NotNull Sdk sdk) {
final String versionString = sdk.getVersionString();
final boolean isJdk1_x = versionString != null && (versionString.contains("1.0") || versionString.contains("1.1"));
return getConvertedHomePath(sdk) + "lib" + File.separator + (isJdk1_x? "classes.zip" : "tools.jar");
}

@Override
public String getVMExecutablePath(Sdk sdk) {
public String getVMExecutablePath(@NotNull Sdk sdk) {
return getBinPath(sdk) + File.separator + VM_EXE_NAME;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.projectRoots.*;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.util.HashMap;
Expand All @@ -35,11 +36,12 @@ public class UnknownSdkType extends SdkType{
/**
* @param typeName the name of the SDK type that this SDK serves as a plug for
*/
private UnknownSdkType(String typeName) {
private UnknownSdkType(@NotNull String typeName) {
super(typeName);
}

public static UnknownSdkType getInstance(String typeName) {
@NotNull
public static UnknownSdkType getInstance(@NotNull String typeName) {
UnknownSdkType instance = ourTypeNameToInstanceMap.get(typeName);
if (instance == null) {
instance = new UnknownSdkType(typeName);
Expand Down Expand Up @@ -86,7 +88,7 @@ public String getVMExecutablePath(Sdk sdk) {
}

@Override
public void saveAdditionalData(SdkAdditionalData additionalData, Element additional) {
public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ public void removeListener(Listener listener) {

@Override
public SdkTypeId getDefaultSdkType() {
return UnknownSdkType.getInstance(null);
return UnknownSdkType.getInstance("");
}

@Override
public SdkTypeId getSdkTypeByName(String sdkTypeName) {
public SdkTypeId getSdkTypeByName(@NotNull String sdkTypeName) {
return findSdkTypeByName(sdkTypeName);
}

public static SdkTypeId findSdkTypeByName(String sdkTypeName) {
public static SdkTypeId findSdkTypeByName(@NotNull String sdkTypeName) {
final SdkType[] allSdkTypes = SdkType.getAllTypes();
for (final SdkType type : allSdkTypes) {
if (type.getName().equals(sdkTypeName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.EventListener;
Expand Down Expand Up @@ -88,7 +89,7 @@ public interface Listener extends EventListener {

public abstract SdkTypeId getDefaultSdkType();

public abstract SdkTypeId getSdkTypeByName(String name);
public abstract SdkTypeId getSdkTypeByName(@NotNull String name);

public abstract Sdk createSdk(final String name, final SdkTypeId sdkType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
package com.intellij.openapi.projectRoots;

import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* @author yole
*/
public interface SdkTypeId {
@NotNull
String getName();

@Nullable
String getVersionString(Sdk sdk);
String getVersionString(@NotNull Sdk sdk);

void saveAdditionalData(SdkAdditionalData additionalData, Element additional);
void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional);

@Nullable
SdkAdditionalData loadAdditionalData(Sdk currentSdk, Element additional);
SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, Element additional);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkTypeId;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -99,7 +100,7 @@ public SdkTypeId getDefaultSdkType() {
}

@Override
public SdkTypeId getSdkTypeByName(String name) {
public SdkTypeId getSdkTypeByName(@NotNull String name) {
return CoreSdkType.INSTANCE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.intellij.openapi.projectRoots.SdkAdditionalData;
import com.intellij.openapi.projectRoots.SdkTypeId;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;

/**
* @author yole
Expand All @@ -29,22 +30,23 @@ private CoreSdkType() {

public static CoreSdkType INSTANCE = new CoreSdkType();

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

@Override
public String getVersionString(Sdk sdk) {
public String getVersionString(@NotNull Sdk sdk) {
return "";
}

@Override
public void saveAdditionalData(SdkAdditionalData additionalData, Element additional) {
public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) {
}

@Override
public SdkAdditionalData loadAdditionalData(Sdk currentSdk, Element additional) {
public SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, Element additional) {
return null;
}
}
12 changes: 6 additions & 6 deletions plugins/devkit/src/projectRoots/IdeaJdk.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public boolean accept(File pathname) {
}

@Nullable
public final String getVersionString(final Sdk sdk) {
public final String getVersionString(@NotNull final Sdk sdk) {
final Sdk internalJavaSdk = getInternalJavaSdk(sdk);
return internalJavaSdk != null ? internalJavaSdk.getVersionString() : null;
}
Expand Down Expand Up @@ -401,13 +401,13 @@ public AdditionalDataConfigurable createAdditionalDataConfigurable(final SdkMode
}

@Nullable
public String getBinPath(Sdk sdk) {
public String getBinPath(@NotNull Sdk sdk) {
final Sdk internalJavaSdk = getInternalJavaSdk(sdk);
return internalJavaSdk == null ? null : JavaSdk.getInstance().getBinPath(internalJavaSdk);
}

@Nullable
public String getToolsPath(Sdk sdk) {
public String getToolsPath(@NotNull Sdk sdk) {
final Sdk jdk = getInternalJavaSdk(sdk);
if (jdk != null && jdk.getVersionString() != null){
return JavaSdk.getInstance().getToolsPath(jdk);
Expand All @@ -416,12 +416,12 @@ public String getToolsPath(Sdk sdk) {
}

@Nullable
public String getVMExecutablePath(Sdk sdk) {
public String getVMExecutablePath(@NotNull Sdk sdk) {
final Sdk internalJavaSdk = getInternalJavaSdk(sdk);
return internalJavaSdk == null ? null : JavaSdk.getInstance().getVMExecutablePath(internalJavaSdk);
}

public void saveAdditionalData(SdkAdditionalData additionalData, Element additional) {
public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) {
if (additionalData instanceof Sandbox) {
try {
((Sandbox)additionalData).writeExternal(additional);
Expand All @@ -432,7 +432,7 @@ public void saveAdditionalData(SdkAdditionalData additionalData, Element additio
}
}

public SdkAdditionalData loadAdditionalData(Sdk sdk, Element additional) {
public SdkAdditionalData loadAdditionalData(@NotNull Sdk sdk, Element additional) {
Sandbox sandbox = new Sandbox(sdk);
try {
sandbox.readExternal(additional);
Expand Down

0 comments on commit 7d6de4f

Please sign in to comment.