Select Git revision
common.ts 6.26 KiB
import { lexer, parser, query as q } from 'good-enough-parser';
import { clone } from '../../../../util/clone';
import { regEx } from '../../../../util/regex';
import type { Ctx, NonEmptyArray, PackageVariables } from '../types';
export const REGISTRY_URLS = {
google: 'https://dl.google.com/android/maven2/',
gradlePluginPortal: 'https://plugins.gradle.org/m2/',
jcenter: 'https://jcenter.bintray.com/',
mavenCentral: 'https://repo.maven.apache.org/maven2',
};
export const GRADLE_PLUGINS = {
checkstyle: 'com.puppycrawl.tools:checkstyle',
codenarc: 'org.codenarc:CodeNarc',
detekt: 'io.gitlab.arturbosch.detekt:detekt-core',
findbugs: 'com.google.code.findbugs:findbugs',
googleJavaFormat: 'com.google.googlejavaformat:google-java-format',
jacoco: 'org.jacoco:jacoco',
lombok: 'org.projectlombok:lombok',
pmd: 'net.sourceforge.pmd:pmd-java',
spotbugs: 'com.github.spotbugs:spotbugs',
};
export const ANNOYING_METHODS: ReadonlySet<string> = new Set([
'createXmlValueRemover',
'events',
'args',
'arrayOf',
'listOf',
'mutableListOf',
'setOf',
'mutableSetOf',
'stages', // https://github.com/ajoberstar/reckon,
'mapScalar', // https://github.com/apollographql/apollo-kotlin
]);
export function storeVarToken(ctx: Ctx, node: lexer.Token): Ctx {
ctx.varTokens.push(node);
return ctx;
}
export function increaseNestingDepth(ctx: Ctx): Ctx {
ctx.tmpNestingDepth.push(...ctx.varTokens);
ctx.varTokens = [];
return ctx;
}
export function reduceNestingDepth(ctx: Ctx): Ctx {
ctx.tmpNestingDepth.pop();
return ctx;
}
export function prependNestingDepth(ctx: Ctx): Ctx {
ctx.varTokens = [...clone(ctx.tmpNestingDepth), ...ctx.varTokens];
return ctx;
}
export function storeInTokenMap(ctx: Ctx, tokenMapKey: string): Ctx {
ctx.tokenMap[tokenMapKey] = ctx.varTokens;
ctx.varTokens = [];
return ctx;
}
export function loadFromTokenMap(
ctx: Ctx,
tokenMapKey: string
): NonEmptyArray<lexer.Token> {
const tokens = ctx.tokenMap[tokenMapKey];