auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void executeCommand() { if (getVds().getStatus() == VDSStatus.Maintenance) { setSucceeded(true); } else { orderListOfRunningVmsOnVds(getVdsId()); if (getVds().getHighlyAvailableIsConfigured()) { try { SetHaMaintenanceModeVDSCommandParameters params = new SetHaMaintenanceModeVDSCommandParameters(getVds(), HaMaintenanceMode.LOCAL, true); if (!runVdsCommand(VDSCommandType.SetHaMaintenanceMode, params).getSucceeded()) { <START> setSucceeded(isHostedEngineOnVds()); <END> haMaintenanceFailed = true; } } catch (VdcBLLException e){ if (isHostedEngineOnVds()) throw e; setSucceeded(false); haMaintenanceFailed = true; } } setSucceeded(migrateAllVms(getExecutionContext())); if (getVds().getStatus() == VDSStatus.NonResponsive || getVds().getStatus() == VDSStatus.Connecting || getVds().getStatus() == VDSStatus.Down) { runVdsCommand(VDSCommandType.SetVdsStatus, new SetVdsStatusVDSCommandParameters(getVdsId(), VDSStatus.Maintenance)); } } if (isVmsExist()) { ExecutionHandler.setAsyncJob(getExecutionContext(), true); } }</code><technical_language>a glance this good. another approach swallow exception SetHaMaintenance command translate error. error handling smaller. this is a specific command for flow I feel more exception approch</technical_language>

Target:
protected void executeCommand() { if (getVds().getStatus() == VDSStatus.Maintenance) { setSucceeded(true); } else { orderListOfRunningVmsOnVds(getVdsId()); if (getVds().getHighlyAvailableIsConfigured()) { SetHaMaintenanceModeVDSCommandParameters params = new SetHaMaintenanceModeVDSCommandParameters(getVds(), HaMaintenanceMode.LOCAL, true); if (!runVdsCommand(VDSCommandType.SetHaMaintenanceMode, params).getSucceeded()) { haMaintenanceFailed = true; if (isHostedEngineOnVds()) { setSucceeded(false); return; } } } setSucceeded(migrateAllVms(getExecutionContext())); if (getVds().getStatus() == VDSStatus.NonResponsive || getVds().getStatus() == VDSStatus.Connecting || getVds().getStatus() == VDSStatus.Down) { runVdsCommand(VDSCommandType.SetVdsStatus, new SetVdsStatusVDSCommandParameters(getVdsId(), VDSStatus.Maintenance)); } } if (isVmsExist()) { ExecutionHandler.setAsyncJob(getExecutionContext(), true); } }
Source:
<code>public void afterQuery(final ExecutionInfo info, final List<QueryInfo> queries) { final Span span = info.getCustomValue(SPAN, Span.class); if (!info.isSuccess()) { final Statement statement = info.getStatement(); final Throwable error = info.getThrowable(); <START> decorator.onError(span, statement, error); <END> } span.finish(); }</code><technical_language>Is issue in case decorator fails (i.e. exception thrown in onError) gonna call span.finish()</technical_language>

Target:
public void afterQuery(final ExecutionInfo info, final List<QueryInfo> queries) { final Span span = info.getCustomValue(SPAN, Span.class); try { if (!info.isSuccess()) { final Statement statement = info.getStatement(); final Throwable error = info.getThrowable(); decorator.onError(span, statement, error); } } finally { span.finish(); } }
Source:
<code>private void rotateTelescope() { if (telescope == null) { telescope = OwlTelescopeReporter.create( OwlTelescopeReporters.EQUIVALENCE_UPDATING_WORKER, Event.Type.EQUIVALENCE ); telescope.startReporting(); <START> timeSinceTelescopeRotated = DateTime.now(); <END> } else if (timeSinceTelescopeRotated.plusHours(1).isBeforeNow()) { telescope.endReporting(); telescope.startReporting(); } }</code><technical_language>personally do a 'timeToNextRotate' method, need +1 time, nitpicking</technical_language>

Target:
private void rotateTelescope() { if (telescope == null) { telescope = OwlTelescopeReporter.create( OwlTelescopeReporters.EQUIVALENCE_UPDATING_WORKER, Event.Type.EQUIVALENCE ); telescope.startReporting(); timeSinceTelescopeRotated = DateTime.now(); } else if (timeSinceTelescopeRotated.plusHours(1).isBeforeNow()) { telescope.endReporting(); telescope = OwlTelescopeReporter.create( OwlTelescopeReporters.EQUIVALENCE_UPDATING_WORKER, Event.Type.EQUIVALENCE ); telescope.startReporting(); timeSinceTelescopeRotated = DateTime.now(); } }
Source:
<code>public void mercury_search_navigateToPageUsingSearchSuggestions() { init(); try { this.topBar.openSearch().typeInSearch(SEARCH_PHRASE).selectSearchSuggestion(0); } catch (Exception e) { <START> System.out.println(e); <END> } Assertion.assertTrue(driver.getCurrentUrl().contains(SEARCH_PHRASE)); }</code><technical_language>SOUT ;) ...and question if this try/catch is needed? If move this logic test side</technical_language>

Target:
public void mercury_search_navigateToPageUsingSearchSuggestions() { String suggestionLink = new ArticlePage() .open(MercurySubpages.MAIN_PAGE) .getTopBar() .openSearch() .typeInSearch(this.SEARCH_PHRASE) .clickSearchSuggestion(0); Assertion.assertTrue(driver.getCurrentUrl().equals(suggestionLink)); }
Source:
<code>private static void handleDynamicResourceAllocation(String[] argArray) { String dynamicAllocProp = System.getenv(HadoopSparkJob.SPARK_DYNAMIC_RES_ENV_VAR); boolean dynamicAllocEnabled = dynamicAllocProp != null && dynamicAllocProp.equals(Boolean.TRUE.toString()); if (dynamicAllocEnabled) { for (int i = 0; i < argArray.length; i++) { if (argArray[i] == null) continue; if (argArray[i].equals(SparkJobArg.NUM_EXECUTORS.sparkParamName) || ( argArray[i].equals(SparkJobArg.SPARK_CONF_PREFIX.sparkParamName) && (argArray[i+1].startsWith(SPARK_CONF_SHUFFLE_SERVICE_ENABLED) <START> || argArray[i+1].startsWith(SPARK_CONF_DYNAMIC_ALLOC_ENABLED)) END> )) { logger.info("Azbakan enforces dynamic resource allocation. Ignore user param: " + argArray[i] + " " + argArray[i+1]); argArray[i] = null; argArray[++i] = null; } } } }</code><technical_language>check for configuration "spark.executor.instances"</technical_language>

Target:
private static void handleDynamicResourceAllocation(String[] argArray) { String dynamicAllocProp = System.getenv(HadoopSparkJob.SPARK_DYNAMIC_RES_ENV_VAR); boolean dynamicAllocEnabled = dynamicAllocProp != null && dynamicAllocProp.equals(Boolean.TRUE.toString()); if (dynamicAllocEnabled) { for (int i = 0; i < argArray.length; i++) { if (argArray[i] == null) continue; if (argArray[i].equals(SparkJobArg.NUM_EXECUTORS.sparkParamName) || ( argArray[i].equals(SparkJobArg.SPARK_CONF_PREFIX.sparkParamName) && (argArray[i+1].startsWith(SPARK_CONF_NUM_EXECUTORS) || argArray[i+1].startsWith(SPARK_CONF_SHUFFLE_SERVICE_ENABLED) || argArray[i+1].startsWith(SPARK_CONF_DYNAMIC_ALLOC_ENABLED)) )) { logger.info("Azbakan enforces dynamic resource allocation. Ignore user param: " + argArray[i] + " " + argArray[i+1]); argArray[i] = null; argArray[++i] = null; } } } }
Source:
<code>private void doAuthenticate(Account account) { SecurityContextHolder.clearContext(); Authentication authentication = new PreAuthenticatedAuthenticationToken( <START> account.getEmail(), null, authenticationProvider.getGrantedAuthorities(account) <END> ); SecurityContextHolder.getContext().setAuthentication(authentication); }</code><technical_language>@dogeared Authentication authentication = new PreAuthenticatedAuthenticationToken(account.getEmail(), null, authenticationProvider.getGrantedAuthorities(account) do Authentication authentication = new PreAuthenticatedAuthenticationToken(account.getEmail(), null, account); authentication = authenticationProvider.authenticate(authentication); this leave responsibility of populate roles granted authorities StormpathAuthenticationProvider. Otherwise, if in future Provider needs do new authenticated tokens this code need change well. basically duplicating responsibility of providing granted authorities here. Furthermore, authenticationProvider.getGrantedAuthorities(Account) method is protected able invoke this class is in package. is intended called class</technical_language>

Target:
private void doAuthenticate(Account account) { SecurityContextHolder.clearContext(); Authentication authentication = new IdSiteAuthenticationToken(account); authenticationProvider.authenticate(authentication); SecurityContextHolder.getContext().setAuthentication(authentication); }
Source:
<code>public void setSourceOnSave(boolean sourceOnSave) { <START> view_.getSourceOnSave().setValue(sourceOnSave); <END> docUpdateSentinel_.setSourceOnSave(sourceOnSave, null); }</code><technical_language>I reason this sync model is setValue fire events default. work .setValue(sourceOnSave, true)</technical_language>

Target:
public void setSourceOnSave(boolean sourceOnSave) { view_.getSourceOnSave().setValue(sourceOnSave, true); }
Source:
<code>protected void updateEmulatedMachines() { <START> Collection<EmulatedMachine> em = new ArrayList<>(); <END> em.add(EmulatedMachine.i440fx_seabios); em.add(EmulatedMachine.q35_ovmf); em.add(EmulatedMachine.q35_secureboot); getModel().getEmulatedMachine().setItems(em); }</code><technical_language>This main method do magic of setting values etc. needs called getDataCenterWithClustersList() changes oSType_SelectedItemChanged() - please add like: EmulatedMachine oldVal = getModel().getEmulatedMachine().getSelectedItem(); getModel().getEmulatedMachine().setSelectedItem(oldVal);</technical_language>

Target:
protected void updateEmulatedMachines() { EmulatedMachine oldVal = getModel().getEmulatedMachine().getSelectedItem(); Collection<EmulatedMachine> emList = new ArrayList<>(); emList.add(EmulatedMachine.i440fx_seabios); emList.add(EmulatedMachine.q35_ovmf); emList.add(EmulatedMachine.q35_secureboot); getModel().getEmulatedMachine().setItems(emList); if (oldVal != null) { getModel().getEmulatedMachine().setSelectedItem(oldVal); } else if (getModel().getOSType().getSelectedItem() != null) { EmulatedMachine em = AsyncDataProvider.getInstance().emulatedMachineByOs(getModel().getOSType().getSelectedItem()); if (em != null && getModel().getEmulatedMachine().getIsAvailable()) { getModel().getEmulatedMachine().setSelectedItem(em); } } }
Source:
<code>protected String httpPost(String request, JsonObject body) throws IOException, RuntimeException { String host = getKieRESTUrl(); URL url = new URL(host + "/" + request); <START> System.out.println("[POST] "+url.toString()+" body: "+body); <END> HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(body!=null); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); setHttpCredentials(conn); if (body!=null) { java.io.OutputStream os = conn.getOutputStream(); Writer writer = new OutputStreamWriter(os, "UTF-8"); body.writeTo(writer); writer.close(); os.flush(); } String response = new BufferedReader(new InputStreamReader((conn.getInputStream()))).readLine(); System.out.println("[POST] response: "+response); if (conn.getResponseCode() != HttpURLConnection.HTTP_ACCEPTED) { throw new IOException("HTTP POST failed : HTTP error code : " + conn.getResponseCode()); } JsonObject jo = JsonObject.readFrom(response); String status = jo.get("status").asString(); if (status != null && !status.isEmpty()) { if (!"APPROVED".equals(status)) throw new IOException("HTTP POST failed : Request status code : " + status); } String jobId = jo.get("jobId").asString(); if (jobId != null && !jobId.isEmpty()) return jobId; return response; }</code><technical_language>System.out statements useful? removed replaces some more configurable logging</technical_language>

Target:
protected String httpPost(String request, JsonObject body) throws IOException, RuntimeException { String host = getKieRESTUrl(); URL url = new URL(host + "/" + request); Activator.println("[POST] "+url.toString()+" body: "+body); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(body!=null); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); setHttpCredentials(conn); if (body!=null) { java.io.OutputStream os = conn.getOutputStream(); Writer writer = new OutputStreamWriter(os, "UTF-8"); body.writeTo(writer); writer.close(); os.flush(); } String response = new BufferedReader(new InputStreamReader((conn.getInputStream()))).readLine(); Activator.println("[POST] response: "+response); if (conn.getResponseCode() != HttpURLConnection.HTTP_ACCEPTED) { throw new IOException("HTTP POST failed : HTTP error code : " + conn.getResponseCode()); } JsonObject jo = JsonObject.readFrom(response); String status = jo.get("status").asString(); if (status != null && !status.isEmpty()) { if (!"APPROVED".equals(status)) throw new IOException("HTTP POST failed : Request status code : " + status); } String jobId = jo.get("jobId").asString(); if (jobId != null && !jobId.isEmpty()) return jobId; return response; }
Source:
<code>private SimRobot() { super(); <START> nodeList.add(new FullSimRunner("Full Sim Toolbox", new LocTuple(40.441670, -79.9416362))); <END> RobobuggyJFrame mainWindow = new RobobuggyJFrame("MainWindow", 1.0, 1.0); Gui.getInstance().addWindow(mainWindow); RobobuggyGUITabs tabs = new RobobuggyGUITabs(); mainWindow.addComponent(tabs, 0.0, 0.0, 1.0, 1.0); tabs.addTab(new MainGuiWindow(), "Home"); tabs.add(new PathPanel(), "Path Visualizer"); tabs.addTab(new ConfigurationPanel(), "Configuration"); }</code><technical_language>Magic numbers</technical_language>

Target:
private SimRobot() { super(); nodeList.add(new FullSimRunner("Full Sim Toolbox", new LocTuple(INITIAL_POS_LAT, INITIAL_POS_LON))); RobobuggyJFrame mainWindow = new RobobuggyJFrame("MainWindow", 1.0, 1.0); Gui.getInstance().addWindow(mainWindow); RobobuggyGUITabs tabs = new RobobuggyGUITabs(); mainWindow.addComponent(tabs, 0.0, 0.0, 1.0, 1.0); tabs.addTab(new MainGuiWindow(), "Home"); tabs.add(new PathPanel(), "Path Visualizer"); tabs.addTab(new ConfigurationPanel(), "Configuration"); }
Source:
<code>public void safeSetValue(String value) throws InvalidParameterException, Exception { <START> System.out.println("Validation helper is " + valueHelper.getClass().getName()); <END> ValidationResult validationResult = valueHelper.validate(this, value); if (!validationResult.isOk()) { StringBuilder invalidParamMsg = new StringBuilder(); invalidParamMsg.append("Cannot set value ") .append(value) .append(" to key ") .append(keyName) .append(". ") .append(StringUtils.isNotEmpty(validationResult.getDetails()) ? validationResult.getDetails() : ""); throw new InvalidParameterException(invalidParamMsg.toString()); } this.value = valueHelper.setValue(value); }</code><technical_language>this print? Is relevant user</technical_language>

Target:
public void safeSetValue(String value) throws InvalidParameterException, Exception { ValidationResult validationResult = valueHelper.validate(this, value); if (!validationResult.isOk()) { StringBuilder invalidParamMsg = new StringBuilder(); invalidParamMsg.append("Cannot set value ") .append(value) .append(" to key ") .append(keyName) .append(". ") .append(StringUtils.isNotEmpty(validationResult.getDetails()) ? validationResult.getDetails() : ""); throw new InvalidParameterException(invalidParamMsg.toString()); } this.value = valueHelper.setValue(value); }
Source:
<code>private WebElement getSessionLinkInRow(String elementClassNamePrefix, int rowId){ waitForElementPresence(By.id("session" + rowId)); <START> By.id("session" + rowId); <END> waitForElementPresence(By.className(elementClassNamePrefix)); return browser.driver.findElement(By.id("session" + rowId)).findElement(By.className(elementClassNamePrefix)); }</code><technical_language>extraneous line me</technical_language>

Target:
private WebElement getSessionLinkInRow(String elementClassNamePrefix, int rowId){ waitForElementPresence(By.id("session" + rowId)); waitForElementPresence(By.className(elementClassNamePrefix)); return browser.driver.findElement(By.id("session" + rowId)).findElement(By.className(elementClassNamePrefix)); }
Source:
<code>private io.fabric8.kubernetes.api.model.Container addContainer( Pod toolingPod, String image, List<EnvVar> env, ResourceRequirements resources) { io.fabric8.kubernetes.api.model.Container container = new ContainerBuilder() .withImage(image) <START> .withName(Names.generateName("")) <END> .withEnv(toK8sEnv(env)) .withResources(toK8sResources(resources)) .build(); toolingPod.getSpec().getContainers().add(container); return container; }</code><technical_language>sense add some meaningful prefix "tooling"</technical_language>

Target:
private io.fabric8.kubernetes.api.model.Container addContainer( Pod toolingPod, String image, List<EnvVar> env, ResourceRequirements resources) { io.fabric8.kubernetes.api.model.Container container = new ContainerBuilder() .withImage(image) .withName(Names.generateName("tooling")) .withEnv(toK8sEnv(env)) .withResources(toK8sResources(resources)) .build(); toolingPod.getSpec().getContainers().add(container); return container; }
Source:
<code>public void stop(final StopContext context) { synchronized (serverInventoryLock) { try { serverInventory = null; serverInventoryLock.set(false); } finally { serverInventoryLock.notifyAll(); } } extensionRegistry.clear(); <START> capabilityRegistry.clear(); <END> super.stop(context); }</code><technical_language>this move AbstractControllerService? nice if clear() method public</technical_language>

Target:
public void stop(final StopContext context) { synchronized (serverInventoryLock) { try { serverInventory = null; serverInventoryLock.set(false); } finally { serverInventoryLock.notifyAll(); } } extensionRegistry.clear(); super.stop(context); }
Source:
<code>protected File createFile() { <START> long count=0; <END> File file = null; try{ file = new File("bigfile.txt"); PrintWriter writer = new PrintWriter(file, "UTF-8"); Random random = new Random(); for(int i = 0; i < 23695522; i++) { char[] word = new char[random.nextInt(8)+3]; count+=word.length; for(int j = 0; j < word.length; j++) { word[j] = (char)('a' + random.nextInt(26)); } writer.print(new String(word) + ' '); count+=1; if (i % 10 == 0){ writer.println(); count+=2; } } writer.close(); } catch (IOException e) { } return file; }</code><technical_language>Need for this method? Construct file file = new File("target", "bigfile.txt"); InputStream testStream = randomStream(0, 256); FileIOUtils.copyInputStreamToFile(testStream, file);</technical_language>

Target:
protected File createFile() { long count=0; File file = null; file = new File("bigfile.txt"); InputStream testStream = randomStream(0, 256); try { FileIOUtils.copyInputStreamToFile(testStream, file); } catch (IOException e) { e.printStackTrace(); } return file; }
Source:
<code>public boolean updateEntityLockedState(String entityName, String entityType, String operation) throws WorkflowException { Connection connection = null; PreparedStatement prepStmtGet = null; PreparedStatement prepStmtSelect = null; ResultSet results; try { <START> connection = JDBCPersistenceManager.getInstance().getDBConnection(); <END> prepStmtGet = connection.prepareStatement(SQLConstants.GET_ENTITY_STATE_QUERY); prepStmtGet.setString(1, entityName); prepStmtGet.setString(2, entityType); prepStmtGet.setString(3, "Operation"); prepStmtGet.setString(4, operation); results = prepStmtGet.executeQuery(); if (results.next()) { return false; } else { prepStmtSelect = connection.prepareStatement(SQLConstants.ADD_ENTITY_STATE_QUERY); prepStmtSelect.setString(1, entityName); prepStmtSelect.setString(2, entityType); prepStmtSelect.setString(3, "Operation"); prepStmtSelect.setString(4, operation); prepStmtSelect.execute(); } connection.commit(); } catch (SQLException | IdentityException e) { log.error("Error while saving new user data for Identity database.", e); throw new WorkflowException("Error while saving new user data for Identity database.", e); } finally { IdentityDatabaseUtil.closeStatement(prepStmtSelect); IdentityDatabaseUtil.closeStatement(prepStmtGet); IdentityDatabaseUtil.closeConnection(connection); } return true; }</code><technical_language>IdentityDBUtils get db connection</technical_language>

Target:
public boolean updateEntityLockedState(String entityName, String entityType, String operation) throws WorkflowException { Connection connection = null; PreparedStatement prepStmtGet = null; PreparedStatement prepStmtSelect = null; ResultSet results; try { connection = IdentityDatabaseUtil.getDBConnection();; prepStmtGet = connection.prepareStatement(SQLConstants.GET_ENTITY_STATE_QUERY); prepStmtGet.setString(1, entityName); prepStmtGet.setString(2, entityType); prepStmtGet.setString(3, "Operation"); prepStmtGet.setString(4, operation); results = prepStmtGet.executeQuery(); if (results.next()) { return false; } else { prepStmtSelect = connection.prepareStatement(SQLConstants.ADD_ENTITY_STATE_QUERY); prepStmtSelect.setString(1, entityName); prepStmtSelect.setString(2, entityType); prepStmtSelect.setString(3, "Operation"); prepStmtSelect.setString(4, operation); prepStmtSelect.execute(); } connection.commit(); } catch (SQLException | IdentityException e) { throw new WorkflowException("Error while saving new user data for Identity database.", e); } finally { IdentityDatabaseUtil.closeStatement(prepStmtSelect); IdentityDatabaseUtil.closeStatement(prepStmtGet); IdentityDatabaseUtil.closeConnection(connection); } return true; }
Source:
<code>String gtk_css_default_theme_values (int swt) { byte buffer; int length; long settings = OS.gtk_settings_get_default (); long ptr = new long [1]; long str; OS.g_object_get (settings, OS.gtk_theme_name, ptr, 0); if (ptr [0] == 0) { return ""; } length = OS.strlen (ptr [0]); if (length == 0) { return ""; } buffer = new byte [length]; OS.memmove (buffer, ptr [0], length); OS.g_free (ptr [0]); String gtkThemeName = new String(Converter.mbcsToWcs (null, buffer)); long themeProvider = OS.gtk_css_provider_get_named(Converter.wcsToMbcs <START> (null, gtkThemeName, true), null); <END> str = OS.gtk_css_provider_to_string (themeProvider); length = OS.strlen (str); if (length == 0) { return ""; } buffer = new byte [length]; OS.memmove (buffer, str, length); String cssOutput = new String (Converter.mbcsToWcs (null, buffer)); String color; switch (swt) { case SWT.COLOR_LIST_SELECTION: int tSelected = cssOutput.indexOf ("@define-color theme_selected_bg_color"); int selected = cssOutput.indexOf ("@define-color selected_bg_color"); if (tSelected != -1) { color = cssOutput.substring(tSelected + 38); if (color.startsWith("#") || color.startsWith("rgb")) { return color; } } if (selected != -1) { color = cssOutput.substring(selected + 32); if (color.startsWith("#") || color.startsWith("rgb")) { return color; } } else { return ""; } default: return ""; } }</code><technical_language>do need gtkThemeName string? useless convert buffer string, string convert buffer pass gtk_css_provider_get_named that</technical_language>

Target:
String gtk_css_default_theme_values (int swt) { byte buffer; int length; long settings = OS.gtk_settings_get_default (); long ptr = new long [1]; long str; OS.g_object_get (settings, OS.gtk_theme_name, ptr, 0); if (ptr [0] == 0) { return ""; } length = OS.strlen (ptr [0]); if (length == 0) { return ""; } buffer = new byte [length]; OS.memmove (buffer, ptr [0], length); OS.g_free (ptr [0]); long themeProvider = OS.gtk_css_provider_get_named(buffer, null); str = OS.gtk_css_provider_to_string (themeProvider); length = OS.strlen (str); if (length == 0) { return ""; } buffer = new byte [length]; OS.memmove (buffer, str, length); String cssOutput = new String (Converter.mbcsToWcs (null, buffer)); String color; switch (swt) { case SWT.COLOR_LIST_SELECTION: int tSelected = cssOutput.indexOf ("@define-color theme_selected_bg_color"); int selected = cssOutput.indexOf ("@define-color selected_bg_color"); if (tSelected != -1) { color = cssOutput.substring(tSelected + 38); if (color.startsWith("#") || color.startsWith("rgb")) { return color; } } if (selected != -1) { color = cssOutput.substring(selected + 32); if (color.startsWith("#") || color.startsWith("rgb")) { return color; } } else { return ""; } default: return ""; } }
Source:
<code>public boolean isSubtype(JavaType t, JavaType s) { boolean result; if (t == s) { result = true; } else { switch (t.tag) { case JavaType.BYTE: case JavaType.CHAR: result = t.tag == s.tag || (t.tag + 2 <= s.tag && s.tag <= JavaType.DOUBLE); break; case JavaType.SHORT: case JavaType.INT: case JavaType.LONG: case JavaType.FLOAT: case JavaType.DOUBLE: result = t.tag <= s.tag && s.tag <= JavaType.DOUBLE; break; case JavaType.BOOLEAN: case JavaType.VOID: result = t.tag == s.tag; break; case JavaType.ARRAY: if(t.tag != s.tag) { result = t.getSymbol().getSuperclass() == s; break; } result = isSubtype(((JavaType.ArrayJavaType) t).elementType(), ((JavaType.ArrayJavaType) s).elementType()); break; case JavaType.CLASS: if(t.tag != s.tag) { result = false; break; } Set<String> erasedTypes = Sets.newHashSet(); for (JavaType.ClassJavaType classType : t.getSymbol().superTypes()) { <START> erasedTypes.add(classType.erasure().fullyQualifiedName()); <END> } result = erasedTypes.contains(s.fullyQualifiedName()); break; case JavaType.BOT: result = s.tag == JavaType.BOT || s.tag == JavaType.CLASS || s.tag == JavaType.ARRAY; break; default: result = false; break; } } return result; }</code><technical_language>I wrong I wondering if not, shortcut erasure relying fully qualified name hacked a solution instead of fixing real issue... need discuss in depth is here</technical_language>

Target:
public boolean isSubtype(JavaType t, JavaType s) { boolean result; if (t == s) { result = true; } else { switch (t.tag) { case JavaType.BYTE: case JavaType.CHAR: result = t.tag == s.tag || (t.tag + 2 <= s.tag && s.tag <= JavaType.DOUBLE); break; case JavaType.SHORT: case JavaType.INT: case JavaType.LONG: case JavaType.FLOAT: case JavaType.DOUBLE: result = t.tag <= s.tag && s.tag <= JavaType.DOUBLE; break; case JavaType.BOOLEAN: case JavaType.VOID: result = t.tag == s.tag; break; case JavaType.ARRAY: if(t.tag != s.tag) { result = t.getSymbol().getSuperclass() == s; break; } result = isSubtype(((JavaType.ArrayJavaType) t).elementType(), ((JavaType.ArrayJavaType) s).elementType()); break; case JavaType.CLASS: if(t.tag != s.tag) { result = false; break; } Set<JavaType> erasedTypes = Sets.newHashSet(); for (JavaType.ClassJavaType classType : t.getSymbol().superTypes()) { erasedTypes.add(classType.erasure()); } result = erasedTypes.contains(s.erasure()); break; case JavaType.BOT: result = s.tag == JavaType.BOT || s.tag == JavaType.CLASS || s.tag == JavaType.ARRAY; break; default: result = false; break; } } return result; }
Source:
<code>public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy) { ElasticsearchTableLayoutHandle layoutHandle = (ElasticsearchTableLayoutHandle) layout; ElasticsearchTableHandle tableHandle = layoutHandle.getTable(); ElasticsearchTableDescription table = client.getTable(tableHandle.getSchemaName(), tableHandle.getTableName()); checkState(table != null, "Table %s.%s no longer exists", tableHandle.getSchemaName(), tableHandle.getTableName()); List<String> indices = client.getIndices(table); for (String index : indices) { log.debug("index: " + index); } ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder(); for (String index : indices) { ClusterSearchShardsResponse response = client.getSearchShards(index, table); DiscoveryNode[] nodes = response.getNodes(); for (ClusterSearchShardsGroup group : response.getGroups()) { int nodeIndex = group.getShardId().getId() % nodes.length; ElasticsearchSplit split = new ElasticsearchSplit(table, index, group.getShardId().getId(), nodes[nodeIndex].getHostName(), nodes[nodeIndex].getAddress().getPort(), layoutHandle.getTupleDomain()); <START> log.debug("split: " + " index: " + index + " shardId: " + group.getShardId() + " node: " + nodes[nodeIndex].getHostName().toString() + " port: " + nodes[nodeIndex].getAddress().getPort()); <END> splits.add(split); } } return new FixedSplitSource(splits.build()); }</code><technical_language>Is this log needed? I feel this is left some debugging session. If need this then: - toString is redundant - %s instead of string concat - This is in a loop log plenty of stuff, want put this line in if(log.isDebugEnabled())</technical_language>

Target:
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy) { ElasticsearchTableLayoutHandle layoutHandle = (ElasticsearchTableLayoutHandle) layout; ElasticsearchTableHandle tableHandle = layoutHandle.getTable(); ElasticsearchTableDescription table = client.getTable(tableHandle.getSchemaName(), tableHandle.getTableName()); checkState(table != null, "Table %s.%s no longer exists", tableHandle.getSchemaName(), tableHandle.getTableName()); List<String> indices = client.getIndices(table); ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder(); for (String index : indices) { ClusterSearchShardsResponse response = client.getSearchShards(index, table); DiscoveryNode[] nodes = response.getNodes(); for (ClusterSearchShardsGroup group : response.getGroups()) { int nodeIndex = group.getShardId().getId() % nodes.length; ElasticsearchSplit split = new ElasticsearchSplit(table, index, group.getShardId().getId(), nodes[nodeIndex].getHostName(), nodes[nodeIndex].getAddress().getPort(), layoutHandle.getTupleDomain()); splits.add(split); } } return new FixedSplitSource(splits.build()); }
Source:
<code>CodeWriter emitAndIndent(String s) throws IOException { boolean first = true; <START> for (String line : s.split("\r?\n", -1)) { <END> if (!first) { if ((javadoc || comment) && trailingNewline) { emitIndentation(); out.append(javadoc ? " *" : " } out.append("\n"); trailingNewline = true; if (statementLine != -1) { if (statementLine == 0) { indent(2); } statementLine++; } } first = false; if (line.isEmpty()) continue; if (trailingNewline) { emitIndentation(); if (javadoc) { out.append(" * "); } else if (comment) { out.append(" } } out.append(line); trailingNewline = false; } return this; }</code><technical_language>Javapoet is a Java 8 project, able linebreak matcher \\R instead</technical_language>

Target:
CodeWriter emitAndIndent(String s) throws IOException { boolean first = true; for (String line : s.split("\\R", -1)) { if (!first) { if ((javadoc || comment) && trailingNewline) { emitIndentation(); out.append(javadoc ? " *" : " } out.append("\n"); trailingNewline = true; if (statementLine != -1) { if (statementLine == 0) { indent(2); } statementLine++; } } first = false; if (line.isEmpty()) continue; if (trailingNewline) { emitIndentation(); if (javadoc) { out.append(" * "); } else if (comment) { out.append(" } } out.append(line); trailingNewline = false; } return this; }
Source:
<code>public static RequestBodyDeserializer getRequestBodyDeserializer(final String contentType) { RequestBodyDeserializer deserializer = REQUEST_BODY_DESERIALIZERS.get(contentType); if (null == deserializer) { synchronized (RequestBodyDeserializerFactory.class) { if (null == REQUEST_BODY_DESERIALIZERS.get(contentType)) { instantiateRequestBodyDeserializerFromFactories(contentType); } deserializer = REQUEST_BODY_DESERIALIZERS.get(contentType); } } if (MISSING_DESERIALIZER == deserializer) { throw new RequestBodyDeserializerNotFoundException(contentType); } <START> return deserializer; <END> }</code><technical_language>result variable named result</technical_language>

Target:
public static RequestBodyDeserializer getRequestBodyDeserializer(final String contentType) { RequestBodyDeserializer result = REQUEST_BODY_DESERIALIZERS.get(contentType); if (null == result) { synchronized (RequestBodyDeserializerFactory.class) { if (null == REQUEST_BODY_DESERIALIZERS.get(contentType)) { instantiateRequestBodyDeserializerFromFactories(contentType); } result = REQUEST_BODY_DESERIALIZERS.get(contentType); } } if (MISSING_DESERIALIZER == result) { throw new RequestBodyDeserializerNotFoundException(contentType); } return result; }
Source:
<code>public void scanWebXml(XmlFile file) { if (hasNoSecurityConstraint(file)) { List<Integer> secondaryLocationLines = new ArrayList<>(); <START> reportIssueOnFile("Add \"security-constraint\" elements to this descriptor.", secondaryLocationLines); <END> } }</code><technical_language>instead of empty ArrayList, I Collections.emptyList()</technical_language>

Target:
public void scanWebXml(XmlFile file) { if (hasNoSecurityConstraint(file)) { List<Integer> secondaryLocationLines = Collections.emptyList(); reportIssueOnFile("Add \"security-constraint\" elements to this descriptor.", secondaryLocationLines); } }
Source:
<code>public String getUrl() { <START> return PluginImpl.getInstance().getServer(serverName).getConfig().getGerritFrontEndUrlFor(tEvent); <END> }</code><technical_language>NPE</technical_language>

Target:
public String getUrl() { return url; }
Source:
<code>private void setupClient() throws FileSystemException { final GenericFileName rootName = getRoot(); String userName; <START> if (rootName.getUserName().equals("") || rootName.getUserName() == null) { <END> userName = ""; } else { if (rootName.getUserName().contains(";")) { userName = rootName.getUserName().substring(rootName.getUserName().indexOf(";") + 1, rootName.getUserName().length()); } else { userName = rootName.getUserName(); } } String password = rootName.getPassword(); String authDomain = (rootName.getUserName().contains(";") ? rootName.getUserName().substring(0, rootName.getUserName().indexOf(";")) : null); AuthenticationContext authContext = new AuthenticationContext(userName, password.toCharArray(), authDomain); try { connection = smbClient.connect(rootName.getHostName()); session = connection.authenticate(authContext); String share = ((Smb2FileName) rootName).getShareName(); diskShare = (DiskShare) session.connectShare(share); } catch (Exception e) { throw new FileSystemException("vfs.provider.smb2/connect.error", rootName.getHostName(), e.getCause()); } }</code><technical_language>arrange this conditions, else this throw NPE</technical_language>

Target:
private void setupClient() throws FileSystemException { final GenericFileName rootName = getRoot(); final String userString = rootName.getUserName(); String userName = ""; if (userString != null && !userString.isEmpty()) { if (userString.contains(";")) { userName = userString.substring(userString.indexOf(";") + 1, userString.length()); } else { userName = userString; } } String password = rootName.getPassword(); String authDomain = (userString.contains(";") ? userString.substring(0, userString.indexOf(";")) : null); AuthenticationContext authContext = new AuthenticationContext(userName, password.toCharArray(), authDomain); try { connection = smbClient.connect(rootName.getHostName()); session = connection.authenticate(authContext); String share = ((Smb2FileName) rootName).getShareName(); diskShare = (DiskShare) session.connectShare(share); } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Error while creating connection to " + rootName.getHostName()); } throw new FileSystemException("vfs.provider.smb2/connect.error", rootName.getHostName(), e); } }
Source:
<code>private boolean warXmlExists(File dir){ boolean looseApp = false; if (dir.exists() && dir.isDirectory()) { File[] files = dir.listFiles(); for (File file : files) { <START> if (file.isFile() && file.getName().endsWith(".war.xml")) { <END> looseApp = true; } } } return looseApp; }</code><technical_language>check if xml file is current app. i.e. check if filename starts DevMojo.this.project.getArtifactId()</technical_language>

Target:
private boolean warXmlExists(File dir){ boolean looseApp = false; if (dir.exists() && dir.isDirectory()) { File[] files = dir.listFiles(); for (File file : files) { if (file.isFile() && file.getName().endsWith(".war.xml") && file.getName().startsWith(DevMojo.this.project.getArtifactId())) { looseApp = true; break; } } } return looseApp; }
Source:
<code>private static String getFileName(HttpURLConnection connection) { String contentType = connection.getContentType(); MediaType type = MediaType.parse(contentType); String fileName = connection.getURL().toString(); if(type.is(MediaType.ANY_APPLICATION_TYPE)) { <START> String contentDisposition = connection.getHeaderField("Content-Disposition"); END> if(contentDisposition != null) { String[] content = contentDisposition.split(";"); for (String string : content) { if (string.contains("filename=")) { int index = string.indexOf('"'); fileName = string.substring(index+1, string.length() - 1); } } } } else if(type.is(MediaType.ANY_TEXT_TYPE)) { String url = connection.getURL().getPath(); int indexFile = url.lastIndexOf('/'); fileName = url.substring(indexFile+1, url.length()); } return fileName; }</code><technical_language>extract top constants. (alt-shift-t in eclipse)</technical_language>

Target:
private static String getFileName(HttpURLConnection connection) { String fileName = getLastSegmentUrl(connection.getURL().toString()); String contentType = connection.getContentType(); if (contentType != null) { MediaType type = MediaType.parse(contentType); if (type.is(MediaType.ANY_APPLICATION_TYPE)) { String contentDisposition = connection.getHeaderField(CONTENT_DISPOSITION); if (contentDisposition != null) { String[] content = contentDisposition.split(";"); for (String string : content) { if (string.contains("filename=")) { int index = string.indexOf('"'); fileName = string.substring(index + 1, string.length() - 1); } } } } } return fileName; }
Source:
<code>private void assertCodeDeploymentWorking(HazelcastInstance client, EntryProcessor entryProcessor) { int keyCount = 100; IMap<Integer, Integer> map = client.getMap(randomName()); for (int i = 0; i < keyCount; i++) { map.put(i, 0); } <START> for (int i = 0; i < 5; i++) { <END> map.executeOnEntries(entryProcessor); } for (int i = 0; i < keyCount; i++) { assertEquals(5, (int) map.get(i)); } }</code><technical_language>put explanation this number 5 for test test maintainer understand significance of this number</technical_language>

Target:
private void assertCodeDeploymentWorking(HazelcastInstance client, EntryProcessor entryProcessor) { int keyCount = 100; IMap<Integer, Integer> map = client.getMap(randomName()); for (int i = 0; i < keyCount; i++) { map.put(i, 0); } int incrementCount = 5; for (int i = 0; i < incrementCount; i++) { map.executeOnEntries(entryProcessor); } for (int i = 0; i < keyCount; i++) { assertEquals(incrementCount, (int) map.get(i)); } }
Source:
<code>private static Instant retrieveDeadlineTimestamp(JobDataMap jobDataMap) { Object timestamp = jobDataMap.get(MESSAGE_TIMESTAMP); <START> if (timestamp instanceof String) return Instant.parse(timestamp.toString()); <END> return Instant.ofEpochMilli((long) timestamp); }</code><technical_language>do single line if-statements project. a nitty point, prefer change curly braces</technical_language>

Target:
private static Instant retrieveDeadlineTimestamp(JobDataMap jobDataMap) { Object timestamp = jobDataMap.get(MESSAGE_TIMESTAMP); if (timestamp instanceof String) { return Instant.parse(timestamp.toString()); } return Instant.ofEpochMilli((long) timestamp); }
Source:
<code>private static boolean isPublic(DetailAST modifiers) { return ScopeUtil.isInInterfaceBlock(modifiers) && modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) == null <START> || ScopeUtil.isInAnnotationBlock(modifiers) <END> || modifiers.findFirstToken(TokenTypes.LITERAL_PUBLIC) != null; }</code><technical_language>methods? this check is fields</technical_language>

Target:
private static boolean isPublic(DetailAST modifiers) { return modifiers.findFirstToken(TokenTypes.LITERAL_PUBLIC) != null || ScopeUtil.isInAnnotationBlock(modifiers) || ScopeUtil.isInInterfaceBlock(modifiers) && modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) == null; }
Source:
<code>public SeLionSauceProxy(RegistrationRequest request, Registry registry) { super(fixTimeout(request), registry); down = false; <START> poll = true; <END> pollingInterval = request.getConfigAsInt(RegistrationRequest.NODE_POLLING, DEFAULT_POLLING_INTERVAL); downPollingLimit = request.getConfigAsInt(RegistrationRequest.DOWN_POLLING_LIMIT, DEFAULT_DOWN_POLLING_LIMIT); if (!SauceServlet.PROXY_ID.equals(remoteHost.toExternalForm())) { throw new GridException(SeLionSauceProxy.class.getSimpleName() + " can not be used by an external process"); } try { sauceConfigReader = SauceConfigReader.getInstance(); defaultParentTunnel = sauceConfigReader.getDefaultParentTunnel(); defaultTunnelIdentifier = sauceConfigReader.getDefaultTunnelIdentifier(); sauceApi = new SauceLabsRestApi(); } catch (GridConfigurationException e) { throw new GridException("Failed to initialize proxy: ", e); } }</code><technical_language>Do want allow able turn polling a polling interval of "0"</technical_language>

Target:
public SeLionSauceProxy(RegistrationRequest request, Registry registry) { super(fixTimeout(request), registry); down = false; poll = true; pollingInterval = request.getConfigAsInt(RegistrationRequest.NODE_POLLING, DEFAULT_POLLING_INTERVAL); downPollingLimit = request.getConfigAsInt(RegistrationRequest.DOWN_POLLING_LIMIT, DEFAULT_DOWN_POLLING_LIMIT); if ((pollingInterval <= 0) || (downPollingLimit <= 0)) { poll = false; } if (!SauceServlet.PROXY_ID.equals(remoteHost.toExternalForm())) { throw new GridException(SeLionSauceProxy.class.getSimpleName() + " can not be used by an external process"); } try { sauceConfigReader = SauceConfigReader.getInstance(); defaultParentTunnel = sauceConfigReader.getDefaultParentTunnel(); defaultTunnelIdentifier = sauceConfigReader.getDefaultTunnelIdentifier(); sauceApi = new SauceLabsRestApi(); } catch (GridConfigurationException e) { throw new GridException("Failed to initialize proxy: ", e); } renderer = new WebProxyHtmlRenderer(this); }
Source:
<code><START> public TestingServer(boolean start) throws Exception <END> { this(-1, null); }</code><technical_language>start argument is used. Is meant be</technical_language>

Target:
public TestingServer(boolean start) throws Exception { this(-1, null, start); }
Source:
<code>public VoxelShape getSelectionShape(@Nullable ISelectionContext ctx) { boolean hasHammer; if(ctx!=null&&ctx.hasItem(Tools.hammer)) hasHammer = true; else <START> hasHammer = false; <END> return SHAPES.get(new BoundingBoxKey(hasHammer, this)); }</code><technical_language>I prefer this Utils.isHammer(ItemStack), need check ctx EntitySelectionContext retrieve MAIN_HAND item of entity involved. is more complex, utility method whereever possible, if logic for detecting a hammer changes (currently tool classes, allow tags in future), change in place</technical_language>

Target:
public VoxelShape getSelectionShape(@Nullable ISelectionContext ctx) { return SHAPES.get(new BoundingBoxKey(ctx!=null&&ctx.getEntity() instanceof ClientPlayerEntity&&Utils.isHammer(((ClientPlayerEntity)ctx.getEntity()).getHeldItemMainhand()), this)); }
Source:
<code>public void onTrackInfoChanged(@NonNull MediaController controller, @NonNull List<TrackInfo> trackInfos) { <START> onTracksChanged(controller, trackInfos); <END> }</code><technical_language>onTracksChanged called twice. L1187 of MediaControllerImplBase (in patch set) enough</technical_language>

Target:
public void onTrackInfoChanged(@NonNull MediaController controller, @NonNull List<TrackInfo> trackInfos) { }
Source:
<code>public void testFilteredContent_2() throws Throwable { UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24") .withAuthorization(Group.FREE_GROUP_NAME, "tempRole", Permission.BACKOFFICE).build(); String accessToken = mockOAuthInterceptor(user); ResultActions result = mockMvc .perform(get("/plugins/cms/contents") .param("status", IContentService.STATUS_ONLINE) .param("sort", IContentManager.CONTENT_CREATION_DATE_FILTER_KEY) .param("direction", FieldSearchFilter.DESC_ORDER) .param("filters[0].attribute", "id") .param("filters[0].value", "EVN194") .sessionAttr("user", user) .header("Authorization", "Bearer " + accessToken)); <START> String bodyResult = result.andReturn().getResponse().getContentAsString(); result.andExpect(status().isOk()); String expectedContentId = "EVN194"; int payloadSize = JsonPath.read(bodyResult, "$.payload.size()"); String extractedId = JsonPath.read(bodyResult, "$.payload[" + 0 + "].id"); Assert.assertEquals(expectedContentId, extractedId); <END> }</code><technical_language>Check code style for building mvc test rules latest commit PR #556</technical_language>

Target:
public void testFilteredContent_2() throws Throwable { UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24") .withAuthorization(Group.FREE_GROUP_NAME, "tempRole", Permission.BACKOFFICE).build(); String accessToken = mockOAuthInterceptor(user); ResultActions result = mockMvc .perform(get("/plugins/cms/contents") .param("status", IContentService.STATUS_ONLINE) .param("sort", IContentManager.CONTENT_CREATION_DATE_FILTER_KEY) .param("direction", FieldSearchFilter.DESC_ORDER) .param("filters[0].attribute", "id") .param("filters[0].value", "EVN194") .sessionAttr("user", user) .header("Authorization", "Bearer " + accessToken)); result.andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.payload.size()", is(1))) .andExpect(jsonPath("$.payload[0].id", is("EVN194"))); }
Source:
<code>public Object decorate(ClassLoader loader, Field field) { <START> try { <END> if (isTypifiedElement(field)) { return decorateTypifiedElement(loader, field); } else if (isHtmlElement(field)) { return decorateHtmlElement(loader, field); } else if (isWebElement(field) && !field.getName().equals("wrappedElement")) { return decorateWebElement(loader, field); } else if (isTypifiedElementList(field)) { return decorateTypifiedElementList(loader, field); } else if (isHtmlElementList(field)) { return decorateHtmlElementList(loader, field); } else if (isWebElementList(field)) { return decorateWebElementList(loader, field); } else { return null; } } catch (ClassCastException ignore) { return null; } }</code><technical_language>add try-catch changing if style elif? Previous variant is more readable for</technical_language>

Target:
public Object decorate(ClassLoader loader, Field field) { try { if (isTypifiedElement(field)) { return decorateTypifiedElement(loader, field); } if (isHtmlElement(field)) { return decorateHtmlElement(loader, field); } if (isWebElement(field) && !field.getName().equals("wrappedElement")) { return decorateWebElement(loader, field); } if (isTypifiedElementList(field)) { return decorateTypifiedElementList(loader, field); } if (isHtmlElementList(field)) { return decorateHtmlElementList(loader, field); } if (isWebElementList(field)) { return decorateWebElementList(loader, field); } return null; } catch (ClassCastException ignore) { return null; } }
Source:
<code>public void setCodeMiningProviders(ICodeMiningProvider[] codeMiningProviders) { if (fCodeMiningProviders != null) { for (ICodeMiningProvider contentMiningProvider : fCodeMiningProviders) { contentMiningProvider.dispose(); } } boolean enable= codeMiningProviders != null && codeMiningProviders.length > 0; fCodeMiningProviders= codeMiningProviders; if (enable) { if (fCodeMiningManager != null) { fCodeMiningManager.setCodeMiningProviders(fCodeMiningProviders); } ensureCodeMiningManagerInstalled(); } else { if (fCodeMiningManager != null) { fCodeMiningManager.uninstall(); <START> if (codeMiningProviders == null || codeMiningProviders.length == 0) { <END> fInlinedAnnotationSupport.updateAnnotations(new HashSet<>()); } } fCodeMiningManager= null; } }</code><technical_language>this extra condition here? If is manager, clear annotations</technical_language>

Target:
public void setCodeMiningProviders(ICodeMiningProvider[] codeMiningProviders) { if (fCodeMiningProviders != null) { for (ICodeMiningProvider contentMiningProvider : fCodeMiningProviders) { contentMiningProvider.dispose(); } } boolean enable= codeMiningProviders != null && codeMiningProviders.length > 0; fCodeMiningProviders= codeMiningProviders; if (enable) { if (fCodeMiningManager != null) { fCodeMiningManager.setCodeMiningProviders(fCodeMiningProviders); } ensureCodeMiningManagerInstalled(); } else { if (fCodeMiningManager != null) { fCodeMiningManager.uninstall(); } fCodeMiningManager= null; } }