com.intellij.openapi.util.NotNullLazyValue Java Examples

The following examples show how to use com.intellij.openapi.util.NotNullLazyValue. 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: StdArrangementTokens.java    From consulo with Apache License 2.0 6 votes vote down vote up
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;
    }
  };
}
 
Example #2
Source File: CSharpAbstractLightAttributeBuilder.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
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)));
	}));
}
 
Example #3
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 #4
Source File: ExtensibleQueryFactory.java    From consulo with Apache License 2.0 6 votes vote down vote up
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() {
          String epName = ExtensibleQueryFactory.this.getClass().getName();
          int pos = epName.lastIndexOf('.');
          if (pos >= 0) {
            epName = epName.substring(pos+1);
          }
          epName = epNamespace + "." + StringUtil.decapitalize(epName);
          return Application.get().getExtensionPoint(ExtensionPointName.create(epName));
        }
      };
    }
  };
}
 
Example #5
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 #6
Source File: NavigationGutterIconBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #7
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 #8
Source File: InspectionManagerEx.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public InspectionManagerEx(final Project project) {
  super(project);
  if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
    myContentManager = new NotNullLazyValue<ContentManager>() {
      @Nonnull
      @Override
      protected ContentManager compute() {
        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        toolWindowManager.registerToolWindow(ToolWindowId.INSPECTION, true, ToolWindowAnchor.BOTTOM, project);
        return ContentFactory.getInstance().createContentManager(new TabbedPaneContentUI(), true, project);
      }
    };
  }
  else {
    myContentManager = new NotNullLazyValue<ContentManager>() {
      @Nonnull
      @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;
      }
    };
  }
}
 
Example #9
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 #10
Source File: RelatedItemLineMarkerInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public RelatedItemLineMarkerInfo(@Nonnull T element, @Nonnull TextRange range, Image icon, int updatePass,
                                 @Nullable Function<? super T, String> tooltipProvider,
                                 @Nullable GutterIconNavigationHandler<T> navHandler,
                                 GutterIconRenderer.Alignment alignment,
                                 @Nonnull final Collection<? extends GotoRelatedItem> targets) {
  this(element, range, icon, updatePass, tooltipProvider, navHandler, alignment, new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() {
    @Nonnull
    @Override
    protected Collection<? extends GotoRelatedItem> compute() {
      return targets;
    }
  });
}
 
Example #11
Source File: RelatedItemLineMarkerInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public RelatedItemLineMarkerInfo(@Nonnull T element, @Nonnull TextRange range, Image icon, int updatePass,
                                 @Nullable Function<? super T, String> tooltipProvider,
                                 @Nullable GutterIconNavigationHandler<T> navHandler,
                                 GutterIconRenderer.Alignment alignment,
                                 @Nonnull NotNullLazyValue<Collection<? extends GotoRelatedItem>> targets) {
  super(element, range, icon, updatePass, tooltipProvider, navHandler, alignment);
  myTargets = targets;
}
 
Example #12
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 #13
Source File: ServiceUtil.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Nullable
public static NavigationGutterIconBuilder<PsiElement> getLineMarkerForDecoratedServiceId(@NotNull Project project, @NotNull ServiceLineMarker lineMarker, @NotNull Map<String, Collection<ContainerService>> decorated, @NotNull String id) {
    if(!decorated.containsKey(id)) {
        return null;
    }

    NotNullLazyValue<Collection<? extends PsiElement>> lazy = ServiceIndexUtil.getServiceIdDefinitionLazyValue(
        project,
        ContainerUtil.map(decorated.get(id), ContainerService::getName)
    );

    return NavigationGutterIconBuilder.create(PhpIcons.IMPLEMENTS)
        .setTargets(lazy)
        .setTooltipText(lineMarker == ServiceLineMarker.DECORATE ? "Navigate to decoration" : "Navigate to parent" );
}
 
Example #14
Source File: ServiceLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
protected Collection<? extends PsiElement> compute() {
    Collection<PsiElement> myTargets = new HashSet<>();
    targets.stream().map(NotNullLazyValue::getValue).forEach(myTargets::addAll);
    return myTargets;
}
 
Example #15
Source File: NavigationGutterIconBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public NavigationGutterIconBuilder<T> setTargets(@Nonnull final Collection<? extends T> targets) {
  myTargets = new NotNullLazyValue<Collection<? extends T>>() {
    @Override
    @Nonnull
    public Collection<? extends T> compute() {
      return targets;
    }
  };
  return this;
}
 
Example #16
Source File: NavigationGutterIconBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public MyNavigationGutterIconRenderer(@Nonnull NavigationGutterIconBuilder builder,
                                      final Alignment alignment,
                                      final Image icon,
                                      @Nullable final String tooltipText,
                                      @Nonnull NotNullLazyValue<List<SmartPsiElementPointer>> pointers,
                                      Computable<PsiElementListCellRenderer> cellRenderer,
                                      boolean empty) {
  super(builder.myPopupTitle, builder.myEmptyText, cellRenderer, pointers);
  myAlignment = alignment;
  myIcon = icon;
  myTooltipText = tooltipText;
  myEmpty = empty;
}
 
Example #17
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 #18
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 #19
Source File: CSharpAbstractLightAttributeBuilder.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@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);
}
 
Example #20
Source File: TaskConfigurationType.java    From JHelper with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TaskConfigurationType() {
	super(
			"name.admitriev.jhelper.configuration.TaskConfigurationType",
			"Task",
			"Task for JHelper",
			new NotNullLazyValue<Icon>() {
				@NotNull
				@Override
				protected Icon compute() {
					return IconLoader.getIcon("/name/admitriev/jhelper/icons/task.png");
				}
			}
	);
}
 
Example #21
Source File: NavigationGutterIconRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected NavigationGutterIconRenderer(final String popupTitle, final String emptyText, @Nonnull Computable<PsiElementListCellRenderer> cellRenderer,
  @Nonnull NotNullLazyValue<List<SmartPsiElementPointer>> pointers) {
  myPopupTitle = popupTitle;
  myEmptyText = emptyText;
  myCellRenderer = cellRenderer;
  myPointers = pointers;
}
 
Example #22
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()));
}
 
Example #23
Source File: NavigationGutterIconBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
private MyNavigationGutterIconRenderer createGutterIconRenderer(@Nonnull Project project) {
  checkBuilt();
  final SmartPointerManager manager = SmartPointerManager.getInstance(project);

  NotNullLazyValue<List<SmartPsiElementPointer>> pointers = new NotNullLazyValue<List<SmartPsiElementPointer>>() {
    @Override
    @Nonnull
    public List<SmartPsiElementPointer> compute() {
      Set<PsiElement> elements = new THashSet<PsiElement>();
      Collection<? extends T> targets = myTargets.getValue();
      final List<SmartPsiElementPointer> list = new ArrayList<SmartPsiElementPointer>(targets.size());
      for (final T target : targets) {
        for (final PsiElement psiElement : myConverter.fun(target)) {
          if (elements.add(psiElement) && psiElement.isValid()) {
            list.add(manager.createSmartPsiElementPointer(psiElement));
          }
        }
      }
      return list;
    }
  };

  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);
}
 
Example #24
Source File: NavigationGutterIconBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
public NavigationGutterIconBuilder<T> setTargets(@Nonnull final NotNullLazyValue<Collection<? extends T>> targets) {
  myTargets = targets;
  myLazy = true;
  return this;
}
 
Example #25
Source File: CamelRouteLineMarkerProvider.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element,
                                        Collection<? super RelatedItemLineMarkerInfo> result) {
    //TODO: remove this when IdeaUtils.isFromJavaMethodCall will be fixed
    if (isJavaTokenLiteralExpression(element)
        || isXmlTokenLiteralExpression(element)
        || isCamelRouteStartIdentifierExpression(element)) {
        boolean showIcon = getCamelPreferenceService().isShowCamelIconInGutter();
        boolean camelPresent = ServiceManager.getService(element.getProject(), CamelService.class).isCamelPresent();

        if (!showIcon || !camelPresent) {
            return;
        }

        boolean validCamelFile = isCamelFile(element);
        if (!validCamelFile) {
            return;
        }

        //skip the PsiLiteralExpression that are not the first operand of PsiPolyadicExpression to avoid having multiple gutter icons
        // on the same PsiPolyadicExpression
        if (element instanceof PsiLiteralExpression) {
            if (isPartOfPolyadicExpression((PsiLiteralExpression) element)) {
                if (!element.isEquivalentTo(getFirstExpressionFromPolyadicExpression((PsiLiteralExpression) element))) {
                    return;
                }
            }
        }

        Icon icon = getCamelPreferenceService().getCamelIcon();

        if (getCamelIdeaUtils().isCamelRouteStartExpression(element)) {

            // evaluate the targets lazy
            NotNullLazyValue<Collection<? extends PsiElement>> targets = new NotNullLazyValue<Collection<? extends PsiElement>>() {
                @NotNull
                @Override
                protected Collection<PsiElement> compute() {
                    List<PsiElement> routeDestinationForPsiElement = findRouteDestinationForPsiElement(element);
                    // Add identifier references as navigation target
                    resolvedIdentifier(element)
                        .map(PsiElement::getNavigationElement)
                        .ifPresent(routeDestinationForPsiElement::add);
                    return routeDestinationForPsiElement;
                }
            };

            NavigationGutterIconBuilder<PsiElement> builder =
                NavigationGutterIconBuilder.create(icon)
                    .setTargets(targets)
                    .setTooltipText("Camel route")
                    .setPopupTitle("Navigate to " + findRouteFromElement(element))
                    .setAlignment(GutterIconRenderer.Alignment.RIGHT)
                    .setCellRenderer(new GutterPsiElementListCellRenderer());
            result.add(builder.createLineMarkerInfo(element));
        }
    }
}
 
Example #26
Source File: InspectionManagerEx.java    From consulo with Apache License 2.0 4 votes vote down vote up
@TestOnly
public NotNullLazyValue<ContentManager> getContentManager() {
  return myContentManager;
}
 
Example #27
Source File: VcsManagerConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
private Configurable createVcsConfigurableWrapper(final VcsDescriptor vcs) {
  final NotNullLazyValue<Configurable> delegate = new NotNullLazyValue<Configurable>() {
    @Nonnull
    @Override
    protected Configurable compute() {
      return ProjectLevelVcsManager.getInstance(myProject).findVcsByName(vcs.getName()).getConfigurable();
    }
  };
  return new SearchableConfigurable(){

    @Override
    @Nls
    public String getDisplayName() {
      return vcs.getDisplayName();
    }

    @Override
    public String getHelpTopic() {
      return delegate.getValue().getHelpTopic();
    }

    @Override
    public JComponent createComponent() {
      return delegate.getValue().createComponent();
    }

    @Override
    public boolean isModified() {
      return delegate.getValue().isModified();
    }

    @Override
    public void apply() throws ConfigurationException {
      delegate.getValue().apply();
    }

    @Override
    public void reset() {
      delegate.getValue().reset();
    }

    @Override
    public void disposeUIResources() {
      delegate.getValue().disposeUIResources();
    }

    @Override
    @Nonnull
    public String getId() {
      return "vcs." + getDisplayName();
    }

    @Override
    public Runnable enableSearch(String option) {
      return null;
    }

    @Override
    public String toString() {
      return "VcsConfigurable for "+vcs.getDisplayName();
    }
  };
}
 
Example #28
Source File: ServiceIndexUtil.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
/**
 * Lazy values for linemarker
 */
@NotNull
public static NotNullLazyValue<Collection<? extends PsiElement>> getServiceIdDefinitionLazyValue(@NotNull Project project, @NotNull Collection<String> ids) {
    return new MyServiceIdLazyValue(project, ids);
}
 
Example #29
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 #30
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;
	});
}