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.resolve.calls.inference; 018 019import com.google.common.collect.Maps; 020 021import java.util.Map; 022 023public class ConstraintPosition { 024 public static final ConstraintPosition RECEIVER_POSITION = new ConstraintPosition("RECEIVER_POSITION"); 025 public static final ConstraintPosition EXPECTED_TYPE_POSITION = new ConstraintPosition("EXPECTED_TYPE_POSITION"); 026 public static final ConstraintPosition BOUND_CONSTRAINT_POSITION = new ConstraintPosition("BOUND_CONSTRAINT_POSITION"); 027 public static final ConstraintPosition FROM_COMPLETER = new ConstraintPosition("FROM_COMPLETER"); 028 029 private static final Map<Integer, ConstraintPosition> valueParameterPositions = Maps.newHashMap(); 030 031 public static ConstraintPosition getValueParameterPosition(int index) { 032 ConstraintPosition position = valueParameterPositions.get(index); 033 if (position == null) { 034 position = new ConstraintPosition("VALUE_PARAMETER_POSITION(" + index + ")"); 035 valueParameterPositions.put(index, position); 036 } 037 return position; 038 } 039 040 private final String debugName; 041 042 private ConstraintPosition(String name) { 043 debugName = name; 044 } 045 046 @Override 047 public String toString() { 048 return debugName; 049 } 050}