some magic annotations

This commit is contained in:
Max Medvedev
2013-06-06 20:18:53 +04:00
parent 0646860431
commit df83960685
2 changed files with 15 additions and 10 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -34,6 +34,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiFile;
import org.intellij.lang.annotations.MagicConstant;
import java.util.List;
import java.util.Map;
@@ -94,7 +95,7 @@ public class JavaParametersUtil {
public static void configureModule(final RunConfigurationModule runConfigurationModule,
final JavaParameters parameters,
final int classPathType,
@MagicConstant(valuesFromClass = JavaParameters.class) final int classPathType,
final String jreHome) throws CantRunException {
Module module = runConfigurationModule.getModule();
if (module == null) {
@@ -103,11 +104,11 @@ public class JavaParametersUtil {
configureModule(module, parameters, classPathType, jreHome);
}
public static void configureModule(Module module, JavaParameters parameters, int classPathType, String jreHome) throws CantRunException {
public static void configureModule(Module module, JavaParameters parameters, @MagicConstant(valuesFromClass = JavaParameters.class) int classPathType, String jreHome) throws CantRunException {
parameters.configureByModule(module, classPathType, createModuleJdk(module, jreHome));
}
public static void configureProject(Project project, final JavaParameters parameters, final int classPathType, final String jreHome)
public static void configureProject(Project project, final JavaParameters parameters, @MagicConstant(valuesFromClass = JavaParameters.class) final int classPathType, final String jreHome)
throws CantRunException {
parameters.configureByProject(project, classPathType, createProjectJdk(project, jreHome));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
import com.intellij.util.NotNullFunction;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -53,7 +54,9 @@ public class JavaParameters extends SimpleJavaParameters {
public static final int JDK_AND_CLASSES_AND_TESTS = JDK_ONLY | CLASSES_ONLY | TESTS_ONLY;
public static final int CLASSES_AND_TESTS = CLASSES_ONLY | TESTS_ONLY;
public void configureByModule(final Module module, final int classPathType, final Sdk jdk) throws CantRunException {
public void configureByModule(final Module module,
@MagicConstant(valuesFromClass = JavaParameters.class) final int classPathType,
final Sdk jdk) throws CantRunException {
if ((classPathType & JDK_ONLY) != 0) {
if (jdk == null) {
throw CantRunException.noJdkConfigured();
@@ -70,7 +73,7 @@ public class JavaParameters extends SimpleJavaParameters {
}
@Nullable
private static NotNullFunction<OrderEntry, VirtualFile[]> computeRootProvider(int classPathType, final Sdk jdk) {
private static NotNullFunction<OrderEntry, VirtualFile[]> computeRootProvider(@MagicConstant(valuesFromClass = JavaParameters.class) int classPathType, final Sdk jdk) {
return (classPathType & JDK_ONLY) == 0 ? null : new NotNullFunction<OrderEntry, VirtualFile[]>() {
@NotNull
@Override
@@ -90,7 +93,8 @@ public class JavaParameters extends SimpleJavaParameters {
}
}
public void configureByModule(final Module module, final int classPathType) throws CantRunException {
public void configureByModule(final Module module,
@MagicConstant(valuesFromClass = JavaParameters.class) final int classPathType) throws CantRunException {
configureByModule(module, classPathType, getModuleJdk(module));
}
@@ -106,7 +110,7 @@ public class JavaParameters extends SimpleJavaParameters {
return jdk;
}
public void configureByProject(final Project project, final int classPathType, final Sdk jdk) throws CantRunException {
public void configureByProject(final Project project, @MagicConstant(valuesFromClass = JavaParameters.class) final int classPathType, final Sdk jdk) throws CantRunException {
if ((classPathType & JDK_ONLY) != 0) {
if (jdk == null) {
throw CantRunException.noJdkConfigured();
@@ -121,7 +125,7 @@ public class JavaParameters extends SimpleJavaParameters {
configureEnumerator(OrderEnumerator.orderEntries(project).runtimeOnly(), classPathType, jdk).collectPaths(getClassPath());
}
private static OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, int classPathType, Sdk jdk) {
private static OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, @MagicConstant(valuesFromClass = JavaParameters.class) int classPathType, Sdk jdk) {
if ((classPathType & JDK_ONLY) == 0) {
enumerator = enumerator.withoutSdk();
}