auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public synchronized ITmfStateInterval doSingularQuery(long t, int attributeQuark) <END> throws TimeRangeException, StateSystemDisposedException { ITmfStateInterval ret = super.doSingularQuery(t, attributeQuark); if (ret != null) { return ret; } for (HTInterval interval : fCurrentChunk) { if (interval.getAttribute() == attributeQuark && interval.intersects(t)) { return interval; } } for (Iterable<HTInterval> intervals : intervalQueue) { for (HTInterval interval : intervals) { if (interval.getAttribute() == attributeQuark && interval.intersects(t)) { return interval; } } } return super.doSingularQuery(t, attributeQuark); }</code><technical_language>ugh, blocking insertions while iterating do a query a huge slowdown. needs locking in here, abstracted nicely in a separate "BufferedBlockingQueue" class</technical_language>

Target:
public ITmfStateInterval doSingularQuery(long t, int attributeQuark) throws TimeRangeException, StateSystemDisposedException { ITmfStateInterval ret = super.doSingularQuery(t, attributeQuark); if (ret != null) { return ret; } fRwl.readLock().lock(); for (HTInterval interval : fCurrentChunk) { if (interval.getAttribute() == attributeQuark && interval.intersects(t)) { return interval; } } fRwl.readLock().unlock(); for (Iterable<HTInterval> intervals : intervalQueue) { for (HTInterval interval : intervals) { if (interval.getAttribute() == attributeQuark && interval.intersects(t)) { return interval; } } } return super.doSingularQuery(t, attributeQuark); }
Source:
<code>public AsyncDataToken execute(ExecutorService executor) throws QueryStoreException { if (!validate()) { <START> throw new QueryStoreException(QueryStoreException.ErrorCode.NO_SUCH_TABLE, "Table/s not found"); <END> } executor.submit(this); return new AsyncDataToken(cacheToken, cacheKey()); }</code><technical_language>validate throw exception instead of throwing ErrorCode for validation failures</technical_language>

Target:
public AsyncDataToken execute(ExecutorService executor) throws QueryStoreException { validate(); executor.submit(this); return new AsyncDataToken(cacheToken, cacheKey()); }
Source:
<code>private IgniteCache<RowColMatrixKey, Map<Integer, Double>> newCache() { CacheConfiguration<RowColMatrixKey, Map<Integer, Double>> cfg = new CacheConfiguration<>(); cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC); cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); cfg.setEvictionPolicy(null); cfg.setCopyOnRead(false); cfg.setCacheMode(CacheMode.PARTITIONED); <START> cfg.setReadFromBackup(false); <END> cfg.setName(CACHE_NAME); return Ignition.localIgnite().getOrCreateCache(cfg); }</code><technical_language>Please describe this change problem is a lot of Java copy-paste configs for primitives in 1.0 release unified configuration avoid strange cluster effects Do a test for this case</technical_language>

Target:
private IgniteCache<RowColMatrixKey, Map<Integer, Double>> newCache() { CacheConfiguration<RowColMatrixKey, Map<Integer, Double>> cfg = new CacheConfiguration<>(); cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC); cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); cfg.setEvictionPolicy(null); cfg.setCopyOnRead(false); cfg.setCacheMode(CacheMode.PARTITIONED); cfg.setName(CACHE_NAME); return Ignition.localIgnite().getOrCreateCache(cfg); }
Source:
<code>public void LightboxTest_011_filepage_image() { WikiBasePageObject base = new WikiBasePageObject(driver); SpecialNewFilesPageObject specialNewFiles = base.openSpecialNewFiles(wikiURL); int itemNumber = 0; String fileUrl = specialNewFiles.getFileUrl(wikiURL, itemNumber); LightboxComponentObject lightbox = specialNewFiles.openLightboxForGridVideo(itemNumber); lightbox.verifyLightboxPopup(); lightbox.verifyLightboxImage(); lightbox.verifyTitleUrl(fileUrl); <START> lightbox.verifyMoreInfoUrl(fileUrl); <END> FilePagePageObject filePage = lightbox.clickTitle(); filePage.verifyTabsExistImage(); }</code><technical_language>need line, verifyTitleUrl is checking that. point1</technical_language>

Target:
public void LightboxTest_011_filepage_image() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL); SpecialNewFilesPageObject specialNewFiles = base.openSpecialNewFiles(wikiURL); int itemNumber = 0; String fileUrl = specialNewFiles.getFileUrl(wikiURL, itemNumber); LightboxComponentObject lightbox = specialNewFiles.openLightbox(itemNumber); lightbox.verifyLightboxPopup(); lightbox.verifyLightboxImage(); FilePagePageObject filePage = lightbox.clickTitle(); filePage.verifyTabsExistImage(); }
Source:
<code>public static String validatePathCapabilityArgs( final Path path, final String capability) { checkArgument(path != null, "null path"); checkArgument(capability != null && !capability.isEmpty(), <START> "null/empty capability"); <END> return capability.toLowerCase(Locale.ENGLISH); }</code><technical_language>form a proper sentence there? I wondering helpful audience side distinguish null empty case (moving a separate checkArgument)</technical_language>

Target:
public static String validatePathCapabilityArgs( final Path path, final String capability) { checkArgument(path != null, "null path"); checkArgument(capability != null, "capability parameter is null"); checkArgument(!capability.isEmpty(), "capability parameter is empty string"); return capability.toLowerCase(Locale.ENGLISH); }
Source:
<code>private void startWarmup() { try { long start = System.nanoTime(); pageCacheWarmer.reheat().ifPresent( pagesLoaded -> { long elapsedMillis = NANOSECONDS.toMillis( System.nanoTime() - start ); monitor.warmupCompleted( elapsedMillis, pagesLoaded ); log.debug( "Active page cache warmup took " + Format.duration( elapsedMillis ) + <START> " to load " + pagesLoaded + " pages." ); <END> } ); } catch ( Exception e ) { log.debug( "Active page cache warmup failed, " + "so it may take longer for the cache to be populated with hot data.", e ); } scheduleProfile(); }</code><technical_language>this timing logging PageCacheWarmer#reheat? PageCacheWarmerKernelExtension is other place call this contains identical logging logic, a instance of Monitor</technical_language>

Target:
private void startWarmup() { if ( !available ) { return; } try { pageCacheWarmer.reheat().ifPresent( monitor::warmupCompleted ); } catch ( Exception e ) { log.debug( "Active page cache warmup failed, " + "so it may take longer for the cache to be populated with hot data.", e ); } scheduleProfile(); }
Source:
<code>public void rollbackToSavepoint(String name, GridNearTxLocal tx) throws IgniteCheckedException { assert tx != null; ListIterator<TxSavepoint> spIter = findSP(name); if (spIter == null) <START> throw new IllegalArgumentException("No such savepoint."); <END> rollbackToSavepoint(spIter.next(), tx); releaseNextSPs(spIter); }</code><technical_language>IgniteCheckedException here</technical_language>

Target:
public void rollbackToSavepoint(String name, GridNearTxLocal tx) throws IgniteCheckedException { assert name != null; assert tx != null; ListIterator<TxSavepoint> spIter = findSP(name); if (spIter == null) throw new IllegalArgumentException("No such savepoint. [name=" + name + ']'); rollbackToSavepoint(spIter.next(), tx); savepoints.subList(spIter.nextIndex(), savepoints.size()).clear(); }
Source:
<code>public void testMultiConditionalBind_cat() { props.setProperty("animal.type", "cat"); Injector injector = Guice.createInjector(new Module() { @Override public void configure(Binder binder) { ConditionalMultibind.create(props, binder, Animal.class) .conditionBinder(ANIMAL_TYPE, Predicates.equalTo("cat"), Cat.class) .conditionBinder(ANIMAL_TYPE, Predicates.equalTo("dog"), Dog.class); } }); <START> Set<Animal> animalSet = injector.getInstance(Key.get(new TypeLiteral<Set<Animal>>(){})); <END> Assert.assertEquals(1, animalSet.size()); Assert.assertEquals(animalSet, ImmutableSet.<Animal>of(new Cat())); }</code><technical_language>if object java class PetShopAvails { @Inject Set<Animals> animals; } call java PetShopAvails shop = new PetShopAvails(); injector.inject(shop); fill in animals set appropriately</technical_language>

Target:
public void testMultiConditionalBind_cat() { props.setProperty("animal.type", "cat"); Injector injector = Guice.createInjector(new Module() { @Override public void configure(Binder binder) { ConditionalMultibind.create(props, binder, Animal.class) .addConditionBinding(ANIMAL_TYPE, Predicates.equalTo("cat"), Cat.class) .addConditionBinding(ANIMAL_TYPE, Predicates.equalTo("dog"), Dog.class); } }); Set<Animal> animalSet = injector.getInstance(Key.get(new TypeLiteral<Set<Animal>>() { })); Assert.assertEquals(1, animalSet.size()); Assert.assertEquals(animalSet, ImmutableSet.<Animal>of(new Cat())); }
Source:
<code>public void executeStoredProcedureWithScriptLoggingEnabled() throws Exception { CosmosStoredProcedureProperties storedProcedure = new CosmosStoredProcedureProperties( UUID.randomUUID().toString(), "function() {" + " var mytext = \"x\";" + " var myval = 1;" + " try {" + " console.log(\"The value of %s is %s.\", mytext, myval);" + " getContext().getResponse().setBody(\"Success!\");" + " }" + " catch(err) {" + " getContext().getResponse().setBody(\"inline err: [\" + err.number + \"] \" + err);" + " }" + "}"); container.getScripts().createStoredProcedure(storedProcedure); CosmosStoredProcedureRequestOptions options = new CosmosStoredProcedureRequestOptions(); options.setScriptLoggingEnabled(true); options.setPartitionKey(PartitionKey.NONE); CosmosStoredProcedureResponse executeResponse = container.getScripts() .getStoredProcedure(storedProcedure.getId()) .execute(null, options); String logResult = "The value of x is 1."; <START> assertThat(URLDecoder.decode(executeResponse.getScriptLog(), StandardCharsets.UTF_8)).isEqualTo(logResult); <END> }</code><technical_language>I job is do decoding? is SDK job decode scriptLog user</technical_language>

Target:
public void executeStoredProcedureWithScriptLoggingEnabled() throws Exception { CosmosStoredProcedureProperties storedProcedure = new CosmosStoredProcedureProperties( UUID.randomUUID().toString(), "function() {" + " var mytext = \"x\";" + " var myval = 1;" + " try {" + " console.log(\"The value of %s is %s.\", mytext, myval);" + " getContext().getResponse().setBody(\"Success!\");" + " }" + " catch(err) {" + " getContext().getResponse().setBody(\"inline err: [\" + err.number + \"] \" + err);" + " }" + "}"); container.getScripts().createStoredProcedure(storedProcedure); CosmosStoredProcedureRequestOptions options = new CosmosStoredProcedureRequestOptions(); options.setScriptLoggingEnabled(true); options.setPartitionKey(PartitionKey.NONE); CosmosStoredProcedureResponse executeResponse = container.getScripts() .getStoredProcedure(storedProcedure.getId()) .execute(null, options); String logResult = "The value of x is 1."; assertThat(executeResponse.getScriptLog()).isEqualTo(logResult); }
Source:
<code>public void testEqualityAndCopyConstructor() { RankedBitVectorImpl bv0 = new RankedBitVectorImpl(); for (int i = 0; i < 0x100000; i++) { boolean value = (i % 3) == 0; bv0.addBit(value); } RankedBitVectorImpl bv1 = new RankedBitVectorImpl(); for (int i = 0; i < 0x100000; i++) { boolean value = (i % 3) == 0; bv1.addBit(value); } assertEqualsForBitVector(bv0, bv1); bv1.setBit(0x12345, false); Assert.assertFalse(bv0.equals(bv1)); Assert.assertFalse(bv1.equals(bv0)); bv1.setBit(0x12346, true); Assert.assertFalse(bv0.equals(bv1)); Assert.assertFalse(bv1.equals(bv0)); RankedBitVectorImpl bv2 = new RankedBitVectorImpl(bv1); for (int i = 0; i < 0x100000; i++) { boolean value = (i % 3) == 0; bv1.addBit(value); <START> } <END> bv2.setBit(0x12345, true); Assert.assertFalse(bv0.equals(bv2)); Assert.assertFalse(bv2.equals(bv0)); Assert.assertFalse(bv1.equals(bv2)); Assert.assertFalse(bv2.equals(bv1)); bv2.setBit(0x12346, false); assertEqualsForBitVector(bv0, bv2); for (int i = 0; i < 0x100000; i++) { if ((i % 0x6785) == 0) { assertCorrectCount(bv2, i); } } }</code><technical_language>do do this? honest, test is a bit unclear me. change a bit assert result is longer equal -- fine -- change another bit check if is equals. if bitvectors random, unequal, checking for inequality times changes a useful test</technical_language>

Target:
public void testEqualityAndCopyConstructor() { final long aLargeNumber = 0x100000; RankedBitVectorImpl bv0 = new RankedBitVectorImpl(); RankedBitVectorImpl bv1 = new RankedBitVectorImpl(); PseudorandomBooleanGenerator generator = new PseudorandomBooleanGenerator( 0x1234); for (int i = 0; i < aLargeNumber; i++) { boolean value = generator.getPseudorandomBoolean(); bv0.addBit(value); bv1.addBit(value); } assertEqualsForBitVector(bv0, bv1); RankedBitVectorImpl bv2 = new RankedBitVectorImpl(bv1); assertEqualsForBitVector(bv0, bv2); }
Source:
<code>public AuditAssociationQuery<? extends AuditAssociationQuery<Q>> traverseRelation( String associationName, JoinType joinType, String alias) { <START> AbstractAuditAssociationQuery<AbstractAuditAssociationQuery<Q>> result = associationQueryMap.get(associationName ); <END> if ( result == null ) { result = new EntitiesAtRevisionAssociationQuery<>( enversService, auditReader, this, queryBuilder, associationName, joinType, aliasToEntityNameMap, this.alias, alias ); associationQueries.add( (EntitiesAtRevisionAssociationQuery<Q>) result ); associationQueryMap.put( associationName, result ); } return result; }</code><technical_language>insert a " " get(, a big deal</technical_language>

Target:
public AuditAssociationQuery<? extends AuditAssociationQuery<Q>> traverseRelation( String associationName, JoinType joinType, String alias) { return associationQueryMap.computeIfAbsent( associationName, name -> { AbstractAuditAssociationQuery<AbstractAuditAssociationQuery<Q>> query = new EntitiesAtRevisionAssociationQuery<>( enversService, auditReader, this, queryBuilder, associationName, joinType, aliasToEntityNameMap, this.alias, alias ); associationQueries.add( query ); return query; } ); }
Source:
<code>public LatLng androidGeocode(String addressText) { List<Address> addresses; Geocoder g = new Geocoder(this.context); try { addresses = g.getFromLocationName(addressText, 10); } catch (IOException e) { e.printStackTrace(); return null; } double iRadius, iLat, iLng; try { iRadius = currentInstance.getRadius(); iLat = currentInstance.getLat(); iLng = currentInstance.getLon(); } catch (Exception e) { e.printStackTrace(); Log.e(App.LOG_TAG, "Required instance data not found. Exiting android geocoder", e); return null; <START> } <END> for (Address address : addresses) { float[] results = new float[1]; Location.distanceBetween(iLat, iLng, address.getLatitude(), address.getLongitude(), results); if (results[0] <= iRadius) { return new LatLng(address.getLatitude(), address.getLongitude()); } } return null; }</code><technical_language>I accessing values a try catch. values _should_ set, if a failure of build tooling. this is a tricky bug spot, fail in a noticeable if incorrect configuration, fail in a silent way</technical_language>

Target:
public LatLng androidGeocode(String addressText) { List<Address> addresses; Geocoder g = new Geocoder(this.context); try { addresses = g.getFromLocationName(addressText, 10); } catch (IOException e) { e.printStackTrace(); return null; } double instanceRadius, instanceLat, instanceLng; try { instanceRadius = currentInstance.getRadius(); instanceLat = currentInstance.getLat(); instanceLng = currentInstance.getLon(); } catch (Exception e) { Log.e(App.LOG_TAG, "Required instance data not found. Exiting android geocoder", e); return null; } for (Address address : addresses) { float[] results = new float[1]; Location.distanceBetween(instanceLat, instanceLng, address.getLatitude(), address.getLongitude(), results); if (results[0] <= instanceRadius) { return new LatLng(address.getLatitude(), address.getLongitude()); } } return null; }
Source:
<code>public ICompletableFuture<V> getAsync(K key) { checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED); <START> return new DelegatingFuture<V>(getAsyncInternal(key), getSerializationService()); <END> }</code><technical_language>this get additional object invocation? If so, in favor of merging this pr</technical_language>

Target:
public ICompletableFuture<V> getAsync(K key) { checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED); return new ClientDelegatingFuture<V>(getAsyncInternal(key), getSerializationService(), GET_ASYNC_RESPONSE_DECODER); }
Source:
<code>private boolean init(ChangeBoundsRequest request, GraphicalEditPart hostGraphicalEditPart) { List<?> editParts = request.getEditParts(); <START> DDiagram parentDiagram = (DDiagram) hostGraphicalEditPart.getNotationView().getDiagram().getElement(); boolean layoutingModeActivated = parentDiagram.isIsInLayoutingMode(); <END> for (Object editPart : editParts) { if (editPart instanceof DragAndDropWrapper) { DragAndDropWrapper dragAndDropWrapperToDrop = (DragAndDropWrapper) editPart; elementsFromEclipseViewToDrop.add(dragAndDropWrapperToDrop); } else if (editPart instanceof IGraphicalEditPart) { IGraphicalEditPart graphicalEditPartToDrop = (IGraphicalEditPart) editPart; if (!(graphicalEditPartToDrop.getParent() == hostGraphicalEditPart || hostGraphicalEditPart instanceof CompartmentEditPart && graphicalEditPartToDrop.getParent() == hostGraphicalEditPart.getParent()) && graphicalEditPartToDrop.resolveSemanticElement() instanceof DSemanticDecorator) { EObject elementFromDiagramToDrop = graphicalEditPartToDrop.resolveSemanticElement(); DDiagramElement dDiagramElementTopDrop = (DDiagramElement) elementFromDiagramToDrop; elementsFromDiagramToDrop.add(dDiagramElementTopDrop); editPartsFromDiagramToDrop.add(graphicalEditPartToDrop); if (layoutingModeActivated && graphicalEditPartToDrop instanceof IDiagramBorderNodeEditPart) { return false; } } } } return true; }</code><technical_language>rewritten</technical_language>

Target:
private boolean init(ChangeBoundsRequest request, GraphicalEditPart hostGraphicalEditPart) { List<?> editParts = request.getEditParts(); for (Object editPart : editParts) { if (editPart instanceof DragAndDropWrapper) { DragAndDropWrapper dragAndDropWrapperToDrop = (DragAndDropWrapper) editPart; elementsFromEclipseViewToDrop.add(dragAndDropWrapperToDrop); } else if (editPart instanceof IGraphicalEditPart) { IGraphicalEditPart graphicalEditPartToDrop = (IGraphicalEditPart) editPart; if (!(graphicalEditPartToDrop.getParent() == hostGraphicalEditPart || hostGraphicalEditPart instanceof CompartmentEditPart && graphicalEditPartToDrop.getParent() == hostGraphicalEditPart.getParent()) && graphicalEditPartToDrop.resolveSemanticElement() instanceof DSemanticDecorator) { EObject elementFromDiagramToDrop = graphicalEditPartToDrop.resolveSemanticElement(); DDiagramElement dDiagramElementTopDrop = (DDiagramElement) elementFromDiagramToDrop; elementsFromDiagramToDrop.add(dDiagramElementTopDrop); editPartsFromDiagramToDrop.add(graphicalEditPartToDrop); if (isInLayoutingMode(hostGraphicalEditPart) && graphicalEditPartToDrop instanceof IDiagramBorderNodeEditPart) { return false; } } } } return true; }
Source:
<code>public int compareTo(final DayProfile other) { <START> return other.dayId.compareTo(this.dayId); <END> }</code><technical_language>Is reversed comparison intentional</technical_language>

Target:
public int compareTo(final DayProfile other) { return this.dayId.compareTo(other.dayId); }
Source:
<code>public void testSubstVarsTwoLevelsWithDefault() { context.putProperty("APP_NAME", "LOGBACK"); context.putProperty("ARCHIVE_SUFFIX", "archive.log"); context.putProperty("LOG_HOME", "${logfilepath.default:-logs}"); <START> context.putProperty("LOG_PATH", "${LOG_HOME}/${APP_NAME}"); <END> context.putProperty("ARCHIVE_PATH", "${LOG_HOME}/archive/${APP_NAME}"); String result = OptionHelper.substVars("${ARCHIVE_PATH}_trace_${ARCHIVE_SUFFIX}", context); assertEquals("logs/archive/LOGBACK_trace_archive.log", result); }</code><technical_language>This unused. <del>Did LOG_PATH instead of LOG_HOME in property below?</del> mind. I now. This copied JIRA report sample input. active log path while archives stored in other path. property for this test, remove it</technical_language>

Target:
public void testSubstVarsTwoLevelsWithDefault() { context.putProperty("APP_NAME", "LOGBACK"); context.putProperty("ARCHIVE_SUFFIX", "archive.log"); context.putProperty("LOG_HOME", "${logfilepath.default:-logs}"); context.putProperty("ARCHIVE_PATH", "${LOG_HOME}/archive/${APP_NAME}"); String result = OptionHelper.substVars("${ARCHIVE_PATH}_trace_${ARCHIVE_SUFFIX}", context); assertEquals("logs/archive/LOGBACK_trace_archive.log", result); }
Source:
<code>private void setColors() { Resources res = mContext.getResources(); mColorSelected = res.getColor(mSettings.getScoreColor()); mColorEnabled = res.getColor(mSettings.getSurveyColor()); mRatingBar.setSelectedColor(mColorSelected); mBtnDismiss.setTextColor(mColorEnabled); mTvSurveyHeader.setBackgroundColor(mColorEnabled); <START> setCursorDrawableColor(mEtFeedback, mColorSelected); <END> }</code><technical_language>Yeah, need do text color white always, change is background</technical_language>

Target:
private void setColors() { Resources res = mContext.getResources(); mColorSelected = res.getColor(mSettings.getScoreColor()); mColorEnabled = res.getColor(mSettings.getSurveyColor()); mRatingBar.setSelectedColor(mColorSelected); mBtnDismiss.setTextColor(mColorEnabled); mBtnEditScore.setBackgroundColor(mColorEnabled); mTvSurveyHeader.setBackgroundColor(mColorEnabled); setCursorDrawableColor(mEtFeedback, mColorSelected); }
Source:
<code>public Map<String, String> updateSensorProperties(OwBaseBridgeHandler bridgeHandler) throws OwException { Map<String, String> properties = new HashMap<String, String>(); OwPageBuffer pages = bridgeHandler.readPages(sensorIds.get(0)); OwSensorType sensorType = OwSensorType.UNKNOWN; try { sensorType = OwSensorType.valueOf(new String(pages.getPage(0), 0, 7, StandardCharsets.US_ASCII)); } catch (IllegalArgumentException e) { } <START> if ((sensorType != OwSensorType.EDS0064) && (sensorType != OwSensorType.EDS0065) <END> && (sensorType != OwSensorType.EDS0066) && (sensorType != OwSensorType.EDS0067)) { throw new OwException("sensorType not supported for EDSSensorThing"); } int fwRevisionLow = pages.getByte(3, 3); int fwRevisionHigh = pages.getByte(3, 4); String fwRevision = String.format("%d.%d", fwRevisionHigh, fwRevisionLow); properties.put(PROPERTY_MODELID, sensorType.name()); properties.put(PROPERTY_VENDOR, "Embedded Data Systems"); properties.put(PROPERTY_HW_REVISION, String.valueOf(fwRevision)); return properties; }</code><technical_language>sense contains a static collection contains alls EDS Sensor types like: Java if (!EDSSensorTypes.contains(sensorType)) { ... }</technical_language>

Target:
public Map<String, String> updateSensorProperties(OwBaseBridgeHandler bridgeHandler) throws OwException { Map<String, String> properties = new HashMap<String, String>(); OwPageBuffer pages = bridgeHandler.readPages(sensorIds.get(0)); OwSensorType sensorType = OwSensorType.UNKNOWN; try { sensorType = OwSensorType.valueOf(new String(pages.getPage(0), 0, 7, StandardCharsets.US_ASCII)); } catch (IllegalArgumentException e) { } if (!SUPPORTED_SENSOR_TYPES.contains(sensorType)) { throw new OwException("sensorType not supported for EDSSensorThing"); } int fwRevisionLow = pages.getByte(3, 3); int fwRevisionHigh = pages.getByte(3, 4); String fwRevision = String.format("%d.%d", fwRevisionHigh, fwRevisionLow); properties.put(PROPERTY_MODELID, sensorType.name()); properties.put(PROPERTY_VENDOR, "Embedded Data Systems"); properties.put(PROPERTY_HW_REVISION, String.valueOf(fwRevision)); return properties; }
Source:
<code>void testEntryIsUnchangedAfterChecks() { BibEntry entry = new BibEntry(); for (Field field : FieldFactory.getCommonFields()) { entry.setField(field, UUID.randomUUID().toString()); } entry.setField(StandardField.EPRINT, UUID.randomUUID().toString()); BibEntry clonedEntry = (BibEntry) entry.clone(); BibDatabase bibDatabase = new BibDatabase(); bibDatabase.insertEntry(entry); BibDatabaseContext context = new BibDatabaseContext(bibDatabase); new IntegrityCheck(context, mock(FilePreferences.class), createBibtexKeyPatternPreferences(), <START> new JournalAbbreviationRepository(), true, false) <END> .checkDatabase(); assertEquals(clonedEntry, entry); }</code><technical_language>stumbled this - get rid of true false somehow? - enums maybe</technical_language>

Target:
void testEntryIsUnchangedAfterChecks() { BibEntry entry = new BibEntry(); for (Field field : FieldFactory.getCommonFields()) { entry.setField(field, UUID.randomUUID().toString()); } entry.setField(StandardField.EPRINT, UUID.randomUUID().toString()); BibEntry clonedEntry = (BibEntry) entry.clone(); BibDatabase bibDatabase = new BibDatabase(); bibDatabase.insertEntry(entry); BibDatabaseContext context = new BibDatabaseContext(bibDatabase); new IntegrityCheck(context, mock(FilePreferences.class), createBibtexKeyPatternPreferences(), JournalAbbreviationLoader.loadBuiltInRepository(), true, false) .checkDatabase(); assertEquals(clonedEntry, entry); }
Source:
<code>boolean shouldApply(long msgId) { if (msgId < lowerWaterMark) { return false; } if (msgId > higerWaterMark.get()) { return true; } final AtomicBoolean shouldApply = new AtomicBoolean(false); inProgressMessages.computeIfPresent(msgId, (id, state) -> { <START> if (state != true) { <END> shouldApply.set(true); } return null; }); return shouldApply.get(); }</code><technical_language>state is a boolean - need _compare_</technical_language>

Target:
boolean shouldApply(long msgId) { Lock lock = lwmLock.readLock(); try { lock.lock(); if (msgId < lowerWaterMark) { return false; } } finally { lock.unlock(); } if (msgId > higherWaterMark.get()) { return true; } final AtomicBoolean shouldApply = new AtomicBoolean(false); inProgressMessages.computeIfPresent(msgId, (id, state) -> { if (!state) { shouldApply.set(true); } return true; }); updateLowerWaterMark(); return shouldApply.get(); }
Source:
<code>public void checkSerializableSimplifiedServer() throws Exception { final String echoIpStepWindows = "bat \"echo Instance IP: ${srv.address}\""; final String echoIpStepUnix = "sh \"echo Instance IP: ${srv.address}\""; final String echoIpStep = Functions.isWindows() ? echoIpStepWindows : echoIpStepUnix; <START> WorkflowJob bootSerializableCheck = j.jenkins.createProject(WorkflowJob.class, "bootSerializableCheck"); <END> bootSerializableCheck.setDefinition(new CpsFlowDefinition( " def srv = openstackMachine cloud: 'openstack', template: 'template0'\n" + "node ('master') { \n" + " " + echoIpStep + " \n" + "} \n" + "srv.destroy()", true)); WorkflowRun b = j.assertBuildStatusSuccess(bootSerializableCheck.scheduleBuild2(0)); j.assertLogContains("Instance IP: 42.42.42", b); assertThat(openstack.getRunningNodes(), emptyIterable()); }</code><technical_language>I guess is reason wrap this a sh/bat. [echo](<LINK_0> step do I guess</technical_language>

Target:
public void checkSerializableSimplifiedServer() throws Exception { WorkflowJob bootSerializableCheck = j.jenkins.createProject(WorkflowJob.class, "bootSerializableCheck"); bootSerializableCheck.setDefinition(new CpsFlowDefinition( " def srv = openstackMachine cloud: 'openstack', template: 'template0'\n" + "node ('master') { \n" + " echo \"Instance IP: ${srv.address}\" \n" + "} \n" + "srv.destroy()", true)); WorkflowRun b = j.assertBuildStatusSuccess(bootSerializableCheck.scheduleBuild2(0)); j.assertLogContains("Instance IP: 42.42.42", b); assertThat(openstack.getRunningNodes(), emptyIterable()); }
Source:
<code>public static HttpClient getClient(){ HttpClient httpClient = new HttpClient(); if (Config.<Boolean> GetValue(ConfigValues.SecureConnectionWithOATServers)) { <START> URL truststoreUrl; <END> try { int port = Config.<Integer> GetValue(ConfigValues.AttestationPort); truststoreUrl = new URL("file://" + Config.resolveAttestationTrustStorePath()); String truststorePassword = Config.<String> GetValue(ConfigValues.AttestationTruststorePass); String attestationServer = Config.<String> GetValue(ConfigValues.AttestationServer); ProtocolSocketFactory factory = new AuthSSLProtocolSocketFactory(null, null, truststoreUrl, truststorePassword); Protocol clientAuthHTTPS = new Protocol("https", factory, port); httpClient.getHostConfiguration().setHost(attestationServer, port, clientAuthHTTPS); } catch (Exception e) { log.fatal("Failed to init AuthSSLProtocolSocketFactory. SSL connections will not work", e); } } return httpClient; }</code><technical_language>truststoreUrl / trustStoreUrl</technical_language>

Target:
public static HttpClient getClient() { HttpClient httpClient = new HttpClient(); if (Config.<Boolean> GetValue(ConfigValues.SecureConnectionWithOATServers)) { URL trustStoreUrl; try { int port = Config.<Integer> GetValue(ConfigValues.AttestationPort); trustStoreUrl = new URL("file://" + Config.resolveAttestationTrustStorePath()); String truststorePassword = Config.<String> GetValue(ConfigValues.AttestationTruststorePass); String attestationServer = Config.<String> GetValue(ConfigValues.AttestationServer); ProtocolSocketFactory factory = new AuthSSLProtocolSocketFactory(null, null, trustStoreUrl, truststorePassword); Protocol clientAuthHTTPS = new Protocol("https", factory, port); httpClient.getHostConfiguration().setHost(attestationServer, port, clientAuthHTTPS); } catch (Exception e) { log.fatal("Failed to init AuthSSLProtocolSocketFactory. SSL connections will not work", e); } } return httpClient; }
Source:
<code>public Object newInstance(OperationContext ctx, Map<String, Object> args) throws OperationException { <START> Map<String, Object> parms = new HashMap<>(args); <END> scripting.parmsInjector.inject(parms, ctx, desc); return new ScriptingOperationImpl(desc.source, ctx, parms); }</code><technical_language>parms -> params</technical_language>

Target:
public Object newInstance(OperationContext ctx, Map<String, Object> args) throws OperationException { Map<String, Object> params = new HashMap<>(args); scripting.paramsInjector.inject(params, ctx, desc); return new ScriptingOperationImpl(desc.source, ctx, params); }
Source:
<code>boolean configureAdColony(Context context, Bundle serverParams, MediationAdRequest adRequest, Bundle networkExtras) { String appId = serverParams.getString(AdColonyAdapterUtils.KEY_APP_ID); ArrayList<String> newZoneList = parseZoneList(serverParams); boolean needToConfigure = false; if (!(context instanceof Activity || context instanceof Application)) { Log.w(TAG, "Context must be of type Activity or Application."); return false; } if (appId == null) { Log.w(TAG, "A valid appId wasn't provided."); return false; } if (newZoneList == null || newZoneList.isEmpty()) { Log.w(TAG, "No zones provided to request ad."); return false; } for (String zone : newZoneList) { if (!configuredZones.contains(zone)) { configuredZones.add(zone); needToConfigure = true; } } AdColonyAppOptions appOptions = buildAppOptions(adRequest, networkExtras); <START> AdColony.setAppOptions(appOptions); <END> if (isConfigured && !needToConfigure) { AdColony.setAppOptions(appOptions); } else { String[] zones = configuredZones.toArray(new String[0]); appOptions.setMediationNetwork(AdColonyAppOptions.ADMOB, BuildConfig.VERSION_NAME); isConfigured = context instanceof Activity ? AdColony.configure((Activity) context, appOptions, appId, zones) : AdColony.configure((Application) context, appOptions, appId, zones); } return isConfigured; }</code><technical_language>This called line 78 81. Remove call setAppOptions then</technical_language>

Target:
boolean configureAdColony(Context context, Bundle serverParams, MediationAdRequest adRequest, Bundle networkExtras) { String appId = serverParams.getString(AdColonyAdapterUtils.KEY_APP_ID); ArrayList<String> newZoneList = parseZoneList(serverParams); if (!(context instanceof Activity || context instanceof Application)) { Log.w(TAG, "Context must be of type Activity or Application."); return false; } if (appId == null) { Log.w(TAG, "A valid appId wasn't provided."); return false; } if (newZoneList == null || newZoneList.isEmpty()) { Log.w(TAG, "No zones provided to request ad."); return false; } for (String zone : newZoneList) { if (!configuredZones.contains(zone)) { configuredZones.add(zone); isConfigured = false; } } AdColonyAppOptions appOptions = buildAppOptions(adRequest, networkExtras); if (isConfigured) { AdColony.setAppOptions(appOptions); } else { String[] zones = configuredZones.toArray(new String[0]); appOptions.setMediationNetwork(AdColonyAppOptions.ADMOB, BuildConfig.VERSION_NAME); isConfigured = context instanceof Activity ? AdColony.configure((Activity) context, appOptions, appId, zones) : AdColony.configure((Application) context, appOptions, appId, zones); } return isConfigured; }
Source:
<code>protected FactModelTree createFactModelTreeForCollection(Map<String, List<String>> genericTypeInfoMap, String factName, DMNType type, SortedMap<String, FactModelTree> hiddenFacts, FactModelTree.Type fmType, List<String> alreadyVisited) throws WrongDMNTypeException { if (!type.isCollection() && !isToBeManagedAsCollection(type)) { throw new WrongDMNTypeException(); } String typeName = type.getName(); <START> populateGeneric(genericTypeInfoMap, "value", typeName); <END> FactModelTree toReturn = createFactModelTreeForSimple(genericTypeInfoMap, factName, List.class.getCanonicalName(), fmType); if (!hiddenFacts.containsKey(typeName) && !alreadyVisited.contains(typeName)) { alreadyVisited.add(typeName); FactModelTree genericFactModelTree = createFactModelTreeForGenericType(new HashMap<>(), typeName, typeName, typeName, type, hiddenFacts, fmType, alreadyVisited); hiddenFacts.put(typeName, genericFactModelTree); } return toReturn; }</code><technical_language>@danielezonca Please put this "value" string in a static final constant, considering in multiple points</technical_language>

Target:
protected FactModelTree createFactModelTreeForCollection(Map<String, List<String>> genericTypeInfoMap, String factName, DMNType type, SortedMap<String, FactModelTree> hiddenFacts, FactModelTree.Type fmType, List<String> alreadyVisited) throws WrongDMNTypeException { if (!type.isCollection() && !isToBeManagedAsCollection(type)) { throw new WrongDMNTypeException(); } String typeName = type.getName(); populateGeneric(genericTypeInfoMap, VALUE, typeName); FactModelTree toReturn = createFactModelTreeForSimple(genericTypeInfoMap, factName, List.class.getCanonicalName(), fmType); if (!hiddenFacts.containsKey(typeName) && !alreadyVisited.contains(typeName)) { alreadyVisited.add(typeName); FactModelTree genericFactModelTree = createFactModelTreeForGenericType(new HashMap<>(), typeName, typeName, typeName, type, hiddenFacts, fmType, alreadyVisited); hiddenFacts.put(typeName, genericFactModelTree); } return toReturn; }
Source:
<code>private String showPasteDlg(final ERepositoryObjectType type, final ContainerItem parentItem, String initLabel) { InputDialog dlg = new InputDialog(getShell(), Messages.RepositoryDropAssistant_pasteObject, Messages.Common_inputName, initLabel, new IInputValidator() { @Override public String isValid(String newText) { if (newText == null || newText.trim().length() == 0) { return Messages.Common_nameCanNotBeEmpty; } if (type.equals(IServerObjectRepositoryType.TYPE_TRANSFORMERV2) <START> || type.equals(IServerObjectRepositoryType.TYPE_VIEW)) { <END> if (type.equals(IServerObjectRepositoryType.TYPE_TRANSFORMERV2)) { if (newText.startsWith(ITransformerV2NodeConsDef.PREFIX_SMARTVIEW_UPPER)) { if (!ValidateUtil.matchSmartViewRegex(newText)) { return Messages.Common_nameInvalid; } } if (!ValidateUtil.matchViewProcessRegex(newText)) { return Messages.Common_nameInvalid; } } else if (type.equals(IServerObjectRepositoryType.TYPE_VIEW)) { if (!ValidateUtil.matchViewProcessRegex(newText)) { return Messages.Common_nameInvalid; } } } else if (type.equals(IServerObjectRepositoryType.TYPE_ROLE)) { if (!ValidateUtil.matchRoleRegex(newText)) { return Messages.Common_nameInvalid; } } else if (!ValidateUtil.matchCommonRegex(newText)) { return Messages.Common_nameInvalid; } if (RepositoryResourceUtil.isExistByName(parentItem.getRepObjType(), newText.trim())) { return Messages.Common_nameIsUsed; } return null; }; }); dlg.setBlockOnOpen(true); if (dlg.open() == Window.CANCEL) { return null; } return dlg.getValue(); }</code><technical_language>"if (type.equals(IServerObjectRepositoryType.TYPE_TRANSFORMERV2)) ||type.equals(IServerObjectRepositoryType.TYPE_VIEW)) " is unnecessary</technical_language>

Target:
private String showPasteDlg(final ERepositoryObjectType type, final ContainerItem parentItem, String initLabel) { InputDialog dlg = new InputDialog(getShell(), Messages.RepositoryDropAssistant_pasteObject, Messages.Common_inputName, initLabel, new IInputValidator() { @Override public String isValid(String newText) { if (newText == null || newText.trim().length() == 0) { return Messages.Common_nameCanNotBeEmpty; } if (type.equals(IServerObjectRepositoryType.TYPE_TRANSFORMERV2)) { if (newText.startsWith(ITransformerV2NodeConsDef.PREFIX_SMARTVIEW_UPPER)) { if (!ValidateUtil.matchSmartViewRegex(newText)) { return Messages.Common_nameInvalid; } } if (!ValidateUtil.matchViewProcessRegex(newText)) { return Messages.Common_nameInvalid; } } else if (type.equals(IServerObjectRepositoryType.TYPE_VIEW)) { if (!ValidateUtil.matchViewProcessRegex(newText)) { return Messages.Common_nameInvalid; } } else if (type.equals(IServerObjectRepositoryType.TYPE_ROLE)) { if (!ValidateUtil.matchRoleRegex(newText)) { return Messages.Common_nameInvalid; } } else if (!ValidateUtil.matchCommonRegex(newText)) { return Messages.Common_nameInvalid; } if (RepositoryResourceUtil.isExistByName(parentItem.getRepObjType(), newText.trim())) { return Messages.Common_nameIsUsed; } return null; }; }); dlg.setBlockOnOpen(true); if (dlg.open() == Window.CANCEL) { return null; } return dlg.getValue(); }
Source:
<code>public String getValue(ITask task) { AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(task.getConnectorKind()); TaskRepository repository = TasksUiInternal.getRepository(task); <START> URL url = connector.getBrowserUrl(repository, task); <END> if (url == null) { return task.getUrl(); } return url.toString(); }</code><technical_language>This check repository is null</technical_language>

Target:
public String getValue(ITask task) { AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(task.getConnectorKind()); TaskRepository repository = TasksUiInternal.getRepository(task); if (repository != null) { URL url = connector.getBrowserUrl(repository, task); if (url != null) { return url.toString(); } } return task.getUrl(); }
Source:
<code>public String toString(Object o, String formatString, Locale locale) { if ( formatString==null ) return o.toString(); Formatter f = new Formatter(locale); f.format(formatString, o); <START> String str = f.toString(); <END> f.close(); return str; }</code><technical_language>bulb: This code in a try/finally for exception-safe closing of Formatter instance</technical_language>

Target:
public String toString(Object o, String formatString, Locale locale) { if ( formatString==null ) return o.toString(); Formatter f = new Formatter(locale); try { f.format(formatString, o); return f.toString(); } finally { f.close(); } }
Source:
<code>long flush(final long now) { try { final FlushResult flushResult = this.timeTracker.flush(); <START> return flushResult.getFlushTime(); <END> } catch (Exception e) { if (this.logger.isLoggable(getClass(), TechnicalLogSeverity.WARNING)) { this.logger.log(getClass(), TechnicalLogSeverity.WARNING, "Exception caught while flushing: " + e.getMessage(), e); } } return now; }</code><technical_language>strange delegate flush result is flush timestamp, flush result return time flush thread determine flush timestamp</technical_language>

Target:
long flush(final long now) { try { final FlushResult flushResult = this.timeTracker.flush(); return flushResult.getFlushTime(); } catch (Exception e) { log(TechnicalLogSeverity.WARNING, "Exception caught while flushing: " + e.getMessage(), e); } return now; }
Source:
<code>public JsPromise<OrionHoverOverlay> computeHover(OrionHoverContextOverlay context) { EditorPartPresenter activeEditor = editorAgent.getActiveEditor(); if (activeEditor == null || !(activeEditor instanceof TextEditor)) { return null; } TextEditor editor = ((TextEditor)activeEditor); if (!(editor.getConfiguration() instanceof LanguageServerEditorConfiguration)) { return null; } LanguageServerEditorConfiguration configuration = (LanguageServerEditorConfiguration)editor.getConfiguration(); if (configuration.getServerCapabilities().getHoverProvider() == null || !configuration.getServerCapabilities().getHoverProvider()) { return null; } Document document = editor.getDocument(); TextDocumentPositionParams paramsDTO = helper.createTDPP(document, context.getOffset()); Promise<Hover> promise = client.hover(paramsDTO); <START> Promise<OrionHoverOverlay> then = promise.then((Function<Hover, OrionHoverOverlay>)arg -> { <END> OrionHoverOverlay hover = OrionHoverOverlay.create(); hover.setType("markdown"); String content = renderContent(arg); if (StringUtils.isNullOrWhitespace(content)) { return null; } hover.setContent(content); return hover; }); return (JsPromise<OrionHoverOverlay>)then; }</code><technical_language>I writing (Hover arg)->....' generic types clear feels nicer a cast</technical_language>

Target:
public JsPromise<OrionHoverOverlay> computeHover(OrionHoverContextOverlay context) { EditorPartPresenter activeEditor = editorAgent.getActiveEditor(); if (activeEditor == null || !(activeEditor instanceof TextEditor)) { return null; } TextEditor editor = ((TextEditor)activeEditor); if (!(editor.getConfiguration() instanceof LanguageServerEditorConfiguration)) { return null; } LanguageServerEditorConfiguration configuration = (LanguageServerEditorConfiguration)editor.getConfiguration(); if (configuration.getServerCapabilities().getHoverProvider() == null || !configuration.getServerCapabilities().getHoverProvider()) { return null; } Document document = editor.getDocument(); TextDocumentPositionParams paramsDTO = helper.createTDPP(document, context.getOffset()); Promise<Hover> promise = client.hover(paramsDTO); Promise<OrionHoverOverlay> then = promise.then((Hover arg) -> { OrionHoverOverlay hover = OrionHoverOverlay.create(); hover.setType("markdown"); String content = renderContent(arg); if (StringUtils.isNullOrWhitespace(content)) { return null; } hover.setContent(content); return hover; }); return (JsPromise<OrionHoverOverlay>)then; }
Source:
<code>public List<Map<String, String>> linkify(HttpServletRequest req, String message) { List<CommentLinkInfo> operationalCommentLinks = new ArrayList<>(commentLinks); String baseGerritUrl = urls.getBaseGerritUrl(req); if (baseGerritUrl != null) { System.out.println("baseGerritUrl: " + baseGerritUrl); CommentLinkInfo changeIds = new CommentLinkInfo(CHANGE_ID_PATTERN, baseGerritUrl + "#/q/$0,n,z"); operationalCommentLinks.add(changeIds); } List<Map<String, String>> parsed = Lists.newArrayList(); parsed.add(ImmutableMap.of("text", message)); for (int index = 0; index < parsed.size(); index++) { <START> if (parsed.get(index).get("url") == null) { <END> Matcher m = allPattern.matcher(parsed.get(index).get("text")); if (m.find()) { for (CommentLinkInfo cli : operationalCommentLinks) { if (parsed.get(index).get("url") == null) { List<Map<String, String>> resultingReplacement = cli.replace(parsed.get(index).get("text")); if (resultingReplacement != null) { parsed.remove(index); parsed.addAll(index, resultingReplacement); } } } } } } return parsed; }</code><technical_language>(optional) decrease nesting negating condition: if (parsed.get(index).get("url") != null) { continue; } ... 'if (m.find())' below</technical_language>

Target:
public List<Map<String, String>> linkify(HttpServletRequest req, String message) { List<CommentLinkInfo> operationalCommentLinks = new ArrayList<>(commentLinks); String baseGerritUrl = urls.getBaseGerritUrl(req); if (baseGerritUrl != null) { System.out.println("baseGerritUrl: " + baseGerritUrl); CommentLinkInfo changeIds = new CommentLinkInfo(CHANGE_ID_PATTERN, baseGerritUrl + "#/q/$0,n,z"); operationalCommentLinks.add(changeIds); } List<Map<String, String>> parsed = Lists.newArrayList(); parsed.add(ImmutableMap.of("text", message)); for (int index = 0; index < parsed.size(); index++) { if (parsed.get(index).get("url") != null) { continue; } Matcher m = allPattern.matcher(parsed.get(index).get("text")); if (!m.find()) { continue; } for (CommentLinkInfo cli : operationalCommentLinks) { if (parsed.get(index).get("url") != null) { break; } List<Map<String, String>> resultingReplacement = cli.replace(parsed.get(index).get("text")); if (resultingReplacement != null) { parsed.remove(index); parsed.addAll(index, resultingReplacement); } } } return parsed; }
Source:
<code>public static Collection<Stereotype> getAllSuperStereotypes(Stereotype stereotype) { Set<Stereotype> result = new <START> HashSet<>(); <END> if (stereotype != null) { getAllSuperStereotypes(stereotype, result); } return result; }</code><technical_language>type</technical_language>

Target:
public static Collection<Stereotype> getAllSuperStereotypes(Stereotype stereotype) { Set<Stereotype> result = new HashSet<Stereotype>(); if (stereotype != null) { getAllSuperStereotypes(stereotype, result); } return result; }
Source:
<code>public void testGetBlacklistedMetacardTransformers() { Set<String> blacklist = ImmutableSet.of("hello", "world"); descriptors.setBlackListedMetacardTransformerIds(blacklist); <START> assertThat(descriptors.getBlackListedMetacardTransformerIds(), is(blacklist)); <END> }</code><technical_language>Hamcrest assertions simpler: java assertThat(transformerDescriptors, hasItem(allOf(hasEntry("id", "bar"), hasEntry("displayName", "foo")))); java assertThat(descriptors.getBlackListedMetacardTransformerIds(), contains("hello", "world"));</technical_language>

Target:
public void testGetBlacklistedMetacardTransformers() { Set<String> blacklist = ImmutableSet.of("hello", "world"); descriptors.setBlackListedMetacardTransformerIds(blacklist); assertThat(descriptors.getBlackListedMetacardTransformerIds(), contains("hello", "world")); }
Source:
<code>int getWidth(Text text) { ITextComponent component = SpongeTexts.toComponent(text); Iterable<ITextComponent> children = ((IMixinTextComponent) component).withChildren(); int total = 0; for(ITextComponent child : children) { PrimitiveIterator.OfInt i_it; if(child instanceof TextComponentString || child instanceof TextComponentTranslation) { i_it = child.getUnformattedComponentText().codePoints().iterator(); } else { continue; } boolean bold = child .getStyle() .getBold(); Integer cp; while(i_it.hasNext()){ cp = i_it.next(); <START> if (cp == 10) { <END> total = ((int) Math.ceil((double) total / LINE_WIDTH)) * LINE_WIDTH; } else { int width = getWidth(cp, bold); total += width; } } } return total; }</code><technical_language>more clear '\n' instead of 10</technical_language>

Target:
int getWidth(Text text) { ITextComponent component = SpongeTexts.toComponent(text); Iterable<ITextComponent> children = ((IMixinTextComponent) component).withChildren(); int total = 0; for(ITextComponent child : children) { PrimitiveIterator.OfInt i_it; if(child instanceof TextComponentString || child instanceof TextComponentTranslation) { i_it = child.getUnformattedComponentText().codePoints().iterator(); } else { continue; } boolean bold = child .getStyle() .getBold(); Integer cp; boolean newLine = false; while(i_it.hasNext()){ cp = i_it.next(); if (cp == '\n') { if (newLine) { total += LINE_WIDTH; } else { total = ((int) Math.ceil((double) total / LINE_WIDTH)) * LINE_WIDTH; newLine = true; } } else { int width = getWidth(cp, bold); total += width; newLine = false; } } } return total; }