MCPcopy Create free account
hub / github.com/baldurk/renderdoc / newImportedDummyContext

Method newImportedDummyContext

qrenderdoc/Windows/PythonShell.cpp:1559–1593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1557}
1558
1559PythonContext *PythonShell::newImportedDummyContext()
1560{
1561 sptr_t pos = scriptEditor->currentPos();
1562
1563 PythonContext *context = new PythonContext();
1564
1565 setGlobals(context);
1566
1567 // super hack. Try to import any modules to get completion suggestions from them.
1568 // we only process imports with no indentation since they should be unconditional. We ignore
1569 // imports that fail.
1570 QByteArray text = scriptEditor->getText(pos + 1);
1571
1572 for(int offs = 0; offs < text.length();)
1573 {
1574 // find the next newline (may be NULL if we're at the end)
1575 int newline = text.indexOf('\n', offs);
1576
1577 // execute the import if there is one
1578 const char *c = text.data() + offs;
1579 if(!strncmp(c, "import ", 7))
1580 {
1581 context->executeString(newline >= 0 ? QString::fromUtf8(c, newline - offs + 1)
1582 : QString::fromUtf8(c));
1583 }
1584
1585 if(newline < 0)
1586 break;
1587
1588 // move to the next line
1589 offs = newline + 1;
1590 }
1591
1592 return context;
1593}
1594
1595PythonContext *PythonShell::newContext()
1596{

Callers

nothing calls this directly

Calls 7

currentPosMethod · 0.80
getTextMethod · 0.80
executeStringMethod · 0.80
fromUtf8Function · 0.50
lengthMethod · 0.45
indexOfMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected