@Test public void testContainsCode() { assertThat(kotlinCodeVerifier.containsCode("This is a normal sentence: definitely not code")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("this is a normal comment")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("just three words")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("SNAPSHOT")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("")).isFalse(); assertThat(kotlinCodeVerifier.containsCode(" ")).isFalse(); assertThat(kotlinCodeVerifier.containsCode(" continue ")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("description for foo(\"hello world\")")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("foo(\"hello world\")")).isTrue(); assertThat(kotlinCodeVerifier.containsCode("foo.rs")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("this is a + b")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("The user name is empty")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("exposed as public")).isFalse(); assertThat(kotlinCodeVerifier.containsCode(" --- check")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("Loops --- ")).isFalse(); assertThat(kotlinCodeVerifier.containsCode( "Generic Query tests (combining both FungibleState and LinearState contract types)")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("\"E0308 cyclic type of infinite size\"")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("(just remove it)")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("1 shl 2")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("1 shl foo")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("* @return foo(bar)")).isFalse(); assertThat(kotlinCodeVerifier.containsCode("only unlocked states")).isFalse(); assertThat(kotlinCodeVerifier.containsCode(" 0\n 1")).isFalse(); }
@Override public boolean containsCode(String content) { int words = content.trim().split("\\w+").length; if (words < 2 || isKDoc(content)) { return false; } try { String wrappedContent = "fun function () { " + content + " }"; KotlinConverter.KotlinTree kotlinTree = new KotlinConverter.KotlinTree(wrappedContent); return !isSimpleExpression(kotlinTree.psiFile); } catch (ParseException e) { } return false; }
KotlinCodeVerifier implements CodeVerifier { @Override public boolean containsCode(String content) { int words = content.trim().split("\\w+").length; if (words < 2 || isKDoc(content)) { return false; } try { String wrappedContent = "fun function () { " + content + " }"; KotlinConverter.KotlinTree kotlinTree = new KotlinConverter.KotlinTree(wrappedContent); return !isSimpleExpression(kotlinTree.psiFile); } catch (ParseException e) { } return false; } }
KotlinCodeVerifier implements CodeVerifier { @Override public boolean containsCode(String content) { int words = content.trim().split("\\w+").length; if (words < 2 || isKDoc(content)) { return false; } try { String wrappedContent = "fun function () { " + content + " }"; KotlinConverter.KotlinTree kotlinTree = new KotlinConverter.KotlinTree(wrappedContent); return !isSimpleExpression(kotlinTree.psiFile); } catch (ParseException e) { } return false; }  }
KotlinCodeVerifier implements CodeVerifier { @Override public boolean containsCode(String content) { int words = content.trim().split("\\w+").length; if (words < 2 || isKDoc(content)) { return false; } try { String wrappedContent = "fun function () { " + content + " }"; KotlinConverter.KotlinTree kotlinTree = new KotlinConverter.KotlinTree(wrappedContent); return !isSimpleExpression(kotlinTree.psiFile); } catch (ParseException e) { } return false; }  @Override boolean containsCode(String content); }
KotlinCodeVerifier implements CodeVerifier { @Override public boolean containsCode(String content) { int words = content.trim().split("\\w+").length; if (words < 2 || isKDoc(content)) { return false; } try { String wrappedContent = "fun function () { " + content + " }"; KotlinConverter.KotlinTree kotlinTree = new KotlinConverter.KotlinTree(wrappedContent); return !isSimpleExpression(kotlinTree.psiFile); } catch (ParseException e) { } return false; }  @Override boolean containsCode(String content);  }