Skip to content

Conversation

@vasily-kirichenko
Copy link
Contributor

@vasily-kirichenko vasily-kirichenko commented Dec 23, 2016

It fixes #2041

1

At attribute application position:

  • suggest namespaces, modules and types only
  • remove "Attribute" suffix from attribute types

@KevinRansom
Copy link
Contributor

Now this is nice.

| [] -> failwith "Unexpected empty bag"
| items ->
let glyphMajor, glyphMinor = GlyphOfItem(denv,items.Head)
let nm = if atAttributeApplication && IsAttribute infoReader items.Head then nm.[0..nm.Length-10] else nm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you add a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@vladima
Copy link
Contributor

vladima commented Dec 24, 2016

Looks great!

@saul
Copy link
Contributor

saul commented Dec 24, 2016

Thanks for doing this so quickly - fantastic 👍

@vasily-kirichenko
Copy link
Contributor Author

@dotnet-bot test this please

@cartermp
Copy link
Contributor

Great stuff.

@dsyme
Copy link
Contributor

dsyme commented Dec 27, 2016

Yes, this is great

@KevinRansom
Copy link
Contributor

@vasily-kirichenko

some autocomplete test failures may be related:

1) Failed : Tests.LanguageService.AutoCompletion.UsingMSBuild.Attribute.WhenAttachedToNothingInNamespace.Bug70080
Couldn't find 'AttributeUsageAttribute' in completion list
at Salsa.VsOpsUtils.AssertCompListContains$cont@220(String membername, Tuple`4[] completions, Unit unitVar) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 223
at Salsa.VsOpsUtils.AssertCompListContains(Tuple`4[] completions, String membername) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 220
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 238
at <StartupCode$VisualFSharp-Unittests>.$Tests.LanguageService.Completion.AssertAutoCompleteContains@59-2.Invoke(Tuple`4[] completions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 60
at Tests.LanguageService.AutoCompletion.UsingMSBuild.DoWithAutoCompleteUsingExtraRefs(FSharpList`1 refs, Boolean coffeeBreak, SourceFileKind fileKind, BackgroundRequestReason reason, FSharpList`1 code, String marker, FSharpFunc`2 f) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 50
at Tests.LanguageService.AutoCompletion.UsingMSBuild.DoWithAutoComplete(Boolean coffeeBreak, SourceFileKind fileKind, BackgroundRequestReason reason, FSharpList`1 code, String marker, FSharpFunc`2 f) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 54
at <StartupCode$VisualFSharp-Unittests>.$Tests.LanguageService.Completion.AssertAutoCompleteContains@58-1.Invoke(FSharpList`1 code, String marker, FSharpList`1 should, FSharpList`1 shouldnot) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 58
at Tests.LanguageService.AutoCompletion.UsingMSBuild.AutoCompleteBug70080HelperHelper(String programText, FSharpList`1 shouldContain, FSharpList`1 shouldNotContain) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 167

2) Failed : Tests.LanguageService.AutoCompletion.UsingMSBuild.LongIdent.AsAttribute
Couldn't find 'ObsoleteAttribute' in completion list
at Salsa.VsOpsUtils.AssertCompListContains$cont@220(String membername, Tuple`4[] completions, Unit unitVar) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 223
at Salsa.VsOpsUtils.AssertCompListContains(Tuple`4[] completions, String membername) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 220
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 238
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 239

3) Failed : Tests.LanguageService.AutoCompletion.UsingMSBuild.LongIdent.PInvoke.AsAttribute
Couldn't find 'SomeAttrib' in completion list
at Salsa.VsOpsUtils.AssertCompListContains$cont@220(String membername, Tuple`4[] completions, Unit unitVar) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 223
at Salsa.VsOpsUtils.AssertCompListContains(Tuple`4[] completions, String membername) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 220
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 238

4) Failed : Tests.LanguageService.AutoCompletion.UsingProjectSystem.Attribute.WhenAttachedToNothingInNamespace.Bug70080
Couldn't find 'AttributeUsageAttribute' in completion list
at Salsa.VsOpsUtils.AssertCompListContains$cont@220(String membername, Tuple`4[] completions, Unit unitVar) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 223
at Salsa.VsOpsUtils.AssertCompListContains(Tuple`4[] completions, String membername) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 220
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 238
at <StartupCode$VisualFSharp-Unittests>.$Tests.LanguageService.Completion.AssertAutoCompleteContains@59-2.Invoke(Tuple`4[] completions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 60
at Tests.LanguageService.AutoCompletion.UsingMSBuild.DoWithAutoCompleteUsingExtraRefs(FSharpList`1 refs, Boolean coffeeBreak, SourceFileKind fileKind, BackgroundRequestReason reason, FSharpList`1 code, String marker, FSharpFunc`2 f) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 50
at Tests.LanguageService.AutoCompletion.UsingMSBuild.DoWithAutoComplete(Boolean coffeeBreak, SourceFileKind fileKind, BackgroundRequestReason reason, FSharpList`1 code, String marker, FSharpFunc`2 f) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 54
at <StartupCode$VisualFSharp-Unittests>.$Tests.LanguageService.Completion.AssertAutoCompleteContains@58-1.Invoke(FSharpList`1 code, String marker, FSharpList`1 should, FSharpList`1 shouldnot) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 58
at Tests.LanguageService.AutoCompletion.UsingMSBuild.AutoCompleteBug70080HelperHelper(String programText, FSharpList`1 shouldContain, FSharpList`1 shouldNotContain) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\unittests\Tests.LanguageService.Completion.fs:line 167

5) Failed : Tests.LanguageService.AutoCompletion.UsingProjectSystem.LongIdent.AsAttribute
Couldn't find 'ObsoleteAttribute' in completion list
at Salsa.VsOpsUtils.AssertCompListContains$cont@220(String membername, Tuple`4[] completions, Unit unitVar) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 223
at Salsa.VsOpsUtils.AssertCompListContains(Tuple`4[] completions, String membername) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 220
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 238
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 239

6) Failed : Tests.LanguageService.AutoCompletion.UsingProjectSystem.LongIdent.PInvoke.AsAttribute
Couldn't find 'SomeAttrib' in completion list
at Salsa.VsOpsUtils.AssertCompListContains$cont@220(String membername, Tuple`4[] completions, Unit unitVar) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 223
at Salsa.VsOpsUtils.AssertCompListContains(Tuple`4[] completions, String membername) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 220
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 238

@vasily-kirichenko
Copy link
Contributor Author

Different attribute completiion tests fails from launch to launch. I think it's because completion list caching:

  • a test executes completion at "no attribute application" point => "AnAttribute" completion is cached
  • another test executes at "attribute application" point => the caches "AnAttribute" is returned instead of "An"

This behavior is also reproduced in the editor. We should clean the cache if we move from attr appl point to non such a point.

@vasily-kirichenko
Copy link
Contributor Author

Where can I find why the tests failed? I examined all the files in this list:

image

and found nothing labeled as "error" or "failure".

@forki
Copy link
Contributor

forki commented Dec 28, 2016 via email

@vasily-kirichenko
Copy link
Contributor Author

@forki Thanks, but I didn't find any failures in the console output, the only thing that has helped is searching for "failure" in the text that's available by "View as plain text" link.

@vasily-kirichenko
Copy link
Contributor Author

Hm. I've no idea why the tests do not pass now. The sample from one of them works in editor:

image

@vasily-kirichenko
Copy link
Contributor Author

@dotnet-bot test this please

@KevinRansom
Copy link
Contributor

Still a couple of failures:

Errors and Failures

1) Failed : Tests.LanguageService.AutoCompletion.UsingMSBuild.LongIdent.AsAttribute
Couldn't find 'Obsolete' in completion list: [|"AccessViolationException"; "Action"; "ActivationContext"; "Activator";
  "AggregateException"; "AppContext"; "AppDomain"; "AppDomainInitializer";
  "AppDomainManager"; "AppDomainManagerInitializationOptions"; "AppDomainSetup";
  "AppDomainUnloadedException"; "ApplicationException"; "ApplicationId";
  "ApplicationIdentity"; "ArgIterator"; "ArgumentException";
  "ArgumentNullException"; "ArgumentOutOfRangeException"; "ArithmeticException";
  "Array"; "ArraySegment"; "ArrayTypeMismatchException"; "AssemblyLoadEventArgs";
  "AssemblyLoadEventHandler"; "AsyncCallback"; "Attribute"; "AttributeTargets";
  "AttributeUsageAttribute"; "BadImageFormatException";
  "Base64FormattingOptions"; "BitConverter"; "Boolean"; "Buffer"; "Byte";
  "CLSCompliantAttribute"; "CannotUnloadAppDomainException"; "Char";
  "CharEnumerator"; "Collections"; "Comparison"; "Configuration"; "Console";
  "ConsoleCancelEventArgs"; "ConsoleCancelEventHandler"; "ConsoleColor";
  "ConsoleKey"; "ConsoleKeyInfo"; "ConsoleModifiers"; "ConsoleSpecialKey";
  "ContextBoundObject"; "ContextMarshalException"; "ContextStaticAttribute";
  "Convert"; "Converter"; "CrossAppDomainDelegate"; "DBNull";
  "DataMisalignedException"; "DateTime"; "DateTimeKind"; "DateTimeOffset";
  "DayOfWeek"; "Decimal"; "Delegate"; "Deployment"; "Diagnostics";
  "DivideByZeroException"; "DllNotFoundException"; "Double";
  "DuplicateWaitObjectException"; "Dynamic"; "EntryPointNotFoundException";
  "Enum"; "Environment"; "EnvironmentVariableTarget"; "EventArgs";
  "EventHandler"; "Exception"; "FieldAccessException"; "FlagsAttribute";
  "FormatException"; "FormattableString"; "Func"; "GC"; "GCCollectionMode";
  "GCNotificationStatus"; "Globalization"; "Guid"; "IAppDomainSetup";
  "IAsyncResult"; "ICloneable"; "IComparable"; "IConvertible";
  "ICustomFormatter"; "IDisposable"; "IEquatable"; "IFormatProvider";
  "IFormattable"; "IO"; "IObservable"; ...|]
at Salsa.VsOpsUtils.AssertCompListContains$cont@220(String membername, Tuple`4[] completions, Unit unitVar) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 223
at Salsa.VsOpsUtils.AssertCompListContains(Tuple`4[] completions, String membername) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 220
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 238
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 239

2) Failed : Tests.LanguageService.AutoCompletion.UsingProjectSystem.LongIdent.AsAttribute
Couldn't find 'Obsolete' in completion list: [|"AccessViolationException"; "Action"; "ActivationContext"; "Activator";
  "AggregateException"; "AppContext"; "AppDomain"; "AppDomainInitializer";
  "AppDomainManager"; "AppDomainManagerInitializationOptions"; "AppDomainSetup";
  "AppDomainUnloadedException"; "ApplicationException"; "ApplicationId";
  "ApplicationIdentity"; "ArgIterator"; "ArgumentException";
  "ArgumentNullException"; "ArgumentOutOfRangeException"; "ArithmeticException";
  "Array"; "ArraySegment"; "ArrayTypeMismatchException"; "AssemblyLoadEventArgs";
  "AssemblyLoadEventHandler"; "AsyncCallback"; "Attribute"; "AttributeTargets";
  "AttributeUsageAttribute"; "BadImageFormatException";
  "Base64FormattingOptions"; "BitConverter"; "Boolean"; "Buffer"; "Byte";
  "CLSCompliantAttribute"; "CannotUnloadAppDomainException"; "Char";
  "CharEnumerator"; "Collections"; "Comparison"; "Configuration"; "Console";
  "ConsoleCancelEventArgs"; "ConsoleCancelEventHandler"; "ConsoleColor";
  "ConsoleKey"; "ConsoleKeyInfo"; "ConsoleModifiers"; "ConsoleSpecialKey";
  "ContextBoundObject"; "ContextMarshalException"; "ContextStaticAttribute";
  "Convert"; "Converter"; "CrossAppDomainDelegate"; "DBNull";
  "DataMisalignedException"; "DateTime"; "DateTimeKind"; "DateTimeOffset";
  "DayOfWeek"; "Decimal"; "Delegate"; "Deployment"; "Diagnostics";
  "DivideByZeroException"; "DllNotFoundException"; "Double";
  "DuplicateWaitObjectException"; "Dynamic"; "EntryPointNotFoundException";
  "Enum"; "Environment"; "EnvironmentVariableTarget"; "EventArgs";
  "EventHandler"; "Exception"; "FieldAccessException"; "FlagsAttribute";
  "FormatException"; "FormattableString"; "Func"; "GC"; "GCCollectionMode";
  "GCNotificationStatus"; "Globalization"; "Guid"; "IAppDomainSetup";
  "IAsyncResult"; "ICloneable"; "IComparable"; "IConvertible";
  "ICustomFormatter"; "IDisposable"; "IEquatable"; "IFormatProvider";
  "IFormattable"; "IO"; "IObservable"; ...|]
at Salsa.VsOpsUtils.AssertCompListContains$cont@220(String membername, Tuple`4[] completions, Unit unitVar) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 223
at Salsa.VsOpsUtils.AssertCompListContains(Tuple`4[] completions, String membername) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 220
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 238
at Salsa.VsOpsUtils.AssertCompListContainsAll(Tuple`4[] completions, FSharpList`1 expectedCompletions) in D:\j\workspace\release_ci_pa---3f142ccc\vsintegration\tests\Salsa\SalsaUtils.fs:line 239

…mpletion

# Conflicts:
#	vsintegration/src/FSharp.Editor/Common/LanguageService.fs
@vasily-kirichenko
Copy link
Contributor Author

I think it's finally ready.

@KevinRansom KevinRansom merged commit f2748ff into dotnet:master Dec 29, 2016
@KevinRansom
Copy link
Contributor

Thanks for taking care of this.

Kevin

nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
* add FSharpDeclarationListItem.IsAttribute

try to handle attributes in a special way at attribute application point (wip)

* almost works

* suggest all types, modules and namespaces at attribute application position

* fix Context.AttributeApplication detection

* autocomplete does not remove "Attribute" suffix if an attribute type does not have it

fix related tests

* do not try to use AstVisitorBase to determine that we are at attribute application position

* try to fix tests

* fix some tests

* cut attribute prefix on editor side

* fixed: IsAttribute can throw exceptions which results with empty completion list

* fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-completing attributes adds 'Attribute' suffix

8 participants