1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = TagFile.rb -- The TaskJuggler III Project Management Software
#
# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
# by Chris Schlaeger <cs@taskjuggler.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
require 'taskjuggler/reports/ReportBase.rb'
require 'taskjuggler/Tj3Config'
class TaskJuggler
# This class specializes ReportBase to generate tag files used by editors
# such as vim.
class TagFile < ReportBase
# The TagFileEntry class is used to store the intermediate representation
# of the TagFile.
class TagFileEntry
attr_reader :tag, :file, :line, :kind
# Create a new TagFileEntry object. _tag_ is the property ID. _file_ is
# the source file name, _line_ the line number in this file. _kind_
# specifies the property type. The following types should be used:
# r : Resource
# t : Task
# p : Report
def initialize(tag, file, line, kind)
@tag = tag
@file = file
@line = line
@kind = kind
end
# Used to sort the tag file entries by tag.
def <=>(e)
@tag <=> e.tag
end
# Convert the entry into a ctags compatible line.
def to_ctags
"#{@tag}\t#{@file}\t#{@line};\"\t#{@kind}\n"
end
end
def initialize(report)
super
end
def generateIntermediateFormat
super
@tags = []
# Add the resources.
@resourceList = PropertyList.new(@project.resources)
@resourceList.setSorting(a('sortResources'))
@resourceList = filterResourceList(@resourceList, nil, a('hideResource'),
a('rollupResource'), a('openNodes'))
@resourceList.each do |resource|
next unless resource.sourceFileInfo
@tags << TagFileEntry.new(resource.fullId,
resource.sourceFileInfo.fileName,
resource.sourceFileInfo.lineNo, 'r')
end
# Add the tasks.
@taskList = PropertyList.new(@project.tasks)
@taskList.setSorting(a('sortTasks'))
@taskList = filterTaskList(@taskList, nil, a('hideTask'), a('rollupTask'),
a('openNodes'))
@taskList.each do |task|
next unless task.sourceFileInfo
@tags << TagFileEntry.new(task.fullId,
task.sourceFileInfo.fileName,
task.sourceFileInfo.lineNo, 't')
end
# Add the reports.
@project.reports.each do |report|
next unless report.sourceFileInfo
@tags << TagFileEntry.new(report.fullId,
report.sourceFileInfo.fileName,
report.sourceFileInfo.lineNo, 'p')
end
end
# Returns a String that contains the content of the ctags file.
# See http://vimdoc.sourceforge.net/htmldoc/tagsrch.html for the spec.
def to_ctags
# The ctags header. Not used if this is really needed.
s = <<"EOT"
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR #{AppConfig.authors.join(';')} //
!_TAG_PROGRAM_NAME #{AppConfig.softwareName} //
!_TAG_PROGRAM_URL #{AppConfig.contact} /official site/
!_TAG_PROGRAM_VERSION #{AppConfig.version} //
EOT
# Turn the list of Tags into ctags lines.
@tags.sort.each do |tag|
s << tag.to_ctags
end
s
end
end
end
|