001/* 002 * Copyright 2010-2013 JetBrains s.r.o. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.jetbrains.jet.lang.psi.stubs.impl; 018 019import com.intellij.psi.stubs.StubBase; 020import com.intellij.psi.stubs.StubElement; 021import com.intellij.util.io.StringRef; 022import org.jetbrains.jet.lang.psi.JetTypeParameter; 023import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeParameterStub; 024import org.jetbrains.jet.lang.psi.stubs.elements.JetTypeParameterElementType; 025 026public class PsiJetTypeParameterStubImpl extends StubBase<JetTypeParameter> implements PsiJetTypeParameterStub { 027 private final StringRef name; 028 private final StringRef extendBoundTypeText; 029 private final boolean isInVariance; 030 private final boolean isOutVariance; 031 032 public PsiJetTypeParameterStubImpl(JetTypeParameterElementType type, StubElement parent, 033 StringRef name, StringRef extendBoundTypeText, boolean isInVariance, boolean isOutVariance) { 034 super(parent, type); 035 036 this.name = name; 037 this.extendBoundTypeText = extendBoundTypeText; 038 this.isInVariance = isInVariance; 039 this.isOutVariance = isOutVariance; 040 } 041 042 public PsiJetTypeParameterStubImpl(JetTypeParameterElementType type, StubElement parent, 043 String name, String extendBoundTypeText, boolean isInVariance, boolean isOutVariance) { 044 this(type, parent, StringRef.fromString(name), StringRef.fromString(extendBoundTypeText), isInVariance, isOutVariance); 045 } 046 047 @Override 048 public String getExtendBoundTypeText() { 049 return StringRef.toString(extendBoundTypeText); 050 } 051 052 @Override 053 public boolean isInVariance() { 054 return isInVariance; 055 } 056 057 @Override 058 public boolean isOutVariance() { 059 return isOutVariance; 060 } 061 062 @Override 063 public String getName() { 064 return StringRef.toString(name); 065 } 066 067 @Override 068 public String toString() { 069 StringBuilder builder = new StringBuilder(); 070 builder.append("PsiJetTypeParameterStubImpl["); 071 072 if (isInVariance()) { 073 builder.append("in "); 074 } 075 076 if (isOutVariance()) { 077 builder.append("out "); 078 } 079 080 builder.append("name=").append(getName()); 081 builder.append(" extendText=").append(getExtendBoundTypeText()); 082 083 builder.append("]"); 084 085 return builder.toString(); 086 } 087}