auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
Builder addClientCapabilities(Collection<String> clientCapabilities) { for (String cap: clientCapabilities) { // TODO(ifrade): Do this is done on parse time if (cap.startsWith("agent=")) { //$NON-NLS-1$ setAgent(cap.substring("agent=".length())); //$NON-NLS-1$ } else { clientCaps.add(cap); } } clientCaps.addAll(clientCapabilities); return this; }

Target:
Builder addClientCapabilities(Collection<String> clientCapabilities) { for (String cap: clientCapabilities) { // TODO(ifrade): Do this is done on parse time if (cap.startsWith("agent=")) { //$NON-NLS-1$ setAgent(cap.substring("agent=".length())); //$NON-NLS-1$ } else { clientCaps.add(cap); } } return this; }
Source:
private static boolean canMatchPacket(final ITmfEvent event) { /* Make sure all required fields are present to match with this event */ ITmfEventField content = event.getContent(); return ((content.getFieldValue(Long.class, TcpEventStrings.SEQ) == null) || (content.getFieldValue(Long.class, TcpEventStrings.ACKSEQ) == null) || (content.getFieldValue(Long.class, TcpEventStrings.FLAGS) == null)); }

Target:
private static boolean canMatchPacket(final ITmfEvent event) { /* Make sure all required fields are present to match with this event */ ITmfEventField content = event.getContent(); return !((content.getFieldValue(Long.class, TcpEventStrings.SEQ) == null) || (content.getFieldValue(Long.class, TcpEventStrings.ACKSEQ) == null) || (content.getFieldValue(Long.class, TcpEventStrings.FLAGS) == null)); }
Source:
private boolean isBinaryEquivalent(IntegerDeclaration other) { if (fAlignment != other.fAlignment) { return false; } if (fLength != other.fLength) { return false; } if (fSigned != other.fSigned) { return false; } // no need for base // no need for encoding // no need for clock // byte inversion is ok on byte order if the element is one byte long return !(fLength == BYTE_ALIGN) && fByteOrder.equals(other.fByteOrder); }

Target:
private boolean isBinaryEquivalent(IntegerDeclaration other) { if (fAlignment != other.fAlignment) { return false; } if (fLength != other.fLength) { return false; } if (fSigned != other.fSigned) { return false; } // no need for base // no need for encoding // no need for clock // byte inversion is ok on byte order if the element is one byte long return !((fLength != BYTE_ALIGN) && !fByteOrder.equals(other.fByteOrder)); }
Source:
private static boolean canMatchPacket(final ITmfEvent event) { /* Make sure all required fields are present to match with this event */ ITmfEventField content = event.getContent(); return ((content.getFieldValue(Long.class, TcpEventStrings.SEQ) != null) || (content.getFieldValue(Long.class, TcpEventStrings.ACKSEQ) != null) || (content.getFieldValue(Long.class, TcpEventStrings.FLAGS) != null)); }

Target:
private static boolean canMatchPacket(final ITmfEvent event) { /* Make sure all required fields are present to match with this event */ ITmfEventField content = event.getContent(); return ((content.getFieldValue(Long.class, TcpEventStrings.SEQ) == null) || (content.getFieldValue(Long.class, TcpEventStrings.ACKSEQ) == null) || (content.getFieldValue(Long.class, TcpEventStrings.FLAGS) == null)); }
Source:
protected boolean checkLevelExists(int level) { return !(level < levelQuarks.size() || level >= 0); }

Target:
protected boolean checkLevelExists(int level) { return !(level >= levelQuarks.size() || level < 0); // if (level >= levelQuarks.size() || level < 0) { // return false; // } // return true; }
Source:
protected SimpleName getNewName(ASTRewrite rewrite) { AST ast= rewrite.getAST(); SimpleName nameNode= ast.newSimpleName(String.valueOf("provider")); //$NON-NLS-1$ // TypeConstants.PROVIDER return nameNode; }

Target:
protected SimpleName getNewName(ASTRewrite rewrite) { AST ast= rewrite.getAST(); SimpleName nameNode= ast.newSimpleName("provider"); //$NON-NLS-1$ // TypeConstants.PROVIDER return nameNode; }
Source:
protected IStatus validateItem(Object item) { for (int i = 0; i < fdisabledModels.length; i++) { if (((IPluginModelBase) item).equals(fdisabledModels[i])) { return new Status(IStatus.CANCEL, IPDEUIConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ } } return new Status(IStatus.OK, IPDEUIConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ }

Target:
protected IStatus validateItem(Object item) { if (fdisabledModels != null && fdisabledModels.contains(item)) { return new Status(IStatus.CANCEL, IPDEUIConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ } return new Status(IStatus.OK, IPDEUIConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ }
Source:
public long getValueReference() { if (getFmiVariable() != null) { return (int) getFmiVariable().getValueReference(); } return super.getValueReference(); }

Target:
public long getValueReference() { if (getFmiVariable() != null) { return getFmiVariable().getValueReference(); } return super.getValueReference(); }
Source:
public synchronized void dispose() { synchronized (this) { if (fFileInput != null) { try { fFileInput.close(); } catch (IOException e) { Activator.getInstance().logError("Error disposing trace. File: " + getPath(), e); //$NON-NLS-1$ } } } super.dispose(); }

Target:
public synchronized void dispose() { if (fFileInput != null) { try { fFileInput.close(); } catch (IOException e) { Activator.getInstance().logError("Error disposing trace. File: " + getPath(), e); //$NON-NLS-1$ } } super.dispose(); }
Source:
public Object run(Object object) throws Exception { String[] args = Platform.getCommandLineArgs(); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=540222: log stack traces when we are nearing the test timeout String timeoutParameter = getParameterValue(args, "-timeout"); //$NON-NLS-1$ if (timeoutParameter != null) { DumpStackTracesTimer.startStackDumpTimeoutTimer(timeoutParameter); } return Integer.valueOf(OsgiSurefireBooter.run(args)); }

Target:
public Object run(Object object) throws Exception { String[] args = Platform.getCommandLineArgs(); return Integer.valueOf(OsgiSurefireBooter.run(args)); }
Source:
public String getName() { return fName.get(0); }

Target:
public String getName() { return fName.isEmpty() ? "" : fName.get(0); //$NON-NLS-1$ }
Source:
private void changeExperimentName(TracePackageExperimentElement experimentElement) { String currentName = experimentElement.getImportName(); int nameSuffixIndex = 1; while (experimentExists(experimentElement)) { String newName = currentName + " (" + nameSuffixIndex + ')'; //$NON-NLS-1$ experimentElement.setImportName(newName); nameSuffixIndex++; } }

Target:
private void changeExperimentName(TracePackageExperimentElement experimentElement) { String currentName = experimentElement.getImportName(); int nameSuffixIndex = 2; while (experimentExists(experimentElement)) { String newName = currentName + " (" + nameSuffixIndex + ')'; //$NON-NLS-1$ experimentElement.setImportName(newName); nameSuffixIndex++; } }
Source:
public String getText(final Object element) { if (element == null) { return ""; //$NON-NLS-1$ } return ((FileDiff) element).getLabel(element); }

Target:
public String getText(final Object element) { if (element == null) { return null; } return ((FileDiff) element).getLabel(element); }
Source:
long /*int*/ getsurePressReleaseProc (long /*int*/ gesture, int n_press, double x, double y, long /*int*/ user_data) { long /*int*/ event = GTK.gtk_get_current_event(); long /*int*/ result = 0; switch ((int)/*64*/user_data) { case GESTURE_PRESSED: result = gtk_gesture_press_event(gesture, n_press, x, y); break; case GESTURE_RELEASED: result = gtk_gesture_release_event(gesture, n_press, x, y); break; } gdk_event_free(event); return result; }

Target:
long /*int*/ getsurePressReleaseProc (long /*int*/ gesture, int n_press, double x, double y, long /*int*/ user_data) { long /*int*/ event = GTK.gtk_get_current_event(); long /*int*/ result = 0; switch ((int)/*64*/user_data) { case GESTURE_PRESSED: result = gtk_gesture_press_event(gesture, n_press, x, y, event); break; case GESTURE_RELEASED: result = gtk_gesture_release_event(gesture, n_press, x, y, event); break; } gdk_event_free(event); return result; }
Source:
private void recreateEmptyArea() { if (emptyArea != null) { // throw away already existing empty area emptyArea.dispose(); emptyArea = null; } if (images != null) { disposeImages(); images = new ArrayList<>(); } // re-read the project wizards and re-create the empty area createEmptyArea(displayArea); switchTopControlRunnable.run(); }

Target:
private void recreateEmptyArea() { if (emptyArea != null) { // throw away already existing empty area emptyArea.dispose(); emptyArea = null; } disposeImages(); // re-read the project wizards and re-create the empty area createEmptyArea(displayArea); switchTopControlRunnable.run(); }
Source:
public String getLine(int lineIndex) { try { final IRegion lineRegion = getLineInformation(lineIndex); return document.get(lineRegion.getOffset(), lineRegion.getLength()); } catch (BadLocationException e) { ConsolePlugin.log(e); return null; } }

Target:
public String getLine(int lineIndex) { try { final IRegion lineRegion = getLineInformation(lineIndex); return document.get(lineRegion.getOffset(), lineRegion.getLength()); } catch (BadLocationException e) { ConsolePlugin.log(e); return ""; //$NON-NLS-1$ } }
Source:
static long /*int*/ gdk_pixbuf_new_from_file(String filename) { int length = filename.length (); char chars = new char [length]; filename.getChars (0, length, chars, 0); byte buffer = Converter.wcsToMbcs(chars, true); long /*int*/ pixbuf = GDK.gdk_pixbuf_new_from_file(buffer, null); return pixbuf; }

Target:
static long /*int*/ gdk_pixbuf_new_from_file(String filename) { int length = filename.length (); char chars = new char [length]; filename.getChars (0, length, chars, 0); byte buffer = Converter.wcsToMbcs(chars, true); return GDK.gdk_pixbuf_new_from_file(buffer, null); }
Source:
public void tesIsModifiedBySameLastModifiedAndDifferentSize() throws Exception { File f1 = createFile("foo", "lorem".getBytes()); File f2 = createFile("bar", "lorem ipsum".getBytes()); long now = System.currentTimeMillis(); f1.setLastModified(f2.lastModified()); // Make sure f1 and f2 have the same lastModified FileSnapshot save = FileSnapshot.save(f1); Thread.sleep(3000L); assertEquals(save.lastModified(), f2.lastModified()); assertTrue(save.isModified(f2)); }

Target:
public void tesIsModifiedBySameLastModifiedAndDifferentSize() throws Exception { File f1 = createFile("foo", "lorem".getBytes()); File f2 = createFile("bar", "lorem ipsum".getBytes()); f1.setLastModified(f2.lastModified()); // Make sure f1 and f2 have the same lastModified FileSnapshot save = FileSnapshot.save(f1); // Make sure that the modified and read timestamps are far enough, so that // check is done by size Thread.sleep(3000L); assertEquals(save.lastModified(), f2.lastModified()); assertTrue(save.isModified(f2)); }
Source:
public void setEmptyExceptionSpecification() { assertNotFrozen(); typeIds = IASTTypeId.EMPTY_TYPEID_ARRAY; setNoexceptExpression(new CPPASTLiteralExpression(IASTLiteralExpression.lk_true, "true".toCharArray())); //$NON-NLS-1$ // TODO this is probably not the correct way to do it... }

Target:
public void setEmptyExceptionSpecification() { assertNotFrozen(); typeIds = IASTTypeId.EMPTY_TYPEID_ARRAY; }
Source:
public static void setUpBeforeClass() throws CoreException { project = TestUtils.createProject("EditorToOutlineAdapterFactoryTest" + System.currentTimeMillis()); testFile = TestUtils.createUniqueTestFile(project, "Hello World !!"); // look for content outline in current workbench, could be null IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .findView("org.eclipse.ui.views.ContentOutline"); //$NON-NLS-1$ // implicitly checks for null if (viewPart instanceof ContentOutline) { outline = (ContentOutline) viewPart; } Assert.assertNotNull(outline); }

Target:
public static void setUpBeforeClass() throws CoreException { // look for content outline in current workbench, could be null IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .findView("org.eclipse.ui.views.ContentOutline"); //$NON-NLS-1$ // implicitly checks for null if (viewPart instanceof ContentOutline) { outline = (ContentOutline) viewPart; } Assert.assertNotNull(outline); }
Source:
public static void beforeClass() { SWTBotUtils.initialize(); Thread.currentThread().setName("SWTBotTest"); /* set up for swtbot */ SWTBotPreferences.TIMEOUT = 60000; /* 60 second timeout */ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; SWTWorkbenchBot bot = new SWTWorkbenchBot(); SWTBotUtils.closeView("welcome", bot); /* Prepare the workspace */ prepareWorkspace(); /* Finish waiting for eclipse to load */ WaitUtils.waitForJobs(); /* Create project */ SWTBotUtils.createProject(PROJECT_NAME); }

Target:
public void beforeClass() { SWTBotUtils.initialize(); Thread.currentThread().setName("SWTBotTest"); /* set up for swtbot */ SWTBotPreferences.TIMEOUT = 60000; /* 60 second timeout */ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; SWTWorkbenchBot bot = new SWTWorkbenchBot(); SWTBotUtils.closeView("welcome", bot); /* Prepare the workspace */ prepareWorkspace(); /* Finish waiting for eclipse to load */ WaitUtils.waitForJobs(); /* Create project */ SWTBotUtils.createProject(PROJECT_NAME); }
Source:
private static int inversePremultipliedColor(int color, int alpha) { // Calculating inverse for premultiplied color gives a range of possible colors // due to rounding that occurs with integer calculations. However, alpha-blend // formula only has the multiplied component, so all of those inverses are equivalent. return (255*color + alpha-1) / alpha; }

Target:
static int inversePremultipliedColor(int color, int alpha) { return (255*color + alpha-1) / alpha; }
Source:
protected Notifier getNotifierFromEditorInput(Object editorInput) { Object input = editorInput; if (input instanceof RootObject) { final EObject root = ((RootObject) input).getRoot(); if (root.eResource() != null) { input = root.eResource(); } else { input = root; } } if (!Notifier.class.isInstance(input)) { throw new IllegalStateException("The editor input is not a Notifier!"); //$NON-NLS-1$ } return (Notifier) input; }

Target:
protected Notifier getNotifierFromEditorInput(Object editorInput) { Object input = editorInput; if (input instanceof RootObject) { input = ((RootObject) input).getRoot(); } if (!Notifier.class.isInstance(input)) { throw new IllegalStateException("The editor input is not a Notifier!"); //$NON-NLS-1$ } return (Notifier) input; }
Source:
private boolean reportInternalServerErrorOverSideband() throws IOException { @SuppressWarnings("resource" /* java 7 */) SideBandOutputStream err = new SideBandOutputStream( SideBandOutputStream.CH_ERROR, SideBandOutputStream.SMALL_BUF, rawOut); err.write(Constants.encode(JGitText.get().internalServerError)); err.flush(); return true; }

Target:
private void reportInternalServerErrorOverSideband() throws IOException { @SuppressWarnings("resource" /* java 7 */) SideBandOutputStream err = new SideBandOutputStream( SideBandOutputStream.CH_ERROR, SideBandOutputStream.SMALL_BUF, rawOut); err.write(Constants.encode(JGitText.get().internalServerError)); err.flush(); }
Source:
public void traceClosed(@Nullable TmfTraceClosedSignal signal) { if (signal == null || signal.getTrace() != fTrace) { return; } // Reset the internal data fTrace = null; Runnable r = this::reset; // Make sure that runnable is called from UI thread if (Display.getCurrent() == null) { Display d = Display.getDefault(); if (!d.isDisposed()) { d.asyncExec(r); } } else { r.run(); } }

Target:
public void traceClosed(@Nullable TmfTraceClosedSignal signal) { if (signal == null || signal.getTrace() != fTrace) { return; } // Reset the internal data fTrace = null; reset(); }
Source:
private Property toProperty(@NonNull String value) { switch (value) { case "hasStagedChanges": //$NON-NLS-1$ return Property.HAS_STAGED_CHANGES; case "hasUnstagedChanges": //$NON-NLS-1$ return Property.HAS_UNSTAGED_CHANGES; case "hasNotIgnoredResources": //$NON-NLS-1$ return Property.HAS_NOT_IGNORED_RESOURCES; case "hasTrackedResources": //$NON-NLS-1$ return Property.HAS_TRACKED_RESOURCES; default: break; } return null; }

Target:
private Property toProperty(@NonNull String value) { switch (value) { case "hasStagedChanges": //$NON-NLS-1$ return Property.HAS_STAGED_CHANGES; case "hasUnstagedChanges": //$NON-NLS-1$ return Property.HAS_UNSTAGED_CHANGES; case "hasNotIgnoredResources": //$NON-NLS-1$ return Property.HAS_NOT_IGNORED_RESOURCES; case "hasTrackedResources": //$NON-NLS-1$ return Property.HAS_TRACKED_RESOURCES; default: return null; } }
Source:
public ImageDescriptor getImageDescriptorForProgram(String extension) { ImageDescriptor imageDescriptor = getImageRegistry().getDescriptor(extension); if (imageDescriptor == null && extension != null) { Program program = ProgramFinder.findProgram(extension.toLowerCase()); if (program == null || program.getImageData() == null) { // provide no image (i.e. leave null) } else { imageDescriptor = ImageDescriptor.createFromImageData(program.getImageData()); getImageRegistry().put(extension, imageDescriptor); } } return imageDescriptor; }

Target:
public ImageDescriptor getImageDescriptorForProgram(String extension) { ImageDescriptor imageDescriptor = getImageRegistry().getDescriptor(extension); if (imageDescriptor == null && extension != null) { Program program = ProgramFinder.findProgram(extension); if (program == null || program.getImageData() == null) { // provide no image (i.e. leave null) } else { imageDescriptor = ImageDescriptor.createFromImageData(program.getImageData()); getImageRegistry().put(extension, imageDescriptor); } } return imageDescriptor; }
Source:
public long nanosToCycles(long nanos) { // CTFTrace subtracts the clock offset in cycles from the output CTFTrace trace = fTrace; if (trace != null) { return trace.timestampNanoToCycles(nanos - trace.getClock().getClockOffsetNs()) + trace.getOffset(); } return 0; }

Target:
public long nanosToCycles(long nanos) { // CTFTrace subtracts the clock offset in cycles from the output CTFTrace trace = fTrace; if (trace != null) { return trace.timestampNanoToCycles(nanos) + trace.getOffset(); } return 0; }
Source:
public int getInt(String key) throws NumberFormatException { String setting = items.get(key); if (setting == null) { // Integer.valueOf(null) will throw a NumberFormatException and // meet our spec, but this message is clearer. throw new NumberFormatException( "There is no setting associated with the key \"" + key + "\"");//$NON-NLS-1$ //$NON-NLS-2$ } return Integer.valueOf(setting).intValue(); }

Target:
public int getInt(String key) throws NumberFormatException { String setting = items.get(key); if (setting == null) { // Integer.valueOf(null) will throw a NumberFormatException and // meet our spec, but this message is clearer. throw new NumberFormatException( "There is no setting associated with the key \"" + key + "\"");//$NON-NLS-1$ //$NON-NLS-2$ } return Integer.parseInt(setting); }
Source:
private static void runInCurrentThread(IRunnableWithProgress runnable, IProgressMonitor progressMonitor) throws InterruptedException, InvocationTargetException { try { if (runnable != null) { runnable.run(progressMonitor); } } catch (InvocationTargetException | InterruptedException | ThreadDeath e) { // Make sure to propagate ThreadDeath, or threads will never fully // terminate. throw e; }catch (OperationCanceledException e) { throw new InterruptedException(); } catch (RuntimeException | Error e) { throw new InvocationTargetException(e); } }

Target:
private static void runInCurrentThread(IRunnableWithProgress runnable, IProgressMonitor progressMonitor) throws InterruptedException, InvocationTargetException { try { if (runnable != null) { runnable.run(progressMonitor); } } catch (InvocationTargetException | InterruptedException e) { throw e; } catch (OperationCanceledException e) { throw new InterruptedException(); } catch (ThreadDeath e) { // Make sure to propagate ThreadDeath, or threads will never fully // terminate. throw e; } catch (RuntimeException | Error e) { throw new InvocationTargetException(e); } }
Source:
public static boolean isTarFile(String fileName) { if (fileName.length() == 0) { return false; } TarFile tarFile = null; try { tarFile = new TarFile(fileName); } catch (TarException | IOException tarException) { return false; } finally { if (tarFile != null) { try { tarFile.close(); } catch (IOException e) { // ignore } } } return true; }

Target:
public static boolean isTarFile(String fileName) { if (fileName.length() == 0) { return false; } TarFile tarFile = null; try { tarFile = new TarFile(fileName); } catch (TarException | IOException exception) { return false; } finally { if (tarFile != null) { try { tarFile.close(); } catch (IOException e) { // ignore } } } return true; }
Source:
public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null) { return false; } if (obj instanceof ReferenceBindingSetWrapper) { ReferenceBindingSetWrapper other = (ReferenceBindingSetWrapper) obj; return identityEqual(this.referenceBinding, other.referenceBinding); } return false; }

Target:
public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof ReferenceBindingSetWrapper) { ReferenceBindingSetWrapper other = (ReferenceBindingSetWrapper) obj; return identityEqual(this.referenceBinding, other.referenceBinding); } return false; }
Source:
private boolean contains(CodeSource codeSource) { if (codeSource == null) return false; URL url = codeSource.getLocation(); if (url == null) return false; // Check to see if this URL is in our set of URLs to give AllPermissions to. for (URL url1 : urls) { // We do simple equals test here because we assume the URLs will be the same objects. if (url1 == url) { return true; } } return false; }

Target:
private boolean contains(CodeSource codeSource) { if (codeSource == null) return false; URL location = codeSource.getLocation(); if (location == null) return false; // Check to see if this URL is in our set of URLs to give AllPermissions to. for (URL url : urls) { // We do simple equals test here because we assume the URLs will be the same objects. if (url == location) { return true; } } return false; }
Source:
public String toString() { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < this.size; i++) { buffer.append(CharOperation.toString(this.elements[i])).append("\n"); //$NON-NLS-1$ } return buffer.toString(); }

Target:
public String toString() { StringBuilder buffer = new StringBuilder(); for (int i = 0; i < this.size; i++) { buffer.append(CharOperation.toString(this.elements[i])).append("\n"); //$NON-NLS-1$ } return buffer.toString(); }
Source:
private URI resolve(IResourceLocator locator) { String attributeDataPath = getAttributeDataPath(); StringBuilder builder = new StringBuilder(attributeDataPath); String rawPath = locator.getRawPath(); builder.append(rawPath); String pathname = builder.toString(); // Default db/attr to workspace if this is developer's runtime if (pathname.contains("workspace")) { pathname = pathname.replaceAll("\\\\", "/"); pathname = pathname.replaceFirst("file:", ""); } File file = new File(pathname); return file.toURI(); }

Target:
private URI resolve(IResourceLocator locator) { String attributeDataPath = getAttributeDataPath(); String rawPath = locator.getRawPath(); String pathname = attributeDataPath + rawPath; // Default db/attr to workspace if this is developer's runtime if (pathname.contains("workspace")) { pathname = pathname.replaceAll("\\\\", "/"); pathname = pathname.replaceFirst("file:", ""); } File file = new File(pathname); return file.toURI(); }
Source:
private boolean sameCommit(RevCommit a, RevCommit b) { // Reference comparison is intentional; BlameGenerator uses a single // RevWalk which caches the RevCommit objects, and if a given commit // is cached the RevWalk returns the same instance. return a == b; }

Target:
private static boolean sameCommit(RevCommit a, RevCommit b) { // Reference comparison is intentional; BlameGenerator uses a single // RevWalk which caches the RevCommit objects, and if a given commit // is cached the RevWalk returns the same instance. return a == b; }
Source:
private static String getTracePath(String projectName, String traceName, Boolean isExperiment) { String separator = "/"; //$NON-NLS-1$ StringJoiner filePath = new StringJoiner(separator, separator, separator); filePath.add(projectName); String childrenName = isExperiment ? "Experiments" : "Traces"; //$NON-NLS-1$ //$NON-NLS-2$ filePath.add(childrenName); filePath.add(traceName); return filePath.toString(); }

Target:
private static String getTracePath(String projectName, String traceName, Boolean isExperiment) { String separator = "/"; //$NON-NLS-1$ StringJoiner filePath = new StringJoiner(separator, separator, separator); filePath.add(projectName); String childrenName = isExperiment ? "Experiments" : "Traces"; //$NON-NLS-1$ //$NON-NLS-2$ filePath.add(childrenName); filePath.add(traceName); return String.valueOf(filePath); }
Source:
public int getMarks(TreeWalk walk) throws MissingObjectException, IncorrectObjectTypeException, IOException { int marks = 0; for (int index = 0; index < filters.length; index++) { TreeFilter filter = filters[index]; if (filter != null) { try { boolean marked = filter.include(walk); if (marked) marks |= (int) (1L << index); } catch (StopWalkException e) { // Don't check tree filter anymore, it will no longer // match filters[index] = null; } } } return marks; }

Target:
public int getMarks(TreeWalk walk) throws MissingObjectException, IncorrectObjectTypeException, IOException { int marks = 0; for (int index = 0; index < filters.length; index++) { TreeFilter filter = filters[index]; if (filter != null) { try { boolean marked = filter.include(walk); if (marked) marks |= (1 << index); } catch (StopWalkException e) { // Don't check tree filter anymore, it will no longer // match filters[index] = null; } } } return marks; }
Source:
public boolean isDecorationReady(Object element, IDecorationContext context) { // the decoration is only reported as ready, if we are in the UI thread and if // the update job is running. // Because the update job is running in the UI thread, it can be the only caller // of this method if the flag isUpdateJobRunning is TRUE if (isUpdateJobRunning.get()) { return internalGetResult(element, context) != null; } // in all other cases, some other logic than the update job is asking and that // should always be answered with false - see Bug 417255 return false; }

Target:
public boolean isDecorationReady(Object element, IDecorationContext context) { // the decoration is only reported as ready, if we are in the UI thread and if // the update job is running. // Because the update job is running in the UI thread, it can be the only caller // of this method if the flag isUpdateJobRunning is TRUE if (isUpdateJobRunning) { return internalGetResult(element, context) != null; } // in all other cases, some other logic than the update job is asking and that // should always be answered with false - see Bug 417255 return false; }
Source:
public void addStream(long id, File streamFile) throws CTFException { final File file = streamFile; if (file == null) { throw new CTFException("cannot create a stream with no file"); //$NON-NLS-1$ } ICTFStream stream = fStreams.computeIfAbsent(id, k -> new CTFStream(this)); if (stream instanceof CTFStream) { CTFStream ctfStream = (CTFStream) stream; ctfStream.addInput(new CTFStreamInput(stream, file)); } else { throw new CTFException("Stream does not support adding input"); //$NON-NLS-1$ } }

Target:
public void addStream(long id, File streamFile) throws CTFException { final File file = streamFile; if (file == null) { throw new CTFException("cannot create a stream with no file"); //$NON-NLS-1$ } ICTFStream stream = fStreams.computeIfAbsent(id, ctfStream -> new CTFStream(this)); if (stream instanceof CTFStream) { CTFStream ctfStream = (CTFStream) stream; ctfStream.addInput(new CTFStreamInput(stream, file)); } else { throw new CTFException("Stream does not support adding input"); //$NON-NLS-1$ } }
Source:
public StringFieldEditor(String name, String labelText, int width, int strategy, Composite parent) { init(name, labelText); widthInChars = width; setValidateStrategy(strategy); isValid = false; errorMessage = JFaceResources .getString("StringFieldEditor.errorMessage");//$NON-NLS-1$ createControl(parent); }

Target:
public StringFieldEditor(String name, String labelText, int width, int strategy, Composite parent) { this(name, labelText, width, 1, strategy, parent); }
Source:
public static void touch(Path f) throws IOException { try (FileChannel fc = FileChannel.open(f, StandardOpenOption.CREATE, StandardOpenOption.APPEND, StandardOpenOption.SYNC)) { Files.setLastModifiedTime(f, FileTime.from(Instant.now())); } }

Target:
public static void touch(Path f) throws IOException { try (FileChannel fc = FileChannel.open(f, StandardOpenOption.CREATE, StandardOpenOption.APPEND, StandardOpenOption.SYNC)) { // touch } Files.setLastModifiedTime(f, FileTime.from(Instant.now())); }
Source:
public int hashCode() { return Objects.hash(fEntry, fTime, fDuration, fValue); }

Target:
public int hashCode() { return Objects.hash(fEntry, fTime, fDuration, getValue()); }
Source:
private boolean isFileKeyChanged(Object currFileKey) { boolean changed = currFileKey != MISSING_FILEKEY && !currFileKey.equals(fileKey); LOG.debug("file={}, FileKey changed from to {}", //$NON-NLS-1$ file, fileKey, currFileKey); return changed; }

Target:
private boolean isFileKeyChanged(Object currFileKey) { boolean changed = currFileKey != MISSING_FILEKEY && !currFileKey.equals(fileKey); if (changed) { LOG.debug("file={}, FileKey changed from to {}", //$NON-NLS-1$ file, fileKey, currFileKey); } return changed; }
Source:
public void setNewName(String newName) { this.fRenameResourceProcessor.setNewResourceName(newName); super.setForcePreview(true); super.setForceFinish(true); System.out.println("new name set"); //$NON-NLS-1$ }

Target:
public void setNewName(String newName) { this.fRenameResourceProcessor.setNewResourceName(newName); super.setForcePreview(true); super.setForceFinish(true); }
Source:
private void updateSslVerifyUser(boolean value) { StoredConfig userConfig = null; try { userConfig = SystemReader.getInstance().getUserConfig(); updateSslVerify(userConfig, value); } catch (IOException | ConfigInvalidException e) { // Log it, but otherwise ignore here. LOG.error(MessageFormat.format(JGitText.get().userConfigInvalid, userConfig, e)); } }

Target:
private void updateSslVerifyUser(boolean value) { StoredConfig userConfig = null; try { userConfig = SystemReader.getInstance().getUserConfig(); updateSslVerify(userConfig, value); } catch (IOException | ConfigInvalidException e) { // Log it, but otherwise ignore here. LOG.error(e.getMessage(), e); } }
Source:
public HttpConfig(URIish uri) { StoredConfig userConfig = GlobalConfigCache.getInstance() .getUserConfig(); try { userConfig.load(); } catch (IOException | ConfigInvalidException e) { // Log it and then work with default values. LOG.error(MessageFormat.format(JGitText.get().userConfigFileInvalid, userConfig, e)); init(new Config(), uri); return; } init(userConfig, uri); }

Target:
public HttpConfig(URIish uri) { StoredConfig userConfig = null; try { userConfig = GlobalConfigCache.getInstance().getUserConfig(); } catch (IOException | ConfigInvalidException e) { // Log it and then work with default values. LOG.error(MessageFormat.format(JGitText.get().userConfigFileInvalid, userConfig, e)); init(new Config(), uri); return; } init(userConfig, uri); }
Source:
public StoredConfig getSystemConfig() { if (systemConfig.isOutdated()) { try { LOG.debug("loading system config {}", //$NON-NLS-1$ systemConfig); systemConfig.load(); } catch (IOException e) { throw new RuntimeException(e); } catch (ConfigInvalidException e) { throw new RuntimeException( MessageFormat.format( JGitText.get().systemConfigFileInvalid, systemConfig.getFile().getAbsolutePath(), e), e); } } return systemConfig; }

Target:
public StoredConfig getSystemConfig() throws IOException, ConfigInvalidException { if (systemConfig.isOutdated()) { try { LOG.debug("loading system config {}", //$NON-NLS-1$ systemConfig); systemConfig.load(); } catch (ConfigInvalidException e) { LOG.error(MessageFormat.format( JGitText.get().systemConfigFileInvalid, systemConfig.getFile().getAbsolutePath()), e); throw e; } } return systemConfig; }
Source:
private void commit(boolean pushUpstream) { boolean reEnable = false; // Don't allow to do anything as long as commit is in progress enableAllWidgets(false); try { boolean jobScheduled = !internalCommit(pushUpstream, () -> enableAllWidgets(true)); // If a job was scheduled, our Runnable will re-enable the widgets // once the commit and push is done; even if it fails. Otherwise, we // must re-enable the widgets here and now ourselves. reEnable = !jobScheduled; } catch (RuntimeException e) { // See bugs 550336, 550513 // If internalCommit() should fail after having scheduled the job, // we may re-enable a little too early. But better that than never. reEnable = true; Activator.handleError(e.getLocalizedMessage(), e, true); } finally { if (reEnable) { enableAllWidgets(true); } } }

Target:
private void commit(boolean pushUpstream) { boolean reEnable = false; // Don't allow to do anything as long as commit is in progress enableAllWidgets(false); try { boolean jobScheduled = internalCommit(pushUpstream, () -> enableAllWidgets(true)); // If a job was scheduled, our Runnable will re-enable the widgets // once the commit and push is done; even if it fails. Otherwise, we // must re-enable the widgets here and now ourselves. reEnable = !jobScheduled; } catch (RuntimeException e) { // See bugs 550336, 550513 // If internalCommit() should fail after having scheduled the job, // we may re-enable a little too early. But better that than never. reEnable = true; Activator.handleError(e.getLocalizedMessage(), e, true); } finally { if (reEnable) { enableAllWidgets(true); } } }
Source:
private File getRunDirectory(Repository repository, @NonNull String hookName) { if (repository.isBare()) { return repository.getDirectory(); } else { switch (hookName) { case "pre-receive": //$NON-NLS-1$ case "update": //$NON-NLS-1$ case "post-receive": //$NON-NLS-1$ case "post-update": //$NON-NLS-1$ case "push-to-checkout": //$NON-NLS-1$ return repository.getDirectory(); default: return repository.getWorkTree(); } } }

Target:
private File getRunDirectory(Repository repository, @NonNull String hookName) { if (repository.isBare()) { return repository.getDirectory(); } switch (hookName) { case "pre-receive": //$NON-NLS-1$ case "update": //$NON-NLS-1$ case "post-receive": //$NON-NLS-1$ case "post-update": //$NON-NLS-1$ case "push-to-checkout": //$NON-NLS-1$ return repository.getDirectory(); default: return repository.getWorkTree(); } }
Source:
private static void testPidSorting(final SWTBotTree tree, final SWTBotTimeGraph timeGraph) { SWTBotTreeColumn column = tree.header(PID_COLUMN); String[] expected = { LTTNG_CONSUMER_PROCESS_NAME, KTHREAD_PROCESS_NAME, SYSTEMD_PROCESS_NAME }; /* Sort direction Up */ SWTBotTestCondition condition = getSortCondition(PID_COLUMN, PROCESS_COLUMN_ID, expected, timeGraph, false); clickColumn(tree, column, condition); /* Sort direction Down */ String[] expected2 = { SYSTEMD_PROCESS_NAME, KTHREAD_PROCESS_NAME, LTTNG_CONSUMER_PROCESS_NAME }; condition = getSortCondition(PID_COLUMN, PROCESS_COLUMN_ID, expected2, timeGraph, false); clickColumn(tree, column, condition); }

Target:
private static void testPidSorting(final SWTBotTree tree, final SWTBotTimeGraph timeGraph) { SWTBotTreeColumn column = tree.header(PID_COLUMN); String[] expected = { SYSTEMD_PROCESS_NAME, KTHREAD_PROCESS_NAME, LTTNG_CONSUMER_PROCESS_NAME }; /* Sort direction Up */ SWTBotTestCondition condition = getSortCondition(PID_COLUMN, PROCESS_COLUMN_ID, expected, timeGraph, false); clickColumn(tree, column, condition); /* Sort direction Down */ String[] expected2 = { LTTNG_CONSUMER_PROCESS_NAME, KTHREAD_PROCESS_NAME, SYSTEMD_PROCESS_NAME }; condition = getSortCondition(PID_COLUMN, PROCESS_COLUMN_ID, expected2, timeGraph, false); clickColumn(tree, column, condition); }
Source:
public void log(IStatus status) { int severity = status.getSeverity(); // Log the status message log(status.getMessage(), severity); // Log the exception if applicable if (status.getException() != null) log(status.getException().getMessage(), severity); // Log any children of this status IStatus[] nestedStatus = status.getChildren(); if (nestedStatus != null) for (IStatus nestedStatu : nestedStatus) { log(nestedStatu); } }

Target:
public void log(IStatus status) { int severity = status.getSeverity(); // Log the status message log(status.getMessage(), severity); // Log the exception if applicable if (status.getException() != null) log(status.getException().getMessage(), severity); // Log any children of this status IStatus[] nestedStatus = status.getChildren(); if (nestedStatus != null) for (IStatus s : nestedStatus) { log(s); } }
Source:
private boolean fullyDelete(File file) { if (file.isDirectory()) { File[] children = file.listFiles(); if (children != null) { for (File children1 : children) { // we will not stop even if some deletion failed fullyDelete(new File(file, children1.getName())); } } } // will attempt to delete before exists check to get rid of dead links if (file.delete()) { return true; } // will return true if files does not actually exist even delete fails return !file.exists(); }

Target:
private boolean fullyDelete(File file) { if (file.isDirectory()) { File[] children = file.listFiles(); if (children != null) { for (File child : children) { // we will not stop even if some deletion failed fullyDelete(new File(file, child.getName())); } } } // will attempt to delete before exists check to get rid of dead links if (file.delete()) { return true; } // will return true if files does not actually exist even delete fails return !file.exists(); }
Source:
public ExecuteCliParsersJob(CliCommandLine commandLine) { super("Executing CLI parser"); //$NON-NLS-1$ setSystem(true); fCommandLine = commandLine; }

Target:
public ExecuteCliParsersJob(CliCommandLine commandLine) { super("Executing CLI parser"); //$NON-NLS-1$ fCommandLine = commandLine; }
Source:
protected void dispose() { super.dispose(); // Get lock on ourself before closing. Closing streams check for console finish. // Finish check need lock on (this) console. Since closing also lock on stream // this can deadlock with other threads (double) closing streams at same time // but already own a lock on console. (bug 551902) // Long story short. Before closing IOConsole...Stream get lock from associated // console to prevent deadlocks. synchronized (this) { // make a copy of the open streams and close them all // a copy is needed as close the streams results in a callback that // removes the streams from the openStreams collection (bug 152794) List<Closeable> list = new ArrayList<>(openStreams); for (Closeable closable : list) { try { closable.close(); } catch (IOException e) { // e.printStackTrace(); } } inputStream = null; } final IDocument document = partitioner.getDocument(); document.setDocumentPartitioner(null); partitioner.disconnect(); }

Target:
protected void dispose() { // Get lock on ourself before closing. Closing streams check for console finish. // Finish check need lock on (this) console. Since closing also lock on stream // this can deadlock with other threads (double) closing streams at same time // but already own a lock on console. (bug 551902) // Long story short. Before closing IOConsole...Stream get lock from associated // console to prevent deadlocks. synchronized (this) { // make a copy of the open streams and close them all // a copy is needed as close the streams results in a callback that // removes the streams from the openStreams collection (bug 152794) List<Closeable> list = new ArrayList<>(openStreams); for (Closeable closable : list) { try { closable.close(); } catch (IOException e) { // e.printStackTrace(); } } inputStream = null; } final IDocument document = partitioner.getDocument(); document.setDocumentPartitioner(null); partitioner.disconnect(); super.dispose(); }
Source:
private void finishInternal() { // Ensure task not currently running. if (m_leasedThread.get() != null) { return; } // Ensure task to be in done state, because method also called for periodic tasks which did not complete yet. if (!isDone()) { return; } // Ensure to be called only once (thread safety). if (!m_finished.compareAndSet(false, true)) { return; } finished(); }

Target:
private void finishInternal() { // Ensure task not currently running. if (m_leasedThread != null) { return; } // Ensure task to be in done state, because method also called for periodic tasks which did not complete yet. if (!isDone()) { return; } // Ensure to be called only once (thread safety). if (!m_finished.compareAndSet(false, true)) { return; } finished(); }
Source:
public static boolean isResurrected(ChangeItem changeItem) { // There's a change corresponding to a Deleted Item, item MUST have been resurrected return (changeItem.getBaselineVersion().isValid() && isDeleted( changeItem.getBaselineVersion())) || (changeItem.getChangeType().equals( ChangeType.TUPLE_CHANGE) && changeItem.getDestinationVersion().isValid() && isDeleted( changeItem.getDestinationVersion()) && changeItem.getCurrentVersion().getModType().equals( ModificationType.INTRODUCED)); }

Target:
public static boolean isResurrected(ChangeItem changeItem) { // There's a change corresponding to a Deleted Item, item MUST have been resurrected return (changeItem.getBaselineVersion().isValid() && isDeleted( changeItem.getBaselineVersion())) || changeItem.getCurrentVersion().getModType().equals( ModificationType.INTRODUCED); }
Source:
private CloseableHttpResponse get(final HttpGet httpGet) { try { return this.httpclient.execute(httpGet, this.context); } catch (IOException e) { throw new IllegalArgumentException(); } }

Target:
private CloseableHttpResponse get(final HttpGet httpGet) { try { return this.httpclient.execute(httpGet, this.context); } catch (IOException e) { throw new IllegalArgumentException(e); } }
Source:
private CloseableHttpResponse put(final HttpPut httpPut) { try { return this.httpclient.execute(httpPut, this.context); } catch (IOException e) { throw new IllegalArgumentException(); } }

Target:
private CloseableHttpResponse put(final HttpPut httpPut) { try { return this.httpclient.execute(httpPut, this.context); } catch (IOException e) { throw new IllegalArgumentException(e); } }
Source:
private static Image getFBTypeImage(IFile element) { Image image; FBType type = getFBTypeFromFile(element); if (type instanceof BasicFBType) { image = FordiacImage.ICON_BASIC_FB.getImage(); } else if (type instanceof CompositeFBType) { image = FordiacImage.ICON_COMPOSITE_FB.getImage(); } else if (type instanceof ServiceInterfaceFBType) { image = FordiacImage.ICON_SIFB.getImage(); } else { // partly load file to determine type image = checkUnloadedFBType(element); } return image; }

Target:
private static Image getFBTypeImage(IFile element) { FBType type = getFBTypeFromFile(element); if (type instanceof BasicFBType) { return FordiacImage.ICON_BASIC_FB.getImage(); } else if (type instanceof CompositeFBType) { return FordiacImage.ICON_COMPOSITE_FB.getImage(); } else if (type instanceof ServiceInterfaceFBType) { return FordiacImage.ICON_SIFB.getImage(); } // partly load file to determine type return checkUnloadedFBType(element); }
Source:
public void start(BundleContext context) throws Exception { super.start(context); fPlugin = this; try { fCommandLine = CliParserManager.getInstance().parse(Platform.getCommandLineArgs()); } catch (CliParserException e) { logError("Error parsing command line arguments", e); //$NON-NLS-1$ throw e; } }

Target:
public void start(BundleContext context) throws Exception { super.start(context); fPlugin = this; }
Source:
public static String getLineIndentation(IDocument document, int offset) throws BadLocationException { // find start of line int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset); IRegion line= document.getLineInformationOfOffset(adjustedOffset); int start= line.getOffset(); // find white spaces int end= findEndOfWhiteSpace(document, start, offset + line.getLength()); return document.get(start, end - start); }

Target:
private static String getLineIndentation(IDocument document, int offset) throws BadLocationException { // find start of line int adjustedOffset= (offset == document.getLength() ? offset - 1 : offset); IRegion line= document.getLineInformationOfOffset(adjustedOffset); int start= line.getOffset(); // find white spaces int end= findEndOfWhiteSpace(document, start, offset + line.getLength()); return document.get(start, end - start); }
Source:
public boolean isItemVisible(VirtualItem item) { // visible items. For now only mark the selected items as visible. for (VirtualItem element : fSelection) { VirtualItem selectionItem = element; while (selectionItem != null) { if (item.equals(selectionItem)) { return true; } selectionItem = selectionItem.getParent(); } } return false; }

Target:
public boolean isItemVisible(VirtualItem item) { // visible items. For now only mark the selected items as visible. for (VirtualItem selectionItem : fSelection) { while (selectionItem != null) { if (item.equals(selectionItem)) { return true; } selectionItem = selectionItem.getParent(); } } return false; }
Source:
public synchronized Collection<Object> values() { List<Object> result = new ArrayList<>(); for (Object element : objects.keySet()) { IPath path = (IPath) element; Node node = getNode(path); if (node.getPayload() != null) result.add(node.getPayload()); } return result; }

Target:
public synchronized Collection<Object> values() { List<Object> result = new ArrayList<>(); for (IPath path : objects.keySet()) { Node node = getNode(path); if (node.getPayload() != null) result.add(node.getPayload()); } return result; }
Source:
public boolean ruleContains(IResource resource) { for (Object element : rules) { ISchedulingRule rule = (ISchedulingRule) element; if (rule != NULL_SCHEDULING_RULE && rule.contains(resource)) { return true; } } return false; }

Target:
public boolean ruleContains(IResource resource) { for (ISchedulingRule rule : rules) { if (rule != NULL_SCHEDULING_RULE && rule.contains(resource)) { return true; } } return false; }
Source:
private boolean isDescendantOfAddedRoot(IResource resource) { for (Object element : addedSubtrees) { IResource root = (IResource) element; if (isParent(root, resource)) { // There is a higher added root already in the list return true; } } return false; }

Target:
private boolean isDescendantOfAddedRoot(IResource resource) { for (IResource root : addedSubtrees) { if (isParent(root, resource)) { // There is a higher added root already in the list return true; } } return false; }
Source:
public void start(@Nullable BundleContext context) throws Exception { super.start(context); plugin = this; // Register CLI parser only if the class exists try { Class.forName("org.eclipse.tracecompass.tracing.rcp.ui.cli.CliParserExtension"); //$NON-NLS-1$ } catch (ClassNotFoundException e) { // RCP not loaded return; } }

Target:
public void start(@Nullable BundleContext context) throws Exception { super.start(context); plugin = this; }
Source:
void loadFiles () { // BAD - holds on to a lot of memory if (sourcePath == null) return; files = new HashMap<> (); for (String element : sourcePath) { File file = new File(element); if (file.exists()) { if (!file.isDirectory()) { if (file.getAbsolutePath().endsWith(".java")) { files.put(file, loadFile(file)); } } else { loadDirectory(file); } } } }

Target:
void loadFiles () { // BAD - holds on to a lot of memory if (sourcePath == null) return; files = new HashMap<> (); for (String path : sourcePath) { File file = new File(path); if (file.exists()) { if (!file.isDirectory()) { if (file.getAbsolutePath().endsWith(".java")) { files.put(file, loadFile(file)); } } else { loadDirectory(file); } } } }
Source:
protected GridData newGridData(int span) { GridData data = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); data.horizontalSpan = span; return data; }

Target:
private static GridData newGridData(int span) { GridData data = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); data.horizontalSpan = span; return data; }
Source:
int memSize() { // treat Operator as free return BASE_NODE_SIZE + 2 * 4; }

Target:
int memSize() { // treat Operator as free return BASE_NODE_SIZE + 3 * 4; }