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.renderer; 018 019 import org.jetbrains.annotations.NotNull; 020 import org.jetbrains.jet.lang.resolve.name.FqName; 021 022 import java.util.Collection; 023 import java.util.Collections; 024 025 public class DescriptorRendererBuilder { 026 private boolean shortNames = false; 027 private boolean withDefinedIn = true; 028 private boolean modifiers = true; 029 private boolean startFromName = false; 030 private boolean debugMode = false; 031 private boolean classWithPrimaryConstructor = false; 032 private boolean verbose = false; 033 private boolean unitReturnType = true; 034 private boolean normalizedVisibilities = false; 035 private boolean showInternalKeyword = true; 036 private boolean alwaysRenderAny = false; 037 private boolean prettyFunctionTypes = true; 038 @NotNull 039 private DescriptorRenderer.OverrideRenderingPolicy overrideRenderingPolicy = DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN; 040 @NotNull 041 private DescriptorRenderer.ValueParametersHandler valueParametersHandler = new DescriptorRenderer.DefaultValueParameterHandler(); 042 @NotNull 043 private DescriptorRenderer.TextFormat textFormat = DescriptorRenderer.TextFormat.PLAIN; 044 @NotNull 045 private Collection<FqName> excludedAnnotationClasses = Collections.emptyList(); 046 047 public DescriptorRendererBuilder() { 048 } 049 050 public DescriptorRendererBuilder setShortNames(boolean shortNames) { 051 this.shortNames = shortNames; 052 return this; 053 } 054 055 public DescriptorRendererBuilder setWithDefinedIn(boolean withDefinedIn) { 056 this.withDefinedIn = withDefinedIn; 057 return this; 058 } 059 060 public DescriptorRendererBuilder setModifiers(boolean modifiers) { 061 this.modifiers = modifiers; 062 return this; 063 } 064 065 public DescriptorRendererBuilder setStartFromName(boolean startFromName) { 066 this.startFromName = startFromName; 067 return this; 068 } 069 070 public DescriptorRendererBuilder setDebugMode(boolean debugMode) { 071 this.debugMode = debugMode; 072 return this; 073 } 074 075 public DescriptorRendererBuilder setClassWithPrimaryConstructor(boolean classWithPrimaryConstructor) { 076 this.classWithPrimaryConstructor = classWithPrimaryConstructor; 077 return this; 078 } 079 080 public DescriptorRendererBuilder setVerbose(boolean verbose) { 081 this.verbose = verbose; 082 return this; 083 } 084 085 public DescriptorRendererBuilder setUnitReturnType(boolean unitReturnType) { 086 this.unitReturnType = unitReturnType; 087 return this; 088 } 089 090 public DescriptorRendererBuilder setNormalizedVisibilities(boolean normalizedVisibilities) { 091 this.normalizedVisibilities = normalizedVisibilities; 092 return this; 093 } 094 095 public DescriptorRendererBuilder setShowInternalKeyword(boolean showInternalKeyword) { 096 this.showInternalKeyword = showInternalKeyword; 097 return this; 098 } 099 100 public DescriptorRendererBuilder setOverrideRenderingPolicy(DescriptorRenderer.OverrideRenderingPolicy overrideRenderingPolicy) { 101 this.overrideRenderingPolicy = overrideRenderingPolicy; 102 return this; 103 } 104 105 public DescriptorRendererBuilder setValueParametersHandler(@NotNull DescriptorRenderer.ValueParametersHandler valueParametersHandler) { 106 this.valueParametersHandler = valueParametersHandler; 107 return this; 108 } 109 110 public DescriptorRendererBuilder setTextFormat(@NotNull DescriptorRenderer.TextFormat textFormat) { 111 this.textFormat = textFormat; 112 return this; 113 } 114 115 public DescriptorRendererBuilder setExcludedAnnotationClasses(@NotNull Collection<FqName> excludedAnnotationClasses) { 116 this.excludedAnnotationClasses = excludedAnnotationClasses; 117 return this; 118 } 119 120 public DescriptorRendererBuilder setAlwaysRenderAny(boolean alwaysRenderAny) { 121 this.alwaysRenderAny = alwaysRenderAny; 122 return this; 123 } 124 125 public DescriptorRendererBuilder setPrettyFunctionTypes(boolean prettyFunctionTypes) { 126 this.prettyFunctionTypes = prettyFunctionTypes; 127 return this; 128 } 129 130 public DescriptorRenderer build() { 131 return new DescriptorRendererImpl(shortNames, withDefinedIn, modifiers, startFromName, debugMode, classWithPrimaryConstructor, 132 verbose, unitReturnType, normalizedVisibilities, showInternalKeyword, alwaysRenderAny, prettyFunctionTypes, 133 overrideRenderingPolicy, valueParametersHandler, textFormat, excludedAnnotationClasses); 134 } 135 136 }