com.intellij.openapi.util.NullableLazyValue Java Examples
The following examples show how to use
com.intellij.openapi.util.NullableLazyValue.
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: FileLookupData.java From intellij with Apache License 2.0 | 6 votes |
public FilePathLookupElement lookupElementForFile( Project project, VirtualFile file, @Nullable WorkspacePath workspacePath) { NullableLazyValue<Icon> icon = new NullableLazyValue<Icon>() { @Override protected Icon compute() { if (file.findChild("BUILD") != null) { return BlazeIcons.BuildFile; } if (file.isDirectory()) { return PlatformIcons.FOLDER_ICON; } PsiFile psiFile = PsiManager.getInstance(project).findFile(file); return psiFile != null ? psiFile.getIcon(0) : AllIcons.FileTypes.Any_type; } }; String fullLabel = workspacePath != null ? getFullLabel(workspacePath.relativePath()) : file.getPath(); String itemText = workspacePath != null ? getItemText(workspacePath.relativePath()) : fullLabel; return new FilePathLookupElement(fullLabel, itemText, quoteType, icon); }
Example #2
Source File: MsilPropertyAsCSharpPropertyDeclaration.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction public MsilPropertyAsCSharpPropertyDeclaration(PsiElement parent, MsilPropertyEntry variable, List<Pair<DotNetXAccessor, MsilMethodEntry>> pairs) { super(parent, getAdditionalModifiers(variable, pairs), variable); myAccessors = buildAccessors(this, pairs); myTypeForImplementValue = NullableLazyValue.of(() -> { String nameFromBytecode = getVariable().getNameFromBytecode(); String typeBeforeDot = StringUtil.getPackageName(nameFromBytecode); SomeType someType = SomeTypeParser.parseType(typeBeforeDot, nameFromBytecode); if(someType != null) { return new DummyType(getProject(), MsilPropertyAsCSharpPropertyDeclaration.this, someType); } return null; }); }
Example #3
Source File: MsilEventAsCSharpEventDeclaration.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction public MsilEventAsCSharpEventDeclaration(PsiElement parent, MsilEventEntry variable, List<Pair<DotNetXAccessor, MsilMethodEntry>> pairs) { super(parent, MsilPropertyAsCSharpPropertyDeclaration.getAdditionalModifiers(variable, pairs), variable); myAccessors = MsilPropertyAsCSharpPropertyDeclaration.buildAccessors(this, pairs); myTypeForImplementValue = NullableLazyValue.of(() -> { String nameFromBytecode = getVariable().getNameFromBytecode(); String typeBeforeDot = StringUtil.getPackageName(nameFromBytecode); SomeType someType = SomeTypeParser.parseType(typeBeforeDot, nameFromBytecode); if(someType != null) { return new DummyType(getProject(), MsilEventAsCSharpEventDeclaration.this, someType); } return null; }); }
Example #4
Source File: MsilMethodAsCSharpMethodDeclaration.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction public MsilMethodAsCSharpMethodDeclaration(PsiElement parent, @Nullable MsilClassEntry declaration, @Nonnull GenericParameterContext genericParameterContext, @Nonnull MsilMethodEntry methodEntry) { super(parent, CSharpModifier.EMPTY_ARRAY, methodEntry); myDelegate = declaration; setGenericParameterList(declaration != null ? declaration : methodEntry, genericParameterContext); 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(), MsilMethodAsCSharpMethodDeclaration.this, someType); } return null; }); }
Example #5
Source File: MsilModifierListToCSharpModifierList.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction public MsilModifierListToCSharpModifierList(@Nonnull CSharpModifier[] additional, @Nonnull PsiElement parent, @Nonnull DotNetModifierList modifierList) { super(parent, modifierList); myAdditional = additional; myModifierList = modifierList; if(myModifierList.hasModifier(MsilTokens.SERIALIZABLE_KEYWORD)) { addAdditionalAttribute(new CSharpLightAttributeBuilder(myModifierList, DotNetTypes.System.Serializable)); } if(myModifierList.hasModifier(MsilTokens.BRACKET_OUT_KEYWORD)) { addAdditionalAttribute(new CSharpLightAttributeBuilder(myModifierList, DotNetTypes2.System.Runtime.InteropServices.OutAttribute)); } if(myModifierList.hasModifier(MsilTokens.BRACKET_IN_KEYWORD)) { addAdditionalAttribute(new CSharpLightAttributeBuilder(myModifierList, DotNetTypes2.System.Runtime.InteropServices.InAttribute)); } myAttributeHolderValue = NullableLazyValue.of(() -> ExternalAttributesUtil.findHolder(myModifierList)); }
Example #6
Source File: MsilMethodAsCSharpLikeMethodDeclaration.java From consulo-csharp with Apache License 2.0 | 5 votes |
protected void setGenericParameterList(@Nonnull DotNetGenericParameterListOwner owner, @Nonnull GenericParameterContext genericParameterContext) { DotNetGenericParameterList genericParameterList = owner.getGenericParameterList(); myGenericParameterList = MsilGenericParameterListAsCSharpGenericParameterList.build(this, genericParameterList, genericParameterContext); myGenericConstraintListValue = new NullableLazyValue<CSharpLightGenericConstraintList>() { @Nullable @Override @RequiredReadAction protected CSharpLightGenericConstraintList compute() { return MsilAsCSharpBuildUtil.buildConstraintList(myGenericParameterList); } }; }
Example #7
Source File: PathReference.java From consulo with Apache License 2.0 | 5 votes |
public PathReference(@Nonnull String path, final @Nonnull Function<PathReference, Icon> icon) { myPath = path; myIcon = new NullableLazyValue<Icon>() { @Override protected Icon compute() { return icon.fun(PathReference.this); } }; }
Example #8
Source File: FilePathLookupElement.java From intellij with Apache License 2.0 | 4 votes |
public FilePathLookupElement( String fullLabel, String itemText, QuoteType quoteWrapping, NullableLazyValue<Icon> icon) { super(fullLabel, quoteWrapping); this.itemText = itemText; this.icon = icon; }
Example #9
Source File: BlazeTypeScriptConfig.java From intellij with Apache License 2.0 | 4 votes |
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 #10
Source File: MsilPropertyAsCSharpIndexMethodDeclaration.java From consulo-csharp with Apache License 2.0 | 4 votes |
@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: TypeIconEP.java From consulo with Apache License 2.0 | 4 votes |
public NullableLazyValue<Image> getIcon() { return myIcon; }
Example #12
Source File: TypeNameEP.java From consulo with Apache License 2.0 | 4 votes |
public NullableLazyValue<String> getTypeName() { return myName; }