Skip to content

Commit

Permalink
Merge branch 're-structure'
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Nov 20, 2023
2 parents 489071b + 6db13d9 commit cc8d690
Show file tree
Hide file tree
Showing 104 changed files with 583 additions and 512 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dev/*.js
src/lib/**/*.*
src/**/*.*
types/**/*.ts
resources/**/*.js
out
Expand Down
7 changes: 7 additions & 0 deletions .madgerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"detectiveOptions": {
"ts": {
"skipTypeImports": true
}
}
}
5 changes: 1 addition & 4 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ out/resources/
out/snippets/
out/test/
test/
src/*.*
src/components/
src/lib/**/*.ts
src/providers/
src/**/*.ts
samples/
types/
viewer/**/*.ts
Expand Down
2 changes: 1 addition & 1 deletion dev/editviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
line.replace('''<title>PDF.js viewer</title>''', '''<meta http-equiv="Content-Security-Policy" content="default-src 'self'; base-uri 'none'; connect-src 'self' ws://127.0.0.1:*; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:;">\n <title>PDF.js viewer</title>''')
.replace('''<link rel="stylesheet" href="viewer.css">''', '''<link rel="stylesheet" href="viewer.css">\n <link rel="stylesheet" href="latexworkshop.css">''')
.replace('''<script src="../build/pdf.mjs" type="module"></script>''', '''<script src="build/pdf.mjs" type="module"></script>''')
.replace('''<script src="viewer.mjs" type="module"></script>''', '''<script src="out/viewer/latexworkshop.js" type="module"></script>''')
.replace('''<script src="viewer.mjs" type="module"></script>''', '''<script src="out/viewer/latexworkshop.js" type="module"></script>\n <script src="viewer/viewer.mjs" type="module"></script>''')
)

with open(args.web + '/viewer.mjs', 'rt', encoding='utf-8') as fin:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2576,7 +2576,7 @@
"latex-utensils": "6.2.0",
"mathjax-full": "3.2.2",
"micromatch": "4.0.5",
"pdfjs-dist": "^4.0.189",
"pdfjs-dist": "4.0.189",
"tmp": "0.2.1",
"workerpool": "8.0.0",
"ws": "8.14.2"
Expand Down
16 changes: 8 additions & 8 deletions src/components/builder.ts → src/compile/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as path from 'path'
import * as fs from 'fs'
import * as cp from 'child_process'
import * as cs from 'cross-spawn'
import * as lw from '../lw'
import { lw } from '../lw'
import { replaceArgumentPlaceholders } from '../utils/utils'
import { AutoBuildInitiated, AutoCleaned, BuildDone } from './eventbus'
import { getLogger } from './logger'
import { parser } from './parser'
import { AutoBuildInitiated, AutoCleaned, BuildDone } from '../core/event-bus'
import { getLogger } from '../utils/logging/logger'
import { parser } from '../parse/parser'

const logger = getLogger('Builder')

Expand All @@ -33,8 +33,8 @@ export class Builder {
private readonly MAX_PRINT_LINE = '10000'

constructor() {
lw.cacher.src.onChange(filePath => this.buildOnFileChanged(filePath))
lw.cacher.bib.onChange(filePath => this.buildOnFileChanged(filePath, true))
lw.watcher.src.onChange(filePath => this.buildOnFileChanged(filePath))
lw.watcher.bib.onChange(filePath => this.buildOnFileChanged(filePath, true))
// Check if pdflatex is available, and is MikTeX distro
try {
const pdflatexVersion = cp.execSync('pdflatex --version')
Expand Down Expand Up @@ -104,9 +104,9 @@ export class Builder {
}
const configuration = vscode.workspace.getConfiguration('latex-workshop', vscode.Uri.file(file))
if (!bibChanged && lw.manager.localRootFile && configuration.get('latex.rootFile.useSubFile')) {
return lw.commander.build(true, lw.manager.localRootFile, lw.manager.rootFileLanguageId)
return lw.commands.build(true, lw.manager.localRootFile, lw.manager.rootFileLanguageId)
} else {
return lw.commander.build(true, lw.manager.rootFile, lw.manager.rootFileLanguageId)
return lw.commands.build(true, lw.manager.rootFile, lw.manager.rootFileLanguageId)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import * as lw from '../lw'
import { getBibtexFormatConfig, type BibtexFormatConfig } from './bibtexformatterlib/bibtexutils'
import { lw } from '../lw'
import { getBibtexFormatConfig, type BibtexFormatConfig } from '../lint/bibtexformatterlib/bibtexutils'

import { getLogger } from '../components/logger'
import { getLogger } from '../utils/logging/logger'

const logger = getLogger('Intelli', 'Bib')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode'
import * as lw from '../../lw'
import type { IProvider, IProviderArgs } from '../completion'
import { lw } from '../../lw'
import type { IProvider, IProviderArgs } from '../latex'
import { CmdEnvSuggestion, filterArgumentHint } from './completerutils'
import { EnvSnippetType } from './environment'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import * as lw from '../../lw'
import type {IProvider, IProviderArgs} from '../completion'
import { lw, registerDisposable } from '../../lw'
import type {IProvider, IProviderArgs} from '../latex'
import {escapeRegExp} from '../../utils/utils'

interface AtSuggestionItemEntry {
Expand All @@ -23,7 +23,7 @@ export class AtSuggestion implements IProvider {

const allSuggestions: {[key: string]: AtSuggestionItemEntry} = JSON.parse(fs.readFileSync(`${lw.extensionRoot}/data/at-suggestions.json`).toString()) as DataAtSuggestionJsonType
this.initialize(allSuggestions)
lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
if (e.affectsConfiguration('latex-workshop.intellisense.atSuggestion.user')) {
this.initialize(allSuggestions)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import {bibtexParser} from 'latex-utensils'
import * as lw from '../../lw'
import * as eventbus from '../../components/eventbus'
import { lw } from '../../lw'
import * as eventbus from '../../core/event-bus'
import {trimMultiLineString} from '../../utils/utils'
import {computeFilteringRange} from './completerutils'
import type { IProvider, ICompletionItem, IProviderArgs } from '../completion'
import { getLogger } from '../../components/logger'
import { parser } from '../../components/parser'
import { Cache } from '../../components/cacher'
import type { IProvider, ICompletionItem, IProviderArgs } from '../latex'
import { getLogger } from '../../utils/logging/logger'
import { parser } from '../../parse/parser'
import { Cache } from '../../core/cache'

const logger = getLogger('Intelli', 'Citation')

Expand Down Expand Up @@ -133,9 +133,9 @@ export class Citation implements IProvider {
private readonly bibEntries = new Map<string, CiteSuggestion[]>()

constructor() {
lw.cacher.bib.onCreate(filePath => this.parseBibFile(filePath))
lw.cacher.bib.onChange(filePath => this.parseBibFile(filePath))
lw.cacher.bib.onDelete(filePath => this.removeEntriesInFile(filePath))
lw.watcher.bib.onCreate(filePath => this.parseBibFile(filePath))
lw.watcher.bib.onChange(filePath => this.parseBibFile(filePath))
lw.watcher.bib.onDelete(filePath => this.removeEntriesInFile(filePath))
}

provideFrom(_result: RegExpMatchArray, args: IProviderArgs) {
Expand Down Expand Up @@ -277,7 +277,8 @@ export class Citation implements IProvider {
return
}
suggestions = suggestions.concat(cachedBibs.map(bib => {
return {...bib,
return {
...bib,
key: bib.label,
detail: bib.detail ? bib.detail : '',
file: cachedFile,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import type * as Ast from '@unified-latex/unified-latex-types'
import * as lw from '../../lw'
import type { IProvider, ICompletionItem, PkgType, IProviderArgs } from '../completion'
import { lw, registerDisposable } from '../../lw'
import type { IProvider, ICompletionItem, PkgType, IProviderArgs } from '../latex'
import { CmdEnvSuggestion, splitSignatureString, filterNonLetterSuggestions, filterArgumentHint } from './completerutils'
import {SurroundCommand} from './commandlib/surround'
import { Environment, EnvSnippetType } from './environment'

import { getLogger } from '../../components/logger'
import { Cache } from '../../components/cacher'
import { getLogger } from '../../utils/logging/logger'
import { Cache } from '../../core/cache'

const logger = getLogger('Intelli', 'Command')

Expand Down Expand Up @@ -55,7 +55,7 @@ export class Command implements IProvider {
const symbols: { [key: string]: CmdType } = JSON.parse(fs.readFileSync(`${lw.extensionRoot}/data/unimathsymbols.json`).toString()) as DataUnimathSymbolsJsonType
Object.entries(symbols).forEach(([key, symbol]) => this.defaultSymbols.push(this.entryCmdToCompletion(key, symbol)))

lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
if (!e.affectsConfiguration('latex-workshop.intellisense.command.user') &&
!e.affectsConfiguration('latex-workshop.intellisense.package.exclude')) {
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode'
import type { ICompletionItem } from '../../completion'
import type { ICompletionItem } from '../../latex'

export class SurroundCommand {
static surround(cmdItems: ICompletionItem[]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode'
import type { ICompletionItem } from '../completion'
import type { ICompletionItem } from '../latex'

interface CmdSignature {
/** name without leading `\` */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import * as lw from '../../lw'
import type { IProvider } from '../completion'
import { lw } from '../../lw'
import type { IProvider } from '../latex'

type DataClassnamesJsonType = typeof import('../../../data/classnames.json')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import type * as Ast from '@unified-latex/unified-latex-types'
import * as lw from '../../lw'
import type { ICompletionItem, IProviderArgs } from '../completion'
import type { IProvider } from '../completion'
import { lw, registerDisposable } from '../../lw'
import type { ICompletionItem, IProvider, IProviderArgs } from '../latex'
import { CmdEnvSuggestion, splitSignatureString, filterNonLetterSuggestions, filterArgumentHint } from './completerutils'

import { getLogger } from '../../components/logger'
import { Cache } from '../../components/cacher'
import { getLogger } from '../../utils/logging/logger'
import { Cache } from '../../core/cache'

const logger = getLogger('Intelli', 'Environment')

Expand Down Expand Up @@ -45,7 +44,7 @@ export class Environment implements IProvider {
private readonly packageEnvsForBegin= new Map<string, CmdEnvSuggestion[]>()

constructor() {
lw.registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
registerDisposable(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
if (!e.affectsConfiguration('latex-workshop.intellisense.package.exclude')) {
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as vscode from 'vscode'
import type * as Ast from '@unified-latex/unified-latex-types'
import * as lw from '../../lw'
import type { ICompletionItem } from '../completion'
import type { IProvider } from '../completion'
import { Cache } from '../../components/cacher'
import { lw } from '../../lw'
import type { ICompletionItem, IProvider } from '../latex'
import { Cache } from '../../core/cache'
import { argContentToStr } from '../../utils/parser'
import { getLongestBalancedString } from '../../utils/utils'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as vscode from 'vscode'
import * as fs from 'fs'
import * as path from 'path'
import * as micromatch from 'micromatch'
import * as lw from '../../lw'
import type { IProvider, IProviderArgs } from '../completion'
import { lw } from '../../lw'
import type { IProvider, IProviderArgs } from '../latex'

import { getLogger } from '../../components/logger'
import { Cache } from '../../components/cacher'
import { getLogger } from '../../utils/logging/logger'
import type { Cache } from '../../core/cache'

const logger = getLogger('Intelli', 'Input')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import type * as Ast from '@unified-latex/unified-latex-types'
import * as lw from '../../lw'
import type { IProvider } from '../completion'
import { lw } from '../../lw'
import type { IProvider } from '../latex'
import { argContentToStr } from '../../utils/parser'
import { Cache } from '../../components/cacher'
import { kpsewhich } from '../../components/cacherlib/pathutils'
import { Cache } from '../../core/cache'
import { kpsewhich } from '../../core/cacherlib/pathutils'

type DataPackagesJsonType = typeof import('../../../data/packagenames.json')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import * as vscode from 'vscode'
import * as fs from 'fs'
import * as path from 'path'
import type * as Ast from '@unified-latex/unified-latex-types'
import * as lw from '../../lw'
import { lw } from '../../lw'
import { getLongestBalancedString, stripEnvironments } from '../../utils/utils'
import { computeFilteringRange } from './completerutils'
import type { IProvider, ICompletionItem, IProviderArgs } from '../completion'
import type { IProvider, ICompletionItem, IProviderArgs } from '../latex'
import { argContentToStr } from '../../utils/parser'
import { Cache } from '../../components/cacher'
import { Cache } from '../../core/cache'

export interface ReferenceEntry extends ICompletionItem {
/** The file that defines the ref. */
Expand Down
4 changes: 2 additions & 2 deletions src/providers/completion.ts → src/completion/latex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import * as path from 'path'
import * as lw from '../lw'
import { lw } from '../lw'
import { Citation } from './completer/citation'
import { DocumentClass } from './completer/documentclass'
import { Command } from './completer/command'
Expand All @@ -16,7 +16,7 @@ import { Input, Import, SubImport } from './completer/input'
import { Glossary } from './completer/glossary'
import type { ReferenceDocType } from './completer/reference'
import { escapeRegExp } from '../utils/utils'
import { getLogger } from '../components/logger'
import { getLogger } from '../utils/logging/logger'

const logger = getLogger('Intelli')

Expand Down
Loading

0 comments on commit cc8d690

Please sign in to comment.