auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected SlaveObjectAxisProvider getSlaveObjectAxisProvider(final TableConfiguration configuration) { SlaveObjectAxisProvider slave = null; // Try to get an existing master axis provider if (0 < configuration.getRowAxisProviders().size()) { final Iterator<AbstractAxisProvider> columnAxisProvidersIterator = configuration.getColumnAxisProviders().iterator(); while (columnAxisProvidersIterator.hasNext() && null == slave) { AbstractAxisProvider axisProvider = columnAxisProvidersIterator.next(); if (axisProvider instanceof SlaveObjectAxisProvider) { slave = (SlaveObjectAxisProvider) axisProvider; } } } return slave; }

Target:
protected SlaveObjectAxisProvider getSlaveObjectAxisProvider(final TableConfiguration configuration) { SlaveObjectAxisProvider slave = null; // Try to get an existing master axis provider if (0 < configuration.getRowAxisProviders().size()) { final Iterator<AbstractAxisProvider> columnAxisProvidersIterator = configuration.getColumnAxisProviders().iterator(); while (columnAxisProvidersIterator.hasNext() && null == slave) { final AbstractAxisProvider axisProvider = columnAxisProvidersIterator.next(); if (axisProvider instanceof SlaveObjectAxisProvider) { slave = (SlaveObjectAxisProvider) axisProvider; } } } return slave; }
Source:
protected void setupInternals() throws IOException { if (getObjectDirectory() == null) { if (getGitCommonDir() != null) setObjectDirectory( safeFS().resolve(getGitCommonDir(), OBJECTS)); // $NON-NLS-1$ else if (getGitDir() != null) setObjectDirectory(safeFS().resolve(getGitDir(), OBJECTS)); // $NON-NLS-1$ } }

Target:
protected void setupInternals() throws IOException { if (getObjectDirectory() == null) { if (getGitCommonDir() != null) { setObjectDirectory( safeFS().resolve(getGitCommonDir(), OBJECTS)); } else if (getGitDir() != null) { setObjectDirectory(safeFS().resolve(getGitDir(), OBJECTS)); } } }
Source:
public Object getParameter(String name) { if (name.equals(CriticalPathModule.PARAM_WORKER)) { final HostThread currentHostThread = fCurrentHostThread; if (currentHostThread == null) { return null; } /* Try to find the worker for the critical path */ IAnalysisModule mod = getModule(); if ((mod != null) && (mod instanceof CriticalPathModule)) { LttngWorker worker = new LttngWorker(currentHostThread, "", 0); //$NON-NLS-1$ return worker; } return currentHostThread; } return null; }

Target:
public Object getParameter(String name) { if (name.equals(CriticalPathModule.PARAM_WORKER)) { final HostThread currentHostThread = fCurrentHostThread; if (currentHostThread == null) { return null; } /* Try to find the worker for the critical path */ IAnalysisModule mod = getModule(); if ((mod != null) && (mod instanceof CriticalPathModule)) { LttngWorker worker = new LttngWorker(currentHostThread, "", 0); //$NON-NLS-1$ return worker; } } return null; }
Source:
private String getCombinedLabels(IThreadDMContext processDmc, IMIExecutionDMContext execDmc) { // get the process label IThreadDMData processData = getData(processDmc); String label = getLabel(processData); // get the execution (thread) context label if (execDmc != null) { int threadId; try { threadId = Integer.parseInt(execDmc.getThreadId()); label += !label.isEmpty() ? ": " : ""; //$NON-NLS-1$//$NON-NLS-2$ label += "Thread [" + Integer.toString(threadId) + "]"; //$NON-NLS-1$//$NON-NLS-2$ } catch (NumberFormatException e) { // No additional label adjustments } } return label; }

Target:
private String getCombinedLabels(IThreadDMContext processDmc, IMIExecutionDMContext execDmc) { // get the process label IThreadDMData processData = getData(processDmc); String label = getLabel(processData); // get the execution (thread) context label if (execDmc != null) { String threadId = execDmc.getThreadId(); label += !label.isEmpty() ? ": " : ""; //$NON-NLS-1$//$NON-NLS-2$ label += "Thread [" + threadId + "]"; //$NON-NLS-1$//$NON-NLS-2$ } return label; }
Source:
private Session getOrOpenTargetSession(final URI sessionResourceUri) { Session session = SessionManager.INSTANCE.getExistingSession(sessionResourceUri); if (session == null) { // Try to open a session. ModelingProjectManager.INSTANCE.loadAndOpenRepresentationsFile(sessionResourceUri, true); // Wait the end of the loading of the representations file try { Job.getJobManager().join(AbstractRepresentationsFileJob.FAMILY, new NullProgressMonitor()); } catch (InterruptedException e) { throw new RuntimeException(e); } session = SessionManager.INSTANCE.getExistingSession(sessionResourceUri); } return session; }

Target:
private Session getOrOpenTargetSession(final URI sessionResourceUri) { Session session = SessionManager.INSTANCE.getExistingSession(sessionResourceUri); if (session == null) { // Try to open a session. ModelingProjectManager.INSTANCE.loadAndOpenRepresentationsFile(sessionResourceUri, true); // Wait the end of the loading of the representations file try { Job.getJobManager().join(AbstractRepresentationsFileJob.FAMILY, new NullProgressMonitor()); } catch (InterruptedException e) { // Do nothing; } session = SessionManager.INSTANCE.getExistingSession(sessionResourceUri); } return session; }
Source:
public static IoOperationType getType(int rwbs) { if (rwbs % 2 == 0) { return READ; } return WRITE; }

Target:
public static IoOperationType getType(int rwbs) { /* Even is a "read", odd is a "write" */ return (rwbs % 2 == 0) ? READ : WRITE; }
Source:
public boolean isModelerResource() { if (resource.getURI() != null) { return new FileQuery(resource.getURI().fileExtension()).isVSMFile(); } return false; }

Target:
public boolean isModelerResource() { try { if (resource.getURI() != null) { return new FileQuery(resource.getURI().fileExtension()).isVSMFile(); } } catch (IllegalStateException e) { // Silent catch: if an issue occurred while getting this Resource's // URI, then it will not be considered as a representation resource } return false; }
Source:
protected final void activate(BundleContext bundleContext) { databindingServiceReference = bundleContext.getServiceReference(EMFFormsDatabindingEMF.class); if (databindingServiceReference == null) { throw new IllegalStateException( "The org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF Service is not available!"); //$NON-NLS-1$ } setEMFFormsDatabinding(bundleContext.getService(databindingServiceReference)); }

Target:
protected final void activate(BundleContext bundleContext) { this.bundleContext = bundleContext; }
Source:
public void init(Composite parent, String viewerName, ITmfTrace trace) { super.init(parent, viewerName); // Increment a counter to make sure the tree ID is unique. fCountInstance++; fInstanceNb = fCountInstance; fTrace = trace; // The viewer will process all events if he is assigned to an experiment fProcessAll = (trace instanceof TmfExperiment); initContent(parent); initInput(); fSash.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { internalDispose(); } }); }

Target:
public void init(Composite parent, String viewerName, ITmfTrace trace) { super.init(parent, viewerName); // Increment a counter to make sure the tree ID is unique. fCountInstance++; fInstanceNb = fCountInstance; fTrace = trace; // The viewer will process all events if he is assigned to an experiment fProcessAll = (trace instanceof TmfExperiment); initContent(parent); initInput(); fSash.addDisposeListener((e) -> { internalDispose(); }); }
Source:
public void setJSRuntimeArguments(String runtimeArgs) { if (fRuntimeArgs == null) { if (runtimeArgs == null) { // No change return; } } else if (fRuntimeArgs.equals(runtimeArgs)) { // No change return; } fRuntimeArgs = runtimeArgs; }

Target:
public void setJSRuntimeArguments(String runtimeArgs) { fRuntimeArgs = runtimeArgs; }
Source:
public String getMessage(EObject eObject, String value) { URI uri = eObject.eResource().getURI(); if (uri != null && uri.isPlatformPlugin() && uri.segmentCount() > 1) { // Segment 0 is the scheme // Segment 1 is the bundle Bundle bundle = Platform.getBundle(uri.segment(1)); return MessageTranslator.INSTANCE.getMessage(bundle, value); } return value; }

Target:
public String getMessage(EObject eObject, String value) { if (eObject.eResource() != null) { URI uri = eObject.eResource().getURI(); if (uri != null && uri.isPlatformPlugin() && uri.segmentCount() > 1) { // Segment 0 is the scheme // Segment 1 is the bundle Bundle bundle = Platform.getBundle(uri.segment(1)); return MessageTranslator.INSTANCE.getMessage(bundle, value); } } return value; }
Source:
protected String getFontName(String fontNameExpression, EAttribute eAttribute, FontData defaultFontData) { String fontName = defaultFontData.getName(); Eval eval = new Eval(interpreter, variableManager); if (fontNameExpression != null && !fontNameExpression.isEmpty()) { String fontNameValue = eval.get(eAttribute, fontNameExpression, String.class); if (fontNameValue != null) { // Get font name fontName = fontNameValue; } } return fontName; }

Target:
private String getFontName(String fontNameExpression, EAttribute eAttribute, FontData defaultFontData) { String fontName = defaultFontData.getName(); Eval eval = new Eval(interpreter, variableManager); if (fontNameExpression != null && !fontNameExpression.isEmpty()) { String fontNameValue = eval.get(eAttribute, fontNameExpression, String.class); if (fontNameValue != null) { // Get font name fontName = fontNameValue; } } return fontName; }
Source:
public static boolean isValidFile(IFile file) { // File must be a js file String fileExtension = file.getFileExtension(); if (!fileExtension.equals(JS_EXT)) { return false; } // File must exists and be accessible if (file.exists() && file.isAccessible()) { String filePath = file.getFullPath().toOSString(); // Js file cannot be inside node_modules or bower_components if (filePath != null && !filePath.contains(NODE_MODULES_FOLDER) && !filePath.contains(BOWER_COMPONENTS_FOLDER)) { return true; } } return false; }

Target:
private boolean isValidFile(IFile file) { // File must be a js file String fileExtension = file.getFileExtension(); if (!fileExtension.equals(JS_EXT)) { return false; } // File must exists and be accessible if (file.exists() && file.isAccessible()) { String filePath = file.getFullPath().toOSString(); // Js file cannot be inside node_modules or bower_components if (filePath != null && !filePath.contains(NODE_MODULES_FOLDER) && !filePath.contains(BOWER_COMPONENTS_FOLDER)) { return true; } } return false; }
Source:
public void testCallStackRequirements() { /* Test optional requirement */ LttngUstCallStackAnalysisRequirement req = new LttngUstCallStackAnalysisRequirement(ILttngUstEventLayout.DEFAULT_LAYOUT); for (TestData item: TestData.values()) { assertEquals(item.isValid(), req.test(item.getTrace())); } }

Target:
public void testCallStackRequirements() { LttngUstCallStackAnalysisRequirement req = new LttngUstCallStackAnalysisRequirement(ILttngUstEventLayout.DEFAULT_LAYOUT); for (TestData item: TestData.values()) { assertEquals(item.name(), item.isValid(), req.test(item.getTrace())); } }
Source:
private boolean isJobOverridingCancelingMethod() { Method cancelingMethod = null; try { cancelingMethod = currentJob.getClass().getDeclaredMethod("canceling"); //$NON-NLS-1$ } catch (NoSuchMethodException | SecurityException e) { return false; } // sufficient as InternalJob and Job classes are abstract, // currentJob.getClass cannot be one or the other. return (cancelingMethod != null); }

Target:
private boolean isJobOverridingCancelingMethod() { Method cancelingMethod = null; try { cancelingMethod = currentJob.getClass().getDeclaredMethod("canceling"); //$NON-NLS-1$ } catch (NoSuchMethodException | SecurityException e) { return false; } // Sufficient as InternalJob and Job classes are abstract, // currentJob.getClass cannot be one or the other. return cancelingMethod != null; }
Source:
public @NonNull String @NonNull getFullAttribute() { LinkedList<String> list = new LinkedList<>(); Attribute curNode = this; /* Add recursive parents to the list, but stop at the root node */ while (curNode.parent != null) { list.addFirst(curNode.getName()); curNode = curNode.parent; } return list.toArray(new @NonNull String[0]); }

Target:
public @NonNull String @NonNull getFullAttribute() { LinkedList<String> list = new LinkedList<>(); Attribute curNode = this; /* Add recursive parents to the list, but stop at the root node */ while (curNode.parent != null) { list.addFirst(curNode.getName()); curNode = curNode.parent; } return list.toArray(new @NonNull String[list.size()]); }
Source:
public static IJavaElement resolveJavaElement(Object object, ILaunch launch) throws CoreException { Object sourceElement = resolveSourceElement(object, launch); IJavaElement javaElement = getJavaElement(sourceElement); if (javaElement == null) { // fallback if default stratum does not provide a Java element sourceElement = resolveSourceElement(object, JAVA_STRATUM, launch); if (sourceElement != null) javaElement = getJavaElement(sourceElement); } return javaElement; }

Target:
public static IJavaElement resolveJavaElement(Object object, ILaunch launch) throws CoreException { Object sourceElement = resolveSourceElement(object, launch); IJavaElement javaElement = getJavaElement(sourceElement); if (javaElement == null) { // fallback if default stratum does not provide a Java element sourceElement = resolveSourceElement(object, JAVA_STRATUM, launch); javaElement = getJavaElement(sourceElement); } return javaElement; }
Source:
public @Nullable String toString() { Number startValue = fBegin.getValue(); Number endValue = fEnd.getValue(); // TODO: The string should probably include the low and // high limits here. if (startValue != null && endValue != null) { return "[" + String.valueOf(fBegin) + " - " + String.valueOf(fEnd) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return null; }

Target:
public @Nullable String toString() { Long startValue = fBegin.getValue(); Long endValue = fEnd.getValue(); // TODO: The string should probably include the low and // high limits here. if (startValue != null && endValue != null) { return "[" + String.valueOf(fBegin) + " - " + String.valueOf(fEnd) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return null; }
Source:
public static CallEvent getCallEvent(Operation operation) { CallEvent result = null; Package nearestPackage = operation.getNearestPackage(); if (nearestPackage != null) { for (Element element : nearestPackage.getOwnedElements()) { if (element instanceof CallEvent) { final CallEvent callEvent = (CallEvent) element; if (callEvent.getOperation() != null && callEvent.getOperation().equals(operation)) { result = callEvent; break; } } } } return result; }

Target:
public static CallEvent getCallEvent(Operation operation) { CallEvent result = null; Package nearestPackage = operation.getNearestPackage(); if (nearestPackage != null) { for (Element element : nearestPackage.getOwnedElements()) { if (element instanceof CallEvent) { final CallEvent callEvent = (CallEvent) element; if (operation.equals(callEvent.getOperation())) { result = callEvent; break; } } } } return result; }
Source:
private void handleUnknownFeatures(final EObject owner, final FeatureMap featureMap) { final Iterator<FeatureMap.Entry> iter = featureMap.iterator(); List<FeatureMap.Entry> entryList = Lists.newArrayList(); while (iter.hasNext()) { entryList.add(iter.next()); } // Don't call handleFeature when iterating the FeatureMap // Indeed, the handleFeature allows to set the value of the unknown // feature in // another feature. Doing this the FeatureMap is updated and may raise // concurrency if the Feature is being iterated. for (FeatureMap.Entry currentEntry : entryList) { handleFeature(owner, currentEntry.getEStructuralFeature(), currentEntry.getValue()); } }

Target:
private void handleUnknownFeatures(final EObject owner, final FeatureMap featureMap) { // Don't call handleFeature when iterating the FeatureMap // Indeed, the handleFeature allows to set the value of the unknown // feature in // another feature. Doing this the FeatureMap is updated and may raise // concurrency if the Feature is being iterated. List<FeatureMap.Entry> entryList = Lists.newArrayList(featureMap.iterator()); for (FeatureMap.Entry currentEntry : entryList) { handleFeature(owner, currentEntry.getEStructuralFeature(), currentEntry.getValue()); } }
Source:
public long getCleanupDelay() { if (cleanupDelayMillis > 0) { return cleanupDelayMillis; } else { return Math.min(expireAfterMillis / 10, TimeUnit.MINUTES.toMillis(10)); } }

Target:
public long getCleanupDelay() { if (cleanupDelayMillis < 0) { return Math.min(expireAfterMillis / 10, TimeUnit.MINUTES.toMillis(10)); } return cleanupDelayMillis; }
Source:
public void dispose() { // run super. super.dispose(); // remove ourselves as a selection and registry listener getSite().getPage().removePostSelectionListener(this); RegistryFactory.getRegistry().removeListener(this); SaveablesList saveables = (SaveablesList) getSite().getService(ISaveablesLifecycleListener.class); saveables.removeModelLifecycleListener(saveablesTracker); currentPart = null; currentSelection = null; pinPropertySheetAction = null; }

Target:
public void dispose() { // run super. super.dispose(); // remove ourselves as a selection and registry listener getSite().getPage().removePostSelectionListener(this); RegistryFactory.getRegistry().removeListener(this); SaveablesList saveables = (SaveablesList) getSite().getService(ISaveablesLifecycleListener.class); if (saveables != null) { saveables.removeModelLifecycleListener(saveablesTracker); } currentPart = null; currentSelection = null; pinPropertySheetAction = null; }
Source:
protected void resetAll() { try { m_organizedTable.setTableChanging(true); // m_organizedTable.resetColumns(); m_organizedTable.removeUserRowFilters(); m_organizedTable.applyRowFilters(); TableUserFilterManager m = m_organizedTable.getUserFilterManager(); if (m != null) { m.reset(); } ITableCustomizer cst = m_organizedTable.getTableCustomizer(); if (cst != null) { cst.removeAllColumns(); } } finally { m_organizedTable.setTableChanging(false); } getColumnsTableField().reloadTableData(); }

Target:
protected void resetAll() { try { m_organizedTable.setTableChanging(true); // m_organizedTable.resetColumns(); TableUserFilterManager m = m_organizedTable.getUserFilterManager(); if (m != null) { m.reset(); } ITableCustomizer cst = m_organizedTable.getTableCustomizer(); if (cst != null) { cst.removeAllColumns(); } } finally { m_organizedTable.setTableChanging(false); } getColumnsTableField().reloadTableData(); }
Source:
public void setParent(CalledFunction parent) { fParent = parent; }

Target:
private void setParent(CalledFunction parent) { fParent = parent; }
Source:
public boolean canExecute(ITmfTrace trace) { return !Iterables.isEmpty(getDependentAnalyses()); }

Target:
public boolean canExecute(ITmfTrace trace) { /* * FIXME: change to !Iterables.isEmpty(getDependentAnalyses()) when * analysis dependencies work better */ return true; }
Source:
public boolean handle(TreeNode treeNode) { EObject data = treeNode.getData(); // we are interested only in the root match boolean handles = data instanceof Match && data.eContainer() instanceof Comparison; return handles; }

Target:
public boolean handle(TreeNode treeNode) { EObject data = treeNode.getData(); // we are interested only in the root match return data instanceof Match && data.eContainer() instanceof Comparison; }
Source:
protected IMIBackend createBackendGDBService(DsfSession session, ILaunchConfiguration lc) { if (compareVersionWith(GDB_7_12_VERSION) >= 0 || compareVersionWith("7.11.50") >= 0 // TODO remove once GDB 7.12 is released ) { return new GDBBackend_7_12(session, lc); } return new GDBBackend(session, lc); }

Target:
protected IMIBackend createBackendGDBService(DsfSession session, ILaunchConfiguration lc) { if (compareVersionWith(GDB_7_12_VERSION) >= 0) { return new GDBBackend_7_12(session, lc); } return new GDBBackend(session, lc); }
Source:
public void update() { IDebuggerConsole[] consoles = getDebuggerConsoleManager().getConsoles(); setEnabled(consoles.length > 1); }

Target:
public void update() { IDebuggerConsole[] consoles = getDebuggerConsoleManager().getConsoles(); // Keep the button enabled as soon as there is at least one console. // Having it disabled for a single console can prove confusing to users, // so we enable it even for a single console. setEnabled(consoles.length > 0); }
Source:
public Direction getDirection(ITmfEvent event) { try { IKernelAnalysisEventLayout layout = TRACE_LAYOUTS.get(event.getTrace()); if (layout == null) { return null; } String evname = event.getName(); /* Is the event a tcp socket in or out event */ if (layout.eventsNetworkReceive().contains(evname)) { return Direction.EFFECT; } else if (layout.eventsNetworkSend().contains(evname)) { return Direction.CAUSE; } } catch (ExecutionException e) { } return null; }

Target:
public Direction getDirection(ITmfEvent event) { IKernelAnalysisEventLayout layout = TRACE_LAYOUTS.get(event.getTrace()); if (layout == null) { return null; } String evname = event.getName(); /* Is the event a tcp socket in or out event */ if (layout.eventsNetworkReceive().contains(evname)) { return Direction.EFFECT; } else if (layout.eventsNetworkSend().contains(evname)) { return Direction.CAUSE; } return null; }
Source:
public List<String> getPushOptions() { if (allowPushOptions) { if (enabledCapabilities == null) { throw new RequestNotYetReadException(); } return pushOptions == null ? null : Collections.unmodifiableList(pushOptions); } else { throw new IllegalStateException(); } }

Target:
public List<String> getPushOptions() { if (!allowPushOptions) { // Reading push options without a prior setAllowPushOptions(true) // call doesn't make sense. throw new IllegalStateException(); } if (enabledCapabilities == null) { // Push options are not available until receive() has been called. throw new RequestNotYetReadException(); } if (pushOptions == null) { // The client doesn't support push options. Return null to // distinguish this from the case where the client declared support // for push options and sent an empty list of them. return null; } return Collections.unmodifiableList(pushOptions); }
Source:
private static String computeNewName(String str) { String fileExtension = ""; //$NON-NLS-1$ String fileNameNoExtension = str; Pattern p = Pattern.compile("[0-9]+$"); //$NON-NLS-1$ Matcher m = p.matcher(fileNameNoExtension); if (m.find()) { // String ends with a number: increment it by 1 int newNumber = Integer.parseInt(m.group()) + 1; String numberStr = m.replaceFirst(Integer.toString(newNumber)); return numberStr + fileExtension; } return fileNameNoExtension + "2" + fileExtension; //$NON-NLS-1$ }

Target:
private static String computeNewName(String str) { String fileNameNoExtension = str; Pattern p = Pattern.compile("[0-9]+$"); //$NON-NLS-1$ Matcher m = p.matcher(fileNameNoExtension); if (m.find()) { // String ends with a number: increment it by 1 int newNumber = Integer.parseInt(m.group()) + 1; return m.replaceFirst(Integer.toString(newNumber)); } return fileNameNoExtension + "2"; //$NON-NLS-1$ }
Source:
public Object[] getChildren(Object object, IMergeViewerItemProviderConfiguration configuration) { return ResourceAttachmentChangeMergeViewerItem.class.cast(object).getChildren( configuration.getDifferenceGroupProvider(), configuration.getDifferenceFilterPredicate()); }

Target:
public Object[] getChildren(Object object, IMergeViewerItemProviderConfiguration configuration) { return ((ResourceAttachmentChangeMergeViewerItem)object).getChildren( configuration.getDifferenceGroupProvider(), configuration.getDifferenceFilterPredicate()); }
Source:
public boolean hasChildren(Object object, IMergeViewerItemProviderConfiguration configuration) { return ResourceAttachmentChangeMergeViewerItem.class.cast(object).hasChildren( configuration.getDifferenceGroupProvider(), configuration.getDifferenceFilterPredicate()); }

Target:
public boolean hasChildren(Object object, IMergeViewerItemProviderConfiguration configuration) { return ((ResourceAttachmentChangeMergeViewerItem)object).hasChildren( configuration.getDifferenceGroupProvider(), configuration.getDifferenceFilterPredicate()); }
Source:
public <T> T getSoleAttributeValue(IAttributeType attributeType, DeletionFlag flag, T defaultValue) { T value = defaultValue; Attribute<T> attribute = null; try { attribute = getSoleAttribute(attributeType, flag); } catch (AttributeDoesNotExist ex) { // do nothing } if (attribute != null) { value = attribute.getValue(); } return value; }

Target:
public <T> T getSoleAttributeValue(IAttributeType attributeType, DeletionFlag flag, T defaultValue) { T value = defaultValue; Attribute<T> attribute = null; try { attribute = getSoleAttribute(attributeType, flag); value = attribute.getValue(); } catch (AttributeDoesNotExist ex) { // do nothing } return value; }
Source:
private static IMarker[] getMarkersOfView(String viewId, IMarker[] markers) throws CoreException { if (null == viewId) // all markers should be shown return markers; ArrayList<IMarker> markersOfView = new ArrayList<>(); for (IMarker marker : markers) { if (viewId.equals(getViewId(marker))) markersOfView.add(marker); } return markersOfView.toArray(new IMarker[markersOfView.size()]); }

Target:
private static IMarker[] getMarkersOfView(String viewId, IMarker[] markers) throws CoreException { if (null == viewId) // all markers should be shown return markers; ArrayList<IMarker> markersOfView = new ArrayList<>(); for (IMarker marker : markers) { if (null != marker && viewId.equals(getViewId(marker))) markersOfView.add(marker); } return markersOfView.toArray(new IMarker[markersOfView.size()]); }
Source:
public Object getImage(final Object object) { EObject element = EMFHelper.getEObject(object); if (element == null) { return null; } // Delegate to UML2 Edit providers to get localized and inferred names where applicable IItemLabelProvider provider = getDelegate(element); return (provider == null) ? null : provider.getImage(element); }

Target:
public Object getImage(final Object object) { EObject element = EMFHelper.getEObject(object); if (null == element) { return null; } // Delegate to UML2 Edit providers to get localized and inferred names where applicable IItemLabelProvider provider = getDelegate(element); return (provider == null) ? null : provider.getImage(element); }
Source:
public void run() { try { fLaunch.terminate(); setImageDescriptor(GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_TERMINATE_DISABLED_COLOR)); } catch (DebugException e) { GdbUIPlugin.log(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Unable to terminate launch", e)); //$NON-NLS-1$ } }

Target:
public void run() { try { fLaunch.terminate(); } catch (DebugException e) { GdbUIPlugin.log(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Unable to terminate launch", e)); //$NON-NLS-1$ } }
Source:
public void createControl(Composite parent, FormToolkit toolkit) { super.createControl(parent, toolkit, (getLayoutHint().rowSpan == RowSpan.MULTIPLE ? SWT.WRAP : SWT.NONE)); if (!isReadOnly() && isMultiSelect) { getText().setToolTipText("Separate multiple values with a comma"); //$NON-NLS-1$ } }

Target:
public void createControl(Composite parent, FormToolkit toolkit) { super.createControl(parent, toolkit, (getLayoutHint() != null && getLayoutHint().rowSpan == RowSpan.MULTIPLE ? SWT.WRAP : SWT.NONE)); if (!isReadOnly() && isMultiSelect) { getText().setToolTipText("Separate multiple values with a comma"); //$NON-NLS-1$ } }
Source:
public String toString() { if (getName() == null) { return getPersonId(); } else { if (getPersonId() == null) { return ""; //$NON-NLS-1$ } else { if (getName().equals(getPersonId())) { return getName(); } else { return getName() + " <" + getPersonId() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ } } } }

Target:
public String toString() { if (getName() == null) { return getPersonId(); } else { if (getPersonId() == null) { return getName(); } else { if (getName().equals(getPersonId())) { return getName(); } else { return getName() + " <" + getPersonId() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ } } } }
Source:
public String toString() { if (getName() == null) { return getPersonId(); } else { if (getPersonId() == null) { return getName(); } else { if (getName().equals(getPersonId())) { return getName(); } else { return getName() + " <" + getPersonId() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ } } } }

Target:
public String toString() { if (getName() == null) { return getPersonId(); } else if (getPersonId() == null) { return getName(); } else if (getName().equals(getPersonId())) { return getName(); } else { return getName() + " <" + getPersonId() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ } }
Source:
public void beginTask(String name, int totalWork) { fTaskName = name; fSubTaskName = ""; //$NON-NLS-1$ updateLabel(); if ((totalWork == IProgressMonitor.UNKNOWN || totalWork == 0) && !fProgressIndicator.isDisposed()) { fProgressIndicator.beginAnimatedTask(); } else { fProgressIndicator.beginTask(totalWork); } if (fToolBar != null && !fToolBar.isDisposed()) { fToolBar.setVisible(true); fToolBar.setFocus(); } }

Target:
public void beginTask(String name, int totalWork) { fTaskName = name; fSubTaskName = ""; //$NON-NLS-1$ updateLabel(); if (!fProgressIndicator.isDisposed()) { if (totalWork == IProgressMonitor.UNKNOWN || totalWork == 0) { fProgressIndicator.beginAnimatedTask(); } else { fProgressIndicator.beginTask(totalWork); } } if (fToolBar != null && !fToolBar.isDisposed()) { fToolBar.setVisible(true); fToolBar.setFocus(); } }
Source:
public GdbAutoTerminateAction() { super(ConsoleMessages.ConsoleAutoTerminateAction_name, IAction.AS_CHECK_BOX); setText(ConsoleMessages.ConsoleAutoTerminateAction_name); setToolTipText(ConsoleMessages.ConsoleAutoTerminateAction_description); // initialize state setChecked(readState()); }

Target:
public GdbAutoTerminateAction() { super(ConsoleMessages.ConsoleAutoTerminateAction_name, IAction.AS_CHECK_BOX); setToolTipText(ConsoleMessages.ConsoleAutoTerminateAction_description); // initialize state setChecked(readState()); }
Source:
public void run() { // Toggle and update the new state boolean terminate = !readState(); setChecked(terminate); // Update preference store IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); if (preferences != null) { preferences.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, terminate); try { preferences.flush(); } catch (BackingStoreException e) { } } }

Target:
public void run() { // All we need to do is update the preference store. There is no other // immediate action to take. IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); if (preferences != null) { preferences.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, !readState()); try { preferences.flush(); } catch (BackingStoreException e) { } } }
Source:
private boolean canPerformInverseNavigation(EStructuralFeature feature){ return allowInverseNavigation && ( // Feature has opposite (this only possible for references) hasEOpposite(feature) || ( // Or // indexing is enabled, and the feature can be indexed (it's not a non-well-behaving derived feature) // and it's a reference TODO this constraint might not be needed. It shall be possible to find elements by an attribute value using the base indexer useIndex && modelComprehension.representable(feature) && (feature instanceof EReference) )); }

Target:
private boolean canPerformInverseNavigation(EStructuralFeature feature){ return ( // Feature has opposite (this only possible for references) hasEOpposite(feature) || ( // Or indexing is enabled, and the feature can be indexed (it's not a non-well-behaving // derived feature) and it's a reference TODO this constraint might not be needed. It shall be possible to find elements by an attribute value using the base indexer useIndex && modelComprehension.representable(feature) && (feature instanceof EReference) )); }
Source:
public static void closeSecondaryShells(SWTWorkbenchBot bot) { SWTBotShell[] shells = bot.shells(); SWTBotShell mainShell = getMainShell(shells); if (mainShell == null) { return; } for (SWTBotShell shell : shells) { boolean visible = shell.isVisible(); if (shell != mainShell && visible) { shell.close(); } } }

Target:
public static void closeSecondaryShells(SWTWorkbenchBot bot) { SWTBotShell[] shells = bot.shells(); SWTBotShell mainShell = getMainShell(shells); if (mainShell == null) { return; } // Close all non-main shell but make sure we don't close an invisible // shell such the special "limbo shell" that Eclipse needs to work Arrays.stream(shells) .filter(shell -> shell != mainShell) .filter(SWTBotShell::isVisible) .forEach(SWTBotShell::close); }
Source:
public void testCanContribute() { // if the test fails, a section is probably renamed in the configuration section assertTrue(processor.canContribute(mock(IStatus.class))); }

Target:
public void testCanContribute() { // if the test fails, a section is probably renamed in the configuration section assertThat(processor.canContribute(mock(IStatus.class)),is(true)); }
Source:
public void addPageTerminalControl(ITerminalControl terminalControl) { fTerminalPageControls.add(terminalControl); // write the currently available buffered history to this new terminal if (fHistoryBuffer.size() > 0) { new WriteHistoryJob(terminalControl).schedule(); } }

Target:
public void addPageTerminalControl(ITerminalControl terminalControl) { // write the currently available buffered history to this new terminal if (fHistoryBuffer.size() > 0) { new WriteHistoryJob(terminalControl).schedule(); } // Add it to the list so it can now receive new input fTerminalPageControls.add(terminalControl); }
Source:
public String generateModelElementId(EObject eObject, ESObjectContainer<ModelElementId> collection) { if (EGenericType.class.isInstance(eObject)) { final EGenericType eGeneric = EGenericType.class.cast(eObject); if (eGeneric.eContainer() != null && eGeneric.eContainer() != this && collection.contains(eGeneric.eContainer())) { final ModelElementId containerId = collection.getModelElementId(eGeneric.eContainer()); return containerId.getId() + ID_SUFFIX; } } return null; }

Target:
public String generateModelElementId(EObject eObject, ESObjectContainer<ModelElementId> collection) { if (EGenericType.class.isInstance(eObject)) { final EGenericType eGeneric = EGenericType.class.cast(eObject); if (eGeneric.eContainer() != null && eGeneric.eContainer() != collection && collection.contains(eGeneric.eContainer())) { // generate artificial ID based on the container of the EGenericType final ModelElementId containerId = collection.getModelElementId(eGeneric.eContainer()); return containerId.getId() + ID_SUFFIX; } } return null; }
Source:
protected ContentSecurityPolicy addOrAppend(String key, String value) { if (m_directives.containsKey(key)) { String existingSource = m_directives.get(key); // Only change directive, if the former value was not-null OR the new value is not null. // If existingSource and new value are both null, do not change directive, since StringUtility.join creates an empty string for two null values // Further check for duplicates and do not add new value, if value already is part of the existing source if ((existingSource != null || value != null) && !StringUtility.containsString(existingSource, value)) { m_directives.put(key, StringUtility.join(SOURCE_SEPARATOR, existingSource, value)); } } else { m_directives.put(key, value); } return this; }

Target:
protected ContentSecurityPolicy addOrAppend(String key, String value) { if (value == null) { return this; } if (m_directives.containsKey(key)) { String existingSource = m_directives.get(key); // Check for duplicates and do not add new value, if value already is part of the existing source if (!StringUtility.containsString(existingSource, value)) { m_directives.put(key, StringUtility.join(SOURCE_SEPARATOR, existingSource, value)); } } else { m_directives.put(key, value); } return this; }
Source:
public void testCrash() throws Exception { IRunnableWithProgress operation = new CrashingRunnable(); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, false, operation); fail("Should have an invocation target exception"); } catch (InvocationTargetException e){ //We should get this } boolean interrupted = Thread.interrupted(); if (interrupted) { fail("Thread was interrupted at end of test"); } }

Target:
public void testCrash() throws Exception { IRunnableWithProgress operation = new CrashingRunnable(); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, false, operation); fail("Should have an invocation target exception"); } catch (InvocationTargetException e){ //We should get this } if (Thread.interrupted()) { fail("Thread was interrupted at end of test"); } }
Source:
private StoredConfig loadUserConfig() throws IOException { FileBasedConfig c = SystemReader.getInstance().openUserConfig(null, FS.DETECTED); try { c.load(); } catch (ConfigInvalidException e1) { IOException e2 = new IOException(MessageFormat .format(LfsText.get().userConfigInvalid, c.getFile() .getAbsolutePath(), e1)); e2.initCause(e1); throw e2; } return c; }

Target:
private StoredConfig loadUserConfig() throws IOException { FileBasedConfig c = SystemReader.getInstance().openUserConfig(null, FS.DETECTED); try { c.load(); } catch (ConfigInvalidException e1) { throw new IOException(MessageFormat .format(LfsText.get().userConfigInvalid, c.getFile() .getAbsolutePath(), e1), e1); } return c; }
Source:
public boolean isDirty() { if (getTrace() == null) { return false; } TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext(); long startTime = ctx.getWindowRange().getStartTime().toNanos(); long endTime = ctx.getWindowRange().getEndTime().toNanos(); // If the time graph control hasn't updated all the way to the end of // the window range then it's dirty. A refresh should happen later. if (getWindowStartTime() != startTime || getWindowEndTime() != endTime) { return true; } return false; }

Target:
public boolean isDirty() { if (getTrace() == null) { return false; } TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext(); long startTime = ctx.getWindowRange().getStartTime().toNanos(); long endTime = ctx.getWindowRange().getEndTime().toNanos(); // If the chart viewer hasn't updated all the way to the end of // the window range then it's dirty. A refresh should happen later. return (getWindowStartTime() != startTime || getWindowEndTime() != endTime); }
Source:
private IBinding resolveBindingPromiscuous() { // If we haven't already resolved the non-promiscuous binding, do so now. if (fBinding == null) { try { CPPSemantics.disablePromiscuousBindingResolution(); resolveBindingNormal(); } finally { CPPSemantics.enablePromiscuousBindingResolution(); } } // If the non-promiscuous binding is not a ProblemBinding, the promiscuous // binding will be the same, so just return it. if (!(fBinding instanceof ProblemBinding)) { return fBinding; } // Otherwise, the non-promiscuous binding is a ProblemBinding. ProblemBinding problem = (ProblemBinding) fBinding; if (problem.getPromiscuousBinding() == null) { // Resolve the promiscuous binding, and store it in the ProblemBinding. IBinding promiscuous = resolveBindingNormal(); problem.setPromiscuousBinding(promiscuous); // Restore the cached ProblemBinding (which resolveBindingNormal() overwrote). fBinding = problem; } return problem.getPromiscuousBinding(); }

Target:
private IBinding resolveBindingPromiscuous() { // If we haven't already resolved the non-promiscuous binding, do so now. if (fBinding == null) { try { CPPSemantics.disablePromiscuousBindingResolution(); resolveBindingNormal(); } finally { CPPSemantics.enablePromiscuousBindingResolution(); } } // If the non-promiscuous binding is not a ProblemBinding, the promiscuous // binding will be the same, so just return it. if (!(fBinding instanceof ProblemBinding)) { return fBinding; } // Otherwise, the non-promiscuous binding is a ProblemBinding. ProblemBinding problem = (ProblemBinding) fBinding; IBinding promiscuous = problem.getPromiscuousBinding(); if (promiscuous == null) { // Resolve the promiscuous binding, and store it in the ProblemBinding. promiscuous = resolveBindingNormal(); problem.setPromiscuousBinding(promiscuous); // Restore the cached ProblemBinding (which resolveBindingNormal() overwrote). fBinding = problem; } return promiscuous; }
Source:
public void paintControl(PaintEvent event) { if (fTextWidget != null) { try { handleDrawRequest(event.gc); } catch (IllegalStateException e) { // Do not allow the exception to escape this PaintListener method into the SWT code. // See http://bugs.eclipse.org/498907 String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$ ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID)); log.log(new Status(IStatus.ERROR, PLUGIN_ID, JFaceTextMessages.getString("MatchingCharacterPainter.unexpected_error"), e)); //$NON-NLS-1$ return; } } }

Target:
public void paintControl(PaintEvent event) { if (fTextWidget != null) { try { handleDrawRequest(event.gc); } catch (IllegalStateException e) { // Do not allow the exception to escape this PaintListener method into the SWT code. // See http://bugs.eclipse.org/498907 String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$ ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID)); log.log(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e)); } } }
Source:
public @NonNull ISegment createSegment(long start, long end) { return new BasicSegment(start, end); }

Target:
protected @NonNull ISegment createSegment(long start, long end) { return new BasicSegment(start, end); }
Source:
protected int getMaximumTotalSize() { // Define max size in properties file. int maxSize = Integer.parseInt(DiagramUIPlugin.INSTANCE.getString("_Pref_DiagramExportSizeMax")); //$NON-NLS-1$ return maxSize; }

Target:
protected int getMaximumTotalSize() { // Define max size in properties file. return Integer.parseInt(DiagramUIPlugin.INSTANCE.getString("_Pref_DiagramExportSizeMax")); //$NON-NLS-1$; }
Source:
void messageConsumptionSingleThreaded() { while (!activeMailboxes.isEmpty() || getFirstRederivable() != null) { RederivableNode node = getFirstRederivable(); while (node != null) { node.rederiveOne(); node = getFirstRederivable(); } if (!activeMailboxes.isEmpty()) { Mailbox mailbox = activeMailboxes.iterator().next(); activeMailboxes.remove(mailbox); mailbox.deliverMessages(); } } }

Target:
void messageConsumptionSingleThreaded() { while (!activeMailboxes.isEmpty() || getFirstRederivable() != null) { // first deliver all the messages ... while (!activeMailboxes.isEmpty()) { Mailbox mailbox = activeMailboxes.iterator().next(); activeMailboxes.remove(mailbox); mailbox.deliverMessages(); } // ... and then start a re-derivation phase RederivableNode node = getFirstRederivable(); if (node != null) { node.rederiveOne(); } } }
Source:
public RangeCondition<E> subCondition(E from, E to) { if (from.compareTo(to) > 0) { throw new IllegalArgumentException(from.toString() + " is greater than " + to.toString()); //$NON-NLS-1$ } return new ContinuousRangeCondition<>(max(fMin, from), min(fMax, to)); }

Target:
public RangeCondition<E> subCondition(E from, E to) { return new ContinuousRangeCondition<>(from, to); }
Source:
private void addViewerToSelectionProvider() { IWorkbenchPart part = getCompareConfiguration().getContainer().getWorkbenchPart(); ISelectionProvider provider = part.getSite().getSelectionProvider(); if (provider instanceof CompareEditorSelectionProvider) { // Replace existing selection provider with our own to track non-text selection EMFCompareEditorSelectionProviderWrapper compareProvider = new EMFCompareEditorSelectionProviderWrapper( (CompareEditorSelectionProvider)provider); part.getSite().setSelectionProvider(compareProvider); compareProvider.addViewers(Arrays.asList((Viewer)getViewer()), getViewer()); } }

Target:
private void addViewerToSelectionProvider() { IWorkbenchPart part = getCompareConfiguration().getContainer().getWorkbenchPart(); ISelectionProvider provider = part.getSite().getSelectionProvider(); if (provider instanceof CompareEditorSelectionProvider) { // Replace existing selection provider with our own to track non-text selection EMFCompareEditorSelectionProviderWrapper compareProvider = new EMFCompareEditorSelectionProviderWrapper( (CompareEditorSelectionProvider)provider); part.getSite().setSelectionProvider(compareProvider); compareProvider.addViewers(Arrays.asList(getViewer()), getViewer()); } }
Source:
public String toString() { return new String(this.workspacePath) + "|" + new String(this.fieldDescriptor); //$NON-NLS-1$ }

Target:
public String toString() { StringBuilder builder = new StringBuilder(); builder.append(this.workspacePath); builder.append("|"); //$NON-NLS-1$ builder.append(this.fieldDescriptor); return builder.toString(); }
Source:
public static String normalizeBranchName(String name, boolean trim) { if (trim) { name = name.trim(); } return name.replaceAll("\\s+([_:-])\\s+", "$1") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll(":", "-") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll("\\s+", "_") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll("_{2,}", "_") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll("^_", "") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll("[^\\w-]", ""); //$NON-NLS-1$ //$NON-NLS-2$ }

Target:
public static String normalizeBranchName(String name, boolean trim) { String result = name; if (trim) { result = name.trim(); } return result.replaceAll("\\s+([_:-])\\s+", "$1") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll(":", "-") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll("\\s+", "_") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll("_{2,}", "_") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll("^_", "") //$NON-NLS-1$//$NON-NLS-2$ .replaceAll("[^\\w-]", ""); //$NON-NLS-1$ //$NON-NLS-2$ }
Source:
public void run(IAction action) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( RepositoryUi.ID_VIEW_REPOSITORIES); } catch (PartInitException e) { StatusHandler .log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Can not show Team Repository View", e)); //$NON-NLS-1$ e.printStackTrace(); } }

Target:
public void run(IAction action) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( RepositoryUi.ID_VIEW_REPOSITORIES); } catch (PartInitException e) { StatusHandler .log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Can not show Team Repository View", e)); //$NON-NLS-1$ } }
Source:
static int getRefreshIndexInterval() { return 1000 * getDefault().getPreferenceStore() .getInt(UIPreferences.REFESH_INDEX_INTERVAL); }

Target:
private static int getRefreshIndexInterval() { return 1000 * getDefault().getPreferenceStore() .getInt(UIPreferences.REFESH_INDEX_INTERVAL); }
Source:
static void rotateProc(long /*int*/ gesture, double angle, double angle_delta, long/*int*/ user_data) { if (OS.gtk_gesture_is_recognized(gesture)) { // returning delta is off by two decimal points double delta = OS.gtk_gesture_rotate_get_angle_delta(gesture)*100; Control control = getControl(user_data); /* TODO: X and Y positions are not retrieved yet */ control.sendGestureEvent(0,SWT.GESTURE_ROTATE,0,0,delta); } }

Target:
static void rotateProc(long /*int*/ gesture, double angle, double angle_delta, long/*int*/ user_data) { if (OS.gtk_gesture_is_recognized(gesture)) { /* * Returning delta is off by two decimal points and is returning negative numbers on * counter clockwise rotations from GTK. From the java doc of GestureEvent.rotation, * we have to invert the rotation number so that positive/negative numbers are returned * correctly (inversed). */ double delta = -(OS.gtk_gesture_rotate_get_angle_delta(gesture)*100); Control control = getControl(user_data); /* TODO: X and Y positions are not retrieved yet */ control.sendGestureEvent(0,SWT.GESTURE_ROTATE,0,0,delta); } }
Source:
private void assertIsLegalIndex(final int index) { int totalCount = itemCount(); Assert.isTrue(index < totalCount && index > 0, java.text.MessageFormat.format( "The index ({0}) is more than the number of items ({1}) in the list.", index, totalCount)); //$NON-NLS-1$ }

Target:
private void assertIsLegalIndex(final int index) { int totalCount = itemCount(); Assert.isTrue(index < totalCount && index >= 0, java.text.MessageFormat.format( "The index ({0}) is more than the number of items ({1}) in the list.", index, totalCount)); //$NON-NLS-1$ }