How a programmer thinks about a problem (and a solution) depends greatly on how they think about things in general, the problem itself and their level of experience in particular. Let's go through them in order:
How people think in general
Different people learn, and think differently. Personally, I am an extremely visual thinker, and tend to use a lot of intuition about how things "fit". That's literally because I have a mental model for different patterns, modules and dependencies within the code. When I can't arrange them into a nice shape, I know the solution isn't adequate.
Others are very logical, they have sets of facts that they look to reduce into a result. Yet others are tied to verbal or auditory sort of learning. They need to hear a problem described to understand the relations and emphasises of it. And of course, nobody is "just" visual or "just" verbal. They mix and match at different levels.
The problem itself
Different problems require different solutions. When I'm designing a architecture to handle thousands of transactions a second, I think about it differently than I do trying to make a scheduling algorithm. They have different needs, and using different problem solving approaches allow me to be more effective than using the same approach for everything.
The Programmer's experience level
When beginners start out, they know syntax and (if they're lucky) they have a good grasp of the concept of variables. When presented with a programming problem, they're going to tackle it with these concepts, because that is what they know.
As they gain experience (especially with different languages/paradigms) they begin to abstract away the concrete syntax into concepts. Instead of thinking "oh make a class that inherits from XYZ" they can think "I need some sort polymorphism here". Design Patterns (when used well) are the sort of thing that extends this further so that the programmer can think about tools that encompass broader swaths of syntax.
This is the primary reason that "learn a variety of programming language paradigms" is a common suggestion in the development of programmers. It's also why C++ has greatly fallen out of favor as a first programming language (in some circles) - you spend too much time thinking about syntax and not learning how to solve problems.
(tl;dr) In general, for most problems, programmers move from thinking in syntax to thinking in their own mental model as they gain more experience.