Java Code Examples for com.intellij.openapi.util.NotNullLazyValue#createValue()

The following examples show how to use com.intellij.openapi.util.NotNullLazyValue#createValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSharpUserTypeRef.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
public LambdaResult(@Nonnull PsiElement scope, @Nonnull CSharpMethodDeclaration element, @Nonnull DotNetGenericExtractor extractor)
{
	super(element, extractor);
	myScope = scope;
	myParameterInfosValue = NotNullLazyValue.createValue(() ->
	{
		CSharpSimpleParameterInfo[] parameterInfos = myElement.getParameterInfos();
		if(myExtractor == DotNetGenericExtractor.EMPTY)
		{
			return parameterInfos;
		}
		CSharpSimpleParameterInfo[] temp = new CSharpSimpleParameterInfo[parameterInfos.length];
		for(int i = 0; i < parameterInfos.length; i++)
		{
			CSharpSimpleParameterInfo parameterInfo = parameterInfos[i];
			DotNetTypeRef typeRef = GenericUnwrapTool.exchangeTypeRef(parameterInfo.getTypeRef(), getGenericExtractor(), myScope);
			temp[i] = new CSharpSimpleParameterInfo(parameterInfo.getIndex(), parameterInfo.getName(), parameterInfo.getElement(), typeRef);
		}
		return temp;
	});
	myElementValue = NotNullLazyValue.createValue(() -> CSharpLambdaResolveResultUtil.createTypeFromDelegate(myElement, myExtractor));
	myReturnTypRefValue = NotNullLazyValue.createValue(() -> GenericUnwrapTool.exchangeTypeRef(myElement.getReturnTypeRef(), getGenericExtractor(), scope));
}
 
Example 2
Source File: MsilMethodAsCSharpLikeMethodDeclaration.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
public MsilMethodAsCSharpLikeMethodDeclaration(PsiElement parent, @Nonnull CSharpModifier[] modifiers, MsilMethodEntry methodEntry)
{
	super(parent, methodEntry);
	myModifierList = new MsilModifierListToCSharpModifierList(modifiers, this, methodEntry.getModifierList());

	myReturnTypeRefValue = NotNullLazyValue.createValue(() -> MsilToCSharpUtil.extractToCSharp(myOriginal.getReturnTypeRef(), myOriginal));
	myParameterTypeRefsValue = NotNullLazyValue.createValue(() ->
	{
		DotNetTypeRef[] parameters = myOriginal.getParameterTypeRefs();
		DotNetTypeRef[] refs = new DotNetTypeRef[parameters.length];
		for(int i = 0; i < parameters.length; i++)
		{
			refs[i] = MsilToCSharpUtil.extractToCSharp(parameters[i], myOriginal);
		}
		return refs;
	});
}
 
Example 3
Source File: CSharpLightTypeDeclaration.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
public CSharpLightTypeDeclaration(CSharpTypeDeclaration original, DotNetGenericExtractor extractor)
{
	super(original);
	myExtractor = extractor;
	myMembersValue = NotNullLazyValue.createValue(() ->
	{
		DotNetNamedElement[] originalMembers = myOriginal.getMembers();
		DotNetNamedElement[] members = new DotNetNamedElement[originalMembers.length];
		for(int i = 0; i < originalMembers.length; i++)
		{
			members[i] = GenericUnwrapTool.extract(originalMembers[i], myExtractor, CSharpLightTypeDeclaration.this);
		}
		return members;
	});
}
 
Example 4
Source File: MethodParameterResolveContext.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
public MethodParameterResolveContext(DotNetParameterListOwner parameterListOwner, PsiElement scope, boolean resolveFromParent)
{
	myScope = scope;
	myResolveFromParent = resolveFromParent;
	myParameters = parameterListOwner.getParameters();
	myParamsParameter = ArrayUtil.getLastElement(myParameters);
	if(myParamsParameter != null && !myParamsParameter.hasModifier(CSharpModifier.PARAMS))
	{
		myParamsParameter = null;
	}

	myInnerParamsParameterTypeRefValue = NotNullLazyValue.createValue(() -> myParamsParameter == null ? DotNetTypeRef.ERROR_TYPE : CSharpResolveUtil.resolveIterableType(myScope,
			getParamsParameterTypeRef()));
	myParamsParameterTypeRefValue = NotNullLazyValue.createValue(() -> myParamsParameter == null ? DotNetTypeRef.ERROR_TYPE : myParamsParameter.toTypeRef(true));
}
 
Example 5
Source File: MsilClassAsCSharpTypeDefinition.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
public MsilClassAsCSharpTypeDefinition(@Nullable PsiElement parent, MsilClassEntry classEntry, @Nonnull GenericParameterContext genericParameterContext)
{
	super(parent, classEntry);
	myGenericParameterContext = genericParameterContext;
	myModifierList = new MsilModifierListToCSharpModifierList(this, classEntry.getModifierList());
	DotNetGenericParameterList genericParameterList = classEntry.getGenericParameterList();
	myGenericParameterList = MsilGenericParameterListAsCSharpGenericParameterList.build(this, genericParameterList, genericParameterContext);

	myExtendTypeRefsValue = NotNullLazyValue.createValue(() ->
	{
		String vmQName = getVmQName();
		// hack
		if(DotNetTypes.System.Object.equals(vmQName))
		{
			return DotNetTypeRef.EMPTY_ARRAY;
		}
		DotNetTypeRef[] extendTypeRefs = myOriginal.getExtendTypeRefs();
		if(extendTypeRefs.length == 0)
		{
			return DotNetTypeRef.EMPTY_ARRAY;
		}
		DotNetTypeRef[] typeRefs = new DotNetTypeRef[extendTypeRefs.length];
		for(int i = 0; i < typeRefs.length; i++)
		{
			typeRefs[i] = MsilToCSharpUtil.extractToCSharp(extendTypeRefs[i], myOriginal);
		}
		return typeRefs;
	});
	myTypeRefForEnumConstantsValue = NotNullLazyValue.createValue(() -> MsilToCSharpUtil.extractToCSharp(myOriginal.getTypeRefForEnumConstants(), myOriginal));
}
 
Example 6
Source File: AnalyzerStatus.java    From consulo with Apache License 2.0 5 votes vote down vote up
public AnalyzerStatus(Icon icon, String title, String details, Supplier<UIController> controllerCreator) {
  myIcon = icon;
  myTitle = title;
  myDetails = details;

  myControllerValue = NotNullLazyValue.createValue(controllerCreator);
}
 
Example 7
Source File: ProjectOpenProcessorsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
@SuppressWarnings("unchecked")
public ProjectOpenProcessorsImpl() {
  myCacheValue = NotNullLazyValue.createValue(() -> {
    List<ProjectOpenProcessor> processors = new ArrayList<>();
    processors.add(DefaultProjectOpenProcessor.getInstance());
    processors.add(new ImportProjectOpenProcessor());
    return processors.toArray(new ProjectOpenProcessor[processors.size()]);
  });
}
 
Example 8
Source File: BlazeTypeScriptConfig.java    From intellij with Apache License 2.0 4 votes vote down vote up
private BlazeTypeScriptConfig(
    Project project,
    Label label,
    VirtualFile configFile,
    File tsconfigEditor,
    String workspaceRelativePathPrefix,
    String workspaceRelativePathReplacement) {
  this.project = project;
  this.label = label;
  this.configFile = configFile;
  this.workspaceRelativePathPrefix = workspaceRelativePathPrefix;
  this.workspaceRelativePathReplacement = workspaceRelativePathReplacement;

  this.baseUrlFile =
      NullableLazyValue.createValue(
          () ->
              VfsUtils.resolveVirtualFile(
                  new File(tsconfigEditor.getParentFile(), baseUrl),
                  /* refreshIfNeeded= */ false));
  this.rootDirsFiles =
      NotNullLazyValue.createValue(
          () ->
              baseUrlFile.getValue() != null
                  ? rootDirs.stream()
                      .map(baseUrlFile.getValue()::findFileByRelativePath)
                      .filter(Objects::nonNull)
                      .collect(ImmutableList.toImmutableList())
                  : ImmutableList.of());
  this.rootDirsPsiElements =
      NotNullLazyValue.createValue(
          () -> {
            PsiManager psiManager = PsiManager.getInstance(project);
            return rootDirsFiles.getValue().stream()
                .map(psiManager::findDirectory)
                .filter(Objects::nonNull)
                .collect(ImmutableList.toImmutableList());
          });
  this.files = NotNullLazyValue.createValue(this::resolveFilesList);
  this.dependencies =
      NotNullLazyValue.createValue(
          () -> {
            VirtualFile file =
                VfsUtils.resolveVirtualFile(tsconfigEditor, /* refreshIfNeeded= */ false);
            return file != null ? ImmutableList.of(file) : ImmutableList.of();
          });
  this.includeChecker =
      NotNullLazyValue.createValue(() -> new TypeScriptConfigFilesInclude(this));
  this.resolveContext =
      NotNullLazyValue.createValue(() -> new TypeScriptImportConfigResolveContextImpl(this));
  this.importResolver =
      NotNullLazyValue.createValue(
          () -> TypeScriptImportsResolverProvider.getResolver(project, this));
  this.importStructure =
      NotNullLazyValue.createValue(() -> new TypeScriptFileImportsImpl(project, this));

  try {
    parseJson(
        new JsonParser()
            .parse(
                new InputStreamReader(
                    InputStreamProvider.getInstance().forFile(tsconfigEditor), Charsets.UTF_8))
            .getAsJsonObject());
  } catch (IOException e) {
    logger.warn(e);
  }
}
 
Example 9
Source File: MsilMethodAsCSharpConversionMethodDeclaration.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public MsilMethodAsCSharpConversionMethodDeclaration(PsiElement parent, MsilMethodEntry methodEntry)
{
	super(parent, methodEntry);
	myReturnTypeRefValue = NotNullLazyValue.createValue(() -> MsilToCSharpUtil.extractToCSharp(myOriginal.getReturnTypeRef(), myOriginal));
}
 
Example 10
Source File: MsilPropertyAsCSharpIndexMethodDeclaration.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
public MsilPropertyAsCSharpIndexMethodDeclaration(PsiElement parent, MsilPropertyEntry propertyEntry, List<Pair<DotNetXAccessor, MsilMethodEntry>> pairs)
{
	super(parent, propertyEntry);

	myAccessors = MsilPropertyAsCSharpPropertyDeclaration.buildAccessors(this, pairs);
	myModifierList = new MsilModifierListToCSharpModifierList(MsilPropertyAsCSharpPropertyDeclaration.getAdditionalModifiers(propertyEntry, pairs), this, propertyEntry.getModifierList());

	String name = getName();
	if(!Comparing.equal(name, DotNetPropertyDeclaration.DEFAULT_INDEX_PROPERTY_NAME))
	{
		CSharpLightAttributeBuilder attribute = new CSharpLightAttributeBuilder(propertyEntry, DotNetTypes.System.Runtime.CompilerServices.IndexerName);

		attribute.addParameterExpression(name);

		myModifierList.addAdditionalAttribute(attribute);
	}
	Pair<DotNetXAccessor, MsilMethodEntry> p = pairs.get(0);

	DotNetParameter firstParameter = p.getSecond().getParameters()[0];
	myParameters = new DotNetParameter[]{new MsilParameterAsCSharpParameter(this, firstParameter, this, 0)};

	myTypeForImplementValue = NullableLazyValue.of(() ->
	{
		String nameFromBytecode = myOriginal.getNameFromBytecode();
		String typeBeforeDot = StringUtil.getPackageName(nameFromBytecode);
		SomeType someType = SomeTypeParser.parseType(typeBeforeDot, nameFromBytecode);
		if(someType != null)
		{
			return new DummyType(getProject(), MsilPropertyAsCSharpIndexMethodDeclaration.this, someType);
		}
		return null;
	});

	myReturnTypeRefValue = NotNullLazyValue.createValue(() -> MsilToCSharpUtil.extractToCSharp(myOriginal.toTypeRef(false), myOriginal));
	myParameterTypeRefsValue = NotNullLazyValue.createValue(() ->
	{
		DotNetParameter[] parameters = getParameters();
		DotNetTypeRef[] typeRefs = new DotNetTypeRef[parameters.length];
		for(int i = 0; i < parameters.length; i++)
		{
			DotNetParameter parameter = parameters[i];
			typeRefs[i] = parameter.toTypeRef(false);
		}
		return typeRefs;
	});
}
 
Example 11
Source File: MsilGenericParameterAsCSharpGenericParameter.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
public MsilGenericParameterAsCSharpGenericParameter(@Nonnull PsiElement parent, DotNetGenericParameter msilElement)
{
	super(parent, msilElement);
	myExtendTypeRefsValue = NotNullLazyValue.createValue(() -> CSharpGenericConstraintUtil.getExtendTypes(this));
}
 
Example 12
Source File: GotoActionItemProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
public GotoActionItemProvider(GotoActionModel model) {
  myModel = model;
  myIntentions = NotNullLazyValue.createValue(() -> ReadAction.compute(() -> myModel.getAvailableIntentions()));
}