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 017 package org.jetbrains.jet.lang.resolve.java; 018 019 import org.jetbrains.annotations.NotNull; 020 import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; 021 import org.jetbrains.jet.lang.resolve.name.FqName; 022 import org.jetbrains.jet.lang.resolve.name.Name; 023 024 public class JvmAbi { 025 /** 026 * This constant is used to identify binary format (class file) versions 027 * If you change class file metadata format and/or naming conventions, please increase this number 028 */ 029 public static final int VERSION = 6; 030 031 public static final String TRAIT_IMPL_CLASS_NAME = "$TImpl"; 032 public static final String TRAIT_IMPL_SUFFIX = "$" + TRAIT_IMPL_CLASS_NAME; 033 034 public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default"; 035 public static final String GETTER_PREFIX = "get"; 036 public static final String SETTER_PREFIX = "set"; 037 038 public static final String CLASS_OBJECT_CLASS_NAME = "object"; 039 public static final String CLASS_OBJECT_SUFFIX = "$" + CLASS_OBJECT_CLASS_NAME; 040 041 public static final String DELEGATED_PROPERTY_NAME_POSTFIX = "$delegate"; 042 043 public static final String INSTANCE_FIELD = "instance$"; 044 public static final String CLASS_OBJECT_FIELD = "object$"; 045 public static final String RECEIVER_PARAMETER = "$receiver"; 046 047 public static final JvmClassName JETBRAINS_NOT_NULL_ANNOTATION = 048 JvmClassName.byFqNameWithoutInnerClasses("org.jetbrains.annotations.NotNull"); 049 050 public static final JvmClassName JETBRAINS_MUTABLE_ANNOTATION = 051 JvmClassName.byFqNameWithoutInnerClasses("org.jetbrains.annotations.Mutable"); 052 public static final JvmClassName JETBRAINS_READONLY_ANNOTATION = 053 JvmClassName.byFqNameWithoutInnerClasses("org.jetbrains.annotations.ReadOnly"); 054 055 public static boolean isClassObjectFqName(@NotNull FqName fqName) { 056 return fqName.lastSegmentIs(Name.identifier(CLASS_OBJECT_CLASS_NAME)); 057 } 058 059 public static String getPropertyDelegateName(@NotNull Name name) { 060 return name.asString() + DELEGATED_PROPERTY_NAME_POSTFIX; 061 } 062 063 064 public static String getDefaultPropertyName(Name propertyName, boolean isDelegated, boolean isExtensionProperty) { 065 if (isDelegated) { 066 return getPropertyDelegateName(propertyName); 067 } 068 069 String name = propertyName.asString(); 070 if (isExtensionProperty) { 071 name += "$ext"; 072 } 073 return name; 074 075 } 076 077 private JvmAbi() { 078 } 079 }