From 5ae268758cf99eeee95a86c22361d058e57ee9f5 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 23 May 2009 10:40:19 +0000 Subject: [PATCH] codetools: added example git-svn-id: trunk@20142 - --- .gitattributes | 3 + components/codetools/examples/autoindent.lpi | 65 +++++++++++++++++++ components/codetools/examples/autoindent.pas | 45 +++++++++++++ .../examples/scanexamples/indentation.pas | 13 ++++ 4 files changed, 126 insertions(+) create mode 100644 components/codetools/examples/autoindent.lpi create mode 100644 components/codetools/examples/autoindent.pas create mode 100644 components/codetools/examples/scanexamples/indentation.pas diff --git a/.gitattributes b/.gitattributes index b5290ec4de..19f7e1aa26 100644 --- a/.gitattributes +++ b/.gitattributes @@ -100,6 +100,8 @@ components/codetools/examples/addeventmethod.lpi svneol=native#text/plain components/codetools/examples/addeventmethod.lpr svneol=native#text/plain components/codetools/examples/addmethod.lpi svneol=native#text/plain components/codetools/examples/addmethod.lpr svneol=native#text/plain +components/codetools/examples/autoindent.lpi svneol=native#text/plain +components/codetools/examples/autoindent.pas svneol=native#text/plain components/codetools/examples/codecompletion.lpi svneol=native#text/plain components/codetools/examples/codecompletion.lpr svneol=native#text/plain components/codetools/examples/completeabstractmethods.lpi svneol=native#text/plain @@ -142,6 +144,7 @@ components/codetools/examples/scanexamples/empty.inc svneol=native#text/plain components/codetools/examples/scanexamples/emptymethods1.pas svneol=native#text/plain components/codetools/examples/scanexamples/getcontextexample.pas svneol=native#text/plain components/codetools/examples/scanexamples/identcomplexample.pas svneol=native#text/plain +components/codetools/examples/scanexamples/indentation.pas svneol=native#text/plain components/codetools/examples/scanexamples/missingh2pasdirectives.pas svneol=native#text/plain components/codetools/examples/scanexamples/modemacpas.pas svneol=native#text/plain components/codetools/examples/scanexamples/overloadedfunction.pas svneol=native#text/plain diff --git a/components/codetools/examples/autoindent.lpi b/components/codetools/examples/autoindent.lpi new file mode 100644 index 0000000000..cb496b01c1 --- /dev/null +++ b/components/codetools/examples/autoindent.lpi @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + </General> + <PublishOptions> + <Version Value="2"/> + <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> + <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> + </local> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="CodeTools"/> + </Item1> + </RequiredPackages> + <Units Count="5"> + <Unit0> + <Filename Value="autoindent.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="AutoIndent"/> + </Unit0> + <Unit1> + <Filename Value="scanexamples/brokenfilenames.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="BrokenFilenames"/> + </Unit1> + <Unit2> + <Filename Value="scanexamples/brokenincfiles.inc"/> + <IsPartOfProject Value="True"/> + </Unit2> + <Unit3> + <Filename Value="scanexamples/empty.inc"/> + <IsPartOfProject Value="True"/> + </Unit3> + <Unit4> + <Filename Value="scanexamples/indentation.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="indentation"/> + </Unit4> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="8"/> + <Other> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/components/codetools/examples/autoindent.pas b/components/codetools/examples/autoindent.pas new file mode 100644 index 0000000000..a8a18d515d --- /dev/null +++ b/components/codetools/examples/autoindent.pas @@ -0,0 +1,45 @@ +{ + *************************************************************************** + * * + * This source 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. * + * * + * This code is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * General Public License for more details. * + * * + * A copy of the GNU General Public License is available on the World * + * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also * + * obtain it by writing to the Free Software Foundation, * + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * * + *************************************************************************** + + Author: Mattias Gaertner + + Abstract: + Demo for automatic indentation. +} +program AutoIndent; + +{$mode objfpc}{$H+} + +uses + Classes, SysUtils, DefineTemplates, CodeToolsConfig, FileProcs, + CodeToolsStructs, CodeToolManager, CodeCache; + +var + Code: TCodeBuffer; + Filename: String; +begin + // load the example unit + Filename:=ExpandFileNameUTF8('scanexamples/indentation.pas'); + Code:=CodeToolBoss.LoadFile(Filename,false,false); + if Code=nil then + raise Exception.Create('unable to read '+Filename); + +end. + diff --git a/components/codetools/examples/scanexamples/indentation.pas b/components/codetools/examples/scanexamples/indentation.pas new file mode 100644 index 0000000000..77c214f010 --- /dev/null +++ b/components/codetools/examples/scanexamples/indentation.pas @@ -0,0 +1,13 @@ +unit indentation; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils; + +implementation + +end. +