当前位置: 首页>>代码示例>>Java>>正文


Java MagicConstant类代码示例

本文整理汇总了Java中org.intellij.lang.annotations.MagicConstant的典型用法代码示例。如果您正苦于以下问题:Java MagicConstant类的具体用法?Java MagicConstant怎么用?Java MagicConstant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MagicConstant类属于org.intellij.lang.annotations包,在下文中一共展示了MagicConstant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureByModule

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
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();
    }
    setJdk(jdk);
  }

  if ((classPathType & CLASSES_ONLY) == 0) {
    return;
  }

  setDefaultCharset(module.getProject());
  configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively(), classPathType, jdk).collectPaths(getClassPath());
  configureJavaLibraryPath(OrderEnumerator.orderEntries(module).recursively());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaParameters.java

示例2: getAllowedValues

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
static AllowedValues getAllowedValues(@NotNull PsiModifierListOwner element, PsiType type, Set<PsiClass> visited) {
  PsiAnnotation[] annotations = getAllAnnotations(element);
  PsiManager manager = element.getManager();
  for (PsiAnnotation annotation : annotations) {
    AllowedValues values;
    if (type != null && MagicConstant.class.getName().equals(annotation.getQualifiedName())) {
      //PsiAnnotation magic = AnnotationUtil.findAnnotationInHierarchy(element, Collections.singleton(MagicConstant.class.getName()));
      values = getAllowedValuesFromMagic(element, type, annotation, manager);
      if (values != null) return values;
    }

    PsiJavaCodeReferenceElement ref = annotation.getNameReferenceElement();
    PsiElement resolved = ref == null ? null : ref.resolve();
    if (!(resolved instanceof PsiClass) || !((PsiClass)resolved).isAnnotationType()) continue;
    PsiClass aClass = (PsiClass)resolved;
    if (visited == null) visited = new THashSet<PsiClass>();
    if (!visited.add(aClass)) continue;
    values = getAllowedValues(aClass, type, visited);
    if (values != null) return values;
  }

  return parseBeanInfo(element, manager);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:MagicConstantInspection.java

示例3: f

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
void f(@MagicConstant(intValues={Const.X, Const.Y, Const.Z}) int x) {
  /////////// BAD
  f(0);
  f(1);
  f(Const.X | Const.Y);
  int i = Const.X | Const.Y;
  f(i);
  if (x == 3) {
    x = 2;
    assert x != 1;
  }

  ////////////// GOOD
  f(Const.X);
  f(Const.Y);
  f(Const.Z);
  int i2 = this == null ? Const.X : Const.Y;
  f(i2);
  if (x == Const.X) {
    x = Const.Y;
    assert x != Const.Z;
  }

  f2(x);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:X.java

示例4: f2

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
void f2(@MagicConstant(valuesFromClass =Const.class) int x) {
  /////////// BAD
  f2(0);
  f2(1);
  f2(Const.X | Const.Y);
  int i = Const.X | Const.Y;
  f2(i);
  if (x == 3) {
    x = 2;
    assert x != 1;
  }

  ////////////// GOOD
  f2(Const.X);
  f2(Const.Y);
  f2(Const.Z);
  int i2 = this == null ? Const.X : Const.Y;
  f2(i2);
  if (x == Const.X) {
    x = Const.Y;
    assert x != Const.Z;
  }

  f(x);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:X.java

示例5: isValid

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
@Override
@MagicConstant(intValues={VALID,INVALID,UNCERTAIN})
public int isValid(@NotNull PsiExpression argument) {
  Number size = guessSize(argument);
  if (size == null) {
    return UNCERTAIN;
  }
  int actual = size.intValue();
  if (exact != -1) {
    if (exact != actual) {
      return INVALID;
    }
  } else if (actual < min || actual > max || actual % multiple != 0) {
    return INVALID;
  }

  return VALID;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ResourceTypeInspection.java

示例6: GrIntroduceExpressionSettingsImpl

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
public GrIntroduceExpressionSettingsImpl(IntroduceParameterInfo info,
                                         String name,
                                         boolean declareFinal,
                                         TIntArrayList toRemove,
                                         boolean generateDelegate,
                                         @MagicConstant(
                                           intValues = {IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL,
                                             IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
                                             IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE}) int replaceFieldsWithGetters,
                                         GrExpression expr,
                                         GrVariable var,
                                         PsiType selectedType,
                                         boolean replaceAllOccurrences,
                                         boolean removeLocalVar,
                                         boolean forceReturn) {
  super(info, name, declareFinal, toRemove, generateDelegate, replaceFieldsWithGetters, forceReturn, replaceAllOccurrences, false);
  myExpr = expr;
  myVar = var;
  mySelectedType = selectedType;
  myRemoveLocalVar = removeLocalVar;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GrIntroduceExpressionSettingsImpl.java

示例7: assertContainsWords

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
private void assertContainsWords(
    VirtualFile file,
    @MagicConstant(flagsFromClass = UsageSearchContext.class) short occurenceMask,
    String... words) {

  for (String word : words) {
    VirtualFile[] files =
        CacheManager.SERVICE
            .getInstance(getProject())
            .getVirtualFilesWithWord(
                word, occurenceMask, GlobalSearchScope.fileScope(getProject(), file), true);
    if (!Arrays.asList(files).contains(file)) {
      Assert.fail(String.format("Word '%s' not found in file '%s'", word, file));
    }
  }
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:GlobalWordIndexTest.java

示例8: configureByModule

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
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();
    }
    setJdk(jdk);
  }

  if ((classPathType & CLASSES_ONLY) == 0) {
    return;
  }

  setDefaultCharset(module.getProject());
  configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively(), classPathType, jdk).collectPaths(getClassPath());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:JavaParameters.java

示例9: getAllowedValues

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
static AllowedValues getAllowedValues(@NotNull PsiModifierListOwner element, PsiType type, Set<PsiClass> visited) {
  PsiAnnotation[] annotations = AnnotationUtil.getAllAnnotations(element, true, null);
  PsiManager manager = element.getManager();
  for (PsiAnnotation annotation : annotations) {
    AllowedValues values;
    if (type != null && MagicConstant.class.getName().equals(annotation.getQualifiedName())) {
      //PsiAnnotation magic = AnnotationUtil.findAnnotationInHierarchy(element, Collections.singleton(MagicConstant.class.getName()));
      values = getAllowedValuesFromMagic(element, type, annotation, manager);
      if (values != null) return values;
    }

    PsiJavaCodeReferenceElement ref = annotation.getNameReferenceElement();
    PsiElement resolved = ref == null ? null : ref.resolve();
    if (!(resolved instanceof PsiClass) || !((PsiClass)resolved).isAnnotationType()) continue;
    PsiClass aClass = (PsiClass)resolved;
    if (visited == null) visited = new THashSet<PsiClass>();
    if (!visited.add(aClass)) continue;
    values = getAllowedValues(aClass, type, visited);
    if (values != null) return values;
  }

  return parseBeanInfo(element, manager);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:MagicConstantInspection.java

示例10: moveLineOffset

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
private int moveLineOffset(int offset, @MagicConstant(intValues = {BEFORE, HERE, AFTER}) int direction) {
  if (direction == AFTER) {
    int lineNumber = myEditor.offsetToLogicalPosition(offset).line;
    lineNumber++;
    Document document = myEditor.getDocument();
    if (lineNumber == document.getLineCount()) {
      return -1;
    }
    return document.getLineStartOffset(lineNumber);
  } else if (direction == BEFORE) {
    int lineNumber = myEditor.offsetToLogicalPosition(offset).line;
    lineNumber--;
    if (lineNumber < 0) {
      return -1;
    }
    Document document = myEditor.getDocument();
    return document.getLineStartOffset(lineNumber);
  } else {
    assert direction == HERE;
    return offset;
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:EditorComponentImpl.java

示例11: Options

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
private Options(final Set<Appstore> availableStores,
                final Set<String> availableStoresNames,
                final Map<String, String> storeKeys,
                final boolean checkInventory,
                final @MagicConstant(intValues = {VERIFY_EVERYTHING, VERIFY_ONLY_KNOWN, VERIFY_SKIP}) int verifyMode,
                final Set<String> preferredStoreNames,
                final int samsungCertificationRequestCode,
                final int storeSearchStrategy) {
    this.checkInventory = checkInventory;
    this.availableStores = availableStores;
    this.availableStoreNames = availableStoresNames;
    this.storeKeys = storeKeys;
    this.preferredStoreNames = preferredStoreNames;
    this.verifyMode = verifyMode;
    this.samsungCertificationRequestCode = samsungCertificationRequestCode;
    this.storeSearchStrategy = storeSearchStrategy;
}
 
开发者ID:onepf,项目名称:OpenIAB,代码行数:18,代码来源:OpenIabHelper.java

示例12: newInstance

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
@NotNull
public static SkuMappingException newInstance(@MagicConstant(
        intValues = {REASON_SKU, REASON_STORE_NAME, REASON_STORE_SKU}) int reason) {
    switch (reason) {
        case REASON_SKU:
            return new SkuMappingException("Sku can't be null or empty value.");

        case REASON_STORE_NAME:
            return new SkuMappingException("Store name can't be null or empty value.");

        case REASON_STORE_SKU:
            return new SkuMappingException("Store sku can't be null or empty value.");

        default:
            return new SkuMappingException();
    }
}
 
开发者ID:onepf,项目名称:OpenIAB,代码行数:18,代码来源:SkuMappingException.java

示例13: getClasspathType

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
@MagicConstant(valuesFromClass = OwnJavaParameters.class)
public static int getClasspathType(final RunConfigurationModule configurationModule,
		final String mainClassName,
		final boolean classMustHaveSource,
		final boolean includeProvidedDependencies) throws CantRunException
{
	final Module module = configurationModule.getModule();
	if(module == null)
	{
		throw CantRunException.noModuleConfigured(configurationModule.getModuleName());
	}
	Boolean inProduction = isClassInProductionSources(mainClassName, module);
	if(inProduction == null)
	{
		if(!classMustHaveSource)
		{
			return OwnJavaParameters.JDK_AND_CLASSES_AND_TESTS;
		}
		throw CantRunException.classNotFound(mainClassName, module);
	}

	return inProduction ? (includeProvidedDependencies ? OwnJavaParameters.JDK_AND_CLASSES_AND_PROVIDED : OwnJavaParameters.JDK_AND_CLASSES) : OwnJavaParameters.JDK_AND_CLASSES_AND_TESTS;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:JavaParametersUtil.java

示例14: clearCashes

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
public void clearCashes(@MagicConstant(flagsFromClass = EventRequest.class) int suspendPolicy)
{
	if(!isAttached())
	{
		return;
	}
	switch(suspendPolicy)
	{
		case EventRequest.SUSPEND_ALL:
			getVirtualMachineProxy().clearCaches();
			break;
		case EventRequest.SUSPEND_EVENT_THREAD:
			getVirtualMachineProxy().clearCaches();
			//suspendContext.getThread().clearAll();
			break;
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:DebugProcessImpl.java

示例15: configureByModule

import org.intellij.lang.annotations.MagicConstant; //导入依赖的package包/类
public void configureByModule(final Module module, @MagicConstant(valuesFromClass = OwnJavaParameters.class) int classPathType, @Nullable Sdk jdk) throws CantRunException
{
	if((classPathType & JDK_ONLY) != 0)
	{
		if(jdk == null)
		{
			throw CantRunException.noJdkConfigured();
		}
		setJdk(jdk);
	}

	if((classPathType & CLASSES_ONLY) == 0)
	{
		return;
	}

	setDefaultCharset(module.getProject());
	configureEnumerator(OrderEnumerator.orderEntries(module).recursively(), classPathType, jdk).collectPaths(getClassPath());
	configureJavaLibraryPath(OrderEnumerator.orderEntries(module).recursively());
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:OwnJavaParameters.java


注:本文中的org.intellij.lang.annotations.MagicConstant类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。