if(frame.absoluteFile)
editor = (CodeEditor)ide.OpenFile(frame.absoluteFile, false, true, null, no, normal, false);
if(!editor && frame.file)
- frame.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(frame.file);
+ frame.absoluteFile = ide.workspace.CopyAbsolutePathFromRelative(frame.file);
if(!frame.absoluteFile && askForLocation && frame.file)
{
char * s = null;
if(SourceDirDialog(title, ide.workspace.projectDir, frame.file, sourceDir))
{
AddSourceDir(sourceDir);
- frame.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(frame.file);
+ frame.absoluteFile = ide.workspace.CopyAbsolutePathFromRelative(frame.file);
}
}
if(!editor && frame.absoluteFile)
Workspace ws = ide.workspace;
if(ws)
{
- String path = ide.workspace.GetPathWorkspaceRelativeOrAbsolute(item.value);
+ String path = ide.workspace.CopyUnixPathWorkspaceRelativeOrAbsolute(item.value);
if(strcmp(frame.file, path))
frame.file = path;
delete path;
{
CodeLocation codloc { line = line };
codloc.file = CopyString(loc);
- codloc.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(loc);
+ codloc.absoluteFile = ide.workspace.CopyAbsolutePathFromRelative(loc);
return codloc;
}
}
projectView.GoToError(line, noParsing);
}
+ FileAttribs GoToCodeSelectFile(const char * filePath, const char * dir, Project prj, ProjectNode * node, char * selectedPath)
+ {
+ FileAttribs result { };
+ FileAttribs fileAttribs;
+ if(filePath[0])
+ {
+ if(prj)
+ strcpy(selectedPath, prj.topNode.path);
+ else if(dir && dir[0])
+ strcpy(selectedPath, dir);
+ else
+ selectedPath[0] = '\0';
+ PathCat(selectedPath, filePath);
+
+ if((fileAttribs = FileExists(selectedPath)).isFile)
+ result = fileAttribs;
+ else if(workspace)
+ {
+ bool done = false;
+ for(p : workspace.projects)
+ {
+ strcpy(selectedPath, p.topNode.path);
+ PathCat(selectedPath, filePath);
+ if((fileAttribs = FileExists(selectedPath)).isFile)
+ {
+ done = true;
+ result = fileAttribs;
+ break;
+ }
+ }
+ if(!done)
+ {
+ Project project;
+ ProjectNode n = null;
+ for(p : workspace.projects)
+ {
+ if((n = p.topNode.Find(filePath, false)))
+ {
+ n.GetFullFilePath(selectedPath);
+ if((fileAttribs = FileExists(selectedPath)).isFile)
+ {
+ if(node) *node = n;
+ result = fileAttribs;
+ break;
+ }
+ }
+ }
+ if(!n && (n = workspace.GetObjectFileNode(filePath, &project, selectedPath)) && project &&
+ (fileAttribs = FileExists(selectedPath)).isFile)
+ {
+ if(node) *node = n;
+ result = fileAttribs;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
{
char *s = null;
strcpy(filePath, path);
}
- if(filePath[0])
- {
- if(prj)
- strcpy(completePath, prj.topNode.path);
- else if(dir && dir[0])
- strcpy(completePath, dir);
- else
- completePath[0] = '\0';
- PathCat(completePath, filePath);
-
- if((fileAttribs = FileExists(completePath)))
- CodeLocationGoTo(completePath, fileAttribs, line, col);
- else if(ide.workspace)
- {
- bool done = false;
- for(p : ide.workspace.projects)
- {
- strcpy(completePath, p.topNode.path);
- PathCat(completePath, filePath);
- if((fileAttribs = FileExists(completePath)).isFile)
- {
- CodeLocationGoTo(completePath, fileAttribs, line, col);
- done = true;
- break;
- }
- }
- if(!done)
- {
- Project project;
- ProjectNode node;
- for(p : ide.workspace.projects)
- {
- if((node = p.topNode.Find(filePath, false)))
- {
- node.GetFullFilePath(completePath);
- if((fileAttribs = FileExists(completePath)).isFile)
- {
- CodeLocationGoTo(completePath, fileAttribs, line, col);
- break;
- }
- }
- }
- if(!node && (node = workspace.GetObjectFileNode(filePath, &project, completePath)) && project &&
- (fileAttribs = FileExists(completePath)).isFile)
- CodeLocationGoTo(completePath, fileAttribs, line, col);
- }
- }
- }
+ if((fileAttribs = GoToCodeSelectFile(filePath, dir, prj, null, completePath)))
+ CodeLocationGoTo(completePath, fileAttribs, line, col);
}
void CodeLocationGoTo(const char * path, const FileAttribs fileAttribs, int line, int col)
moduleName[0] = 0; // Avoid opening binary files
if(moduleName[0])
{
- CodeEditor codeEditor;
- if(!filePath[0])
- {
- strcpy(filePath, project.topNode.path);
- PathCatSlash(filePath, moduleName);
- }
+ CodeEditor codeEditor = null;
- codeEditor = (CodeEditor)ide.OpenFile(filePath, false, true, null, no, normal, noParsing);
- if(!codeEditor && !strcmp(ext, "c"))
+ if(ide.GoToCodeSelectFile(moduleName, null, project, null, filePath))
{
- char ecName[MAX_LOCATION];
- ChangeExtension(filePath, "ec", ecName);
- codeEditor = (CodeEditor)ide.OpenFile(ecName, false, true, null, no, normal, noParsing);
+ codeEditor = (CodeEditor)ide.OpenFile(filePath, false, true, null, no, normal, noParsing);
}
+
if(!codeEditor)
{
- char path[MAX_LOCATION];
- // TOFIX: Improve on this, don't use only filename, make a function
- if(ide && ide.workspace)
+ if(!filePath[0])
{
- for(prj : ide.workspace.projects)
- {
- ProjectNode node;
- MakePathRelative(filePath, prj.topNode.path, path);
+ strcpy(filePath, project.topNode.path);
+ PathCatSlash(filePath, moduleName);
+ }
- if((node = prj.topNode.FindWithPath(path, false)))
- {
- strcpy(filePath, prj.topNode.path);
- PathCatSlash(filePath, node.path);
- PathCatSlash(filePath, node.name);
- codeEditor = (CodeEditor)ide.OpenFile(filePath, false, true, null, no, normal, noParsing);
- if(codeEditor)
- break;
- }
- }
- if(!codeEditor && (strchr(moduleName, '/') || strchr(moduleName, '\\')))
+ codeEditor = (CodeEditor)ide.OpenFile(filePath, false, true, null, no, normal, noParsing);
+ if(!codeEditor && !strcmp(ext, "c"))
+ {
+ char ecName[MAX_LOCATION];
+ ChangeExtension(filePath, "ec", ecName);
+ codeEditor = (CodeEditor)ide.OpenFile(ecName, false, true, null, no, normal, noParsing);
+ }
+ if(!codeEditor)
+ {
+ char path[MAX_LOCATION];
+ // TOFIX: Improve on this, don't use only filename, make a function
+ if(ide && ide.workspace)
{
for(prj : ide.workspace.projects)
{
ProjectNode node;
- if((node = prj.topNode.FindWithPath(moduleName, false)))
+ MakePathRelative(filePath, prj.topNode.path, path);
+
+ if((node = prj.topNode.FindWithPath(path, false)))
{
strcpy(filePath, prj.topNode.path);
PathCatSlash(filePath, node.path);
break;
}
}
- }
- if(!codeEditor)
- {
- GetLastDirectory(moduleName, moduleName);
- for(prj : ide.workspace.projects)
+ if(!codeEditor && (strchr(moduleName, '/') || strchr(moduleName, '\\')))
{
- ProjectNode node;
- if((node = prj.topNode.Find(moduleName, false)))
+ for(prj : ide.workspace.projects)
{
- strcpy(filePath, prj.topNode.path);
- PathCatSlash(filePath, node.path);
- PathCatSlash(filePath, node.name);
- codeEditor = (CodeEditor)ide.OpenFile(filePath, false, true, null, no, normal, noParsing);
- if(codeEditor)
- break;
+ ProjectNode node;
+ if((node = prj.topNode.FindWithPath(moduleName, false)))
+ {
+ strcpy(filePath, prj.topNode.path);
+ PathCatSlash(filePath, node.path);
+ PathCatSlash(filePath, node.name);
+ codeEditor = (CodeEditor)ide.OpenFile(filePath, false, true, null, no, normal, noParsing);
+ if(codeEditor)
+ break;
+ }
+ }
+ }
+ if(!codeEditor)
+ {
+ GetLastDirectory(moduleName, moduleName);
+ for(prj : ide.workspace.projects)
+ {
+ ProjectNode node;
+ if((node = prj.topNode.Find(moduleName, false)))
+ {
+ strcpy(filePath, prj.topNode.path);
+ PathCatSlash(filePath, node.path);
+ PathCatSlash(filePath, node.name);
+ codeEditor = (CodeEditor)ide.OpenFile(filePath, false, true, null, no, normal, noParsing);
+ if(codeEditor)
+ break;
+ }
}
}
}