MCPcopy Index your code
hub / github.com/github/copilot-sdk / shouldSkipFragment

Function shouldSkipFragment

scripts/docs-validation/extract.ts:168–204  ·  view source on GitHub ↗

* Detect code fragments that can't be validated as standalone files. * These are typically partial snippets showing configuration options * or code that's meant to be part of a larger context.

(block: CodeBlock)

Source from the content-addressed store, hash-verified

166 * or code that's meant to be part of a larger context.
167 */
168function shouldSkipFragment(block: CodeBlock): boolean {
169 const code = block.code.trim();
170
171 // TypeScript/JavaScript: Skip bare object literals (config snippets)
172 if (block.language === "typescript") {
173 // Starts with property: value pattern (e.g., "provider: {")
174 if (/^[a-zA-Z_]+\s*:\s*[\{\[]/.test(code)) {
175 return true;
176 }
177 // Starts with just an object/array that's not assigned
178 if (/^\{[\s\S]*\}$/.test(code) && !code.includes("import ") && !code.includes("export ")) {
179 return true;
180 }
181 }
182
183 // Go: Skip fragments that are just type definitions without package
184 if (block.language === "go") {
185 // Function signatures without bodies (interface definitions shown in docs)
186 if (/^func\s+\w+\([^)]*\)\s*\([^)]*\)\s*$/.test(code)) {
187 return true;
188 }
189 }
190
191 // Java: Skip interface definitions, annotations-only, or method signatures without bodies
192 if (block.language === "java") {
193 // Just an annotation
194 if (/^@\w+/.test(code) && !code.includes("{")) {
195 return true;
196 }
197 // Method signature without body
198 if (/^(public|private|protected)?\s*(static\s+)?[\w<>\[\]]+\s+\w+\([^)]*\)\s*(throws\s+[\w,\s]+)?;\s*$/.test(code)) {
199 return true;
200 }
201 }
202
203 return false;
204}
205
206function wrapCodeForValidation(block: CodeBlock): string {
207 let code = block.code;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…