private JavaOverrideImplementMemberChooser(final PsiMethodMember[] allElements, final PsiMethodMember[] onlyPrimaryElements, final NotNullLazyValue<PsiMethodWithOverridingPercentMember[]> lazyElementsWithPercent, final @NotNull Project project, final boolean isInsertOverrideVisible, final boolean merge, final boolean toImplement, final boolean sortedByOverriding) { super(false, true, project, isInsertOverrideVisible, null, null); myAllElements = allElements; myOnlyPrimaryElements = onlyPrimaryElements; myLazyElementsWithPercent = lazyElementsWithPercent; myProject = project; myMerge = merge; myToImplement = toImplement; mySortedByOverriding = sortedByOverriding; resetElements(getInitialElements(allElements, onlyPrimaryElements, lazyElementsWithPercent, merge, toImplement, sortedByOverriding)); init(); }
protected ExtensibleQueryFactory(@NonNls final String epNamespace) { myPoint = new NotNullLazyValue<SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>>>() { @Override @NotNull protected SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>> compute() { return new SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>>(new SmartList<QueryExecutor<Result, Parameters>>()){ @Override @NotNull protected ExtensionPoint<QueryExecutor<Result, Parameters>> getExtensionPoint() { @NonNls String epName = ExtensibleQueryFactory.this.getClass().getName(); int pos = epName.lastIndexOf('.'); if (pos >= 0) { epName = epName.substring(pos+1); } epName = epNamespace + "." + StringUtil.decapitalize(epName); return Extensions.getRootArea().getExtensionPoint(epName); } }; } }; }
@NotNull public NotNullLazyValue<?> getValue() { if (value == null) { value = new AtomicNotNullLazyValue<Object>() { @NotNull @Override protected Object compute() { try { if (service == null) { Class<Object> aClass = findClass(implementation); return asInstance ? instantiate(aClass, ApplicationManager.getApplication().getPicoContainer(), true) : aClass; } else { return ServiceManager.getService(findClass(service)); } } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } }; } return value; }
public ProjectDataManager() { myServices = new NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>>() { @NotNull @Override protected Map<Key<?>, List<ProjectDataService<?, ?>>> compute() { Map<Key<?>, List<ProjectDataService<?, ?>>> result = ContainerUtilRt.newHashMap(); for (ProjectDataService<?, ?> service : ProjectDataService.EP_NAME.getExtensions()) { List<ProjectDataService<?, ?>> services = result.get(service.getTargetDataKey()); if (services == null) { result.put(service.getTargetDataKey(), services = ContainerUtilRt.newArrayList()); } services.add(service); } for (List<ProjectDataService<?, ?>> services : result.values()) { ExternalSystemApiUtil.orderAwareSort(services); } return result; } }; }
private static NotNullLazyValue<Set<ArrangementSettingsToken>> collectFields(@NotNull final Class<?> clazz) { return new NotNullLazyValue<Set<ArrangementSettingsToken>>() { @NotNull @Override protected Set<ArrangementSettingsToken> compute() { Set<ArrangementSettingsToken> result = ContainerUtilRt.newHashSet(); for (Field field : clazz.getFields()) { if (ArrangementSettingsToken.class.isAssignableFrom(field.getType())) { try { result.add((ArrangementSettingsToken)field.get(null)); } catch (IllegalAccessException e) { assert false : e; } } } return result; } }; }
private static <T> NotNullLazyValue<List<SmartPsiElementPointer>> createPointersThunk(boolean lazy, final Project project, final Factory<Collection<T>> targets, final NotNullFunction<T, Collection<? extends PsiElement>> converter) { if (!lazy) { return NotNullLazyValue.createConstantValue(calcPsiTargets(project, targets.create(), converter)); } return new NotNullLazyValue<List<SmartPsiElementPointer>>() { @Override @NotNull public List<SmartPsiElementPointer> compute() { return calcPsiTargets(project, targets.create(), converter); } }; }
public RelatedItemLineMarkerInfo<PsiElement> createLineMarkerInfo(@NotNull PsiElement element) { final MyNavigationGutterIconRenderer renderer = createGutterIconRenderer(element.getProject()); final String tooltip = renderer.getTooltipText(); NotNullLazyValue<Collection<? extends GotoRelatedItem>> gotoTargets = new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() { @NotNull @Override protected Collection<? extends GotoRelatedItem> compute() { if (myGotoRelatedItemProvider != null) { return ContainerUtil.concat(myTargets.getValue(), myGotoRelatedItemProvider); } return Collections.emptyList(); } }; return new RelatedItemLineMarkerInfo<PsiElement>(element, element.getTextRange(), renderer.getIcon(), Pass.UPDATE_OVERRIDEN_MARKERS, tooltip == null ? null : new ConstantFunction<PsiElement, String>(tooltip), renderer.isNavigateAction() ? renderer : null, renderer.getAlignment(), gotoTargets); }
public void addParameterExpression(Object o) { if(myCallArguments.isEmpty()) { myCallArguments = new SmartList<>(); } myCallArguments.add(NotNullLazyValue.createValue(() -> { Object value = o; if(value instanceof String) { value = StringUtil.QUOTER.fun((String) value); } return new CSharpLightCallArgument(CSharpFileFactory.createExpression(getProject(), String.valueOf(value))); })); }
@RequiredReadAction public LambdaResult(@NotNull PsiElement scope, @NotNull CSharpMethodDeclaration element, @NotNull 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)); }
@RequiredReadAction public MsilMethodAsCSharpLikeMethodDeclaration(PsiElement parent, @NotNull 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; }); }
protected ExtensibleQueryFactory(@NonNls final String epNamespace) { myPoint = new NotNullLazyValue<SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>>>() { @Override @Nonnull protected SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>> compute() { return new SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>>(new SmartList<QueryExecutor<Result, Parameters>>()){ @Override @Nonnull protected ExtensionPoint<QueryExecutor<Result, Parameters>> getExtensionPoint() { @NonNls String epName = ExtensibleQueryFactory.this.getClass().getName(); int pos = epName.lastIndexOf('.'); if (pos >= 0) { epName = epName.substring(pos+1); } epName = epNamespace + "." + StringUtil.decapitalize(epName); return Extensions.getRootArea().getExtensionPoint(epName); } }; } }; }
private static NotNullLazyValue<Set<ArrangementSettingsToken>> collectFields(@Nonnull final Class<?> clazz) { return new NotNullLazyValue<Set<ArrangementSettingsToken>>() { @Nonnull @Override protected Set<ArrangementSettingsToken> compute() { Set<ArrangementSettingsToken> result = ContainerUtilRt.newHashSet(); for (Field field : clazz.getFields()) { if (ArrangementSettingsToken.class.isAssignableFrom(field.getType())) { try { result.add((ArrangementSettingsToken)field.get(null)); } catch (IllegalAccessException e) { assert false : e; } } } return result; } }; }
public RelatedItemLineMarkerInfo<PsiElement> createLineMarkerInfo(@Nonnull PsiElement element) { final MyNavigationGutterIconRenderer renderer = createGutterIconRenderer(element.getProject()); final String tooltip = renderer.getTooltipText(); NotNullLazyValue<Collection<? extends GotoRelatedItem>> gotoTargets = new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() { @Nonnull @Override protected Collection<? extends GotoRelatedItem> compute() { if (myGotoRelatedItemProvider != null) { return ContainerUtil.concat(myTargets.getValue(), myGotoRelatedItemProvider); } return Collections.emptyList(); } }; return new RelatedItemLineMarkerInfo<PsiElement>(element, element.getTextRange(), renderer.getIcon(), Pass.LINE_MARKERS, tooltip == null ? null : new ConstantFunction<PsiElement, String>(tooltip), renderer.isNavigateAction() ? renderer : null, renderer.getAlignment(), gotoTargets); }
public TemplateEngineProvider(Project project, NotNullLazyValue<ModificationTracker> tracker) { super(project); this.tracker = tracker; for (TemplateEngine engine : TemplateEngine.values()) { engines.put("catberry-" + engine, engine); } }
private static PsiMethodMember[] getInitialElements(PsiMethodMember[] allElements, PsiMethodMember[] onlyPrimaryElements, NotNullLazyValue<PsiMethodWithOverridingPercentMember[]> lazyElementsWithPercent, boolean merge, boolean toImplement, boolean sortByOverriding) { final boolean showElementsWithPercents = sortByOverriding && !toImplement; final PsiMethodMember[] defaultElements = toImplement || merge ? allElements : onlyPrimaryElements; return showElementsWithPercents ? lazyElementsWithPercent.getValue() : defaultElements; }
public void registerDomain(@NotNull String name, @NotNull NotNullLazyValue commands, boolean overridable) { if (domains.containsKey(name)) { if (overridable) { return; } else { throw new IllegalArgumentException(name + " is already registered"); } } domains.put(name, commands); }
public RelatedItemLineMarkerInfo(@NotNull T element, @NotNull TextRange range, Icon icon, int updatePass, @Nullable Function<? super T, String> tooltipProvider, @Nullable GutterIconNavigationHandler<T> navHandler, @NotNull GutterIconRenderer.Alignment alignment, @NotNull NotNullLazyValue<Collection<? extends GotoRelatedItem>> targets) { super(element, range, icon, updatePass, tooltipProvider, navHandler, alignment); myTargets = targets; }
public RelatedItemLineMarkerInfo(@NotNull T element, @NotNull TextRange range, Icon icon, int updatePass, @Nullable Function<? super T, String> tooltipProvider, @Nullable GutterIconNavigationHandler<T> navHandler, @NotNull GutterIconRenderer.Alignment alignment, @NotNull final Collection<? extends GotoRelatedItem> targets) { this(element, range, icon, updatePass, tooltipProvider, navHandler, alignment, new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() { @NotNull @Override protected Collection<? extends GotoRelatedItem> compute() { return targets; } }); }
public InspectionManagerEx(final Project project) { super(project); if (ApplicationManager.getApplication().isHeadlessEnvironment()) { myContentManager = new NotNullLazyValue<ContentManager>() { @NotNull @Override protected ContentManager compute() { ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); toolWindowManager.registerToolWindow(ToolWindowId.INSPECTION, true, ToolWindowAnchor.BOTTOM, project); return ContentFactory.SERVICE.getInstance().createContentManager(new TabbedPaneContentUI(), true, project); } }; } else { myContentManager = new NotNullLazyValue<ContentManager>() { @NotNull @Override protected ContentManager compute() { ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.INSPECTION, true, ToolWindowAnchor.BOTTOM, project); ContentManager contentManager = toolWindow.getContentManager(); toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowInspection); new ContentManagerWatcher(toolWindow, contentManager); return contentManager; } }; } }
public void reset() { myPeerHolder = new NotNullLazyValue<GeneratorPeer<T>>() { @NotNull @Override protected GeneratorPeer<T> compute() { return createPeer(); } }; }
public boolean isNewStyleClass(@Nullable TypeEvalContext context) { return new NotNullLazyValue<ParameterizedCachedValue<Boolean, TypeEvalContext>>() { @NotNull @Override protected ParameterizedCachedValue<Boolean, TypeEvalContext> compute() { return CachedValuesManager.getManager(getProject()).createParameterizedCachedValue(new NewStyleCachedValueProvider(), false); } }.getValue().getValue(context); }
public RelatedItemLineMarkerInfo<PsiElement> createLineMarkerInfo(@NotNull PsiElement element) { final MyNavigationGutterIconRenderer renderer = createGutterIconRenderer(element.getProject()); final String tooltip = renderer.getTooltipText(); NotNullLazyValue<Collection<? extends GotoRelatedItem>> gotoTargets = createGotoTargetsThunk(myLazy, myGotoRelatedItemProvider, evaluateAndForget(myTargets)); return new RelatedItemLineMarkerInfo<PsiElement>(element, element.getTextRange(), renderer.getIcon(), Pass.UPDATE_OVERRIDEN_MARKERS, tooltip == null ? null : new ConstantFunction<PsiElement, String>(tooltip), renderer.isNavigateAction() ? renderer : null, renderer.getAlignment(), gotoTargets); }
private static <T> Factory<T> evaluateAndForget(NotNullLazyValue<T> lazyValue) { final Ref<NotNullLazyValue<T>> ref = Ref.create(lazyValue); return new Factory<T>() { @Override public T create() { T result = ref.get().getValue(); ref.set(null); return result; } }; }
private MyNavigationGutterIconRenderer createGutterIconRenderer(@NotNull final Project project) { checkBuilt(); NotNullLazyValue<List<SmartPsiElementPointer>> pointers = createPointersThunk(myLazy, project, evaluateAndForget(myTargets), myConverter); final boolean empty = isEmpty(); if (myTooltipText == null && !myLazy) { final SortedSet<String> names = new TreeSet<String>(); for (T t : myTargets.getValue()) { final String text = myNamer.fun(t); if (text != null) { names.add(MessageFormat.format(PATTERN, text)); } } @NonNls StringBuilder sb = new StringBuilder("<html><body>"); if (myTooltipTitle != null) { sb.append(myTooltipTitle).append("<br>"); } for (String name : names) { sb.append(name).append("<br>"); } sb.append("</body></html>"); myTooltipText = sb.toString(); } Computable<PsiElementListCellRenderer> renderer = myCellRenderer == null ? new Computable<PsiElementListCellRenderer>() { @Override public PsiElementListCellRenderer compute() { return new DefaultPsiElementCellRenderer(); } } : myCellRenderer; return new MyNavigationGutterIconRenderer(this, myAlignment, myIcon, myTooltipText, pointers, renderer, empty); }
public MyNavigationGutterIconRenderer(@NotNull NavigationGutterIconBuilder builder, final Alignment alignment, final Icon icon, @Nullable final String tooltipText, @NotNull NotNullLazyValue<List<SmartPsiElementPointer>> pointers, Computable<PsiElementListCellRenderer> cellRenderer, boolean empty) { super(builder.myPopupTitle, builder.myEmptyText, cellRenderer, pointers); myAlignment = alignment; myIcon = icon; myTooltipText = tooltipText; myEmpty = empty; }
protected NavigationGutterIconRenderer(final String popupTitle, final String emptyText, @NotNull Computable<PsiElementListCellRenderer> cellRenderer, @NotNull NotNullLazyValue<List<SmartPsiElementPointer>> pointers) { myPopupTitle = popupTitle; myEmptyText = emptyText; myCellRenderer = cellRenderer; myPointers = pointers; }
public RelatedItemLineMarkerInfo(@NotNull T element, @NotNull TextRange range, Icon icon, int updatePass, @Nullable Function<? super T, String> tooltipProvider, @Nullable GutterIconNavigationHandler<T> navHandler, GutterIconRenderer.Alignment alignment, @NotNull NotNullLazyValue<Collection<? extends GotoRelatedItem>> targets) { super(element, range, icon, updatePass, tooltipProvider, navHandler, alignment); myTargets = targets; }
public RelatedItemLineMarkerInfo(@NotNull T element, @NotNull TextRange range, Icon icon, int updatePass, @Nullable Function<? super T, String> tooltipProvider, @Nullable GutterIconNavigationHandler<T> navHandler, GutterIconRenderer.Alignment alignment, @NotNull final Collection<? extends GotoRelatedItem> targets) { this(element, range, icon, updatePass, tooltipProvider, navHandler, alignment, new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() { @NotNull @Override protected Collection<? extends GotoRelatedItem> compute() { return targets; } }); }
public InspectionManagerEx(final Project project) { super(project); if (ApplicationManager.getApplication().isHeadlessEnvironment()) { myContentManager = new NotNullLazyValue<ContentManager>() { @NotNull @Override protected ContentManager compute() { return ContentFactory.SERVICE.getInstance().createContentManager(new TabbedPaneContentUI(), true, project); } }; } else { myContentManager = new NotNullLazyValue<ContentManager>() { @NotNull @Override protected ContentManager compute() { ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.INSPECTION, true, ToolWindowAnchor.BOTTOM, project); ContentManager contentManager = toolWindow.getContentManager(); toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowInspection); new ContentManagerWatcher(toolWindow, contentManager); return contentManager; } }; } }
/** @see CompletionDataEP */ @Deprecated public static void registerCompletionData(FileType fileType, final CompletionData completionData) { registerCompletionData(fileType, new NotNullLazyValue<CompletionData>() { @Override @NotNull protected CompletionData compute() { return completionData; } }); }
@Nullable public static CompletionData getCompletionDataByFileType(FileType fileType) { for(CompletionDataEP ep: Extensions.getExtensions(CompletionDataEP.EP_NAME)) { if (ep.fileType.equals(fileType.getName())) { return ep.getHandler(); } } final NotNullLazyValue<CompletionData> lazyValue = ourCustomCompletionDatas.get(fileType); return lazyValue == null ? null : lazyValue.getValue(); }
public NavigationGutterIconBuilder<T> setTargets(@NotNull final Collection<? extends T> targets) { myTargets = new NotNullLazyValue<Collection<? extends T>>() { @NotNull public Collection<? extends T> compute() { return targets; } }; return this; }
@NotNull @Override public CSharpCallArgument[] getCallArguments() { if(myCallArguments.isEmpty()) { return CSharpCallArgument.EMPTY_ARRAY; } List<CSharpCallArgument> arguments = new ArrayList<>(myCallArguments.size()); for(NotNullLazyValue<CSharpCallArgument> callArgument : myCallArguments) { arguments.add(callArgument.getValue()); } return ContainerUtil.toArray(arguments, CSharpCallArgument.ARRAY_FACTORY); }