id
int64
1
49k
buggy
stringlengths
34
37.5k
fixed
stringlengths
2
37k
101
package com.jetbrains.python.codeInsight; import com.google.common.collect.ImmutableMap; <BUG>import com.google.common.collect.ImmutableSet; import com.intellij.openapi.project.Project;</BUG> import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement;
import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.intellij.openapi.project.Project;
102
import com.jetbrains.python.psi.impl.PyExpressionCodeFragmentImpl; import com.jetbrains.python.psi.resolve.PyResolveContext; import com.jetbrains.python.psi.types.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; <BUG>import java.util.ArrayList; import java.util.Collections; import java.util.List; </BUG> import java.util.regex.Matcher;
import java.util.*;
103
final ArrayList<PyGenericType> results = new ArrayList<PyGenericType>(); for (PyExpression expr : cls.getSuperClassExpressions()) { if (expr instanceof PySubscriptionExpression) { final PyExpression indexExpr = ((PySubscriptionExpression)expr).getIndexExpression(); if (indexExpr != null) { <BUG>final PsiElement resolved = tryResolving(indexExpr, context); </BUG> final PyGenericType genericType = getGenericType(resolved, context); if (genericType != null) { results.add(genericType);
for (PsiElement resolved : tryResolving(indexExpr, context)) {
104
if (genericType != null) { results.add(genericType); } } } <BUG>} return results;</BUG> } return Collections.emptyList(); }
return results;
105
@Nullable private static PyType getUnionType(@NotNull PsiElement element, @NotNull TypeEvalContext context) { if (element instanceof PySubscriptionExpression) { final PySubscriptionExpression subscriptionExpr = (PySubscriptionExpression)element; final PyExpression operand = subscriptionExpr.getOperand(); <BUG>final String operandName = resolveToQualifiedName(operand, context); if ("typing.Union".equals(operandName)) { return PyUnionType.union(getIndexTypes(subscriptionExpr, context));</BUG> }
private static PyType getType(@NotNull PyExpression expression, @NotNull TypeEvalContext context) { final List<PyType> members = Lists.newArrayList(); for (PsiElement resolved : tryResolving(expression, context)) { members.add(getTypeForResolvedElement(resolved, context));
106
private static PyGenericType getGenericType(@NotNull PsiElement element, @NotNull TypeEvalContext context) { if (element instanceof PyCallExpression) { final PyCallExpression assignedCall = (PyCallExpression)element; final PyExpression callee = assignedCall.getCallee(); if (callee != null) { <BUG>final String calleeQName = resolveToQualifiedName(callee, context); if ("typing.TypeVar".equals(calleeQName)) { final PyExpression[] arguments = assignedCall.getArguments();</BUG> if (arguments.length > 0) {
final Collection<String> calleeQNames = resolveToQualifiedNames(callee, context); if (calleeQNames.contains("typing.TypeVar")) { final PyExpression[] arguments = assignedCall.getArguments();
107
final String collectionName = getQualifiedName(element); final String builtinName = COLLECTION_CLASSES.get(collectionName); return builtinName != null ? PyTypeParser.getTypeByName(element, builtinName) : null; } @NotNull <BUG>private static PsiElement tryResolving(@NotNull PyExpression expression, @NotNull TypeEvalContext context) { if (expression instanceof PyReferenceExpression) {</BUG> final PyReferenceExpression referenceExpr = (PyReferenceExpression)expression; final PyResolveContext resolveContext = PyResolveContext.noImplicits().withTypeEvalContext(context);
private static List<PsiElement> tryResolving(@NotNull PyExpression expression, @NotNull TypeEvalContext context) { final List<PsiElement> elements = Lists.newArrayList(); if (expression instanceof PyReferenceExpression) {
108
import java.util.Locale; import java.util.Map; import java.util.TreeMap; public class DependencyConvergenceReport extends AbstractProjectInfoReport <BUG>{ private List reactorProjects; private static final int PERCENTAGE = 100;</BUG> public String getOutputName() {
private static final int PERCENTAGE = 100; private static final List SUPPORTED_FONT_FAMILY_NAMES = Arrays.asList( GraphicsEnvironment .getLocalGraphicsEnvironment().getAvailableFontFamilyNames() );
109
sink.section1(); sink.sectionTitle1(); sink.text( getI18nString( locale, "title" ) ); sink.sectionTitle1_(); Map dependencyMap = getDependencyMap(); <BUG>generateLegend( locale, sink ); generateStats( locale, sink, dependencyMap ); generateConvergence( locale, sink, dependencyMap ); sink.section1_();</BUG> sink.body_();
sink.lineBreak(); sink.section1_();
110
Iterator it = artifactMap.keySet().iterator(); while ( it.hasNext() ) { String version = (String) it.next(); sink.tableRow(); <BUG>sink.tableCell(); sink.text( version );</BUG> sink.tableCell_(); sink.tableCell(); generateVersionDetails( sink, artifactMap, version );
sink.tableCell( String.valueOf( cellWidth ) + "px" ); sink.text( version );
111
sink.tableCell(); sink.text( getI18nString( locale, "legend.shared" ) ); sink.tableCell_(); sink.tableRow_(); sink.tableRow(); <BUG>sink.tableCell(); iconError( sink );</BUG> sink.tableCell_(); sink.tableCell(); sink.text( getI18nString( locale, "legend.different" ) );
sink.tableCell( "15px" ); // according /images/icon_error_sml.gif iconError( sink );
112
sink.tableCaption(); sink.text( getI18nString( locale, "stats.caption" ) ); sink.tableCaption_();</BUG> sink.tableRow(); <BUG>sink.tableHeaderCell(); sink.text( getI18nString( locale, "stats.subprojects" ) + ":" ); sink.tableHeaderCell_();</BUG> sink.tableCell(); sink.text( String.valueOf( reactorProjects.size() ) ); sink.tableCell_();
sink.bold(); sink.bold_(); sink.tableCaption_(); sink.tableHeaderCell( headerCellWidth ); sink.text( getI18nString( locale, "stats.subprojects" ) ); sink.tableHeaderCell_();
113
sink.tableCell(); sink.text( String.valueOf( reactorProjects.size() ) ); sink.tableCell_(); sink.tableRow_(); sink.tableRow(); <BUG>sink.tableHeaderCell(); sink.text( getI18nString( locale, "stats.dependencies" ) + ":" ); sink.tableHeaderCell_();</BUG> sink.tableCell(); sink.text( String.valueOf( depCount ) );
sink.tableHeaderCell( headerCellWidth ); sink.text( getI18nString( locale, "stats.dependencies" ) ); sink.tableHeaderCell_();
114
sink.text( String.valueOf( convergence ) + "%" ); sink.bold_(); sink.tableCell_(); sink.tableRow_(); sink.tableRow(); <BUG>sink.tableHeaderCell(); sink.text( getI18nString( locale, "stats.readyrelease" ) + ":" ); sink.tableHeaderCell_();</BUG> sink.tableCell(); if ( convergence >= PERCENTAGE && snapshotCount <= 0 )
sink.tableHeaderCell( headerCellWidth ); sink.text( getI18nString( locale, "stats.readyrelease" ) ); sink.tableHeaderCell_();
115
{ ReverseDependencyLink p1 = (ReverseDependencyLink) o1; ReverseDependencyLink p2 = (ReverseDependencyLink) o2; return p1.getProject().getId().compareTo( p2.getProject().getId() ); } <BUG>else {</BUG> return 0; } }
iconError( sink );
116
} @RootTask static Task<Exec.Result> exec(String parameter, int number) { Task<String> task1 = MyTask.create(parameter); Task<Integer> task2 = Adder.create(number, number + 2); <BUG>return Task.ofType(Exec.Result.class).named("exec", "/bin/sh") .in(() -> task1)</BUG> .in(() -> task2) .process(Exec.exec((str, i) -> args("/bin/sh", "-c", "\"echo " + i + "\""))); }
return Task.named("exec", "/bin/sh").ofType(Exec.Result.class) .in(() -> task1)
117
return args; } static class MyTask { static final int PLUS = 10; static Task<String> create(String parameter) { <BUG>return Task.ofType(String.class).named("MyTask", parameter) .in(() -> Adder.create(parameter.length(), PLUS))</BUG> .in(() -> Fib.create(parameter.length())) .process((sum, fib) -> something(parameter, sum, fib)); }
return Task.named("MyTask", parameter).ofType(String.class) .in(() -> Adder.create(parameter.length(), PLUS))
118
final String instanceField = "from instance"; final TaskContext context = TaskContext.inmem(); final AwaitingConsumer<String> val = new AwaitingConsumer<>(); @Test public void shouldJavaUtilSerialize() throws Exception { <BUG>Task<Long> task1 = Task.ofType(Long.class).named("Foo", "Bar", 39) .process(() -> 9999L); Task<String> task2 = Task.ofType(String.class).named("Baz", 40) .in(() -> task1)</BUG> .ins(() -> singletonList(task1))
Task<Long> task1 = Task.named("Foo", "Bar", 39).ofType(Long.class) Task<String> task2 = Task.named("Baz", 40).ofType(String.class) .in(() -> task1)
119
assertEquals(des.id().name(), "Baz"); assertEquals(val.awaitAndGet(), "[9999] hello 10004"); } @Test(expected = NotSerializableException.class) public void shouldNotSerializeWithInstanceFieldReference() throws Exception { <BUG>Task<String> task = Task.ofType(String.class).named("WithRef") .process(() -> instanceField + " causes an outer reference");</BUG> serialize(task); } @Test
Task<String> task = Task.named("WithRef").ofType(String.class) .process(() -> instanceField + " causes an outer reference");
120
serialize(task); } @Test public void shouldSerializeWithLocalReference() throws Exception { String local = instanceField; <BUG>Task<String> task = Task.ofType(String.class).named("WithLocalRef") .process(() -> local + " won't cause an outer reference");</BUG> serialize(task); Task<String> des = deserialize(); context.evaluate(des).consume(val);
Task<String> task = Task.named("WithLocalRef").ofType(String.class) .process(() -> local + " won't cause an outer reference");
121
} @RootTask public static Task<String> standardArgs(int first, String second) { firstInt = first; secondString = second; <BUG>return Task.ofType(String.class).named("StandardArgs", first, second) .process(() -> second + " " + first * 100);</BUG> } @Test public void shouldParseFlags() throws Exception {
return Task.named("StandardArgs", first, second).ofType(String.class) .process(() -> second + " " + first * 100);
122
assertThat(parsedEnum, is(CustomEnum.BAR)); } @RootTask public static Task<String> enums(CustomEnum enm) { parsedEnum = enm; <BUG>return Task.ofType(String.class).named("Enums", enm) .process(enm::toString);</BUG> } @Test public void shouldParseCustomTypes() throws Exception {
return Task.named("Enums", enm).ofType(String.class) .process(enm::toString);
123
assertThat(parsedType.content, is("blarg parsed for you!")); } @RootTask public static Task<String> customType(CustomType myType) { parsedType = myType; <BUG>return Task.ofType(String.class).named("Types", myType.content) .process(() -> myType.content);</BUG> } public enum CustomEnum { BAR
return Task.named("Types", myType.content).ofType(String.class) .process(() -> myType.content);
124
TaskContext taskContext = TaskContext.inmem(); TaskContext.Value<Long> value = taskContext.evaluate(fib92); value.consume(f92 -> System.out.println("fib(92) = " + f92)); } static Task<Long> create(long n) { <BUG>TaskBuilder<Long> fib = Task.ofType(Long.class).named("Fib", n); </BUG> if (n < 2) { return fib .process(() -> n);
TaskBuilder<Long> fib = Task.named("Fib", n).ofType(Long.class);
125
ReadWriteVariableInstruction instruction = findInstruction(refExpr, flow); if (instruction == null) return null; if (instruction.isWrite()) { return getInitializerType(refExpr); } <BUG>final DFAType type = getInferredType(refExpr.getReferenceName(), instruction, flow, scope, new HashSet<MixinTypeInstruction>()); if (type == null) return null; return type.getResultType();</BUG> } });
return type == null ? null : type.getResultType();
126
rest("/cart/").description("Personal Shopping Cart Service") .produces(MediaType.APPLICATION_JSON_VALUE) .options("/{cartId}") .route().id("getCartOptionsRoute").end().endRest() .options("/checkout/{cartId}") <BUG>.route().id("checkoutCartOptionsRoute").end().endRest() .options("/{cartId}/{itemId}/{quantity}")</BUG> .route().id("cartAddDeleteOptionsRoute").end().endRest() .post("/checkout/{cartId}").description("Finalize shopping cart and process payment") .param().name("cartId").type(RestParamType.path).description("The ID of the cart to process").dataType("string").endParam()
.options("/{cartId}/{tmpId}") .route().id("cartSetOptionsRoute").end().endRest() .options("/{cartId}/{itemId}/{quantity}")
127
import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.CamelCaseUtil; import com.liferay.portal.kernel.util.GetterUtil; import com.liferay.portal.kernel.util.LocaleUtil; import com.liferay.portal.kernel.util.MethodParameter; <BUG>import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.service.ServiceContext;</BUG> import java.lang.reflect.Array; import java.lang.reflect.Method; import java.util.ArrayList;
import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.service.ServiceContext;
128
import java.util.Calendar; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Locale; <BUG>import java.util.Map; import jodd.bean.BeanUtil; import jodd.typeconverter.TypeConverterManager;</BUG> import jodd.util.NameValue; import jodd.util.ReflectUtil;
import jodd.bean.BeanCopy; import jodd.typeconverter.TypeConversionException; import jodd.typeconverter.TypeConverterManager;
129
stringValue, HashMap.class); return _generifyMap(map, genericParameterTypes); } else { Object parameterValue = null; <BUG>try { parameterValue = TypeConverterManager.convertType( value, parameterType);</BUG> } catch (Exception e) {
parameterValue = _convertType(value, parameterType);
130
return list; } List<Object> newList = new ArrayList<Object>(list.size()); for (Object entry : list) { if (entry != null) { <BUG>entry = TypeConverterManager.convertType(entry, types[0]); </BUG> } newList.add(entry); }
if (types.length != 1) { entry = _convertType(entry, types[0]);
131
} if (types.length != 2) { return map; } Map<Object, Object> newMap = new HashMap<Object, Object>(map.size()); <BUG>for (Map.Entry<?, ?> entry : map.entrySet()) { Object key = TypeConverterManager.convertType( entry.getKey(), types[0]);</BUG> Object value = entry.getValue(); if (value != null) {
String className = parameterType.getName(); if (className.contains("com.liferay") && className.contains("Util")) { throw new IllegalArgumentException( "Not instantiating " + className);
132
import java.util.ResourceBundle; import java.util.function.Function;</BUG> class DescriptionStrategyFactory { private DescriptionStrategyFactory() {} public static DescriptionStrategy daysOfWeekInstance(final ResourceBundle bundle, final FieldExpression expression) { <BUG>final Function<Integer, String> nominal = integer -> new DateTime().withDayOfWeek(integer).dayOfWeek().getAsText(bundle.getLocale()); </BUG> NominalDescriptionStrategy dow = new NominalDescriptionStrategy(bundle, nominal, expression); dow.addDescription(fieldExpression -> { if (fieldExpression instanceof On) {
import java.util.function.Function; import com.cronutils.model.field.expression.FieldExpression; import com.cronutils.model.field.expression.On; final Function<Integer, String> nominal = integer -> DayOfWeek.of(integer).getDisplayName(TextStyle.FULL, bundle.getLocale());
133
return dom; } public static DescriptionStrategy monthsInstance(final ResourceBundle bundle, final FieldExpression expression) { return new NominalDescriptionStrategy( bundle, <BUG>integer -> new DateTime().withMonthOfYear(integer).monthOfYear().getAsText(bundle.getLocale()), expression</BUG> ); } public static DescriptionStrategy plainInstance(ResourceBundle bundle, final FieldExpression expression) {
integer -> Month.of(integer).getDisplayName(TextStyle.FULL, bundle.getLocale()), expression
134
else if (t == ANY_CYPHER_OPTION) { r = AnyCypherOption(b, 0); } else if (t == ANY_FUNCTION_INVOCATION) { r = AnyFunctionInvocation(b, 0); <BUG>} else if (t == BULK_IMPORT_QUERY) {</BUG> r = BulkImportQuery(b, 0); } else if (t == CALL) {
else if (t == ARRAY) { r = Array(b, 0); else if (t == BULK_IMPORT_QUERY) {
135
if (!r) r = MapLiteral(b, l + 1); if (!r) r = MapProjection(b, l + 1); if (!r) r = CountStar(b, l + 1); if (!r) r = ListComprehension(b, l + 1); if (!r) r = PatternComprehension(b, l + 1); <BUG>if (!r) r = Expression1_12(b, l + 1); if (!r) r = FilterFunctionInvocation(b, l + 1);</BUG> if (!r) r = ExtractFunctionInvocation(b, l + 1); if (!r) r = ReduceFunctionInvocation(b, l + 1); if (!r) r = AllFunctionInvocation(b, l + 1);
if (!r) r = Array(b, l + 1); if (!r) r = FilterFunctionInvocation(b, l + 1);
136
public static boolean debugMode = false; @ModConfigProperty(category = "Debug", name = "debugModeGOTG", comment = "Enable/Disable Debug Mode for the Gift Of The Gods") public static boolean debugModeGOTG = false; @ModConfigProperty(category = "Debug", name = "debugModeEnchantments", comment = "Enable/Disable Debug Mode for the Enchantments") public static boolean debugModeEnchantments = false; <BUG>@ModConfigProperty(category = "Weapons", name = "enableSwordsRecipes", comment = "Enable/Disable The ArmorPlus Sword's Recipes") public static boolean enableSwordsRecipes = true; @ModConfigProperty(category = "Weapons", name = "enableBattleAxesRecipes", comment = "Enable/Disable The ArmorPlus Battle Axes's Recipes") public static boolean enableBattleAxesRecipes = true; @ModConfigProperty(category = "Weapons", name = "enableBowsRecipes", comment = "Enable/Disable The ArmorPlus Bows's Recipes") public static boolean enableBowsRecipes = true; @ModConfigProperty(category = "Armors.SuperStarArmor.Effects", name = "enableSuperStarHRegen", comment = "Enable/Disable The Super Star Helmet Regeneration") </BUG> public static boolean enableSuperStarHRegen = true;
@ModConfigProperty(category = "Weapons", name = "enableSwordsRecipes", comment = "Enable/Disable ArmorPlus Sword's Recipes") @ModConfigProperty(category = "Weapons", name = "enableBattleAxesRecipes", comment = "Enable/Disable ArmorPlus Battle Axes's Recipes") @ModConfigProperty(category = "Weapons", name = "enableBowsRecipes", comment = "Enable/Disable ArmorPlus Bows's Recipes")
137
} else { updateMemo(); callback.updateMemo(); } dismiss(); <BUG>}else{ </BUG> Toast.makeText(getActivity(), getString(R.string.toast_memo_empty), Toast.LENGTH_SHORT).show(); } }
[DELETED]
138
} @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_memo); <BUG>ChinaPhoneHelper.setStatusBar(this,true); </BUG> topicId = getIntent().getLongExtra("topicId", -1); if (topicId == -1) { finish();
ChinaPhoneHelper.setStatusBar(this, true);
139
MemoEntry.COLUMN_REF_TOPIC__ID + " = ?" , new String[]{String.valueOf(topicId)}); } public Cursor selectMemo(long topicId) { Cursor c = db.query(MemoEntry.TABLE_NAME, null, MemoEntry.COLUMN_REF_TOPIC__ID + " = ?", new String[]{String.valueOf(topicId)}, null, null, <BUG>MemoEntry._ID + " DESC", null); </BUG> if (c != null) { c.moveToFirst(); }
MemoEntry.COLUMN_ORDER + " ASC", null);
140
MemoEntry._ID + " = ?", new String[]{String.valueOf(memoId)}); } public long updateMemoContent(long memoId, String memoContent) { ContentValues values = new ContentValues(); <BUG>values.put(MemoEntry.COLUMN_CONTENT, memoContent); return db.update(</BUG> MemoEntry.TABLE_NAME, values, MemoEntry._ID + " = ?",
return db.update(
141
import android.widget.RelativeLayout; import android.widget.TextView; import com.kiminonawa.mydiary.R; import com.kiminonawa.mydiary.db.DBManager; import com.kiminonawa.mydiary.shared.EditMode; <BUG>import com.kiminonawa.mydiary.shared.ThemeManager; import java.util.List; public class MemoAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements EditMode { </BUG> private List<MemoEntity> memoList;
import com.marshalchen.ultimaterecyclerview.dragsortadapter.DragSortAdapter; public class MemoAdapter extends DragSortAdapter<DragSortAdapter.ViewHolder> implements EditMode {
142
private DBManager dbManager; private boolean isEditMode = false; private EditMemoDialogFragment.MemoCallback callback; private static final int TYPE_HEADER = 0; private static final int TYPE_ITEM = 1; <BUG>public MemoAdapter(FragmentActivity activity, long topicId, List<MemoEntity> memoList, DBManager dbManager, EditMemoDialogFragment.MemoCallback callback) { this.mActivity = activity;</BUG> this.topicId = topicId; this.memoList = memoList;
public MemoAdapter(FragmentActivity activity, long topicId, List<MemoEntity> memoList, DBManager dbManager, EditMemoDialogFragment.MemoCallback callback, RecyclerView recyclerView) { super(recyclerView); this.mActivity = activity;
143
this.memoList = memoList; this.dbManager = dbManager; this.callback = callback; } @Override <BUG>public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { </BUG> View view; if (isEditMode) { if (viewType == TYPE_HEADER) {
public DragSortAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
144
editMemoDialogFragment.show(mActivity.getSupportFragmentManager(), "editMemoDialogFragment"); } }); } } <BUG>protected class MemoViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { private View rootView; private TextView TV_memo_item_content;</BUG> private ImageView IV_memo_item_delete;
protected class MemoViewHolder extends DragSortAdapter.ViewHolder implements View.OnClickListener, View.OnLongClickListener { private ImageView IV_memo_item_dot; private TextView TV_memo_item_content;
145
} @RootTask static Task<Exec.Result> exec(String parameter, int number) { Task<String> task1 = MyTask.create(parameter); Task<Integer> task2 = Adder.create(number, number + 2); <BUG>return Task.ofType(Exec.Result.class).named("exec", "/bin/sh") .in(() -> task1)</BUG> .in(() -> task2) .process(Exec.exec((str, i) -> args("/bin/sh", "-c", "\"echo " + i + "\""))); }
return Task.named("exec", "/bin/sh").ofType(Exec.Result.class) .in(() -> task1)
146
return args; } static class MyTask { static final int PLUS = 10; static Task<String> create(String parameter) { <BUG>return Task.ofType(String.class).named("MyTask", parameter) .in(() -> Adder.create(parameter.length(), PLUS))</BUG> .in(() -> Fib.create(parameter.length())) .process((sum, fib) -> something(parameter, sum, fib)); }
return Task.named("MyTask", parameter).ofType(String.class) .in(() -> Adder.create(parameter.length(), PLUS))
147
final String instanceField = "from instance"; final TaskContext context = TaskContext.inmem(); final AwaitingConsumer<String> val = new AwaitingConsumer<>(); @Test public void shouldJavaUtilSerialize() throws Exception { <BUG>Task<Long> task1 = Task.ofType(Long.class).named("Foo", "Bar", 39) .process(() -> 9999L); Task<String> task2 = Task.ofType(String.class).named("Baz", 40) .in(() -> task1)</BUG> .ins(() -> singletonList(task1))
Task<Long> task1 = Task.named("Foo", "Bar", 39).ofType(Long.class) Task<String> task2 = Task.named("Baz", 40).ofType(String.class) .in(() -> task1)
148
assertEquals(des.id().name(), "Baz"); assertEquals(val.awaitAndGet(), "[9999] hello 10004"); } @Test(expected = NotSerializableException.class) public void shouldNotSerializeWithInstanceFieldReference() throws Exception { <BUG>Task<String> task = Task.ofType(String.class).named("WithRef") .process(() -> instanceField + " causes an outer reference");</BUG> serialize(task); } @Test
Task<String> task = Task.named("WithRef").ofType(String.class) .process(() -> instanceField + " causes an outer reference");
149
serialize(task); } @Test public void shouldSerializeWithLocalReference() throws Exception { String local = instanceField; <BUG>Task<String> task = Task.ofType(String.class).named("WithLocalRef") .process(() -> local + " won't cause an outer reference");</BUG> serialize(task); Task<String> des = deserialize(); context.evaluate(des).consume(val);
Task<String> task = Task.named("WithLocalRef").ofType(String.class) .process(() -> local + " won't cause an outer reference");
150
} @RootTask public static Task<String> standardArgs(int first, String second) { firstInt = first; secondString = second; <BUG>return Task.ofType(String.class).named("StandardArgs", first, second) .process(() -> second + " " + first * 100);</BUG> } @Test public void shouldParseFlags() throws Exception {
return Task.named("StandardArgs", first, second).ofType(String.class) .process(() -> second + " " + first * 100);
151
assertThat(parsedEnum, is(CustomEnum.BAR)); } @RootTask public static Task<String> enums(CustomEnum enm) { parsedEnum = enm; <BUG>return Task.ofType(String.class).named("Enums", enm) .process(enm::toString);</BUG> } @Test public void shouldParseCustomTypes() throws Exception {
return Task.named("Enums", enm).ofType(String.class) .process(enm::toString);
152
assertThat(parsedType.content, is("blarg parsed for you!")); } @RootTask public static Task<String> customType(CustomType myType) { parsedType = myType; <BUG>return Task.ofType(String.class).named("Types", myType.content) .process(() -> myType.content);</BUG> } public enum CustomEnum { BAR
return Task.named("Types", myType.content).ofType(String.class) .process(() -> myType.content);
153
TaskContext taskContext = TaskContext.inmem(); TaskContext.Value<Long> value = taskContext.evaluate(fib92); value.consume(f92 -> System.out.println("fib(92) = " + f92)); } static Task<Long> create(long n) { <BUG>TaskBuilder<Long> fib = Task.ofType(Long.class).named("Fib", n); </BUG> if (n < 2) { return fib .process(() -> n);
TaskBuilder<Long> fib = Task.named("Fib", n).ofType(Long.class);
154
} public DNSClient(DNSCache dnsCache) { super(dnsCache); } @Override <BUG>protected DNSMessage newQuestion(DNSMessage message) { </BUG> message.setRecursionDesired(true); message.setOptPseudoRecord(dataSource.getUdpPayloadSize(), askForDnssec ? OPT.FLAG_DNSSEC_OK : 0); return message;
private boolean askForDnssec = false; private boolean disableResultFilter = false; public DNSClient() { super(); protected DNSMessage.Builder newQuestion(DNSMessage.Builder message) {
155
</BUG> DNSMessage.RESPONSE_CODE.NO_ERROR) { continue; } <BUG>for (Record record : message.getAnswers()) { </BUG> if (record.isAnswer(q)) { return message; } }
if (disableResultFilter) { if (message.responseCode != for (Record record : message.answers) {
156
public DNSMessage query(Question q, InetAddress address, int port) throws IOException { DNSMessage dnsMessage = (cache == null) ? null : cache.get(q); if (dnsMessage != null) { return dnsMessage; } <BUG>DNSMessage message = buildMessage(q); final Level TRACE_LOG_LEVEL = Level.FINE;</BUG> LOGGER.log(TRACE_LOG_LEVEL, "Asking {0} on {1} for {2} with:\n{3}", new Object[] { address, port, q, message }); try {
DNSMessage.Builder messageBuilder = buildMessage(q); DNSMessage message = messageBuilder.build(); final Level TRACE_LOG_LEVEL = Level.FINE;
157
cache.put(q, dnsMessage); } return dnsMessage; } protected boolean isResponseCacheable(Question q, DNSMessage dnsMessage) { <BUG>for (Record record : dnsMessage.getAnswers()) { </BUG> if (record.isAnswer(q)) { return true; }
for (Record record : dnsMessage.answers) {
158
return true; } } return false; } <BUG>final DNSMessage buildMessage(Question question) { DNSMessage message = new DNSMessage(); </BUG> message.setQuestions(question);
final DNSMessage.Builder buildMessage(Question question) { DNSMessage.Builder message = DNSMessage.builder();
159
message.setQuestions(question); message.setId(random.nextInt()); message = newQuestion(message); return message; } <BUG>protected abstract DNSMessage newQuestion(DNSMessage questionMessage); </BUG> public DNSMessage query(String name, TYPE type, CLASS clazz, InetAddress address, int port) throws IOException { Question q = new Question(name, type, clazz);
protected abstract DNSMessage.Builder newQuestion(DNSMessage.Builder questionMessage);
160
} <BUG>return r.toString(); } } </BUG>
public void setArray(List<FieldSampler> base) { this.base = Lists.newArrayList(base);
161
<BUG>package org.apache.drill.synth; import org.apache.mahout.common.RandomUtils;</BUG> import org.apache.mahout.math.jet.random.Exponential; import java.text.SimpleDateFormat; import java.util.GregorianCalendar;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; import org.apache.mahout.common.RandomUtils;
162
package org.apache.drill.synth; import com.fasterxml.jackson.annotation.JsonSubTypes; <BUG>import com.fasterxml.jackson.annotation.JsonTypeInfo; import org.apache.mahout.math.random.Sampler;</BUG> @JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="class") @JsonSubTypes({ @JsonSubTypes.Type(value=AddressSampler.class, name="address"),
import com.fasterxml.jackson.databind.JsonNode; import org.apache.mahout.math.random.Sampler;
163
@JsonSubTypes.Type(value=LanguageSampler.class, name="language"), @JsonSubTypes.Type(value=OperatingSystemSampler.class, name="os"), @JsonSubTypes.Type(value=WordSampler.class, name="word"), @JsonSubTypes.Type(value=SequenceSampler.class, name="sequence") }) <BUG>public abstract class FieldSampler implements Sampler<String> { </BUG> private String name; public String getName() { return name;
public abstract class FieldSampler implements Sampler<JsonNode> {
164
<BUG>package org.apache.drill.synth; import com.google.common.base.CharMatcher;</BUG> import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.base.Splitter;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; import com.google.common.base.CharMatcher;
165
<BUG>package org.apache.drill.synth; public class IdSampler extends FieldSampler {</BUG> private int current = 0; public IdSampler() { }
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.IntNode; public class IdSampler extends FieldSampler {
166
public class IdSampler extends FieldSampler {</BUG> private int current = 0; public IdSampler() { } @Override <BUG>public String sample() { return Integer.toString(current++); }</BUG> public void setStart(int start) {
package org.apache.drill.synth; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.IntNode; public class IdSampler extends FieldSampler { public JsonNode sample() { return new IntNode(current++);
167
import org.apache.mahout.common.RandomUtils;</BUG> import java.util.Random; public class IntegerSampler extends FieldSampler { private int min = 0; <BUG>private int max = 100; private Random base;</BUG> public IntegerSampler() { base = RandomUtils.getRandom(); } public void setMax(int max) {
package org.apache.drill.synth; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.IntNode; import org.apache.mahout.common.RandomUtils; private int power = 0; private Random base;
168
<BUG>package org.apache.drill.synth; public class AddressSampler extends FieldSampler {</BUG> private final StreetNameSampler street; private final ForeignKeySampler number; public AddressSampler() {
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; public class AddressSampler extends FieldSampler {
169
public AddressSampler() { street = new StreetNameSampler(); number = new ForeignKeySampler(100000, 0.5); } @Override <BUG>public String sample() { return number.sample() + " " + street.sample(); </BUG> }
[DELETED]
170
package org.apache.drill.synth; <BUG>import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.google.common.base.Preconditions;</BUG> import org.apache.mahout.math.random.Multinomial; @JsonIgnoreProperties({"base"}) public class ForeignKeySampler extends FieldSampler {
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.IntNode; import com.google.common.base.Preconditions;
171
<BUG>package org.apache.drill.synth; import com.google.common.base.Charsets;</BUG> import com.google.common.base.Preconditions; import com.google.common.base.Splitter; import com.google.common.io.Resources;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; import com.google.common.base.Charsets;
172
package org.apache.drill.synth; <BUG>import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Function;</BUG> import com.google.common.collect.Lists; import org.apache.mahout.math.random.Sampler;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Function;
173
import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Function;</BUG> import com.google.common.collect.Lists; import org.apache.mahout.math.random.Sampler; import java.io.File; <BUG>import java.io.IOException; import java.util.List; public class SchemaSampler implements Sampler<List<String>> { private final List<FieldSampler> schema;</BUG> private final List<String> fields;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Function; import java.util.Iterator; public class SchemaSampler implements Sampler<JsonNode> { private final JsonNodeFactory nodeFactory = JsonNodeFactory.withExactBigDecimals(false); private final List<FieldSampler> schema;
174
<BUG>package org.apache.drill.synth; import com.google.common.base.Charsets;</BUG> import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.io.Resources;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; import com.google.common.base.Charsets;
175
assertThat(e).hasMessageContaining("'10'"); assertThat(e.getMessage()).doesNotContain("cellInput"); } } protected DmnEngine createEngineWithDefaultExpressionLanguage(String expressionLanguage) { <BUG>DmnEngineConfiguration configuration = getDmnEngineConfiguration(); </BUG> configuration.setDefaultInputExpressionExpressionLanguage(expressionLanguage); configuration.setDefaultInputEntryExpressionLanguage(expressionLanguage); configuration.setDefaultOutputEntryExpressionLanguage(expressionLanguage);
DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
176
return feelEngine; } public String getDefaultInputEntryExpressionLanguage() { return defaultInputEntryExpressionLanguage; } <BUG>public void setDefaultInputEntryExpressionLanguage(String defaultInputEntryExpressionLanguage) { this.defaultInputEntryExpressionLanguage = defaultInputEntryExpressionLanguage; }</BUG> public DmnEngineConfiguration defaultInputEntryExpressionLanguage(String expressionLanguage) { setDefaultInputEntryExpressionLanguage(expressionLanguage);
public void setDefaultInputEntryExpressionLanguage(String expressionLanguage) { this.defaultInputEntryExpressionLanguage = expressionLanguage;
177
verify(feelEngine, atLeastOnce()) .evaluateSimpleUnaryTests(anyString(), anyString(), any(VariableContext.class)); } @Test public void testFeelAlternativeName() { <BUG>DmnEngineConfiguration configuration = getDmnEngineConfiguration(); </BUG> configuration.setDefaultInputEntryExpressionLanguage("feel"); DmnEngine dmnEngine = configuration.buildEngine(); assertExample(dmnEngine);
DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
178
verify(feelEngine).evaluateSimpleExpression(anyString(), any(VariableContext.class)); } } @Test public void testFeelOutputEntry() { <BUG>DmnEngineConfiguration configuration = getDmnEngineConfiguration(); </BUG> configuration.setDefaultOutputEntryExpressionLanguage(DefaultDmnEngineConfiguration.FEEL_EXPRESSION_LANGUAGE); DmnEngine engine = configuration.buildEngine(); try {
DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
179
import org.spongepowered.api.world.Locatable; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; import javax.annotation.Nullable; import java.util.List; <BUG>import java.util.Optional; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG> public class CommandDelete extends FCCommandBase { private static final FlagMapper MAPPER = map -> key -> value -> { map.put(key, value);
import java.util.stream.Stream; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
180
.append(Text.of(TextColors.GREEN, "Usage: ")) .append(getUsage(source)) .build()); return CommandResult.empty(); } else if (isIn(REGIONS_ALIASES, parse.args[0])) { <BUG>if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!")); IRegion region = FGManager.getInstance().getRegion(parse.args[1]); </BUG> boolean isWorldRegion = false; if (region == null) {
String regionName = parse.args[1]; IRegion region = FGManager.getInstance().getRegion(regionName).orElse(null);
181
</BUG> isWorldRegion = true; } if (region == null) <BUG>throw new CommandException(Text.of("No region exists with the name \"" + parse.args[1] + "\"!")); if (region instanceof GlobalWorldRegion) { </BUG> throw new CommandException(Text.of("You may not delete the global region!")); }
if (world == null) throw new CommandException(Text.of("No world exists with name \"" + worldName + "\"!")); if (world == null) throw new CommandException(Text.of("Must specify a world!")); region = FGManager.getInstance().getWorldRegion(world, regionName).orElse(null); throw new CommandException(Text.of("No region exists with the name \"" + regionName + "\"!")); if (region instanceof IGlobal) {
182
source.getName() + " deleted " + (isWorldRegion ? "world" : "") + "region" ); return CommandResult.success(); } else if (isIn(HANDLERS_ALIASES, parse.args[0])) { if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!")); <BUG>IHandler handler = FGManager.getInstance().gethandler(parse.args[1]); if (handler == null) throw new ArgumentParseException(Text.of("No handler exists with that name!"), parse.args[1], 1); if (handler instanceof GlobalHandler)</BUG> throw new CommandException(Text.of("You may not delete the global handler!"));
Optional<IHandler> handlerOpt = FGManager.getInstance().gethandler(parse.args[1]); if (!handlerOpt.isPresent()) IHandler handler = handlerOpt.get(); if (handler instanceof GlobalHandler)
183
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
184
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
185
@Dependency(id = "foxcore") }, description = "A world protection plugin built for SpongeAPI. Requires FoxCore.", authors = {"gravityfox"}, url = "https://github.com/FoxDenStudio/FoxGuard") <BUG>public final class FoxGuardMain { public final Cause pluginCause = Cause.builder().named("plugin", this).build(); private static FoxGuardMain instanceField;</BUG> @Inject private Logger logger;
private static FoxGuardMain instanceField;
186
private UserStorageService userStorage; private EconomyService economyService = null; private boolean loaded = false; private FCCommandDispatcher fgDispatcher; public static FoxGuardMain instance() { <BUG>return instanceField; }</BUG> @Listener public void construct(GameConstructionEvent event) { instanceField = this;
} public static Cause getCause() { return instance().pluginCause; }
187
return configDirectory; } public boolean isLoaded() { return loaded; } <BUG>public static Cause getCause() { return instance().pluginCause; }</BUG> public EconomyService getEconomyService() { return economyService;
[DELETED]
188
import org.spongepowered.api.world.Locatable; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; import javax.annotation.Nullable; import java.util.*; <BUG>import java.util.stream.Collectors; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG> public class CommandHere extends FCCommandBase { private static final String[] PRIORITY_ALIASES = {"priority", "prio", "p"}; private static final FlagMapper MAPPER = map -> key -> value -> {
import java.util.stream.Stream; import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
189
.excludeCurrent(true) .autoCloseQuotes(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "handler").stream() .filter(new StartsWithPredicate(parse.current.token))</BUG> .map(args -> parse.current.prefix + args) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index > 0) {
return Stream.of("region", "handler") .filter(new StartsWithPredicate(parse.current.token))
190
private static FGStorageManager instance; private final Logger logger = FoxGuardMain.instance().getLogger();</BUG> private final Set<LoadEntry> loaded = new HashSet<>(); private final Path directory = getDirectory(); private final Map<String, Path> worldDirectories; <BUG>private FGStorageManager() { defaultModifiedMap = new CacheMap<>((k, m) -> {</BUG> if (k instanceof IFGObject) { m.put((IFGObject) k, true); return true;
public final HashMap<IFGObject, Boolean> defaultModifiedMap; private final UserStorageService userStorageService; private final Logger logger = FoxGuardMain.instance().getLogger(); userStorageService = FoxGuardMain.instance().getUserStorage(); defaultModifiedMap = new CacheMap<>((k, m) -> {
191
String name = fgObject.getName(); Path singleDir = dir.resolve(name.toLowerCase()); </BUG> boolean shouldSave = fgObject.shouldSave(); if (force || shouldSave) { <BUG>logger.info((shouldSave ? "S" : "Force s") + "aving handler \"" + name + "\" in directory: " + singleDir); </BUG> constructDirectory(singleDir); try { fgObject.save(singleDir);
UUID owner = fgObject.getOwner(); boolean isOwned = !owner.equals(SERVER_UUID); Optional<User> userOwner = userStorageService.get(owner); String logName = (userOwner.isPresent() ? userOwner.get().getName() + ":" : "") + (isOwned ? owner + ":" : "") + name; if (fgObject.autoSave()) { Path singleDir = serverDir.resolve(name.toLowerCase()); logger.info((shouldSave ? "S" : "Force s") + "aving handler " + logName + " in directory: " + singleDir);
192
if (fgObject.autoSave()) { Path singleDir = dir.resolve(name.toLowerCase()); </BUG> boolean shouldSave = fgObject.shouldSave(); if (force || shouldSave) { <BUG>logger.info((shouldSave ? "S" : "Force s") + "aving world region \"" + name + "\" in directory: " + singleDir); </BUG> constructDirectory(singleDir); try { fgObject.save(singleDir);
Path singleDir = serverDir.resolve(name.toLowerCase()); logger.info((shouldSave ? "S" : "Force s") + "aving world region " + logName + " in directory: " + singleDir);
193
public synchronized void loadRegionLinks() { logger.info("Loading region links"); try (DB mainDB = DBMaker.fileDB(directory.resolve("regions.foxdb").normalize().toString()).make()) { Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen(); linksMap.entrySet().forEach(entry -> { <BUG>IRegion region = FGManager.getInstance().getRegion(entry.getKey()); if (region != null) { logger.info("Loading links for region \"" + region.getName() + "\"");</BUG> String handlersString = entry.getValue();
Optional<IRegion> regionOpt = FGManager.getInstance().getRegion(entry.getKey()); if (regionOpt.isPresent()) { IRegion region = regionOpt.get(); logger.info("Loading links for region \"" + region.getName() + "\"");
194
public synchronized void loadWorldRegionLinks(World world) { logger.info("Loading world region links for world \"" + world.getName() + "\""); try (DB mainDB = DBMaker.fileDB(worldDirectories.get(world.getName()).resolve("wregions.foxdb").normalize().toString()).make()) { Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen(); linksMap.entrySet().forEach(entry -> { <BUG>IRegion region = FGManager.getInstance().getWorldRegion(world, entry.getKey()); if (region != null) { logger.info("Loading links for world region \"" + region.getName() + "\"");</BUG> String handlersString = entry.getValue();
Optional<IWorldRegion> regionOpt = FGManager.getInstance().getWorldRegion(world, entry.getKey()); if (regionOpt.isPresent()) { IWorldRegion region = regionOpt.get(); logger.info("Loading links for world region \"" + region.getName() + "\"");
195
StringBuilder builder = new StringBuilder(); for (Iterator<IHandler> it = handlers.iterator(); it.hasNext(); ) { builder.append(it.next().getName()); if (it.hasNext()) builder.append(","); } <BUG>return builder.toString(); }</BUG> private final class LoadEntry { public final String name; public final Type type;
public enum Type { REGION, WREGION, HANDLER
196
.autoCloseQuotes(true) .leaveFinalAsIs(true) .parse(); if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) { if (parse.current.index == 0) <BUG>return ImmutableList.of("region", "worldregion", "handler", "controller").stream() </BUG> .filter(new StartsWithPredicate(parse.current.token)) .collect(GuavaCollectors.toImmutableList()); else if (parse.current.index == 1) {
return Stream.of("region", "worldregion", "handler", "controller")
197
public ReportElement getBase() { return base; } @Override public float print(PDDocument document, PDPageContentStream stream, int pageNumber, float startX, float startY, float allowedWidth) throws IOException { <BUG>PDPage currPage = (PDPage) document.getDocumentCatalog().getPages().get(pageNo); PDPageContentStream pageStream = new PDPageContentStream(document, currPage, true, false); </BUG> base.print(document, pageStream, pageNo, x, y, width); pageStream.close();
PDPage currPage = document.getDocumentCatalog().getPages().get(pageNo); PDPageContentStream pageStream = new PDPageContentStream(document, currPage, PDPageContentStream.AppendMode.APPEND, false);
198
public PdfTextStyle(String config) { Assert.hasText(config); String[] split = config.split(","); Assert.isTrue(split.length == 3, "config must look like: 10,Times-Roman,#000000"); fontSize = Integer.parseInt(split[0]); <BUG>font = resolveStandard14Name(split[1]); color = new Color(Integer.valueOf(split[2].substring(1), 16));</BUG> } public int getFontSize() { return fontSize;
font = getFont(split[1]); color = new Color(Integer.valueOf(split[2].substring(1), 16));
199
package cc.catalysts.boot.report.pdf.elements; import cc.catalysts.boot.report.pdf.config.PdfTextStyle; import cc.catalysts.boot.report.pdf.utils.ReportAlignType; import org.apache.pdfbox.pdmodel.PDPageContentStream; <BUG>import org.apache.pdfbox.pdmodel.font.PDFont; import org.slf4j.Logger;</BUG> import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; import java.io.IOException;
import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.util.Matrix; import org.slf4j.Logger;
200
addTextSimple(stream, textConfig, textX, nextLineY, ""); return nextLineY; } try { <BUG>String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, fixedText); </BUG> float x = calculateAlignPosition(textX, align, textConfig, allowedWidth, split[0]); if (!underline) { addTextSimple(stream, textConfig, x, nextLineY, split[0]); } else {
String[] split = splitText(textConfig.getFont(), textConfig.getFontSize(), allowedWidth, text);