Hi Abhishek,
your code is OK and I committed it to CVS.
I just didn't see this solution last night.
Thanks for not trusting me ;-) and for your code.
Gerd
Gupta, Abhishek schrieb:
> This is the code which I had changed to get this working.
>
> -----Original Message-----
> From: Gerd Wagner [mailto:bir...@t-...]
> Sent: Tuesday, January 10, 2006 4:53 PM
> To: Gupta, Abhishek
> Cc: squ...@li...
> Subject: Re: [Squirrel-sql-users] Code Completion Plugin
>
> Hi Abhishek,
>
> thanks for this one. It made me play around with code completion for
> some time.
>
> Unfortunately I don't think I'll find a good solution at the moment.
> Here are some details:
>
> Of course the problem is that you use the same alias for two different
> tables. The decision that has to be made is whether you are in the first
> or the second statement when you use completion on 'a.'
> I could not think of a good way to decide this for now.
>
> If you have got any suggestions let me know. For every day work I'd
> suggest not to use duplicate aliases.
>
> Gerd
>
> Gupta, Abhishek wrote:
>
>>I am facing a problem with the code completion plugin which happens when
>>I have multiple queries in the sql panel.
>>
>>
>>
>>For example:
>>
>>
>>
>>1^st query: select * from table1 a inner join table2 b on table1.id =
>>table2.table1id where a.x = 2 // Auto complete works correctly here I
>>get table1 columns in "a." where clause.
>>
>>
>>
>>2^nd query: select * from table3 a where a.y = 5 // Autocomplete shows
>>the columns for table1 instead of table3.
>>
>>
>>
>>Has any body else seen this problem?
>>
>>
>>
>>Thanks
>>
>>Abhishek
>>
>
>
>
> ------------------------------------------------------------------------
>
> 75a76
>
>> int stringToParsePosition = getStringToParsePosition ( textTillCarret );
>
> 138c139
> < ret.addAll(Arrays.asList(getColumnsForName(catalog, schema, tableNamePat2, colNamePat2)));
> ---
>
>> ret.addAll(Arrays.asList(getColumnsForName(catalog, schema, tableNamePat2, colNamePat2, stringToParsePosition )));
>
> 148c149
> < ret.addAll(Arrays.asList(getColumnsForName(null, null, tableNamePat1, colNamePat1)));
> ---
>
>> ret.addAll(Arrays.asList(getColumnsForName(null, null, tableNamePat1, colNamePat1, stringToParsePosition )));
>
> 206a208,234
>
>> private int getStringToParsePosition(String textTillCaret)
>> {
>>
>> int lastIndexOfLineFeed = textTillCaret.lastIndexOf('\n');
>> String lineTillCaret;
>>
>> if(-1 == lastIndexOfLineFeed)
>> {
>> lineTillCaret = textTillCaret;
>> }
>> else
>> {
>> lineTillCaret = textTillCaret.substring(lastIndexOfLineFeed);
>> }
>>
>> int pos = lastIndexOfLineFeed + 1;
>> if (0 != lineTillCaret.length() && !Character.isWhitespace(lineTillCaret.charAt(lineTillCaret.length() - 1)))
>> {
>> int lastSeparatorIndex = getLastSeparatorIndex(lineTillCaret);
>> if (-1 != lastSeparatorIndex)
>> {
>> pos += lastSeparatorIndex;
>> }
>> }
>>
>> return pos;
>> }
>
> 211c239
> < private CodeCompletionInfo[] getColumnsForName(String catalog, String schema, String name, String colNamePat)
> ---
>
>> private CodeCompletionInfo[] getColumnsForName ( String catalog, String schema, String name, String colNamePat, int colPos )
>
> 214a243,265
>
>> CodeCompletionInfo toReturn = null;
>> if ( colPos != -1 )
>> {
>> // First check aliases
>> for ( int j = 0; j < infos.length ; j++ )
>> {
>> CodeCompletionInfo info = infos[ j ];
>> if ( info instanceof CodeCompletionTableAliasInfo )
>> {
>> if ( info.upperCaseCompletionStringEquals ( upperCaseTableNamePat ) )
>> {
>> // See if this is the same statement
>> CodeCompletionTableAliasInfo a = ( CodeCompletionTableAliasInfo ) info;
>> if ( colPos >= a.getStatBegin () )
>> {
>> toReturn = a;
>> }
>> }
>> }
>> }
>> }
>> if ( toReturn == null )
>> {
>
> 218a270,276
>
>> toReturn = infos[ i ];
>> break;
>> }
>> }
>> }
>> if (toReturn != null)
>> {
>
> 221c279
> < return infos[i].getColumns(_session.getSchemaInfo(), colNamePat);
> ---
>
>> return toReturn.getColumns(_session.getSchemaInfo(), colNamePat);
>
> 228d285
> < }
> 238c295
> < return getColumnsForName(null, null, _lastSelectedCompletionName, colNamePat);
> ---
>
>> return getColumnsForName(null, null, _lastSelectedCompletionName, colNamePat, -1 );
>>
>>
>>------------------------------------------------------------------------
>>
>>41a42,45
>>
>>> public int getStatBegin()
>>> {
>>> return _aliasInfo.statBegin;
>>> }
|