Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import CSAProfile from "../planner/public-transport/CSAProfile";
import IJourneyExtractor from "../planner/public-transport/IJourneyExtractor";
import IPublicTransportPlanner from "../planner/public-transport/IPublicTransportPlanner";
import JourneyExtractorProfile from "../planner/public-transport/JourneyExtractorProfile";
import IRoadPlanner from "../planner/road/IRoadPlanner";
import RoadPlannerPathfinding from "../planner/road/RoadPlannerPathfinding";
import IReachableStopsFinder from "../planner/stops/IReachableStopsFinder";
import ReachableStopsFinderDelaunay from "../planner/stops/ReachableStopsFinderDelaunay";
import ReachableStopsFinderOnlySelf from "../planner/stops/ReachableStopsFinderOnlySelf";
import QueryRunnerExponential from "../query-runner/exponential/QueryRunnerExponential";
import ILocationResolver from "../query-runner/ILocationResolver";
import IQueryRunner from "../query-runner/IQueryRunner";
import LocationResolverConvenience from "../query-runner/LocationResolverConvenience";
import TYPES from "../types";
const container = new Container();
container.bind(TYPES.Context).to(Context).inSingletonScope();
container.bind(TYPES.QueryRunner).to(QueryRunnerExponential);
container.bind(TYPES.LocationResolver).to(LocationResolverConvenience);
// TODO, make this a fixed property of the planner itself
container.bind(TYPES.JourneyExtractor)
.to(JourneyExtractorProfile);
container.bind(TYPES.PublicTransportPlanner)
.to(CSAProfile);
container.bind>(TYPES.PublicTransportPlannerFactory)
.toAutoFactory(TYPES.PublicTransportPlanner);
container.bind(TYPES.RoadPlanner)
.to(RoadPlannerPathfinding);
export const createContainer = () => {
const container = new Container();
// Things are dynamically required() so that we can boot up quickly and not
// require things we don't need in worker processes.
container
.bind(HookManager)
.toDynamicValue(ctx =>
ctx.container.resolve(require('./instrumentation/hook-manager').HookManager),
)
.inSingletonScope();
container
.bind(CoverageInstrumentor)
.toDynamicValue(ctx =>
ctx.container.resolve(
require('./instrumentation/coverage-instrumentor').ConverageInstrumentor,
this.expressApp.use(async (req, res, next) => {
let app = registry.get("app") as Application;
let ctx = new Container();
ctx.parent = registry;
ctx.bind("req").toConstantValue(req);
ctx.bind("res").toConstantValue(res);
registry.bind("RequestContext").toConstantValue(ctx);
// find controller (factor into Router)
let controllers = ctx.getAll("Controller");
for(var controller of controllers) {
if (controller.path === req.url) {
ctx.bind("currentController").toConstantValue(controller);
ctx.bind("currentMethod").toConstantValue("find");
}
}
export default (useWebsocket: boolean) => {
const container = new Container();
container.load(defaultModule, selectModule, moveModule, boundsModule, fadeModule, viewportModule, exportModule, hoverModule, flowModule);
if (useWebsocket)
container.bind(TYPES.ModelSource).to(WebSocketDiagramServer).inSingletonScope();
else
container.bind(TYPES.ModelSource).to(LocalModelSource).inSingletonScope();
overrideViewerOptions(container, {
baseDiv: 'sprotty-flow',
hiddenDiv: 'sprotty-hidden-flow',
popupDiv: 'sprotty-popup-flow',
needsClientLayout: false,
needsServerLayout: true
});
// Register views
const viewRegistry = container.get(TYPES.ViewRegistry);
viewRegistry.register('flow', SGraphView);
test('reports errors while parsing tsconfig.json', (t) => {
const container = new Container();
const files: {[name: string]: string | undefined} = {
'invalid-config.json': '{',
'invalid-base.json': '{"extends": "./invalid-config.json"}',
'invalid-files.json': '{"files": []}',
'no-match.json': '{"include": ["non-existent"], "compilerOptions": {"noLib": true}}',
};
@injectable()
class MockFileSystem extends NodeFileSystem {
public stat(file: string) {
return {
isFile() { return files[path.basename(file)] !== undefined; },
isDirectory() { return false; },
};
}
public readFile(file: string) {
const basename = path.basename(file);
configureModelElement(context, 'icon', Icon, IconView);
configureModelElement(context, 'label:icon', SLabel, SLabelView);
configureModelElement(context, 'edge:straight', SEdge, PolylineEdgeView);
configureModelElement(context, 'html', HtmlRoot, HtmlRootView);
configureModelElement(context, 'pre-rendered', PreRenderedElement, PreRenderedView);
configureModelElement(context, 'button:expand', SButton, ExpandButtonView);
configureModelElement(context, 'routing-point', SRoutingHandle, SRoutingHandleView);
configureModelElement(context, 'volatile-routing-point', SRoutingHandle, SRoutingHandleView);
configureViewerOptions(context, {
needsClientLayout: true,
baseDiv: containerId
});
});
const container = new Container();
loadDefaultModules(container);
container.load(classDiagramModule);
return container;
};
function getInstanceAdministration(target: any) {
let administration: DiInstanceAdministration = target[AdministrationKey];
if (!administration) {
let classAdministration: DiClassAdministration = target.constructor[AdministrationKey];
const parentContainer = (target.context && target.context[ReactContextKey]) as interfaces.Container | null;
let container: interfaces.Container;
if (classAdministration.provides) {
container = new Container();
for (const service of classAdministration.services) {
const bindingInWhenOnSytax = container.bind(service.service)
.toSelf();
switch (service.scope) {
case 'Singleton':
bindingInWhenOnSytax.inSingletonScope();
break;
case 'Transient':
bindingInWhenOnSytax.inTransientScope();
break;
default:
throw new Error(`Invalid service scope '${service.scope}'`);
import * as minimatch from 'minimatch';
import * as sourceMapSupport from 'source-map-support';
import * as yargs from 'yargs';
import {
containerModule as core,
ITranspileService,
TYPE_DRIVER_YARGS,
TYPE_DRIVER_BABEL_CORE,
TYPE_DRIVER_GULP_TYPESCRIPT,
TYPE_DRIVER_TYPESCRIPT,
TYPE_DRIVER_SOURCE_MAP_SUPPORT,
TYPE_DRIVER_MINIMATCH,
TYPE_SERVICE_TRANSPILE
} from 'urbanjs-tools-core';
export const container = new Container();
container.load(core);
container.bind(TYPE_DRIVER_YARGS).toConstantValue(yargs);
container.bind(TYPE_DRIVER_BABEL_CORE).toConstantValue(babelCore);
container.bind(TYPE_DRIVER_GULP_TYPESCRIPT).toConstantValue(gulpTypescript);
container.bind(TYPE_DRIVER_TYPESCRIPT).toConstantValue(typescript);
container.bind(TYPE_DRIVER_SOURCE_MAP_SUPPORT).toConstantValue(sourceMapSupport);
container.bind(TYPE_DRIVER_MINIMATCH).toConstantValue(minimatch);
const transpileService = container.get(TYPE_SERVICE_TRANSPILE);
transpileService.installSourceMapSupport();
babelCore.util.canCompile.EXTENSIONS.concat('.ts', 'tsx').forEach((extension) => {
require.extensions[extension] = (module, filename) => {
module._compile(
transpileService.transpile(readFileSync(filename, 'utf8'), filename),
export function activate(context: ExtensionContext) {
const cont = new Container();
const serviceManager = new ServiceManager(cont);
const serviceContainer = new ServiceContainer(cont);
registerServices(context, serviceManager, serviceContainer);
initialize(serviceContainer);
}
async function activateUnsafe(context: ExtensionContext): Promise {
displayProgress(activationDeferred.promise);
durations.startActivateTime = stopWatch.elapsedTime;
const cont = new Container();
const serviceManager = new ServiceManager(cont);
const serviceContainer = new ServiceContainer(cont);
activatedServiceContainer = serviceContainer;
registerServices(context, serviceManager, serviceContainer);
await initializeServices(context, serviceManager, serviceContainer);
const manager = serviceContainer.get(IExtensionActivationManager);
context.subscriptions.push(manager);
const activationPromise = manager.activate();
serviceManager.get(ITerminalAutoActivation).register();
const configuration = serviceManager.get(IConfigurationService);
const pythonSettings = configuration.getSettings();
const standardOutputChannel = serviceContainer.get(IOutputChannel, STANDARD_OUTPUT_CHANNEL);
activateSimplePythonRefactorProvider(context, standardOutputChannel, serviceContainer);