@NotNull @SuppressWarnings("unchecked") public <T> T getRequiredStubOrPsiChildByIndex(@NotNull TokenSet set, int index) { T element = getStubOrPsiChildByIndex(set, index); if(element == null) { throw new IllegalArgumentException("Element by set: " + set + " and index:" + index + " is not found. Tree:\n " + new PsiTreeDebugBuilder().psiToString(this, false, false)); } return element; }
protected String unexpectedPsiAssertion() { final PsiTreeDebugBuilder builder = new PsiTreeDebugBuilder(); return "Unexpected PSI structure: " + builder.psiToString(this) + "--\ninside: " + builder.psiToString(getContainingFile()); }
@Nullable @RequiredReadAction public String buildArgumentTypeRefs() { CSharpReferenceExpression element = myPointer.getElement(); if(element == null) { return null; } StringBuilder builder = new StringBuilder(); CSharpCallArgumentListOwner parent = PsiTreeUtil.getParentOfType(element, CSharpCallArgumentListOwner.class); if(parent == null) { LOGGER.error("Can't find parent by 'CSharpCallArgumentListOwner'. Element: " + new PsiTreeDebugBuilder().psiToString(element)); return null; } CSharpCallArgument[] callArguments = parent.getCallArguments(); for(int i = 0; i < callArguments.length; i++) { if(i != 0) { builder.append(", "); } CSharpCallArgument callArgument = callArguments[i]; DotNetExpression argumentExpression = callArgument.getArgumentExpression(); if(argumentExpression != null) { DotNetTypeRef typeRef = argumentExpression.toTypeRef(false); builder.append(CSharpTypeRefPresentationUtil.buildShortText(typeRef, element)); } else { builder.append("object"); } } return builder.toString(); }