Is there a Windows API for IntelliSense?

Date:July 25, 2016 / year-entry #154
Tags:other
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20160725-00/?p=93945
Comments:    52
Summary:That's not really an operating system thing.

A customer had a question, forwarded to the operating system group via the customer liaison.

"My customer is developing an IDE and they want to implement the IntelliSense feature. We have been unable to find any documents explaining how to do this. Is there an API for this, or can you recommend a third-party SDK?"

IntelliSense isn't really an operating system feature. This is the sort of thing we call "business logic": The part of the program that is devoted to doing the things the program does, that only the program knows how to do. The operating system doesn't know how your business logic works; that's entirely within you control as the developer.

Windows doesn't really know anything about the syntax of C or C++ or Python or Java or whatever language your IDE is trying to support. Your IDE is going to have to parse the language and figure out what types the objects are and then offer appropriate suggestions based on what it has inferred. (This gets particularly tricky because you have to offer suggestions on code that probably isn't yet fully syntactically valid.)

"How should the customer get going if they accepted an order to develop an IntelliSense feature?"

Okay, wait, let me see if I understand this.

Your customer signed a contract promising to deliver an IntelliSense feature, but they don't have any idea where to start, and they're asking Microsoft to help them either by providing an API, or helping them find somebody who has a ready-made solution.

Apparently, this is what happens when people who grew up with StackOverflow get a job.

The customer needs to grab a blank piece of paper and start designing some software.


Comments (52)
  1. Eduardo says:

    I am not sure about this but, doesn’t the Visual Studio Shell already provides some facilities to implement IntelliSense?

  2. Mason Wheeler says:

    > Apparently, this is what happens when people who grew up with StackOverflow get a job.

    StackOverflow was created in 2008. Kids who grew up on it aren’t old enough to have jobs yet…

    1. Jalopy says:

      People finishing a CS degree in 2008 could be getting towards senior positions having spent their entire career using SO.

      I started programming in 2010, for reference

    2. Nick says:

      StackOverflow was created in 2008 but kids don’t generally start programming anything of substance until about high school. Totally reasonable for someone two years out of college to have done all meaningful programming with StackOverflow available (toy programs, assignments, intern- and entry-level work).

      1. Mason Wheeler says:

        High school? What’s wrong with kids today? I got started in the 3rd grade!

        1. Kirby FC says:

          I started programming in 1981, when I was 27.

          1. DWalker says:

            I started programming in 1976, when I was 15.

        2. So did I. Studied QBasic while on the bus to school.

          1. MarcK4096 says:

            When I was a kid, I had to program up hill…both ways!

    3. outadoc says:

      Stack Overflow was created pretty much as I started teaching myself programming. I’ve been working for a year now.

  3. pc says:

    I haven’t done direct Windows programming in quite some time, but I believe that there’s some built-in dropdown control with support for helping do auto-complete functionality. It’d be reasonable to ask if there’s something in the built-in multiline textbox control for support for helping do inline auto-complete IntelliSense-type functionality, to have a dropdown in the middle of a textbox that the program provides options for, and then includes the selected choice in the textbox.

    Though it doesn’t sound like that’s really what this customer was asking for.

    It *would* be nice to have a standard way for programs to do this, though. I always accept completion suggestions with the Tab key (because that’s what the documentation of the first IDE I used with the feature said to use), and then at some point I used some obscure program that as far as I could tell was just *broken* and didn’t actually do the Autocomplete that it looked like it was trying to do, until eventually I discovered (as it wasn’t in the docs that I could see) that it only accepted the Enter key to accept a completion. It was very frustrating to go back and forth. Luckily, most programs nowadays do seem to work fine using Tab, though I don’t know if that’s the “standard” that other people use too, now.

    1. Mark Jansen says:

      @pc: You are looking for the api SHAutoComplete (https://msdn.microsoft.com/en-us/library/windows/desktop/bb759862(v=vs.85).aspx), or the underlying IAutoComplete / IAutoComplete2 (https://msdn.microsoft.com/en-us/library/windows/desktop/bb776288(v=vs.85).aspx)

      1. DWalker says:

        And you have to supply the entries that would go in the drop-down list. That’s what I think Raymond is alluding to when he says that you have to do all the work/provide all the information.

  4. Brian says:

    I remember working on a system in the late nineties. It included something like an IDE for some proprietary domain-specific languages. While we were working on this, someone released a syntax-coloring library for MFC (our framework of choice at the time). It didn’t take long to convince management to spring for a half-dozen licenses. We had a pretty cool looking demo running for our customers about a month or so later.
    My advice to the customer is to cross their fingers and hope somebody sees a market in an Intellisense-like library. I’d be surprised if a customer that asked a question like that was capable of putting together something so complicated.

    1. SimonRev says:

      I remember my first job out of college was writing an IDE for a proprietary language. For Intellisense, I ended up not only doing the parsing and populating, but writing full blown custom controls to display the suggestions (mostly because I was to inexperienced to understand how to use implement an owner-draw listbox).

      The end result was pretty cool — the suggestion list was alpha blended and used heuristics to fade (alpha blend) out when it appears that the suggestions would obscure code you are looking at and fade in when it appears you are looking at the suggestions.

      1. Mason Wheeler says:

        That actually sounds really interesting. I don’t suppose it’s still around?

        1. SimonRev says:

          It is around, although it hasn’t been updated much recently and looks quite dated now. If you go to my profile and follow the website link and search for “qlarity” you can find it if you are interested in seeing how it worked.

      2. Don Reba says:

        JetBrains sees a market in an Intellesense-like library. Their offering is called Nitra.
        https://confluence.jetbrains.com/display/Nitra/Home

      3. Matt says:

        War story:

        In the VBA97 (VB5/Office97) IntelliSense ‘alpha blending’ wasn’t really on the table, and the screens were small enough that pretty much every popup obscured something. So, a mouse down on a tip window would grab mouse capture and move the window into negative screen territory without ever closing the window.

        Of course, there were bugs:
        1) If you hit escape with the mouse down the subsequent mouse up was bad news. This was the quickest way I knew to shut down Excel without so much as an exception dialog.
        2) When multi monitor support was introduced a year or so later we had a puzzled customer who stacked monitors vertically. With the IDE on the primary monitor placed below a secondary monitor, ‘negative territory’ meant the bottom of the top monitor. The hidden window was no longer hidden, and my little mouse capture sleight-of-hand was on full display.

        Of course, someone later on got the brilliant idea that a click anywhere in the body of the window would scroll through overloads, completely losing the original design of being able to temporarily hide the window. I still inadvertently try to click-hide the popups.

        Seriously, though, it isn’t 1997 anymore. The customer should pick an existing IDE and extend. There is no reason to build from scratch. Microsoft never enforced the patents on this (expiring next year, the $1500 patent bonus wasn’t worth the weeks spent with lawyers writing it up), so just about every code editor has some form of this built in. IntelliSense was very much a marketing name, the code was wrapped up well before the feature had an umbrella name. I’m sure it is still trademarked. Raymond’s point is of course well taken: don’t commit to something if you don’t have the slightest idea how to do it.

    2. exchange development blog team says:

      Oh, I don’t know, just write something that writes monster 50MB database files below your project directory, pegs at least one CPU core at 100% for lengthy periods of time, and causes your IDE to freeze for several seconds at random moments and you’ve got a fair chunk of Intellisense functionality already done. The rest you contract out to India.

      1. DWalker says:

        Then I’m glad that Visual Studio’s Intellisense wasn’t developed this way (I never see those symptoms at all).

        1. Brian says:

          @DWalker: That’s pretty much how the old VC++ Intellisense worked. I think it uses a different mechanism now. Back in the day, deleting the NCB file was a solution to many problems. Then again, it’s been a while since I lived in the VC++ world, so it may still be like that.

  5. xcomcmdr says:

    Just buy Visual Studio already.

  6. henke37 says:

    Guys, remember that IntelliSense is a specific implementation. Not the general name of the feature. I haven’t checked, but if it was me then I’d have trademarked the name,

    1. It is. Microsoft filed the registration in 1993, it went on the register in 1997, and they renewed it in 2007 (registered for use in computer programs).

    2. Alice Rae says:

      We are under no obligation to respect trademarks in casual conversation.

      1. zboot says:

        The comment was referring to the apparent use of “IntelliSense” by the customer. They can’t create their own product an also call it “IntelliSense”.

  7. Andrew says:

    A comment I occasionally leave on StackOverflow:

    Step 1: Hire six highly experienced developers.

    1. JoeWoodbury says:

      Step 2: Listen to them

  8. David says:

    There are third-party SDKs that could be recommended: Edison Design Group’s frontend and the open source frontend clang.
    Clang even includes APIs necessary for implementing code completion.

  9. Richard says:

    I guess I’d start by looking at the .ncb files. According to all of the issues I’ve had with VS over the years, that file is really important.

  10. Incidentally, the Monaco editor, which is what VS Code is based on, is now an NPM module. https://www.npmjs.com/package/monaco-editor

  11. David Haim says:

    This is hilarious.

  12. cyan says:

    Incidentally, this is exactly the way Bill Gates accepted to make DOS for IBM ….

    1. Josh B says:

      Not even close. Bill Gates specifically referred IBM first to Digital’s Dr. DOS, then offered to license QDOS or another CP/M clone as necessary. He never claimed he would write it, just that he would provide a clone from a proven existing OS, modify it however IBM wanted (and boy did they ask for a lot of changes), and write a BASIC for that. On his own, he decided to buy the OS he was licensing outright, and that turned out to be one of the best business gambles in history.

      1. I don’t think they ever actually labeled it as Dr. DOS. I’m pretty sure it was DR-DOS and then just DR DOS, with DR short for Digital Research.

        Of course I totally called it “Doctor DOS” all the time growing up. Was a lot funnier that way.

      2. John Elliott says:

        DR-DOS didn’t exist at the time; Digital Research’s offering for the x86 platform was CP/M-86.

        After CP/M-86 and before DR-DOS there was DOS Plus, which was implemented as a MS-DOS translation layer running as a process on top of a multitasking CP/M-86 kernel.

  13. KIDS THESE DAYS – EXPECTING TO FIND HELP ON THE INTERNET

    WHEN I WAS A YOUNG MAN YOU HAD TO BUILD YOUR SOFTWARE OUT OF BITS THAT YOU HARVESTED FROM YOUR BACK YARD

    I HAD TO WALK TEN MILES TO GET TO THE NEAREST TERMINAL

    ADMITTING THAT YOU NEEDED HELP OR GUIDANCE WITH ANYTHING WAS TANTAMOUNT TO RESIGNING IN SHAME

    WHEN WE DIDN’T KNOW HOW TO DO SOMETHING, WE JUST DIDN’T DO IT, OR DID A BAD JOB

    AND THAT’S THE WAY IT SHOULD BE

    1. Darran Rowe says:

      Insert Monty Python 4 Yorkshire Men sketch here.

  14. Douglas says:

    If you’re interested in IntelliSense for C# or VB, Roslyn is the API you’re looking for. The latest version of Visual Studio uses Roslyn for its IntelliSense implementation.
    http://roslyn.codeplex.com/

    1. I linked to Roslyn in the article. Note that your link is outdated.

  15. cheong00 says:

    I think they’re looking for Windows native control components because you have Autocomplete in jQuery-UI… just that jQuery-UI is still a 3rd party component that’s not built-in in javascript engine of browsers.

  16. Reading your answer to that customer must be fun…

  17. outadoc says:

    > Apparently, this is what happens when people who grew up with StackOverflow get a job.

    Asking for something pre-baked isn’t going to get them anywhere, but *asking* if that something exists seems pretty reasonable to me. Wouldn’t want to reinvent the wheel, right? Or is that something Microsoft does just because that’s what *real programmers* do?

    1. It’s okay to ask if such a thing exists, but you need to ask the right people. Asking the Windows OS team about something that has nothing to do with the OS will not get you good answers. It’s like asking your auto mechanic to recommend a cookie recipe. What made this noteworthy was that after being told, “This isn’t an OS question,” they came back and asked, “So what should we do?”

  18. > Apparently, this is what happens when people who grew up with StackOverflow get a job.

    Ouch. I normally love this blog, it’s a fascinating insight into some internals at Microsoft that we normally don’t get to see – however this jab stung quite a bit.

    There has always been a certain elitism amongst developers, especially the “old school” ones. This idea that if you didn’t know assembler, you were a n00b. Then if you preferred C++ over C, you were an amateur. I guess these days if you use a managed runtime, you’re not a “real” developer.

    Unfortunately, that elitist attitude is nothing short of toxic. Telling people that they’re wrong for asking questions, demanding that people “figure it out themselves” is just a dumb way to waste time. Considering it’s an attitude that stems from programmers, you’d think we’d see the irony in promoting such an inefficient method of learning.

    Yeah sure, you might have had to struggle to learn what you know – you didn’t have the same resources as the “Kids these days” and it can feel bitter just handing the answers out to someone who didn’t suffer like you, but your parents didn’t have the resources you had, nor did their parents have the resources they had. That’s what progress is. We stopped forcing every generation to relearn the same things by trial and error some thousands of years ago. As a result, things got better and continue to do so.

    Imagine being back in school, being thrown a dead rat and being told “Figure out how it worked, but if you ask questions then you may as well just ho home because you’re useless and don’t belong here”.

    That’s the kind of attitude being demonstrated here.

    1. The issue isn’t so much that they’re asking for a library, but that they’re asking the Windows OS team for help with something that is squarely an app business logic issue. Windows can’t help you with your business logic, and asking the Windows OS team is not going to get you any useful recommendations because that’s not what we are experts on. But the real issue is signing a contract to deliver a feature you don’t know how to implement.

  19. Tanveer Badar says:

    It is easy, you only need a couple of Ph. Ds doing the job.

    http://stackoverflow.com/questions/9556026/a-new-and-full-implementation-of-generic-intellisense

    1. DWalker says:

      This bit:

      “I recommend that you obtain an undergraduate or graduate degree in computer science with an emphasis on parser theory if you have not already.”

  20. Leonardo Herrera says:

    Somewhat related, here’s Anders talking about modern compiler construction. He mentions the importance of tooling.

    https://channel9.msdn.com/Blogs/Seth-Juarez/Anders-Hejlsberg-on-Modern-Compiler-Construction

  21. DWalker says:

    “How should the customer get going if they accepted an order to develop an IntelliSense feature?”

    Priceless.

  22. Ron O says:

    I will note it’s quite possible (I’d even say likely) the sales people sold the contract without input from any devs. Or worse, the dev manager (who knows little about actual coding) was consulted and responded “I think Microsoft has some built-in way to do that. Yeah, I can get it done.”

Comments are closed.


*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index