mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 09:19:32 +02:00
codetools: improved error message when searching a position outside of code
git-svn-id: trunk@32778 -
This commit is contained in:
parent
dc13c42eae
commit
a2db5dd194
@ -1646,9 +1646,46 @@ function TCCodeParserTool.FindDeepestNodeAtPos(StartNode: TCodeTreeNode;
|
||||
P: integer; ExceptionOnNotFound: boolean): TCodeTreeNode;
|
||||
|
||||
procedure RaiseNoNodeFoundAtCursor;
|
||||
var
|
||||
Msg: String;
|
||||
Node: TCodeTreeNode;
|
||||
LastPos: Integer;
|
||||
begin
|
||||
//DebugLn('RaiseNoNodeFoundAtCursor ',MainFilename);
|
||||
RaiseException(ctsNoNodeFoundAtCursor);
|
||||
MoveCursorToPos(P);
|
||||
// check if p is in parsed code
|
||||
if (Tree=nil) or (Tree.Root=nil) then begin
|
||||
RaiseException('no pascal code or not yet parsed');
|
||||
end;
|
||||
if p<Tree.Root.StartPos then begin
|
||||
Msg:='In front of code.';
|
||||
if Tree.Root.StartPos<=SrcLen then begin
|
||||
MoveCursorToPos(Tree.Root.StartPos);
|
||||
ReadNextAtom;
|
||||
Msg:=Msg+' The pascal code starts with "'+GetAtom+'" at '
|
||||
+CleanPosToStr(Tree.Root.StartPos)+'. No code';
|
||||
end;
|
||||
MoveCursorToPos(P);
|
||||
RaiseException(Msg);
|
||||
end;
|
||||
Node:=Tree.Root;
|
||||
while Node.NextBrother<>nil do Node:=Node.NextBrother;
|
||||
if (Node.EndPos>0) and (p>Node.EndPos) then
|
||||
LastPos:=Node.EndPos
|
||||
else
|
||||
LastPos:=Node.StartPos;
|
||||
if p>LastPos then begin
|
||||
Msg:='Behind code. The last valid pascal code is at '+CleanPosToStr(LastPos)+'. No code';
|
||||
RaiseException(Msg);
|
||||
end;
|
||||
|
||||
// p is in parsed code, the StartNode is wrong
|
||||
CTDumpStack;
|
||||
if (StartNode<>nil) then
|
||||
RaiseException('Invalid search. The search for pascal started at '
|
||||
+CleanPosToStr(StartNode.StartPos)+'. Invalid search')
|
||||
else
|
||||
RaiseException('Inconsistency error in TCustomCodeTool.FindDeepestNodeAtPos');
|
||||
end;
|
||||
|
||||
var
|
||||
|
@ -68,7 +68,6 @@ ResourceString
|
||||
ctsBracketOpenExpectedButAtomFound = 'bracket open expected, but %s found';
|
||||
ctsBracketCloseExpectedButAtomFound = 'bracket close expected, but %s found';
|
||||
ctsBracketNotFound = 'bracket %s not found';
|
||||
ctsNoNodeFoundAtCursor = 'no pascal node found at cursor (i.e. in unparsed code)';
|
||||
ctsUnknownMainFilename = '(unknown mainfilename)';
|
||||
|
||||
// pascal parser
|
||||
|
@ -2456,9 +2456,46 @@ function TCustomCodeTool.FindDeepestNodeAtPos(StartNode: TCodeTreeNode;
|
||||
P: integer; ExceptionOnNotFound: boolean): TCodeTreeNode;
|
||||
|
||||
procedure RaiseNoNodeFoundAtCursor;
|
||||
var
|
||||
Msg: String;
|
||||
Node: TCodeTreeNode;
|
||||
LastPos: Integer;
|
||||
begin
|
||||
//DebugLn('RaiseNoNodeFoundAtCursor ',MainFilename);
|
||||
RaiseException(ctsNoNodeFoundAtCursor,true);
|
||||
MoveCursorToCleanPos(P);
|
||||
// check if p is in parsed code
|
||||
if (Tree=nil) or (Tree.Root=nil) then begin
|
||||
RaiseException('no pascal code or not yet parsed');
|
||||
end;
|
||||
if p<Tree.Root.StartPos then begin
|
||||
Msg:='In front of code.';
|
||||
if Tree.Root.StartPos<=SrcLen then begin
|
||||
MoveCursorToCleanPos(Tree.Root.StartPos);
|
||||
ReadNextAtom;
|
||||
Msg:=Msg+' The pascal code starts with "'+GetAtom+'" at '
|
||||
+CleanPosToStr(Tree.Root.StartPos)+'. No code';
|
||||
end;
|
||||
MoveCursorToCleanPos(P);
|
||||
RaiseException(Msg);
|
||||
end;
|
||||
Node:=Tree.Root;
|
||||
while Node.NextBrother<>nil do Node:=Node.NextBrother;
|
||||
if (Node.EndPos>0) and (p>Node.EndPos) then
|
||||
LastPos:=Node.EndPos
|
||||
else
|
||||
LastPos:=Node.StartPos;
|
||||
if p>LastPos then begin
|
||||
Msg:='Behind code. The last valid pascal code is at '+CleanPosToStr(LastPos)+'. No code';
|
||||
RaiseException(Msg);
|
||||
end;
|
||||
|
||||
// p is in parsed code, the StartNode is wrong
|
||||
CTDumpStack;
|
||||
if (StartNode<>nil) then
|
||||
RaiseException('Invalid search. The search for pascal started at '
|
||||
+CleanPosToStr(StartNode.StartPos)+'. Invalid search')
|
||||
else
|
||||
RaiseException('Inconsistency error in TCustomCodeTool.FindDeepestNodeAtPos');
|
||||
end;
|
||||
|
||||
var
|
||||
@ -2512,7 +2549,6 @@ begin
|
||||
end;
|
||||
|
||||
if (Result=nil) and ExceptionOnNotFound then begin
|
||||
MoveCursorToCleanPos(P);
|
||||
RaiseNoNodeFoundAtCursor;
|
||||
end;
|
||||
end;
|
||||
|
@ -649,10 +649,6 @@ msgstr "s'ha trobat un node sense context al cursor"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "l'especificador no predeterminat s'ha definit dues vegades"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "s'ha trobat un node no Pascal al cursor. (p.ex. en codi no analitzat)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "no s'ha trobat el codi Pascal (el primer testimoni és %s)"
|
||||
|
@ -650,10 +650,6 @@ msgstr "nenalezen kontext na pozici ukazatele"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "specifikátor nodefault definován dvakrát"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "na pozici ukazatele nenalezen pascalovský kód (např. nezanalyzovaný kód)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "nenalezen pascalovský kód (první symbol je %s)"
|
||||
|
@ -652,10 +652,6 @@ msgstr "kein Kontext-Knoten an der Cursorposition gefunden"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "Nicht-Default-Bezeichner doppelt definiert"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "kein Pascal-Knoten an der Cursorposition gefunden (z.B. in ungeparstem Code) "
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "kein Pascal-Quelltext gefunden (erster Token ist %s)"
|
||||
|
@ -649,10 +649,6 @@ msgstr "contexto de nodo no encontrado desde cursor"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "especificador no por defecto definido dos veces"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "no se encontró nodo pascal desde cursor (es decir en código sin procesar)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "no se encontró código pascal (primer símbolo es %s)"
|
||||
|
@ -642,10 +642,6 @@ msgstr ""
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr ""
|
||||
|
@ -650,10 +650,6 @@ msgstr "noeud trouvé sous le curseur hors contexte"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "défaut déclaré deux fois"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "pas de noeud Pascal trouvé au curseur (c.-à-d. non analysées dans le code)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "Pas de code Pascal trouvé (le premier mot est %s)"
|
||||
|
@ -649,10 +649,6 @@ msgstr "לא נמצאה צומת הקשר במיקום הסמן"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "מציין שאינו ברירת המחדל הוגדר פעמיים"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "לא נמצאה צומת של פסקל במקום הסמן ("
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "לא נמצא קוד של פסקל (הסימן הראשון הוא s%)"
|
||||
|
@ -650,10 +650,6 @@ msgstr "tidak ada node konteks ditemukan pada kursor"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "pemisah non default didefinisikan dua kali"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "tidak ada kode pascal ditemukan pada kursor (contoh. dalam kode yang tidak dipindai)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "Tidak ada kode pascal ditemukan (token pertama adalah %s)"
|
||||
|
@ -647,10 +647,6 @@ msgstr "nessun nodo di contesto trovato al cursore"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "specificatore di default definito due volte"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "nessun nodo pascal trovato al cursore (cioè in codice non analizzato)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "non è stato trovato nessun codice pascal (il primo token è %s)"
|
||||
|
@ -651,10 +651,6 @@ msgstr "ties žymekliu nerastas kontekstinis mazgas"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "nenumatytas specifikatorius apibrėžtas dukart"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "ties žymekliu (t.y. neišanalizuotame kode) nerastas paskalio mazgas"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "paskalio kodas nerastas (pirmoji leksema - %s)"
|
||||
|
@ -649,10 +649,6 @@ msgstr ""
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "geen pascal code gevonden (eerste token is %s)"
|
||||
|
@ -653,10 +653,6 @@ msgstr "nie ma żadnego kontekstowego elementu przy kursorze"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "specyfikator nodefault zdefiniowany dwukrotnie"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "nie znaleziono elementu pacala przy kursorze (np. w niezanalizowanym kodzie)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "nie znaleziono źródła w pascalu (pierwszy token: %s)"
|
||||
|
@ -642,10 +642,6 @@ msgstr ""
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr ""
|
||||
|
@ -649,10 +649,6 @@ msgstr "nenhum nó de contexto encontrada sob o cursor"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "especificador \"nodefault\" duplicado"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "nenhum nó pascal encontrado sob o cursor (ex. em código não analisado)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "nenhum código pascal encontrado (primeira sílaba é %s)"
|
||||
|
@ -648,10 +648,6 @@ msgstr "nenhum nó de contexto encontrada sob o cursor"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "especificador \"nodefault\" duplicado"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "nenhum nó pascal encontrado sob o cursor (ex. em código não analisado)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "nenhum código pascal encontrado (primeira sílaba é %s)"
|
||||
|
@ -648,10 +648,6 @@ msgstr "не найдено контекстного узла у курсора"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "модификатор nodefault определён дважды"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "не найдено конструкций Паскаля у курсора (т.е. необрабатываемый код)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "не найдено кода Паскаля (первый элемент - %s)"
|
||||
|
@ -648,10 +648,6 @@ msgstr ""
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr ""
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr ""
|
||||
|
@ -647,10 +647,6 @@ msgstr "не знайдений контекстний елемент біля
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "модифікатор nodefault двічи визначений"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "не знайдені записи паскаля біля курсору (тобто в досліджуваному коді)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "не знайдений код паскаля (перший елемент - %s)"
|
||||
|
@ -652,10 +652,6 @@ msgstr "光标处未找到关联节点"
|
||||
msgid "nodefault specifier defined twice"
|
||||
msgstr "nodefault specifier defined twice"
|
||||
|
||||
#: codetoolsstrconsts.ctsnonodefoundatcursor
|
||||
msgid "no pascal node found at cursor (i.e. in unparsed code)"
|
||||
msgstr "在光标处未找到pascal节点(也就是在未解析的代码中)"
|
||||
|
||||
#: codetoolsstrconsts.ctsnopascalcodefound
|
||||
msgid "no pascal code found (first token is %s)"
|
||||
msgstr "未找到pascal代码 (第一个象征是 %s)"
|
||||
|
Loading…
Reference in New Issue
Block a user