本文整理汇总了C#中MonoDevelop.Projects.Project.IsFileInProject方法的典型用法代码示例。如果您正苦于以下问题:C# Project.IsFileInProject方法的具体用法?C# Project.IsFileInProject怎么用?C# Project.IsFileInProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Projects.Project
的用法示例。
在下文中一共展示了Project.IsFileInProject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public override ParsedDocument Parse(bool storeAst, string file, TextReader content, Project prj = null)
{
if (!storeAst)
return null;
ProjectFile pf = null;
if (prj == null)
{
var sln = Ide.IdeApp.ProjectOperations.CurrentSelectedSolution;
if (sln != null)
foreach (var proj in sln.GetAllProjects())
if (proj.IsFileInProject(file))
{
prj = proj;
pf = proj.GetProjectFile(file);
break;
}
}
else if(prj.IsFileInProject(file))
{
pf = prj.GetProjectFile(file);
}
// HACK(?) The folds are parsed before the document gets loaded
// - so reuse the last parsed document to save time
// -- What if multiple docs are opened?
var d = LastParsedMod as ParsedDModule;
if (d != null && d.FileName == file)
{
LastParsedMod = null;
return d;
}
else
LastParsedMod = null;
var dprj = prj as AbstractDProject;
// Remove obsolete ast from cache
if(file != null)
GlobalParseCache.RemoveModule (file);
DModule ast;
var doc = new ParsedDModule(file);
var parser = DParser.Create(content);
// Also put attention on non-ddoc comments; These will be used to generate foldable comment regions then
parser.Lexer.OnlyEnlistDDocComments = false;
// Parse the code
try
{
ast = parser.Parse();
}
catch (TooManyErrorsException)
{
ast = parser.Document;
}
catch(System.Exception ex) {
doc.ErrorList.Add(new Error(ErrorType.Error, ex.Message));
return doc;
}
if(ast == null)
return doc;
// Update project owner information / Build appropriate module name
if(string.IsNullOrEmpty(ast.ModuleName))
{
if(pf == null)
ast.ModuleName = file != null ? Path.GetFileNameWithoutExtension(file) : string.Empty;
else
ast.ModuleName = BuildModuleName(pf);
}
ast.FileName = file;
// Assign new ast to the ParsedDDocument object
doc.DDom = ast;
// Add parser errors to the parser output
foreach (var parserError in parser.ParseErrors)
doc.ErrorList.Add(new Error(
ErrorType.Error,
parserError.Message,
parserError.Location.Line,
parserError.Location.Column));
#region Provide comment fold support by addin them to the IDE document object
foreach (var cm in parser.Comments)
{
var c = new MonoDevelop.Ide.TypeSystem.Comment(cm.CommentText){
CommentStartsLine = cm.CommentStartsLine,
CommentType = (cm.CommentType & D_Parser.Parser.Comment.Type.Block) != 0 ? CommentType.Block : CommentType.SingleLine,
IsDocumentation = cm.CommentType.HasFlag(D_Parser.Parser.Comment.Type.Documentation),
};
if (c.CommentType == CommentType.SingleLine)
{
if (c.IsDocumentation)
c.OpenTag = "///";
//.........这里部分代码省略.........
示例2: Parse
public override ParsedDocument Parse(bool storeAst, string file, TextReader content, Project prj = null)
{
if (!storeAst)
return null;
ProjectFile pf = null;
if (prj == null)
{
var sln = Ide.IdeApp.ProjectOperations.CurrentSelectedSolution;
if (sln != null)
foreach (var proj in sln.GetAllProjects())
if (proj.IsFileInProject(file))
{
prj = proj;
pf = proj.GetProjectFile(file);
break;
}
}
else if(prj.IsFileInProject(file))
{
pf = prj.GetProjectFile(file);
}
// HACK(?) The folds are parsed before the document gets loaded
// - so reuse the last parsed document to save time
// -- What if multiple docs are opened?
if (LastParsedMod is ParsedDModule && LastParsedMod.FileName == file)
{
var d = LastParsedMod as ParsedDModule;
LastParsedMod = null;
return d;
}
else
LastParsedMod = null;
var dprj = prj as DProject;
// Remove obsolete ast from cache
DModule ast = null;
if (dprj != null)
{
ast = dprj.LocalFileCache.GetModuleByFileName(file, prj.BaseDirectory) as DModule;
if (ast != null)
{
dprj.LocalFileCache.Remove(ast);
ast = null;
}
}
var doc = new ParsedDModule(file);
var parser = DParser.Create(content);
// Also put attention on non-ddoc comments; These will be used to generate foldable comment regions then
parser.Lexer.OnlyEnlistDDocComments = false;
// Parse the code
try
{
ast = parser.Parse();
}
catch (TooManyErrorsException x)
{
ast = parser.Document;
}
// Update project owner information / Build appropriate module name
if(string.IsNullOrEmpty(ast.ModuleName))
{
if(pf == null)
ast.ModuleName = Path.GetFileNameWithoutExtension(file);
else
ast.ModuleName = BuildModuleName(pf);
}
ast.FileName = file;
// Assign new ast to the ParsedDDocument object
doc.DDom = ast;
// Add parser errors to the parser output
foreach (var parserError in parser.ParseErrors)
doc.ErrorList.Add(new Error(
ErrorType.Error,
parserError.Message,
parserError.Location.Line,
parserError.Location.Column));
#region Provide comment fold support by addin them to the IDE document object
foreach (var cm in parser.TrackerVariables.Comments)
{
var c = new MonoDevelop.Ide.TypeSystem.Comment(cm.CommentText);
c.CommentType = cm.CommentType.HasFlag(D_Parser.Parser.Comment.Type.Block) ? CommentType.Block : CommentType.SingleLine;
c.IsDocumentation = cm.CommentType.HasFlag(D_Parser.Parser.Comment.Type.Documentation);
if (c.CommentType == CommentType.SingleLine)
{
if (c.IsDocumentation)
//.........这里部分代码省略.........
示例3: HandleDeployFile
// Handle unique deploy files, emits non-perconfig stuff, like targets for deploy files,
// un/install commands
void HandleDeployFile (DeployFileData data, string targetDeployVar, Project project, AutotoolsContext ctx)
{
DeployFile dfile = data.File;
string dependencyDeployFile = null; //Dependency for the deployfile target
if (dfile.ContainsPathReferences) {
// Template file, copy to .in file
string full_fname = Path.Combine (project.BaseDirectory, Path.GetFileName (dfile.RelativeTargetPath));
string fname = full_fname;
string infname = fname + ".in";
if (File.Exists (infname) && project.IsFileInProject (infname)) {
string datadir = Path.Combine (project.BaseDirectory, "data");
if (!Directory.Exists (datadir))
Directory.CreateDirectory (datadir);
infname = Path.Combine (datadir, Path.GetFileName (dfile.RelativeTargetPath) + ".in");
}
//Absolute path required
File.Copy (dfile.SourcePath, infname, true);
//Path relative to TargetCombine
fname = FileService.NormalizeRelativePath (
FileService.AbsoluteToRelativePath (ctx.TargetSolution.BaseDirectory, full_fname));
infname = fname + ".in";
ctx.AddAutoconfFile (MakefileData.ToMakefilePath (fname));
ctx.AddGeneratedFile (full_fname + ".in");
//Path relative to project
fname = FileService.NormalizeRelativePath (
FileService.AbsoluteToRelativePath (project.BaseDirectory, full_fname));
infname = fname + ".in";
extras.AppendFormat ("\\\n\t{0} ", MakefileData.ToMakefilePath (infname));
//dependencyDeployFile here should be filename relative to the project
dependencyDeployFile = fname;
} else {
dependencyDeployFile = String.Format ("$({0}_SOURCE)", targetDeployVar);
}
builtFiles.Add (Path.GetFileName (dfile.RelativeTargetPath));
if (dfile.ContainsPathReferences)
deployFileCopyTargets.AppendFormat ("$(eval $(call emit-deploy-wrapper,{0},{1}{2}))\n",
targetDeployVar,
MakefileData.ToMakefilePath (dependencyDeployFile),
(dfile.FileAttributes & DeployFileAttributes.Executable) != 0 ? ",x" : String.Empty);
else {
// The emit-deploy-target macro copies the deployable file to the output directory.
// This is not needed if the file is already there (e.g. for an .mdb file)
if (Path.GetFullPath (dfile.SourcePath) != Path.GetFullPath (Path.Combine (data.Configuration.OutputDirectory, dfile.RelativeTargetPath)))
deployFileCopyTargets.AppendFormat ("$(eval $(call emit-deploy-target,{0}))\n", targetDeployVar);
}
switch (dfile.TargetDirectoryID) {
case TargetDirectory.Gac:
// TODO
break;
default:
string var;
if (dfile.TargetDirectoryID != TargetDirectory.Binaries) {
string ddir = FileService.NormalizeRelativePath (dfile.RelativeTargetPath.ParentDirectory.ToString().Trim ('/',' '));
if (ddir.Length > 0)
ddir = "/" + ddir;
var = ctx.GetDeployDirectoryVar (dfile.TargetDirectoryID + ddir);
}
else
var = "BINARIES";
StringBuilder sb;
if (!deployDirs.TryGetValue (var, out sb)) {
sb = new StringBuilder ();
deployDirs [var] = sb;
}
sb.AppendFormat ("\\\n\t$({0}) ", targetDeployVar);
break;
}
if (!generateAutotools) {
string installDir = Path.GetDirectoryName (ctx.DeployContext.GetResolvedPath (dfile.TargetDirectoryID, dfile.RelativeTargetPath));
//FIXME: temp
installDir = TranslateDir (installDir);
if (!installDirs.Contains (installDir)) {
installTarget.AppendFormat ("\tmkdir -p '$(DESTDIR){0}'\n", installDir);
installDirs.Add (installDir);
}
installTarget.AppendFormat ("\t$(call cp,$({0}),$(DESTDIR){1})\n", targetDeployVar, installDir);
uninstallTarget.AppendFormat ("\t$(call rm,$({1}),$(DESTDIR){0})\n", installDir, targetDeployVar);
}
}