/*
 * Copyright 2013-2014 must-be.org
 *
 * 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 org.mustbe.consulo.csharp.lang.psi.impl.source;

import org.jetbrains.annotations.NotNull;
import org.mustbe.consulo.csharp.lang.psi.CSharpElementVisitor;
import org.mustbe.consulo.dotnet.psi.DotNetExpression;
import org.mustbe.consulo.dotnet.resolve.DotNetTypeRef;
import com.intellij.lang.ASTNode;

/**
 * @author VISTALL
 * @since 04.01.14.
 */
public class CSharpNullCoalescingExpressionImpl extends CSharpElementImpl implements DotNetExpression
{
	public CSharpNullCoalescingExpressionImpl(@NotNull ASTNode node)
	{
		super(node);
	}

	@Override
	public void accept(@NotNull CSharpElementVisitor visitor)
	{
		visitor.visitNullCoalescingExpression(this);
	}

	@NotNull
	@Override
	public DotNetTypeRef toTypeRef()
	{
		return DotNetTypeRef.ERROR_TYPE;
	}
}

@@ -689,16 +689,59 @@
 otNull;%0A
+import org.jetbrains.annotations.Nullable;%0A
 import o
@@ -940,16 +940,52 @@
 ASTNode;
+%0Aimport com.intellij.psi.PsiElement;
 %0A%0A/**%0A *
@@ -1356,88 +1356,531 @@
 ll%0A%09
-@Override%0A%09public DotNetTypeRef toTypeRef()%0A%09%7B%0A%09%09return DotNetTypeRef.ERROR_TYPE
+public DotNetExpression getCondition()%0A%09%7B%0A%09%09return (DotNetExpression) getFirstChild();%0A%09%7D%0A%0A%09@Nullable%0A%09public DotNetExpression getResult()%0A%09%7B%0A%09%09PsiElement%5B%5D children = getChildren();%0A%09%09for(PsiElement child : children)%0A%09%09%7B%0A%09%09%09if(child == getCondition())%0A%09%09%09%7B%0A%09%09%09%09continue;%0A%09%09%09%7D%0A%09%09%09if(child instanceof DotNetExpression)%0A%09%09%09%7B%0A%09%09%09%09return (DotNetExpression) child;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return null;%0A%09%7D%0A%0A%09@NotNull%0A%09@Override%0A%09public DotNetTypeRef toTypeRef()%0A%09%7B%0A%09%09DotNetExpression condition = getCondition();%0A%09%09return condition.toTypeRef()
 ;%0A%09%7D

?? type