This is a much more difficult question than it first appears. There was a time when major projects would use only a handful of languages and tools, but no longer. For example, a typical project these days could easily use 10 or more languages, once you include browsers, code, scripting, make, configuration and so on, and there are literally hundreds of languages with at least some adherents.
One project I just checked has over 50 file extensions and 8 languages and tools. At least 3 of them use XML. I may have missed some.
If your purpose is to find the major implementation language(s) then a simple cross-reference of lines of code against file extension will tell you which files to concentrate on.
If you can identify a specific IDE such as NetBeans, Eclipse or Visual Studio this can help a lot. However, even something as obvious as Ruby on Rails may include a range of additional languages and tools for specific purposes.
If your purpose is to make sure you have all the tools you need to build the project then search out the build scripts. That won't always help -- many IDEs do not play by the rules.
If you have a number of files in an unfamiliar programming language, or an unfamiliar dialect, it can be challenging to find out what it belongs to. I have resorted to web searches of distinctive keywords.
Ultimately it's detective work and a bunch of guesses, with scientific data gathering to narrow the possibilities.