Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitefa5c22

Browse files
authored
Rework Database Storage Path Logic (microsoft#11309)
* Fix typo (microsoft#11275)* rework database logic* resolve PR* fix lint issues* resolve PR* resolve PR* resolve PR* resolve PR* update names* resolve PR* resolve PR* fix lint error* resolve PR* resolve PR
1 parent4199155 commitefa5c22

File tree

2 files changed

+47
-17
lines changed

2 files changed

+47
-17
lines changed

‎Extension/src/LanguageServer/client.ts‎

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ import { localizedStringCount, lookupString } from '../nativeStrings';
4242
import*astelemetryfrom'../telemetry';
4343
import{TestHook,getTestHook}from'../testHook';
4444
import{
45-
CodeAnalysisDiagnosticIdentifiersAndUri,RegisterCodeAnalysisNotifications,
45+
CodeAnalysisDiagnosticIdentifiersAndUri,
46+
RegisterCodeAnalysisNotifications,
4647
RemoveCodeAnalysisProblemsParams,
4748
removeAllCodeAnalysisProblems,
4849
removeCodeAnalysisProblems
@@ -97,6 +98,7 @@ interface ConfigStateReceived {
9798
letdisplayedSelectCompiler:boolean=false;
9899
letsecondPromptCounter:number=0;
99100
letscanForCompilersDone:boolean=false;
101+
letworkspaceHash:string="";
100102

101103
letworkspaceDisposables:vscode.Disposable[]=[];
102104
exportletworkspaceReferences:refs.ReferencesManager;
@@ -539,7 +541,9 @@ export interface TextDocumentWillSaveParams {
539541
interfaceInitializationOptions{
540542
packageVersion:string;
541543
extensionPath:string;
542-
storagePath:string;
544+
cacheStoragePath:string;
545+
workspaceStoragePath:string;
546+
databaseStoragePath:string;
543547
freeMemory:number;
544548
vcpkgRoot:string;
545549
intelliSenseCacheDisabled:boolean;
@@ -821,7 +825,7 @@ export class DefaultClient implements Client {
821825
privaterootPathFileWatcher?:vscode.FileSystemWatcher;
822826
privaterootFolder?:vscode.WorkspaceFolder;
823827
privaterootRealPath:string;
824-
privatestoragePath:string;
828+
privateworkspaceStoragePath:string;
825829
privatetrackedDocuments=newSet<vscode.TextDocument>();
826830
privateisSupported:boolean=true;
827831
privateinactiveRegionsDecorations=newMap<string,DecorationRangesPair>();
@@ -916,7 +920,7 @@ export class DefaultClient implements Client {
916920
publicgetAdditionalEnvironment():{[key:string]:string|string[]}{
917921
return{
918922
workspaceFolderBasename:this.Name,
919-
workspaceStorage:this.storagePath,
923+
workspaceStorage:this.workspaceStoragePath,
920924
execPath:process.execPath,
921925
pathSeparator:(os.platform()==='win32') ?"\\" :"/"
922926
};
@@ -1285,21 +1289,17 @@ export class DefaultClient implements Client {
12851289
this.rootFolder=workspaceFolder;
12861290
this.rootRealPath=this.RootPath ?fs.existsSync(this.RootPath) ?fs.realpathSync(this.RootPath) :this.RootPath :"";
12871291

1288-
letstoragePath:string|undefined;
1289-
if(util.extensionContext){
1290-
constpath:string|undefined=util.extensionContext.storageUri?.fsPath;
1291-
if(path){
1292-
storagePath=path;
1293-
}
1292+
this.workspaceStoragePath=util.extensionContext?.storageUri?.fsPath??"";
1293+
if(this.workspaceStoragePath.length>0){
1294+
workspaceHash=path.basename(path.dirname(this.workspaceStoragePath));
1295+
}else{
1296+
this.workspaceStoragePath=this.RootPath ?path.join(this.RootPath,".vscode") :"";
12941297
}
12951298

1296-
if(!storagePath){
1297-
storagePath=this.RootPath ?path.join(this.RootPath,"/.vscode") :"";
1298-
}
12991299
if(workspaceFolder&&vscode.workspace.workspaceFolders&&vscode.workspace.workspaceFolders.length>1){
1300-
storagePath=path.join(storagePath,util.getUniqueWorkspaceStorageName(workspaceFolder));
1300+
this.workspaceStoragePath=path.join(this.workspaceStoragePath,util.getUniqueWorkspaceStorageName(workspaceFolder));
13011301
}
1302-
this.storagePath=storagePath;
1302+
13031303
constrootUri:vscode.Uri|undefined=this.RootUri;
13041304
this.settingsTracker=newSettingsTracker(rootUri);
13051305

@@ -1622,10 +1622,16 @@ export class DefaultClient implements Client {
16221622
currentCaseSensitiveFileSupport.Value=workspaceSettings.caseSensitiveFileSupport;
16231623
}
16241624

1625+
constcacheStoragePath:string=util.getCacheStoragePath();
1626+
constdatabaseStoragePath:string=(cacheStoragePath.length>0)&&(workspaceHash.length>0) ?
1627+
path.join(cacheStoragePath,workspaceHash) :"";
1628+
16251629
constinitializationOptions:InitializationOptions={
16261630
packageVersion:util.packageJson.version,
16271631
extensionPath:util.extensionPath,
1628-
storagePath:this.storagePath,
1632+
databaseStoragePath:databaseStoragePath,
1633+
workspaceStoragePath:this.workspaceStoragePath,
1634+
cacheStoragePath:cacheStoragePath,
16291635
freeMemory:Math.floor(os.freemem()/1048576),
16301636
vcpkgRoot:util.getVcpkgRoot(),
16311637
intelliSenseCacheDisabled:intelliSenseCacheDisabled,
@@ -2029,7 +2035,7 @@ export class DefaultClient implements Client {
20292035

20302036
constresponse:QueryTranslationUnitSourceResult=awaitthis.languageClient.sendRequest(QueryTranslationUnitSourceRequest,params);
20312037
if(!response.candidates||response.candidates.length===0){
2032-
// If we didn't receive any candidates, no configuration is needed.
2038+
// If we didn't receive any candidates, no configuration is needed.
20332039
onFinished();
20342040
DefaultClient.isStarted.resolve();
20352041
return;

‎Extension/src/common.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,30 @@ export function isValidIdentifier(candidate: string): boolean {
13031303
returntrue;
13041304
}
13051305

1306+
exportfunctiongetCacheStoragePath():string{
1307+
letdefaultCachePath:string="";
1308+
letpathEnvironmentVariable:string|undefined;
1309+
switch(os.platform()){
1310+
case'win32':
1311+
defaultCachePath="Microsoft\\vscode-cpptools\\";
1312+
pathEnvironmentVariable=process.env["LOCALAPPDATA"];
1313+
break;
1314+
case'darwin':
1315+
defaultCachePath="Library/Caches/vscode-cpptools/";
1316+
pathEnvironmentVariable=os.homedir();
1317+
break;
1318+
default:// Linux
1319+
defaultCachePath="vscode-cpptools/";
1320+
pathEnvironmentVariable=process.env["XDG_CACHE_HOME"];
1321+
if(!pathEnvironmentVariable){
1322+
pathEnvironmentVariable=os.homedir();
1323+
}
1324+
break;
1325+
}
1326+
1327+
returnpathEnvironmentVariable ?path.join(pathEnvironmentVariable,defaultCachePath) :"";
1328+
}
1329+
13061330
functiongetUniqueWorkspaceNameHelper(workspaceFolder:vscode.WorkspaceFolder,addSubfolder:boolean):string{
13071331
constworkspaceFolderName:string=workspaceFolder ?workspaceFolder.name :"untitled";
13081332
if(!workspaceFolder||workspaceFolder.index<1){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp