nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: kythe/kythe
Pull request #4876 (2021-04-02 18:26:06)

chore: add compare support for bools


Patch:
diff --git a/kythe/go/util/compare/compare.go b/kythe/go/util/compare/compare.go
index 7ae1bf6c9..40fe3e0a1 100644
--- a/kythe/go/util/compare/compare.go
+++ b/kythe/go/util/compare/compare.go
@@ -61,7 +61,8 @@ func (By) isOption() {}
 
 // Compare returns the Order between two arbitrary values of the same type.
 //
-// Only the following types are currently supported: {string, int, int32, []byte}.
+// Only the following types are currently supported:
+//     {string, int, int32, []byte, bool}.
 //
 // Options may be provided to change the semantics of the comparison.  Other
 // types may be compared if an appropriate By Option transforms the values into
@@ -101,6 +102,8 @@ func Compare(a, b interface{}, opts ...Option) (o Order) {
 		return with(a, b)
 	}
 	switch a := a.(type) {
+	case bool:
+		return Bools(a, b.(bool))
 	case int:
 		return Ints(a, b.(int))
 	case int32:
@@ -192,6 +195,16 @@ func Bytes(s, t []byte) Order { return Order(bytes.Compare(s, t)) }
 // Ints returns LT if a < b, EQ if a == b, or GT if a > b.
 func Ints(a, b int) Order { return ToOrder(a - b) }
 
+// Bools returns LT if !a && b, EQ if a == b, or GT if a && !b.
+func Bools(a, b bool) Order {
+	if a == b {
+		return EQ
+	} else if !a {
+		return LT
+	}
+	return GT
+}
+
 // Options for comparing components of *spb.VName protobuf messages.
 var (
 	ByVNameSignature = By(func(x interface{}) interface{} {


Test patch:
diff --git a/kythe/go/util/compare/compare_test.go b/kythe/go/util/compare/compare_test.go
index f072a8526..220967205 100644
--- a/kythe/go/util/compare/compare_test.go
+++ b/kythe/go/util/compare/compare_test.go
@@ -35,6 +35,10 @@ func TestCompare(t *testing.T) {
 		{1, 3, []Option{Reversed()}, GT},
 		{3, 3, []Option{Reversed()}, EQ},
 		{3, 1, []Option{Reversed()}, LT},
+		{false, false, nil, EQ},
+		{false, true, nil, LT},
+		{true, true, nil, EQ},
+		{true, false, nil, GT},
 		{"a", "b", nil, LT},
 		{[]byte("a"), []byte("b"), nil, LT},
 		{&spb.VName{Signature: "abc"}, &spb.VName{Signature: "bcd"}, []Option{ByVNameSignature}, LT},
Repository: kythe/kythe
Pull request #4976 (2021-06-22 23:19:35)

feat(java_indexer): place builtins in the compilation unit corpus
when --use_compilation_corpus_as_default is enabled


Patch:
diff --git a/kythe/java/com/google/devtools/kythe/analyzers/base/KytheEntrySets.java b/kythe/java/com/google/devtools/kythe/analyzers/base/KytheEntrySets.java
index 0361f7a9a..0837e90e1 100644
--- a/kythe/java/com/google/devtools/kythe/analyzers/base/KytheEntrySets.java
+++ b/kythe/java/com/google/devtools/kythe/analyzers/base/KytheEntrySets.java
@@ -146,6 +146,7 @@ public class KytheEntrySets {
     EntrySet.Builder nodeBuilder =
         newNode(NodeKind.TBUILTIN)
             .setSignature(getBuiltinSignature(name))
+            .setCorpusPath(defaultCorpusPath())
             .setProperty(
                 "code",
                 MarkedSource.newBuilder().setPreText(name).setKind(Kind.IDENTIFIER).build());


Test patch:
diff --git a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/DefaultCorpus.java b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/DefaultCorpus.java
index 97140fde0..48202a02c 100644
--- a/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/DefaultCorpus.java
+++ b/kythe/javatests/com/google/devtools/kythe/analyzers/java/testdata/pkg/DefaultCorpus.java
@@ -11,4 +11,12 @@ class DefaultCorpus {
   //- MyVar typed ListStringType=vname(_,"kythe",_,_,"java")
   //- ListStringType.node/kind "tapp"
   private List<String> myvar;
+
+  //- @myMethod defines/binding MyMethod
+  //- MyMethod typed MyMethodType=vname(_,"kythe",_,_,"java")
+  //- MyMethodType.node/kind "tapp"
+  //- MyMethodType param.0 FnBuiltin?=vname("fn#builtin","kythe",_,_,"java")
+  String myMethod() {
+    return "";
+  }
 }
Repository: kythe/kythe
Pull request #5066 (2021-09-08 22:09:36)

fix(rust_indexer): handle ending offsets for files without ending newline
If a file being indexed does not have an ending newline (such as generated Rust protobuf files), the ending column of a definition span might exceed the number of columns in that line. Therefore if a byte offset is requested for a column that is longer than the line, we just return the offset for the last column in the line.

wcalandro: @jaysachs The easiest way to create the test was to remove the newline at the bottom of the anchors.rs test file. Before this PR, removing that newline would cause the indexer to panic, now it successfully indexes the test file and passes the verifier

Patch:
diff --git a/kythe/rust/indexer/src/indexer/offset.rs b/kythe/rust/indexer/src/indexer/offset.rs
index d4134849b..fb2f9cf41 100644
--- a/kythe/rust/indexer/src/indexer/offset.rs
+++ b/kythe/rust/indexer/src/indexer/offset.rs
@@ -117,8 +117,16 @@ impl LineIndex {
     /// in this line, or if `all_single_byte` is false and the index of
     /// `column - 1` isn't in `column_indices`
     pub fn get_offset_at_col(&self, column: u32) -> Option<u32> {
-        // Column is past total number of columns
-        if column > self.num_columns || column < 1 {
+        // Some generated files do not have a newline at the end of the file.
+        // If there is a module definition, the ending column will be one larger
+        // than the number of columns in the row. Therefore we will just return
+        // the end of the column.
+        if column > self.num_columns {
+            return Some(self.offset + self.num_columns - 1);
+        }
+
+        // Should never happen but we cover it just in case
+        if column < 1 {
             return None;
         }
 


Test patch:
diff --git a/kythe/rust/indexer/testdata/anchors.rs b/kythe/rust/indexer/testdata/anchors.rs
index d8f251eea..8d8698bbc 100644
--- a/kythe/rust/indexer/testdata/anchors.rs
+++ b/kythe/rust/indexer/testdata/anchors.rs
@@ -4,4 +4,4 @@
 //- FnMain.node/kind function
 fn main() {
     println!("Hello, world!");
-}
+}
\ No newline at end of file