/*
 * Copyright 2013-2017 consulo.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package consulo.csharp.ide.breadcrumbs;

import org.jetbrains.annotations.NotNull;
import com.intellij.lang.Language;
import com.intellij.psi.PsiElement;
import com.intellij.ui.breadcrumbs.BreadcrumbsProvider;
import consulo.csharp.lang.CSharpLanguage;
import consulo.dotnet.psi.DotNetLikeMethodDeclaration;
import consulo.dotnet.psi.DotNetNamespaceDeclaration;
import consulo.dotnet.psi.DotNetQualifiedElement;

/**
 * @author VISTALL
 * @since 04-Nov-17
 */
public class CSharpBreadcrumbsProvider implements BreadcrumbsProvider
{
	@NotNull
	@Override
	public Language getLanguage()
	{
		return CSharpLanguage.INSTANCE;
	}

	@Override
	public boolean acceptElement(@NotNull PsiElement psiElement)
	{
		return psiElement instanceof DotNetQualifiedElement;
	}

	@NotNull
	@Override
	public String getElementInfo(@NotNull PsiElement psiElement)
	{
		DotNetQualifiedElement qualifiedElement = (DotNetQualifiedElement) psiElement;
		if(qualifiedElement instanceof DotNetNamespaceDeclaration)
		{
			return qualifiedElement.getPresentableQName();
		}

		if(qualifiedElement instanceof DotNetLikeMethodDeclaration)
		{
			return qualifiedElement.getName() + "()";
		}
		return qualifiedElement.getName();
	}
}

@@ -818,34 +818,215 @@
 ulo.
-csharp.lang.CSharpLanguage
+annotations.RequiredReadAction;%0Aimport consulo.csharp.lang.CSharpLanguage;%0Aimport consulo.csharp.lang.psi.CSharpSimpleParameterInfo;%0Aimport consulo.csharp.lang.psi.impl.source.CSharpAnonymousMethodExpression
 ;%0Aim
@@ -1524,16 +1524,73 @@
 dElement
+ %7C%7C psiElement instanceof CSharpAnonymousMethodExpression
 ;%0A%09%7D%0A%0A%09@
@@ -1600,32 +1600,53 @@
 Null%0A%09@Override%0A
+%09@RequiredReadAction%0A
 %09public String g
@@ -1691,19 +1691,721 @@
 lement)%0A
-
 %09%7B%0A
+%09%09if(psiElement instanceof CSharpAnonymousMethodExpression)%0A%09%09%7B%0A%09%09%09CSharpSimpleParameterInfo%5B%5D parameterInfos = ((CSharpAnonymousMethodExpression) psiElement).getParameterInfos();%0A%0A%09%09%09StringBuilder builder = new StringBuilder();%0A%09%09%09if(parameterInfos.length == 1)%0A%09%09%09%7B%0A%09%09%09%09builder.append(parameterInfos%5B0%5D.getNotNullName());%0A%09%09%09%7D%0A%09%09%09else%0A%09%09%09%7B%0A%09%09%09%09builder.append(%22(%22);%0A%09%09%09%09for(int i = 0; i %3C parameterInfos.length; i++)%0A%09%09%09%09%7B%0A%09%09%09%09%09CSharpSimpleParameterInfo parameterInfo = parameterInfos%5Bi%5D;%0A%09%09%09%09%09if(i != 0)%0A%09%09%09%09%09%7B%0A%09%09%09%09%09%09builder.append(%22,%22);%0A%09%09%09%09%09%7D%0A%09%09%09%09%09builder.append(parameterInfo.getNotNullName());%0A%09%09%09%09%7D%0A%09%09%09%09builder.append(%22)%22);%0A%09%09%09%7D%0A%09%09%09builder.append(%22 =%3E %7B...%7D%22);%0A%09%09%09return builder.toString();%0A%09%09%7D%0A
 %09%09DotNet

support lambdas breadcrumbs