codetools: added example

git-svn-id: trunk@20142 -
This commit is contained in:
mattias 2009-05-23 10:40:19 +00:00
parent fef4a6e9b8
commit 5ae268758c
4 changed files with 126 additions and 0 deletions

3
.gitattributes vendored
View File

@ -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

View File

@ -0,0 +1,65 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="7"/>
<General>
<Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
<Title Value="autoindent"/>
</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>

View File

@ -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.

View File

@ -0,0 +1,13 @@
unit indentation;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
implementation
end.