package org.mustbe.consulo.csharp.lang.psi.impl.source.resolve.type;

import org.jetbrains.annotations.NotNull;
import org.mustbe.consulo.csharp.lang.psi.impl.CSharpTypeUtil;
import org.mustbe.consulo.csharp.lang.psi.impl.msil.CSharpTransform;
import org.mustbe.consulo.dotnet.psi.DotNetTypeDeclaration;
import org.mustbe.consulo.dotnet.resolve.DotNetPsiSearcher;
import org.mustbe.consulo.dotnet.resolve.DotNetTypeRef;
import org.mustbe.consulo.dotnet.resolve.DotNetTypeResolveResult;
import org.mustbe.consulo.dotnet.resolve.SimpleTypeResolveResult;
import com.intellij.psi.PsiElement;

/**
 * @author VISTALL
 * @since 26.10.14
 */
public class CSharpTypeRefByQName extends DotNetTypeRef.Adapter
{
	@NotNull
	private final String myQualifiedName;
	private final Boolean myNullable;

	public CSharpTypeRefByQName(@NotNull String qualifiedName)
	{
		myQualifiedName = qualifiedName;
		myNullable = null;
	}

	public CSharpTypeRefByQName(@NotNull String qualifiedName, boolean nullable)
	{
		myQualifiedName = qualifiedName;
		myNullable = nullable;
	}

	@NotNull
	@Override
	public DotNetTypeResolveResult resolve(@NotNull PsiElement scope)
	{
		DotNetTypeDeclaration type = DotNetPsiSearcher.getInstance(scope.getProject()).findType(myQualifiedName, scope.getResolveScope(),
				DotNetPsiSearcher.TypeResoleKind.UNKNOWN, CSharpTransform.INSTANCE);

		if(type == null)
		{
			return DotNetTypeResolveResult.EMPTY;
		}

		return new SimpleTypeResolveResult(type, myNullable == Boolean.TRUE || CSharpTypeUtil.isElementIsNullable(type));
	}
}

@@ -541,24 +541,74 @@
 olveResult;%0A
+import com.intellij.openapi.util.text.StringUtil;%0A
 import com.i
@@ -1097,16 +1097,219 @@
 le;%0A%09%7D%0A%0A
+%09@NotNull%0A%09@Override%0A%09public String getQualifiedText()%0A%09%7B%0A%09%09return myQualifiedName;%0A%09%7D%0A%0A%09@NotNull%0A%09@Override%0A%09public String getPresentableText()%0A%09%7B%0A%09%09return StringUtil.getShortName(myQualifiedName);%0A%09%7D%0A%0A
 %09@NotNul

fix assert