diff options
| author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 | 
|---|---|---|
| committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 | 
| commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
| tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/perl | |
| download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip  | |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/perl')
29 files changed, 1921 insertions, 0 deletions
diff --git a/languages/perl/Makefile.am b/languages/perl/Makefile.am new file mode 100644 index 00000000..2354c124 --- /dev/null +++ b/languages/perl/Makefile.am @@ -0,0 +1,25 @@ +# Here resides the Perl support part. + +INCLUDES = -I$(top_srcdir)/lib/interfaces \ +	-I$(top_srcdir)/lib/interfaces/extensions -I$(top_srcdir)/lib/interfaces/external -I$(top_srcdir)/lib/util \ +	$(all_includes) +SUBDIRS = app_templates file_templates doc + + +kde_module_LTLIBRARIES = libkdevperlsupport.la kio_perldoc.la +libkdevperlsupport_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkdevperlsupport_la_LIBADD = $(top_builddir)/lib/libkdevelop.la + +libkdevperlsupport_la_SOURCES = perlparser.cpp perlsupportpart.cpp perlconfigwidget.cpp perlconfigwidgetbase.ui + +kio_perldoc_la_SOURCES = perldoc.cpp +kio_perldoc_la_LIBADD = $(LIB_KIO) +kio_perldoc_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = kdevperlsupport.desktop perldoc.protocol + +rcdir = $(kde_datadir)/kdevperlsupport +rc_DATA = kdevperlsupport.rc diff --git a/languages/perl/README.dox b/languages/perl/README.dox new file mode 100644 index 00000000..f8608a41 --- /dev/null +++ b/languages/perl/README.dox @@ -0,0 +1,46 @@ +/** \class PerlSupportPart +This is perl language support plugin. + +Put a more detailed description of your part in these lines. It can span +over several lines. You can even use some html commands in these lines like: +<code>This is code</code>, html links <a href="http://somelocation">link text</a>, +and images. + +\authors <a href="mailto:bernd AT kdevelop.org">Bernd Gehrmann</a> +\authors <a href="mailto:willems.luc AT pandora.be">Luc Willems</a> + +\maintainer <a href="mailto:willems.luc AT pandora.be">Luc Willems</a> + +\feature perl programming language support +\feature Consult \ref LangSupportStatus for a up to date features/status of this programming language support part. + +\bug Describe a the 1st bug that you know of, but probably hasn't been reported yet. +.. +\bug Describe a the nth bug that you know of, but probably hasn't been reported yet. + +\requirement Describe a the 1st requirement of your part. +\requirement Describe a the 2nd requirement of your part. +... +\requirement Describe a the nth requirement of your part. + +\todo Describe a the 1st TODO of your part. +\todo Describe a the 2nd TODO of your part. +... +\todo Describe a the nth TODO of your part. + +\faq <b>First frequenly asked question about your part ?</b> Answer. +\faq <b>Second frequenly asked question about your part ?</b> Answer. +... +\faq <b>Last frequenly asked question about your part ?</b> Answer. + +\note First note text. +\note Second note text. +... +\note Last note text. + +\warning First warning text. +\warning Second warning text. +... +\warning Last warning text. + +*/ diff --git a/languages/perl/app_templates/Makefile.am b/languages/perl/app_templates/Makefile.am new file mode 100644 index 00000000..c284be59 --- /dev/null +++ b/languages/perl/app_templates/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = perlhello +profilesdir = $(kde_datadir)/kdevelop/profiles/IDE/ScriptingLanguageIDE/PerlIDE +profiles_DATA = perl.appwizard diff --git a/languages/perl/app_templates/perl.appwizard b/languages/perl/app_templates/perl.appwizard new file mode 100644 index 00000000..44c9faf9 --- /dev/null +++ b/languages/perl/app_templates/perl.appwizard @@ -0,0 +1,2 @@ +[General] +List=perlhello diff --git a/languages/perl/app_templates/perlhello/.kdev_ignore b/languages/perl/app_templates/perlhello/.kdev_ignore new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/languages/perl/app_templates/perlhello/.kdev_ignore diff --git a/languages/perl/app_templates/perlhello/Makefile.am b/languages/perl/app_templates/perlhello/Makefile.am new file mode 100644 index 00000000..1c1d7b33 --- /dev/null +++ b/languages/perl/app_templates/perlhello/Makefile.am @@ -0,0 +1,16 @@ +dataFiles = app.pl app.kdevelop  +templateName = perlhello + +### no need to change below: +template_DATA = $(templateName).kdevtemplate +templatedir = ${appwizarddatadir}/templates + +appwizarddatadir = ${kde_datadir}/kdevappwizard +$(templateName).tar.gz: ${dataFiles} +	$(TAR) -cf $(templateName).tar -C $(srcdir) ${dataFiles} +	$(GZIP_COMMAND) -f9 $(templateName).tar + +archivedir = ${appwizarddatadir} +archive_DATA = $(templateName).tar.gz ${templateName}.png + +CLEANFILES = *.tar.gz
\ No newline at end of file diff --git a/languages/perl/app_templates/perlhello/app.kdevelop b/languages/perl/app_templates/perlhello/app.kdevelop new file mode 100644 index 00000000..c781322d --- /dev/null +++ b/languages/perl/app_templates/perlhello/app.kdevelop @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<kdevelop> + <general> +  <author>%{AUTHOR}</author> +  <email>%{EMAIL}</email> +  <version>%{VERSION}</version> +  <projectmanagement>KDevScriptProject</projectmanagement> +  <primarylanguage>Perl</primarylanguage> +  <projectdirectory>.</projectdirectory> +  <absoluteprojectpath>false</absoluteprojectpath> + </general> + <kdevscriptproject> +  <run> +   <mainprogram>./%{APPNAMELC}.pl</mainprogram> +  </run> +  <general> +    <includepatterns>*.pl,*.pm</includepatterns> +    <excludepatterns>*~</excludepatterns> +  </general> + </kdevscriptproject> + <kdevdoctreeview> +    <ignoretocs> +      <toc>ada</toc> +      <toc>ada_bugs_gcc</toc> +      <toc>bash</toc> +      <toc>bash_bugs</toc> +      <toc>c++_bugs_gcc</toc> +      <toc>clanlib</toc> +      <toc>w3c-dom-level2-html</toc> +      <toc>fortran_bugs_gcc</toc> +      <toc>gnome1</toc> +      <toc>gnustep</toc> +      <toc>gtk</toc> +      <toc>gtk_bugs</toc> +      <toc>haskell</toc> +      <toc>haskell_bugs_ghc</toc> +      <toc>java_bugs_gcc</toc> +      <toc>java_bugs_sun</toc> +      <toc>kde2book</toc> +      <toc>libc</toc> +      <toc>libstdc++</toc> +      <toc>opengl</toc> +      <toc>pascal_bugs_fp</toc> +      <toc>php</toc> +      <toc>php_bugs</toc> +      <toc>python</toc> +      <toc>python_bugs</toc> +      <toc>qt-kdev3</toc> +      <toc>ruby</toc> +      <toc>ruby_bugs</toc> +      <toc>sdl</toc> +      <toc>stl</toc> +      <toc>w3c-svg</toc> +      <toc>sw</toc> +      <toc>w3c-uaag10</toc> +      <toc>wxwidgets_bugs</toc> +    </ignoretocs> +    <ignoreqt_xml> +      <toc>Guide to the Qt Translation Tools</toc> +      <toc>Qt Assistant Manual</toc> +      <toc>Qt Designer Manual</toc> +      <toc>Qt Reference Documentation</toc> +      <toc>qmake User Guide</toc> +    </ignoreqt_xml> +    <ignoredoxygen> +      <toc>KDE Libraries (Doxygen)</toc> +    </ignoredoxygen> + </kdevdoctreeview> + <kdevfilecreate> +    <filetypes/> +    <useglobaltypes> +      <type ext="" /> +      <type ext="pl" /> +      <type ext="pm" /> +    </useglobaltypes> + </kdevfilecreate> +</kdevelop> diff --git a/languages/perl/app_templates/perlhello/app.pl b/languages/perl/app_templates/perlhello/app.pl new file mode 100755 index 00000000..bd6bbf6a --- /dev/null +++ b/languages/perl/app_templates/perlhello/app.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w +# +use strict; +use warnings; + + +#program version +my $VERSION="%{VERSION}"; + +#For CVS , use following line +#my $VERSION=sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/); + +sub do_something { +  my $text=shift; +  print "$text\n"; +} + +&do_something("Hello World"); +print "That's all folks for version $VERSION \n"; + +__END__ + +=head1 NAME + +%{APPNAME} - short description of your program + +=head1 SYNOPSIS + + how to use your program + +=head1 DESCRIPTION + + long description of your program + +=head1 SEE ALSO + + need to know things before somebody uses your program + +=head1 AUTHOR + + %{AUTHOR} + +=cut diff --git a/languages/perl/app_templates/perlhello/perlhello b/languages/perl/app_templates/perlhello/perlhello new file mode 100644 index 00000000..1f015e1b --- /dev/null +++ b/languages/perl/app_templates/perlhello/perlhello @@ -0,0 +1,10 @@ +# KDE Config File +[General] +Name=Simple Perl script +Name[fr]=Un simple script de test  Hello world  +Icon=camel.png +Category=Perl +Comment=This generates a simplistic 'Hello world' program in Perl (http://www.perl.org) +Comment[fr]=Gnre un simple script de test du type  Hello world  dans le language PERL (http://www.perl.org). +FileTemplates=perl,ShellStyle +ShowFilesAfterGeneration=APPNAMELC.pl diff --git a/languages/perl/app_templates/perlhello/perlhello.kdevtemplate b/languages/perl/app_templates/perlhello/perlhello.kdevtemplate new file mode 100644 index 00000000..ead7b5b8 --- /dev/null +++ b/languages/perl/app_templates/perlhello/perlhello.kdevtemplate @@ -0,0 +1,108 @@ +# KDE Config File +[General] +Name=Simple Perl script +Name[ca]=Simple script en Perl +Name[da]=Simpelt Perl script +Name[de]=Einfaches Perl-Skript +Name[el]=Απλό σενάριο Perl +Name[es]=Guión sencillo en Perl +Name[et]=Lihtne Perli skript +Name[eu]=Perl script sinplea +Name[fa]=دستنوشتۀ سادۀ پرل +Name[fr]=Script Perl simple +Name[ga]=Script shimplí Perl +Name[gl]=Script sinxelo en Perl +Name[hu]=Egyszerű Perl-szkript +Name[it]=Semplice script Perl +Name[ja]=簡単な Perl スクリプト +Name[nds]=Eenfach Perl-Skript +Name[ne]=साधारण पर्ल स्क्रिप्ट +Name[nl]=Eenvoudig Perl-script +Name[pl]=Prosty skrypt w Perlu +Name[pt]=Programa simples em Perl +Name[pt_BR]=Programa simples em Perl +Name[ru]=Простой скрипт Perl +Name[sk]=Jednoduchý Perl skript +Name[sr]=Једноставна Perl скрипта +Name[sr@Latn]=Jednostavna Perl skripta +Name[sv]=Enkelt Perl-skript +Name[tr]=Basit Perl betiği +Name[zh_CN]=简单 Perl 脚本 +Name[zh_TW]=簡單的 Perl 文稿 +Icon=camel.png +Category=Perl +Comment=This generates a simplistic 'Hello world' program in Perl (http://www.perl.org) +Comment[ca]=Genera un simple programa de 'Hello world' en Perl (http://www.perl.org) +Comment[da]=Dette genererer et simplistisk 'Goddag verden' program i Perl (http://www.perl.org) +Comment[de]=Hiermit wird ein einfaches "Hello World"-Programm in Perl erstellt (http://www.perl.org). +Comment[el]=Αυτό δημιουργεί ένα απλό πρόγραμμα 'Γεια σου κόσμε' σε Perl (http://www.perl.org) +Comment[es]=Genera un programa «Hola mundo» sencillo en Perl (http://www.perl.org) +Comment[et]=Lihtsa "Tere, maailm" programmi loomine Perlis (http://www.perl.org) +Comment[eu]=Honek "Kaixo mundua" Perl-en (http://www.perl.org) idatzitako programa sinple bat sortzen du. +Comment[fa]=یک برنامۀ سادۀ «Hello world» در پرل (http://www.perl.org) تولید میکند +Comment[fr]=Génère un programme « Bonjour monde » simple en Perl (http://www.perl.org) +Comment[ga]=Cruthaíonn sé seo ríomhchlár simplí "Hello world" i Perl (http://www.perl.org/) +Comment[gl]=Isto xera un programa sinxelo en Perl 'Ola mundo'(http://www.perl.org) +Comment[hu]=Létrehoz egy egyszerű 'Hello world' programot Perlben (http://www.perl.org) +Comment[it]=Genera un semplice programma di "Hello world" in Perl (http://www.perl.org) +Comment[ja]=Perl で書かれた簡単な Hello world プログラムを作成します +Comment[nds]=Dit stellt en eenfach "Moin Welt"-Programm in Perl op.(http://www.perl.org). +Comment[ne]=यसले पर्लमा साधारण 'हेल्लो वोल्ड' कार्यक्रम उत्पन्न गर्दछ (http://www.perl.org) +Comment[nl]=Dit genereert een eenvoudig Hello World-programma in Perl (http://www.perl.org) +Comment[pl]=Generuje prosty skrypt "Witaj świecie" w Perlu (http://www.perl.org) +Comment[pt]=Isto gera um programa simples 'Olá mundo' em Perl (http://www.perl.org) +Comment[pt_BR]=Isto gera um programa simples 'Olá mundo' em Perl (http://www.perl.org) +Comment[ru]=Создание простой программы 'Hello world' на Perl (http://www.perl.org) +Comment[sk]=Vygeneruje jednoduchý Ahoj svet program v Perl (http://www.perl.org) +Comment[sr]=Прави једноставан „Здраво свете“ програм у Perl-у (http://www.perl.org) +Comment[sr@Latn]=Pravi jednostavan „Zdravo svete“ program u Perl-u (http://www.perl.org) +Comment[sv]=Detta skapar ett förenklat 'Hello world'-program i Perl (http://www.perl.org) +Comment[tr]=Bu, Perl'de basit bir "Merhaba Dünya" programı yaratır (http://www.perl.org) +Comment[zh_CN]=这将生成一个简单的 Perl 语言“Hello world”程序 +Comment[zh_TW]=產生一個簡單的 Perl (http://www.perl.org) 的 Hello world 程式 +FileTemplates=perl,ShellStyle +ShowFilesAfterGeneration=%{dest}/%{APPNAMELC}.pl +Archive=perlhello.tar.gz + +[FILE1] +Type=install +EscapeXML=true +Source=%{src}/app.kdevelop +Dest=%{dest}/%{APPNAMELC}.kdevelop + +[FILE2] +Type=install +Source=%{src}/app.pl +Dest=%{dest}/%{APPNAMELC}.pl + +[MSG] +Type=message +Comment=A simple Perl script was created in %{dest} +Comment[ca]=Un simple script en Perl ha estat creat en %{dest} +Comment[da]=Et simpelt Perl script blev oprettet i %{dest} +Comment[de]=Ein einfaches Perl-Skript wurde in %{dest} erstellt. +Comment[el]=Ένα απλό σενάριο Perl δημιουργήθηκε στο %{dest} +Comment[es]=Un sencillo guión en Perl ha sido creado en %{dest} +Comment[et]=Lihtne Perli skript loodi asukohta %{dest} +Comment[eu]=Perl script sinple bat sortu da hemen: %{dest} +Comment[fa]=یک دستنوشتۀ سادۀ پرل در  %{dest} ایجاد شد +Comment[fr]=Un script Perl simple a été créé dans %{dest} +Comment[ga]=Cruthaíodh script shimplí Perl i %{dest} +Comment[gl]=Creouse un script sinxelo en Perl en %{dest} +Comment[hu]=Létrejött egy egyszerű Perl-szkript itt: %{dest} +Comment[it]=È stato creato un semplice script Perl in %{dest} +Comment[ja]=簡単な Perl スクリプトを %{dest} に作成しました +Comment[nds]=In %{dest} wöör en eenfach Perl-Skript opstellt. +Comment[ne]=साधारण पर्ल स्क्रिप्ट %{dest} मा सिर्जना गरियो +Comment[nl]=Een eenvoudig Perl-script is aangemaakt in %{dest} +Comment[pl]=Prosty skrypt w Perlu został utworzony w %{dest} +Comment[pt]=Foi criado um programa simples em Perl em %{dest} +Comment[pt_BR]=Foi criado um programa simples em Perl em %{dest} +Comment[ru]=Простой скрипт Perl создан в %{dest} +Comment[sk]=Jednoduchý Perl skript bol vytvorený v %{dest} +Comment[sr]=Једноставна Perl скрипта направљена је у %{dest} +Comment[sr@Latn]=Jednostavna Perl skripta napravljena je u %{dest} +Comment[sv]=Ett enkelt Perl-skript skapades i %{dest} +Comment[tr]=Basit Perl betiği %{dest} içinde yaratıldı. +Comment[zh_CN]=在 %{dest} 创建了一个简单的 Perl 脚本 +Comment[zh_TW]=一個簡單的 Perl 文稿已建立於 %{dest} diff --git a/languages/perl/app_templates/perlhello/perlhello.png b/languages/perl/app_templates/perlhello/perlhello.png Binary files differnew file mode 100644 index 00000000..78e0532a --- /dev/null +++ b/languages/perl/app_templates/perlhello/perlhello.png diff --git a/languages/perl/doc/Makefile.am b/languages/perl/doc/Makefile.am new file mode 100644 index 00000000..dae5d699 --- /dev/null +++ b/languages/perl/doc/Makefile.am @@ -0,0 +1,6 @@ +tocdir = ${kde_datadir}/kdevdocumentation/tocs +toc_DATA = perl.toc perl_bugs.toc + +#indexdir = ${kde_datadir}/devdoctreeview/indices +#index_DATA = + diff --git a/languages/perl/doc/perl.toc b/languages/perl/doc/perl.toc new file mode 100644 index 00000000..84cb8145 --- /dev/null +++ b/languages/perl/doc/perl.toc @@ -0,0 +1,54 @@ +<!DOCTYPE kdeveloptoc> +<kdeveloptoc> +<title>Perl</title> +<tocsect1 name="Data structures" url="man:perldata"/> +<tocsect1 name="Syntax" url="man:perlsyn"/> +<tocsect1 name="Operators and Precedence" url="man:perlop"/> +<tocsect1 name="Regular Expressions" url="man:perlre"/> +<tocsect1 name="Execution and Options" url="man:perlrun"/> +<tocsect1 name="Builtin Functions" url="man:perlfunc"/> +<tocsect1 name="open() Tutorial" url="man:perlopentut"/> +<tocsect1 name="Predefined Variables" url="man:perlvar"/> +<tocsect1 name="Subroutines" url="man:perlsub"/> +<tocsect1 name="Modules: how they work" url="man:perlmod"/> +<tocsect1 name="Modules: how to write and use" url="man:perlmodlib"/> +<tocsect1 name="Modules: how to install from CPAN" url="man:perlmodinstall"/> +<tocsect1 name="Formats" url="man:perlform"/> +<tocsect1 name="Unicode Support" url="man:perlunicode"/> +<tocsect1 name="Locale Support" url="man:perllocale"/> +<tocsect1 name="References Introduction" url="man:perlreftut"/> +<tocsect1 name="References, the rest of the story" url="man:perlref"/> +<tocsect1 name="Data Structures: introduction" url="man:perldsc"/> +<tocsect1 name="Data Structures: arrrays of arrays" url="man:perllol"/> +<tocsect1 name="OO tutorial 1" url="man:perlboot"/> +<tocsect1 name="OO tutorial 2" url="man:perltoot"/> +<tocsect1 name="OO tutorial 3" url="man:perltootc"/> +<tocsect1 name="Objects" url="man:perlobj"/> +<tocsect1 name="Objects hidden behind simple variables" url="man:perltie"/> +<tocsect1 name="OO tricks and examples" url="man:perlbot"/> +<tocsect1 name="Interprocess Communication" url="man:perlipc"/> +<tocsect1 name="fork() Information" url="man:perlfork"/> +<tocsect1 name="Threads Tutorial" url="man:perlthrtut"/> +<tocsect1 name="Warnings and their Control" url="man:perllexwarn"/> +<tocsect1 name="Source Filters" url="man:perlfilter"/> +<tocsect1 name="DBM Filters" url="man:perldbmfilter"/> +<tocsect1 name="Compiler Suite Introduction" url="man:perlcompile"/> +<tocsect1 name="Debugging" url="man:perldebug"/> +<tocsect1 name="Diagnostic Messages" url="man:perldiag"/> +<tocsect1 name="Number semantics" url="man:perlnumber"/> +<tocsect1 name="Security" url="man:perlsec"/> +<tocsect1 name="Traps for the Unwary" url="man:perltrap"/> +<tocsect1 name="Portability Guide" url="man:perlport"/> +<tocsect1 name="Style Guide" url="man:perlstyle"/> +<tocsect1 name="POD" url="man:perlpod"/> +<tocsect1 name="Embed Perl in C" url="man:perlembed"/> +<tocsect1 name="Internal IO abstraction interface" url="man:perlapio"/> +<tocsect1 name="Debugging guts and tips" url="man:perldebguts"/> +<tocsect1 name="XS API" url="man:perlxs"/> +<tocsect1 name="XS Tutorial" url="man:perlxstut"/> +<tocsect1 name="Internal Functions" url="man:perlguts"/> +<tocsect1 name="Calling conventions from C" url="man:perlcall"/> +<tocsect1 name="API listing" url="man:perlapi"/> +<tocsect1 name="Internal functions" url="man:perlintern"/> +</kdeveloptoc> + diff --git a/languages/perl/doc/perl_bugs.toc b/languages/perl/doc/perl_bugs.toc new file mode 100644 index 00000000..126b35f3 --- /dev/null +++ b/languages/perl/doc/perl_bugs.toc @@ -0,0 +1,7 @@ +<!DOCTYPE kdeveloptoc> +<kdeveloptoc> +<title>Perl bugs</title> +<base href="http://www.nntp.perl.org/"/> +<tocsect1 name="Query" url="group"> +</tocsect1> +</kdeveloptoc> diff --git a/languages/perl/file_templates/Makefile.am b/languages/perl/file_templates/Makefile.am new file mode 100644 index 00000000..f1f8457d --- /dev/null +++ b/languages/perl/file_templates/Makefile.am @@ -0,0 +1,4 @@ +templatedir = $(kde_datadir)/kdevfilecreate/file-templates +template_DATA = pl pm + + diff --git a/languages/perl/file_templates/pl b/languages/perl/file_templates/pl new file mode 100644 index 00000000..bacfcdda --- /dev/null +++ b/languages/perl/file_templates/pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w +# +use strict; +use warnings; + + +#program version +my $VERSION="$VERSION$"; + +#For CVS , use following line +#my $VERSION=sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/); + +sub do_something { +  my $text=shift; +  print "$text\n"; +} + +&do_something("Hello World"); +print "That's all folks for version $VERSION \n"; + +__END__ + +=head1 NAME + +Script name - short discription of your program + +=head1 SYNOPSIS + + how to us your program + +=head1 DESCRIPTION + + long description of your program + +=head1 SEE ALSO + + need to know things before somebody uses your program + +=head1 AUTHOR + + $AUTHOR$ + +=cut diff --git a/languages/perl/file_templates/pm b/languages/perl/file_templates/pm new file mode 100644 index 00000000..c0e33a1d --- /dev/null +++ b/languages/perl/file_templates/pm @@ -0,0 +1,68 @@ +package $MODULE$; + +use strict; + +require Exporter; +use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); + +# set the version for version checking +$VERSION     = $VERSION$; + +@ISA         = qw(Exporter); +@EXPORT      = qw(&hello); +%EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ], + +# your exported package globals go here, +# as well as any optionally exported functions +@EXPORT_OK   = qw($Var1 %Hashit &func3); + +use vars qw($Var1 %Hashit); +# non-exported package globals go here +use vars qw(@more $stuff); + +# initialize package globals, first exported ones +$Var1   = ''; +%Hashit = (); + +# then the others (which are still accessible as $Some::Module::stuff) +$stuff  = ''; +@more   = (); + + +# file-private lexicals go here +my $priv_var    = ''; +my %secret_hash = (); + + +sub hello { + print "hello world\n";  +} + + +END { }       # module clean-up code here (global destructor) + +1; + +__END__ + +=head1 NAME + +ModuleName - short discription of your program + +=head1 SYNOPSIS + + how to us your module + +=head1 DESCRIPTION + + long description of your module + +=head1 SEE ALSO + + need to know things before somebody uses your program + +=head1 AUTHOR + + $AUTHOR$ + +=cut diff --git a/languages/perl/kdevperlsupport.desktop b/languages/perl/kdevperlsupport.desktop new file mode 100644 index 00000000..66cfc907 --- /dev/null +++ b/languages/perl/kdevperlsupport.desktop @@ -0,0 +1,85 @@ +[Desktop Entry] +Type=Service +Exec=blubb +Comment=Perl Support +Comment[ca]=Suport per a Perl +Comment[da]=Perl-understøttelse +Comment[de]=Perl-Unterstützung für KDevelop +Comment[el]=Υποστήριξη Perl +Comment[es]=Soporte para Perl +Comment[et]=Perli toetus +Comment[eu]=Perl euskarria +Comment[fa]=پشتیبانی پرل +Comment[fr]=Prise en charge du langage Perl +Comment[ga]=Tacaíocht Perl +Comment[gl]=Soporte para Perl +Comment[hi]=पर्ल समर्थन +Comment[hu]=Perl-támogatás +Comment[is]=Perl stuðningur +Comment[it]=Supporto Perl +Comment[ja]=Perl サポート +Comment[nds]=Ünnerstütten för Perl +Comment[ne]=पर्ल समर्थन +Comment[nl]=Ondersteuning voor Perl +Comment[pl]=Obsługa Perla +Comment[pt]=Suporte a Perl +Comment[pt_BR]=Suporte ao Perl +Comment[ru]=Поддержка языка Perl +Comment[sk]=Perl podpora +Comment[sl]=Podpora za perl +Comment[sr]=Подршка за Perl +Comment[sr@Latn]=Podrška za Perl +Comment[sv]=Perl-stöd +Comment[ta]=பெர்ல் ஆதரவு +Comment[tg]=Ёрӣ намудани забони Perl +Comment[tr]=Perl Desteği +Comment[zh_CN]=Perl 支持 +Comment[zh_TW]=Perl 支援 +Name=KDevPerlSupport +Name[da]=KDevelop Perl-understøttelse +Name[de]=Unterstützung für Perl (KDevelop) +Name[hi]=के-डेव-पर्ल-समर्थन +Name[nds]=Perl-Ünnerstütten för KDevelop +Name[pl]=KDevObsługaPerla +Name[sk]=KDev Perl podpora +Name[sv]=KDevelop Perl-stöd +Name[ta]=கெடெவ் பெர்ல் ஆதரவு +Name[zh_TW]=KDevelop Perl 支援 +GenericName=Perl Support +GenericName[ca]=Suport per a Perl +GenericName[da]=Perl-understøttelse +GenericName[de]=Unterstützung für Perl +GenericName[el]=Υποστήριξη Perl +GenericName[es]=Soporte para Perl +GenericName[et]=Perli toetus +GenericName[eu]=Perl euskarria +GenericName[fa]=پشتیبانی پرل +GenericName[fr]=Prise en charge du langage PERL +GenericName[ga]=Tacaíocht Perl +GenericName[gl]=Soporte para Perl +GenericName[hi]=पर्ल समर्थन +GenericName[hu]=Perl-támogatás +GenericName[it]=Supporto per Perl +GenericName[ja]=Perl サポート +GenericName[nds]=Ünnerstütten för Perl +GenericName[ne]=पर्ल समर्थन +GenericName[nl]=Ondersteuning voor Perl +GenericName[pl]=Obsługa Perla +GenericName[pt]=Suporte a Perl +GenericName[pt_BR]=Suporte ao Perl +GenericName[ru]=Поддержка языка Perl +GenericName[sk]=Perl podpora +GenericName[sl]=Podpora za perl +GenericName[sr]=Подршка за Perl +GenericName[sr@Latn]=Podrška za Perl +GenericName[sv]=Perl-stöd +GenericName[ta]=பெர்ல் ஆதரவு +GenericName[tg]=Ёрӣ намудани забони Perl +GenericName[tr]=Perl Desteği +GenericName[zh_CN]=Perl 支持 +GenericName[zh_TW]=Perl 支援 +ServiceTypes=KDevelop/LanguageSupport +X-KDE-Library=libkdevperlsupport +X-KDevelop-Version=5 +X-KDevelop-Language=Perl + diff --git a/languages/perl/kdevperlsupport.rc b/languages/perl/kdevperlsupport.rc new file mode 100644 index 00000000..9f5f4ee9 --- /dev/null +++ b/languages/perl/kdevperlsupport.rc @@ -0,0 +1,14 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="KDevPerlSupport" version="1"> +<MenuBar> +  <Menu name="build" > +    <Action name="build_exec" /> +    <Action name="build_runinterpreter" /> +    <Action name="build_execstring" /> +  </Menu>  + <Menu name="help"> +  <Action name="help_perldocfunction"/> +  <Action name="help_perldocfaq"/> + </Menu> +</MenuBar> +</kpartgui> diff --git a/languages/perl/perlconfigwidget.cpp b/languages/perl/perlconfigwidget.cpp new file mode 100644 index 00000000..475ed8af --- /dev/null +++ b/languages/perl/perlconfigwidget.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + *   Copyright (C) 2002 by Bernd Gehrmann                                  * + *   bernd@kdevelop.org                                                    * + *                                                                         * + *   This program is free software; you can redistribute it and/or modify  * + *   it under the terms of the GNU General Public License as published by  * + *   the Free Software Foundation; either version 2 of the License, or     * + *   (at your option) any later version.                                   * + *                                                                         * + ***************************************************************************/ + +#include "perlconfigwidget.h" + +#include <qcheckbox.h> +#include <qlineedit.h> +#include "domutil.h" + + +PerlConfigWidget::PerlConfigWidget(QDomDocument &projectDom, +                                       QWidget *parent, const char *name) +    : PerlConfigWidgetBase(parent, name), dom(projectDom) +{ +    interpreter_edit->setText(DomUtil::readEntry(dom, "/kdevperlsupport/run/interpreter")); +    terminal_box->setChecked(DomUtil::readBoolEntry(dom, "/kdevperlsupport/run/terminal")); +} + + +PerlConfigWidget::~PerlConfigWidget() +{} + + +void PerlConfigWidget::accept() +{ +    DomUtil::writeEntry(dom, "/kdevperlsupport/run/interpreter", interpreter_edit->text()); +    DomUtil::writeBoolEntry(dom, "/kdevperlsupport/run/terminal", terminal_box->isChecked()); +} + +#include "perlconfigwidget.moc" diff --git a/languages/perl/perlconfigwidget.h b/languages/perl/perlconfigwidget.h new file mode 100644 index 00000000..07364a40 --- /dev/null +++ b/languages/perl/perlconfigwidget.h @@ -0,0 +1,34 @@ +/*************************************************************************** + *   Copyright (C) 2002 by Bernd Gehrmann                                  * + *   bernd@kdevelop.org                                                    * + *                                                                         * + *   This program is free software; you can redistribute it and/or modify  * + *   it under the terms of the GNU General Public License as published by  * + *   the Free Software Foundation; either version 2 of the License, or     * + *   (at your option) any later version.                                   * + *                                                                         * + ***************************************************************************/ + +#ifndef _PERLCONFIGWIDGET_H_ +#define _PERLCONFIGWIDGET_H_ + +#include "perlconfigwidgetbase.h" +#include <qdom.h> + + +class PerlConfigWidget : public PerlConfigWidgetBase +{  +    Q_OBJECT + +public: +    PerlConfigWidget( QDomDocument &projectDom, QWidget *parent=0, const char *name=0 ); +    ~PerlConfigWidget(); + +public slots: +    void accept(); + +private: +    QDomDocument &dom; +}; + +#endif diff --git a/languages/perl/perlconfigwidgetbase.ui b/languages/perl/perlconfigwidgetbase.ui new file mode 100644 index 00000000..8becd0f4 --- /dev/null +++ b/languages/perl/perlconfigwidgetbase.ui @@ -0,0 +1,101 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>PerlConfigWidgetBase</class> +<widget class="QWidget"> +    <property name="name"> +        <cstring>perl_config_widget</cstring> +    </property> +    <property name="geometry"> +        <rect> +            <x>0</x> +            <y>0</y> +            <width>600</width> +            <height>480</height> +        </rect> +    </property> +    <property name="caption"> +        <string>Perl</string> +    </property> +    <vbox> +        <property name="name"> +            <cstring>unnamed</cstring> +        </property> + +        <widget class="QLabel"> +            <property name="name"> +                <cstring>interpreter_label</cstring> +            </property> +            <property name="text"> +                <string>Perl &interpreter:</string> +            </property> +            <property name="buddy" stdset="0"> +                <cstring>interpreter_edit</cstring> +            </property> +        </widget> +        <widget class="QLayoutWidget"> +            <property name="name"> +                <cstring>Layout1</cstring> +            </property> +            <hbox> +                <property name="name"> +                    <cstring>unnamed</cstring> +                </property> +                <property name="margin"> +                    <number>0</number> +                </property> + +                <widget class="QLineEdit"> +                    <property name="name"> +                        <cstring>interpreter_edit</cstring> +                    </property> +                </widget> +                <spacer> +                    <property name="name"> +                        <cstring>Spacer1</cstring> +                    </property> +                    <property name="orientation"> +                        <enum>Horizontal</enum> +                    </property> +                    <property name="sizeType"> +                        <enum>Expanding</enum> +                    </property> +                </spacer> +            </hbox> +        </widget> +        <spacer> +            <property name="name"> +                <cstring>Spacer3</cstring> +            </property> +            <property name="orientation"> +                <enum>Vertical</enum> +            </property> +            <property name="sizeType"> +                <enum>Minimum</enum> +            </property> +        </spacer> +        <widget class="QCheckBox"> +            <property name="name"> +                <cstring>terminal_box</cstring> +            </property> +            <property name="text"> +                <string>&Execute programs in a terminal</string> +            </property> +        </widget> +        <spacer> +            <property name="name"> +                <cstring>Spacer2</cstring> +            </property> +            <property name="orientation"> +                <enum>Vertical</enum> +            </property> +            <property name="sizeType"> +                <enum>Expanding</enum> +            </property> +        </spacer> +    </vbox> +</widget> +<includes> +    <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> diff --git a/languages/perl/perldoc.cpp b/languages/perl/perldoc.cpp new file mode 100644 index 00000000..cbb4d18f --- /dev/null +++ b/languages/perl/perldoc.cpp @@ -0,0 +1,133 @@ +#include "perldoc.h" + +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <qtextstream.h> +#include <kdebug.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kinstance.h> +#include <kprocess.h> +#include <kdeversion.h> +#include <kglobal.h> + +using namespace KIO; + + +PerldocProtocol::PerldocProtocol(const QCString &pool, const QCString &app) +    : SlaveBase("perldoc", pool, app) +{} + + +PerldocProtocol::~PerldocProtocol() +{} + + +void PerldocProtocol::get(const KURL& url) +{ +    QStringList l = QStringList::split('/', url.path()); + +    mimeType("text/html"); + +    bool plain = false; +    QString cmd = "perldoc "; +    if (l[0] == "functions") { +        plain = true; +        cmd += "-t -f "; +        cmd += KProcess::quote(l[1]); +    } else if (l[0] == "faq") { +        cmd += "-u -q "; +        cmd += KProcess::quote(l[1]); +        cmd += " | pod2html"; +    } else { +        QCString errstr(i18n("The only existing directories are functions and faq.").local8Bit()); +        data(errstr); +        finished(); +        return; +    } + +    kdDebug() << "Command: " << cmd << endl; + +    if (plain) +        data(QCString("<blockquote>")); + +    FILE *fd = popen(cmd.local8Bit().data(), "r"); +    char buffer[4090]; +    QByteArray array; + +    while (!feof(fd)) { +        int n = fread(buffer, 1, 2048, fd); +        if (n == -1) { +            pclose(fd); +            return; +        } +        array.setRawData(buffer, n); +        data(array); +        array.resetRawData(buffer, n); +    } + +    pclose(fd); + +    if (plain) +        data(QCString("</blockquote>")); + +    finished(); +} + + +void PerldocProtocol::mimetype(const KURL &url) +{ +    QStringList l = QStringList::split('/', url.path()); +    mimeType((l[0] == "faq")? "text/html" : "text/plain"); +    finished(); +} + + +QCString PerldocProtocol::errorMessage() +{ +    return QCString( "<html><body bgcolor=\"#FFFFFF\">" + i18n("Error in perldoc").local8Bit() + "</body></html>" ); +} + + +void PerldocProtocol::stat(const KURL &/*url*/) +{ +    UDSAtom uds_atom; +    uds_atom.m_uds = KIO::UDS_FILE_TYPE; +    uds_atom.m_long = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO; + +    UDSEntry uds_entry; +    uds_entry.append(uds_atom); + +    statEntry(uds_entry); +    finished(); +} + + +void PerldocProtocol::listDir(const KURL &url) +{ +    error( KIO::ERR_CANNOT_ENTER_DIRECTORY, url.path() ); +} + + +extern "C" { + +    int kdemain(int argc, char **argv) +    { +        KInstance instance( "kio_perldoc" ); +        KGlobal::locale()->setMainCatalogue("kdevelop"); + +        if (argc != 4) { +            fprintf(stderr, "Usage: kio_perldoc protocol domain-socket1 domain-socket2\n"); +            exit(-1); +        } + +        PerldocProtocol slave(argv[2], argv[3]); +        slave.dispatchLoop(); + +        return 0; +    } + +} diff --git a/languages/perl/perldoc.h b/languages/perl/perldoc.h new file mode 100644 index 00000000..00cced89 --- /dev/null +++ b/languages/perl/perldoc.h @@ -0,0 +1,25 @@ +#ifndef _PERLDOC_H_ +#define _PERLDOC_H_ + +#include <qobject.h> +#include <kio/slavebase.h> + + +class PerldocProtocol : public KIO::SlaveBase +{ +public: +    PerldocProtocol(const QCString &pool, const QCString &app); +    virtual ~PerldocProtocol(); + +    virtual void get(const KURL& url); +    virtual void stat(const KURL& url); +    virtual void mimetype(const KURL& url); +    virtual void listDir(const KURL& url); + +protected: +    void decodeURL(const KURL &url); +    void decodePath(QString path); +    QCString errorMessage(); +}; + +#endif diff --git a/languages/perl/perldoc.protocol b/languages/perl/perldoc.protocol new file mode 100644 index 00000000..031ca931 --- /dev/null +++ b/languages/perl/perldoc.protocol @@ -0,0 +1,9 @@ +[Protocol] +exec=kio_perldoc +protocol=perldoc +input=none +output=filesystem +reading=true +listing=Name +determineMimetypeFromExtension=false +Icon=help diff --git a/languages/perl/perlparser.cpp b/languages/perl/perlparser.cpp new file mode 100644 index 00000000..a6a5a834 --- /dev/null +++ b/languages/perl/perlparser.cpp @@ -0,0 +1,494 @@ +/*************************************************************************** +                          perlparser.cpp  -  description +                             ------------------- +    begin                : Sun Nov 2 2003 +    copyright            : (C) 2003 by luc +    email                : willems.luc(at)pandora.be + ***************************************************************************/ + +/*************************************************************************** + *                                                                         * + *   This program is free software; you can redistribute it and/or modify  * + *   it under the terms of the GNU General Public License as published by  * + *   the Free Software Foundation; either version 2 of the License, or     * + *   (at your option) any later version.                                   * + *                                                                         * + ***************************************************************************/ + +#include "perlparser.h" + +#include <kdebug.h> +#include <qfile.h> +#include <qregexp.h> +#include <qfileinfo.h> + +perlparser::perlparser(KDevCore* core,CodeModel* model, QString interpreter) { +  m_core = core; +  m_model = model; +  m_interpreter=interpreter; +  //get INC paths for current installed perl +  getPerlINC(); + +} + +perlparser::~perlparser(){ +} + +const QStringList perlparser::UseFiles() +{ +  return m_usefiles; +} + +void perlparser::initialParse() { +  m_usefiles.clear(); +} + +void perlparser::parse(const QString &fileName){ +  QFile f(fileName); +  if (!f.open(IO_ReadOnly)) +      return; +  QTextStream stream(&f); +  QStringList list; +  QString rawline; +  while (!stream.eof()) { +   rawline = stream.readLine(); +   list.append(rawline.stripWhiteSpace().local8Bit()); + } + f.close(); + kdDebug(9016) << "parsing " << fileName << endl; + + m_file = m_model->create<FileModel>(); + m_file->setName(fileName ); + this->parseLines(&list,fileName); + m_model->addFile( m_file ); +} + +void perlparser::parseLines(QStringList* lines,const QString &fileName) +{ +  QRegExp  packagere("^[ \t]*package[ \t]+([+A-Za-z0-9_:]*).*\\;"); +  QRegExp     basere("^[ \t]*use[ \t]+base[ \t]*\\(\'*\"*([A-Za-z0-9_:]*)"); +  QRegExp      libre("^[ \t]*use[ \t]+lib[ \t]*\\(\'*\"*([A-Za-z0-9_:]*)"); +  QRegExp      usere("^[ \t]*use[ \t]+([+A-Za-z0-9_:]*).*\\;"); +  QRegExp      isare("^[ \t]*@ISA[ \t=qw\\(\'\"]*([A-Za-z0-9_: ]*)"); +  QRegExp   globalre("^[ \t]*our[ \t]+\\(*([ \t,$%@*+A-Za-z0-9_]*)\\)*.*"); +  QRegExp   myre("^[ \t]*my[ \t]+\\(*([ \t,$%@*+A-Za-z0-9_]*)\\)*.*"); +  QRegExp      subre("^[ \t]*sub[ \t]+([A-Za-z0-9_]+)([A-Za-z0-9_]|([ \t]*[{])?)$"); +  QRegExp    blessre("bless[ \t]*[\\( ]*([,$%@*+A-Za-z0-9_]*).*;"); +  QRegExp     namere("^[ \t]*([$%@*])([A-Za-z0-9_]*).*$"); +  QRegExp  privatere("^_([A-Za-z0-9_]*)"); +  QRegExp  startpod("^=[a-z0-9]+ [a-z0-9]*"); +  QRegExp  cutpod("^=cut"); + +  QString line; + +  //clear all "last" know things +  m_lastsub=""; +  m_lastattr=""; +  m_inpackage = false; +  m_inscript = false; +  m_inclass=false; + +  m_lastscript=0; +  m_lastpackage=0; +  m_lastclass=0; + +  int lineNo = -1; +   +  bool inpod = false; +  bool endpod = false; + +  //check if we are parsing a script or module +  QFileInfo fi(fileName); +  bool inscript =(fi.extension() == "pl"); +  kdDebug(9016) << "inscript : " << inscript << "," << fi.extension() << endl; + +  if (inscript) { +    addScript(fileName,lineNo,fi.fileName()); +  } + +  for ( QStringList::Iterator it = lines->begin(); it != lines->end(); ++it ) { +    ++lineNo; +    line = (*it).local8Bit(); +    //empty line ? +    if (line.isEmpty()) { continue;} +    //some POD checking , quick and dirty but it seams to work +    if(inpod && endpod) { inpod=false; endpod=false;} +    //are we in pod documentation ? +    if (startpod.search(line)>=0) {inpod=true; continue;} +    //are we in pod documentation ? +    if (inpod) { endpod=( cutpod.search(line)>=0 ); continue; } + + +    //sub matching +    if (subre.search(line)>=0){ +          QString subname=subre.cap(1); +          kdDebug(9016) << "subre match [" << subname << "]" << endl; +          bool prive = privatere.search(subname) >= 0; +          kdDebug(9016) << "prive match [" << prive << "]" << endl; +          if (m_inscript)      { addScriptSub(fileName,lineNo,subname,prive);} +          else { +             if (m_inclass)    { addClassMethod(fileName,lineNo,subname,prive);} +             else              { addPackageSub(fileName,lineNo,subname,prive);} +          } +          continue; +    } //sub + +    //our matching +    if (globalre.search(line)>=0) { +        //splitup multible ours +        QString varlist=globalre.cap(1); +        kdDebug(9016) << "globalre match [" << varlist <<"]" << endl; +        QStringList vars=QStringList::split(",",varlist); +        for ( QStringList::Iterator it = vars.begin(); it != vars.end(); ++it ) { +            if (namere.search(*it)>=0) { +              QString var = namere.cap(2); +              kdDebug(9016) << "namere match [" << var << "]" << endl; +              if (m_lastpackage)  { addAttributetoPackage(fileName,lineNo,var); } +              else                { addAttributetoScript(fileName,lineNo,var); } +            } +        } +        continue; +    } //globalre + +         +    //bless matching +    if ((blessre.search(line)>=0) && (!m_inscript)) { +         kdDebug(9016) << "blessre match []" << endl; +         addClass(fileName,lineNo); +         addConstructor(fileName,lineNo,m_lastsub); +         continue; +    } //bless + +    //base matching +    if ((basere.search(line)>=0) && (!m_inscript)) { +         QString parent = basere.cap(1); +         //create child & parent classes +         kdDebug(9016) << "basere match [" << parent << "]" << endl; +         addClass(fileName,lineNo); +         addParentClass(parent); +         continue; +    } else { +      if (libre.search(line)>=0) { +         QString path = libre.cap(1); +         //add lib to INC path list +         kdDebug(9016) << "libre match [" << path << "]" << endl; +         m_INClist.append(path); +         continue; +      } else { +         if (usere.search(line)>=0) { +           //add lib to use list for later parsing +           QString lib = usere.cap(1); +           kdDebug(9016) << "usere match [" << lib << "]" << endl; +           addUseLib(lib); +           continue; +         }                              \ +     } +    } //base + +    if ((isare.search(line)>=0) && (!m_inscript)) { +         QString parent = isare.cap(1); +         //create child & parent classes +         kdDebug(9016) << "isare match [" << parent << "]" << endl; +         addClass(fileName,lineNo); +         addParentClass(parent); +         continue; +    } //isa + +    if ((packagere.search(line)>=0) && (!m_inscript)) { +         QString package=packagere.cap(1); +         kdDebug(9016) << "packagere match [" << package << "]" << endl; +         addPackage(fileName,lineNo,package); +         continue; +    }//package + +  } // for lines loop +} + +void perlparser::addPackage(const QString& fileName ,int lineNr , const QString& name) +{ + kdDebug(9016) << "AddPackage [" << name << "]" << endl; + NamespaceDom package = m_model->create<NamespaceModel>(); + + package->setName(name); + package->setFileName(fileName ); + package->setStartPosition(lineNr, 0 ); + package->setScope(name); + + if (!m_file->hasNamespace(name)) { +     m_file->addNamespace(package); +     m_lastpackage=package; + } else { +   kdDebug(9016) << "addPackage [" << name << " exist]" << endl; + } + + //clear all "last" know things + m_lastpackagename=name; + m_lastsub=""; + m_lastattr=""; + m_inpackage=true; + m_inscript = false; + m_inclass=false; + + m_lastclass=0; + m_lastscript=0; + +} + +void perlparser::addScript(const QString& fileName ,int lineNr ,const QString& name) +{ + kdDebug(9016) << "addScript [" << name << "]" << endl; + + //map name of script under /scripts + //m_file->setName("/Scripts/"+name); + + kdDebug(9016) << "addScript [" << name << "]" << endl; + NamespaceDom script = m_model->create<NamespaceModel>(); + + script->setName(name); + script->setFileName(fileName ); + script->setStartPosition(lineNr, 0 ); + script->setScope(name); + + if (!m_file->hasNamespace(name)) { +      m_file->addNamespace(script); +      m_lastscript=script; + } else { +   kdDebug(9016) << "addScript [" << name << " exist]" << endl; + } +  + //clear all "last" know things + m_lastsub=""; + m_lastattr=""; + m_inpackage = false; + m_inscript = true; + m_inclass=false; + + m_lastscriptname=name; + m_lastpackage=0; + m_lastclass=0; + +} + +void perlparser::addAttributetoPackage(const QString& fileName ,int lineNr ,const QString& name) +{ + kdDebug(9016) << "addAttributetoPackage [" << name << "]" << endl; + VariableDom var = m_model->create<VariableModel>(); + var->setName(name); + var->setFileName( fileName ); + var->setStartPosition( lineNr, 0 ); + if (m_lastpackage) { +    if (!m_lastpackage->hasVariable(var->name())) +         m_lastpackage->addVariable(var); + } else { +    kdDebug(9016) << "addAttributetoPackge[ no m_file]" << endl; + } + + m_lastattr=name; +} + +void perlparser::addAttributetoScript(const QString& fileName ,int lineNr ,const QString& name) +{ +  kdDebug(9016) << "addAttributetoScript [" << name << "]" << endl; +  VariableDom var = m_model->create<VariableModel>(); +  var->setName(name); +  var->setFileName( fileName ); +  var->setStartPosition( lineNr, 0 ); +  if (m_lastscript) { +    if (!m_lastscript->hasVariable(var->name())) +       m_lastscript->addVariable(var); +  } else { +    kdDebug(9016) << "addAttributeScript[ no m_file]" << endl; +  } +} + +void perlparser::addClass(const QString& fileName ,int lineNr) +{ +  kdDebug(9016) << "addClass [ " << m_lastpackagename << " ]" << endl; +  if (m_lastpackage->hasClass(m_lastpackagename)) { +    kdDebug(9016) << "Class already defined" << endl; +  } else { +    kdDebug(9016) << "new Class" << endl; +    ClassDom lastClass = m_model->create<ClassModel>(); +    lastClass->setName(m_lastpackagename); +   	lastClass->setFileName(fileName); +	  lastClass->setStartPosition(lineNr, 0); +    m_lastpackage->addClass(lastClass); +    m_lastclass=lastClass; +    m_inclass=true; +  } +} + +void perlparser::addConstructor(const QString& fileName ,int lineNr ,const QString& name) +{ +  kdDebug(9016) << "set Constructor["<< name << "]" << endl; + +  FunctionDom method; + +  if (m_lastpackage->hasFunction(name)) { +      //remove last sub frompackage scope +      method = m_lastpackage->functionByName(name)[0]; +      method->getStartPosition(&lineNr,0); +      m_lastpackage->removeFunction(method); +  } +  method = m_lastclass->functionByName(name)[0]; +  if (!method) {  +     kdDebug(9016) << "add new Constructor["<< name << ", " << lineNr << "]" << endl; +     method = m_model->create<FunctionModel>(); +     method->setName(name); +     method->setFileName( fileName ); +     method->setStartPosition( lineNr, 0 ); +     m_lastclass->addFunction(method); +  } +  method->setStatic(true); +  //update class position +  m_lastclass->setStartPosition(lineNr,0); +} + +void perlparser::addGlobalSub(const QString& fileName ,int lineNr ,const QString& name ,bool privatesub) +{ +  kdDebug(9016) << "addGlobalSub[ " << name << "]" << endl; + +  FunctionDom method = m_model->create<FunctionModel>(); +  method->setName(name); +  method->setFileName( fileName ); +  method->setStartPosition( lineNr, 0 ); +  method->setStatic(true); +  if (privatesub) +     method->setAccess(CodeModelItem::Private); +  if (m_lastpackage) { +    if (!m_lastpackage->hasFunction(method->name())) +         m_lastpackage->addFunction(method); +  } else { +    kdDebug(9016) << "addGlobalsub[ no m_lastpackage]" << endl; +  } + + //also add seperate to namespace + addPackageSub(fileName,lineNr,name,privatesub); + m_lastsub=name; +} + +void perlparser::addScriptSub(const QString& fileName ,int lineNr ,const QString& name ,bool privatesub) + +{ +  kdDebug(9016) << "addScriptSub[ " << name << "]" << endl; +  FunctionDom method = m_model->create<FunctionModel>(); +  method->setName(name); +  method->setFileName( fileName ); +  method->setStartPosition( lineNr, 0 ); +  if (privatesub) +     method->setAccess(CodeModelItem::Private); +  if(m_lastscript) { +    m_lastscript->addFunction(method); +  } else { +  } + +  m_lastsub=name; +} + +void perlparser::addClassMethod(const QString& fileName ,int lineNr ,const QString& name ,bool privatesub) +{ +  kdDebug(9016) << "addClassMethod[ " << name << "]" << endl; +  FunctionDom method = m_model->create<FunctionModel>(); +  method->setName(name); +  method->setFileName( fileName ); +  method->setStartPosition( lineNr, 0 ); +  method->setVirtual(true); +  if (privatesub) +     method->setAccess(CodeModelItem::Private); +  if (m_lastclass) { +    if (!m_lastclass->hasFunction(method->name())) +       m_lastclass->addFunction(method); +  } else { +    kdDebug(9016) << "addClassmethod[ no m_lastclass]" << endl; +  } + +// addPackageSub(fileName,lineNr,name,privatesub); + m_lastsub=name; +} + +void perlparser::addPackageSub(const QString& fileName ,int lineNr ,const QString& name ,bool privatesub) +{ +  kdDebug(9016) << "addPackageSub[ " << name << "]" << endl; +  FunctionDom method = m_model->create<FunctionModel>(); +  method->setName(name); +  method->setFileName( fileName ); +  method->setStartPosition( lineNr, 0 ); +  if (privatesub) +     method->setAccess(CodeModelItem::Private); +  if (m_lastpackage) { +    if (!m_lastpackage->hasFunction(method->name())) +       m_lastpackage->addFunction(method); + } else { +   kdDebug(9016) << "addPackageSub[ no m_file]" << endl; + } + m_lastsub=name; +} + +void perlparser::addParentClass(const QString& parent) +{ + kdDebug(9016) << "addParentClass[ " << parent << "]" << endl; + if (m_lastclass) { +        m_lastclass->addBaseClass(parent); + } else { +    kdDebug(9016) << "addParentClass[ no m_lastclass]" << endl; + } +} + +void perlparser::addUseLib(const QString& lib) +{ + if (!m_model->hasFile(lib)) { +   if (m_usefiles.findIndex(lib) == -1) { +      //only add if not already parsed or in the list +      kdDebug(9016) << "add lib for later parsing [" << lib << "]" << endl; +      m_usefiles.append(lib); +   } + } +} + +void perlparser::getPerlINC() { + + + m_INClist.clear(); + + QString cmd = "/usr/bin/perl -e\" print join('|',@INC);\""; + QString result; + + FILE *fd = popen(cmd.local8Bit().data(), "r"); + char buffer[4090]; + QByteArray array; + + while (!feof(fd)) { +        int n = fread(buffer, 1, 2048, fd); +        if (n == -1) { +            pclose(fd); +            return; +        } +        array.setRawData(buffer, n); +        result=QString::QString(array); +        array.resetRawData(buffer, n); + } + pclose(fd); + //get INC list so we can use it to parse "use" modules + m_INClist = QStringList::split(QString("|"),result); + kdDebug(9016) << "INC " << m_INClist.size() << " "<< result << endl; +} + +QString perlparser::findLib( const QString& lib) +{ +  QString result; + +  QString file=lib; +  file.replace( QRegExp("::"), QString("/")); + +  //find the correct path by using the INC list +  QStringList::Iterator inc = m_INClist.begin(); +  while((inc != m_INClist.end()) && (result.isEmpty()) ) { +     QFileInfo fi((*inc) + "/" + file + ".pm"); +     if ( fi.exists() ) { +        result = (*inc) + "/" + file + ".pm"; +     } +     ++inc; +  } +  return result; +} + diff --git a/languages/perl/perlparser.h b/languages/perl/perlparser.h new file mode 100644 index 00000000..01ded7d8 --- /dev/null +++ b/languages/perl/perlparser.h @@ -0,0 +1,87 @@ +/*************************************************************************** +                          perlparser.h  -  description +                             ------------------- +    begin                : Sun Nov 2 2003 +    copyright            : (C) 2003 by luc +    email                : luc@lieve + ***************************************************************************/ + +/*************************************************************************** + *                                                                         * + *   This program is free software; you can redistribute it and/or modify  * + *   it under the terms of the GNU General Public License as published by  * + *   the Free Software Foundation; either version 2 of the License, or     * + *   (at your option) any later version.                                   * + *                                                                         * + ***************************************************************************/ + +#ifndef PERLPARSER_H +#define PERLPARSER_H + +#include "kdevlanguagesupport.h" +#include <codemodel.h> + + +/**perl source to classview parser +  *@author luc +  */ + +class perlparser { +  public:  +  perlparser(KDevCore* core,CodeModel* model, QString interpreter); +  perlparser(); +  ~perlparser(); + +  void initialParse(); +  void parse(const QString &fileName); +  void parseLines(QStringList* lines,const QString& fileName); +  const QStringList UseFiles(); +  QString findLib( const QString& lib); + +  private: +  //global functions to add to ClassStore +  void addPackage(const QString& fileName ,int lineNr , const QString& name); +  void addAttributetoScript(const QString& fileName ,int lineNr ,const QString& name); +  void addAttributetoPackage(const QString& fileName ,int lineNr ,const QString& name); +  void addClass(const QString& fileName ,int lineNr ); +  void addConstructor(const QString& fileName ,int lineNr ,const QString& methodname); +  void addGlobalSub(const QString& fileName ,int lineNr , const QString& name, bool privatesub); +  void addScriptSub(const QString& fileName ,int lineNr , const QString& name, bool privatesub); +  void addClassMethod(const QString& fileName ,int lineNr , const QString& name , bool privatesub); +  void addPackageSub(const QString& fileName ,int lineNr , const QString& name, bool privatesub); +  void addParentClass(const QString& parent); +  void addScript(const QString& fileName ,int lineNr , const QString& name); +  void addUseLib(const QString& lib); +  void getPerlINC(); + +  bool    m_inpackage; +  bool    m_inscript; +  bool    m_inclass; + +  QString m_lastsub; +  QString m_lastparentclass; +  QString m_lastattr; +  QString m_lastpackagename; +  QString m_lastscriptname; + +  NamespaceDom m_lastscript; +  NamespaceDom m_lastpackage; +  ClassDom m_lastclass; + +  //CodeModel +  CodeModel* m_model; +  KDevCore* m_core; +  FileDom m_file; + +  //this willhav a list of INC paths +  QStringList m_INClist; +  //this will get a list off all files "use" in the perl files +  //and need additional parsing to include the classes in the classview +  QStringList m_usefiles; + +  QString m_interpreter; +   +   +}; + +#endif diff --git a/languages/perl/perlsupportpart.cpp b/languages/perl/perlsupportpart.cpp new file mode 100644 index 00000000..4305644e --- /dev/null +++ b/languages/perl/perlsupportpart.cpp @@ -0,0 +1,330 @@ +/*************************************************************************** + *   Copyright (C) 2001-2002 by Bernd Gehrmann                             * + *   bernd@kdevelop.org                                                    * + *                                                                         * + *   This program is free software; you can redistribute it and/or modify  * + *   it under the terms of the GNU General Public License as published by  * + *   the Free Software Foundation; either version 2 of the License, or     * + *   (at your option) any later version.                                   * + *                                                                         * + ***************************************************************************/ + +#include "perlsupportpart.h" + +#include <qfileinfo.h> +#include <qpopupmenu.h> +#include <qstringlist.h> +#include <qtextstream.h> +#include <qtimer.h> +#include <kaction.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kdevgenericfactory.h> +#include <kinputdialog.h> +#include <klocale.h> +#include <qregexp.h> +#include <codemodel.h> +#include <qprogressbar.h> +#include <kstatusbar.h> +#include "kdevmainwindow.h" + +#include <kprocess.h> +#include <stdlib.h> +#include <unistd.h> + +#include "kdevcore.h" +#include "kdevproject.h" +#include "kdevpartcontroller.h" +#include "kdevplugininfo.h" +#include "kdevappfrontend.h" +//#include "classstore.h" +//#include "parsedclass.h" +//#include "parsedmethod.h" +//#include "parsedscript.h" +#include "domutil.h" +//#include "programmingbycontract.h" + +typedef KDevGenericFactory<PerlSupportPart> PerlSupportFactory; +static const KDevPluginInfo data("kdevperlsupport"); +K_EXPORT_COMPONENT_FACTORY( libkdevperlsupport, PerlSupportFactory( data ) ) + +PerlSupportPart::PerlSupportPart(QObject *parent, const char *name, const QStringList &) +    : KDevLanguageSupport(&data, parent, name ? name : "PerlSupportPart") +{ +    setInstance(PerlSupportFactory::instance()); + +    setXMLFile("kdevperlsupport.rc"); + +    connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) ); +    connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) ); +    connect( partController(), SIGNAL(savedFile(const KURL&)), +             this, SLOT(savedFile(const KURL&)) ); + +    KAction *action; + +    action = new KAction( i18n("Execute Main Program"), "exec", 0, +                          this, SLOT(slotExecute()), +                          actionCollection(), "build_exec" ); +    action->setToolTip( i18n("Runs the Perl program") ); + +    action = new KAction( i18n("Execute String..."), "exec", 0, +                          this, SLOT(slotExecuteString()), +                          actionCollection(), "build_execstring" ); +    action->setToolTip( i18n("Executes a string as Perl code") ); + +    action = new KAction( i18n("Start Perl Interpreter"), "exec", 0, +                          this, SLOT(slotStartInterpreter()), +                          actionCollection(), "build_runinterpreter" ); +    action->setToolTip( i18n("Starts the Perl interpreter without a program") ); + +    action = new KAction( i18n("Find Perl Function Documentation..."), 0, +                          this, SLOT(slotPerldocFunction()), +                          actionCollection(), "help_perldocfunction" ); +    action->setToolTip( i18n("Show the documentation page of a Perl function") ); + +    action = new KAction( i18n("Find Perl FAQ Entry..."), 0, +                          this, SLOT(slotPerldocFAQ()), +                          actionCollection(), "help_perldocfaq" ); +    action->setToolTip( i18n("Show the FAQ entry for a keyword") ); + +    //perl parser for codemodel +    m_parser = new  perlparser(core(),codeModel(),interpreter()); +} + + +PerlSupportPart::~PerlSupportPart() +{ +  if (project()) +      projectClosed(); + +  delete m_parser; +  m_parser=0; +} + + +void PerlSupportPart::projectOpened() +{ +    kdDebug(9007) << "projectOpened()" << endl; + +    connect( project(), SIGNAL(addedFilesToProject(const QStringList &)), +             this, SLOT(addedFilesToProject(const QStringList &)) ); +    connect( project(), SIGNAL(removedFilesFromProject(const QStringList &)), +             this, SLOT(removedFilesFromProject(const QStringList &)) ); + +    // We want to parse only after all components have been +    // properly initialized +    QTimer::singleShot(0, this, SLOT(initialParse())); +} + + +void PerlSupportPart::projectClosed() +{ +} + +void PerlSupportPart::maybeParse(const QString fileName) +{ +    QFileInfo fi(fileName); +    QString path = fi.filePath(); +    QString extension = fi.extension(); +    if (extension == "pl" || extension == "pm") { +        kdDebug(9016) << "maybe " << fileName << endl; +        removeWithReference(fileName); +        m_parser->parse(fileName); +	emit addedSourceInfo( fileName); +    } +} + +void PerlSupportPart::addedFilesToProject(const QStringList &fileList) +{ +	kdDebug(9016) << "addedFilesToProject()" << endl; + +	QStringList::ConstIterator it; + +	for ( it = fileList.begin(); it != fileList.end(); ++it ) +	{ +		maybeParse(project()->projectDirectory() + "/" + ( *it )); +	} +} + + +void PerlSupportPart::removedFilesFromProject(const QStringList &fileList) +{ +    kdDebug(9016) << "removedFilesFromProject()" << endl; +    QStringList::ConstIterator it; +    for ( it = fileList.begin(); it != fileList.end(); ++it ) +    { +     QString fileName = project()->projectDirectory() + "/" + ( *it ); +     removeWithReference(fileName); +   } +  emit updatedSourceInfo(); +} + + +void PerlSupportPart::savedFile(const KURL &fileName) +{ +    Q_UNUSED( fileName.path() ); +#if 0  // not needed anymore +    kdDebug(9016) << "savedFile()" << endl; + +    if (project()->allFiles().contains(fileName.mid ( project()->projectDirectory().length() + 1 ))) { +        maybeParse(fileName); +        emit updatedSourceInfo(); +    } +#endif +} + + +KDevLanguageSupport::Features PerlSupportPart::features() +{ +    return KDevLanguageSupport::Features(Classes | Functions | Variables | Namespaces | /*Scripts | */NewClass | AddMethod | AddAttribute /*| NewScript*/); +//    return Functions; +} + +QString PerlSupportPart::interpreter() +{ +    QString prog = DomUtil::readEntry(*projectDom(), "/kdevperlsupport/run/interpreter"); +    if (prog.isEmpty()) +        prog = "perl"; + +    return prog; +} + + +void PerlSupportPart::startApplication(const QString &program) +{ +    bool inTerminal = DomUtil::readBoolEntry(*projectDom(), "/kdevperlsupport/run/terminal"); +    if (KDevAppFrontend *appFrontend = extension<KDevAppFrontend>("KDevelop/AppFrontend")) +        appFrontend->startAppCommand(QString::QString(), program, inTerminal); +} + + +void PerlSupportPart::slotExecute() +{ +    QString program =  project()->mainProgram(); +    QString cmd = interpreter() + " " + program; +    startApplication(cmd); +} + + +void PerlSupportPart::slotStartInterpreter() +{ +    startApplication(interpreter()); +} + + +void PerlSupportPart::slotExecuteString() +{ +    bool ok; +    QString cmd = KInputDialog::getText(i18n("String to Execute"), i18n("String to execute:"), QString::null, &ok, 0); +    if (ok) { +        cmd.prepend("'"); +        cmd.append("'"); +        startApplication(cmd); +    } +} + + +void PerlSupportPart::slotPerldocFunction() +{ +    bool ok; +    QString key = KInputDialog::getText(i18n("Show Perl Documentation"), i18n("Show Perl documentation for function:"), "", &ok, 0); +    if (ok && !key.isEmpty()) { +        QString url = "perldoc:functions/"; +        url += key; +        partController()->showDocument(KURL(url)); +    } +} + + +void PerlSupportPart::slotPerldocFAQ() +{ +    bool ok; +    QString key = KInputDialog::getText(i18n("Show FAQ Entry"), i18n("Show FAQ entry for keyword:"), "", &ok, 0); +    if (ok && !key.isEmpty()) { +        QString url = "perldoc:faq/"; +        url += key; +        partController()->showDocument(KURL(url)); +    } +} +KMimeType::List PerlSupportPart::mimeTypes( ) +{ +    KMimeType::List list; +    KMimeType::Ptr mime = KMimeType::mimeType( "application/x-perl" ); +    if( mime ) +	list << mime; +    return list; +} + +void PerlSupportPart::initialParse() +{ +    kdDebug(9016) << "initialParse()" << endl; + +    if (project()) { +        //copy from cpp support : give user some feedback +        mainWindow()->statusBar()->message( i18n("Updating...") ); +        kapp->processEvents( ); + +        kapp->setOverrideCursor(waitCursor); +        QStringList files = project()->allFiles(); +        m_parser->initialParse(); + +        //progress bar +        QProgressBar* bar = new QProgressBar( files.count( ), mainWindow( )->statusBar( ) ); +        bar->setMinimumWidth( 120 ); +        bar->setCenterIndicator( true ); +        mainWindow( )->statusBar( )->addWidget( bar ); +        bar->show( ); +        int n = 0; +        for (QStringList::Iterator it = files.begin(); it != files.end() ;++it) { +//            kdDebug(9016) << "maybe parse " << project()->projectDirectory() + "/" + (*it) << endl; +            maybeParse(project()->projectDirectory() + "/" + *it); +            //update progress bar +            bar->setProgress( n++ ); +            if( (n%5) == 0 ) +              kapp->processEvents(); +        } +        parseUseFiles(); +        emit updatedSourceInfo(); + +        //remove progressbar +        mainWindow( )->statusBar( )->removeWidget( bar ); +        delete bar; +        kapp->restoreOverrideCursor(); +        mainWindow()->statusBar()->message( i18n("Done") ); + +    } else { +        kdDebug(9016) << "No project" << endl; +    } +} + +void PerlSupportPart::removeWithReference( const QString & fileName ) +{ +    kdDebug(9016) << "remove with references: " << fileName << endl; +    //m_timestamp.remove( fileName ); +    if( !codeModel()->hasFile(fileName) ) +        return; + +    emit aboutToRemoveSourceInfo( fileName ); +    codeModel()->removeFile( codeModel()->fileByName(fileName) ); +} + +void PerlSupportPart::parseUseFiles() +{ + kdDebug(9016) << "parse addional libs" << endl; + return; + QString filename; + QStringList m_usefiles = m_parser->UseFiles(); + + //parse addional use files + for (QStringList::Iterator it = m_usefiles.begin(); it != m_usefiles.end() ;++it) + { +        filename = m_parser->findLib(*it); +       //if something found , parse it +       if (!filename.isEmpty()) { +            //kdDebug(9016) << "found " << filename << endl; +            maybeParse(filename); +       } + } +} + +#include "perlsupportpart.moc" diff --git a/languages/perl/perlsupportpart.h b/languages/perl/perlsupportpart.h new file mode 100644 index 00000000..91765a47 --- /dev/null +++ b/languages/perl/perlsupportpart.h @@ -0,0 +1,59 @@ +/*************************************************************************** + *   Copyright (C) 2001-2002 by Bernd Gehrmann                             * + *   bernd@kdevelop.org                                                    * + *                                                                         * + *   This program is free software; you can redistribute it and/or modify  * + *   it under the terms of the GNU General Public License as published by  * + *   the Free Software Foundation; either version 2 of the License, or     * + *   (at your option) any later version.                                   * + *                                                                         * + ***************************************************************************/ + +#ifndef _PERLSUPPORTPART_H_ +#define _PERLSUPPORTPART_H_ + +#include "kdevlanguagesupport.h" +#include <codemodel.h> +#include "perlparser.h" + +class PerlSupportPart : public KDevLanguageSupport +{ +    Q_OBJECT + +public: +    PerlSupportPart( QObject *parent, const char *name, const QStringList & ); +    ~PerlSupportPart(); + +protected: +    virtual Features features(); +    virtual KMimeType::List mimeTypes(); + +private slots: +    void projectOpened(); +    void projectClosed(); +    void savedFile(const KURL &fileName); +    void addedFilesToProject(const QStringList &fileList); +    void removedFilesFromProject(const QStringList &fileList); +    void slotExecute(); +    void slotExecuteString(); +    void slotStartInterpreter(); + +    // Internal +    void initialParse(); +    void slotPerldocFunction(); +    void slotPerldocFAQ(); + +private: +    QString interpreter(); +    void startApplication(const QString &program); +    void maybeParse(const QString fileName); +    void parse(const QString &fileName); +    void parseLines(QStringList* lines,const QString& fileName); +    void removeWithReference( const QString & fileName ); +    void parseUseFiles(); +    //Perl Parser +    perlparser* m_parser; + +}; + +#endif  | 
