Chaning file type [message #26379] |
Thu, 07 June 2007 20:23 |
Eclipse User |
|
|
|
Originally posted by: omry.yadan.net
I have a file.js.php, which is actually a javascript file with some
minor php preprocessing. is it possible to tell PDT that its a
javascript file for purposes of code completion?
|
|
|
Re: Chaning file type [message #26660 is a reply to message #26379] |
Fri, 08 June 2007 08:29 |
drm / Gerard Messages: 26 Registered: July 2009 |
Junior Member |
|
|
> I have a file.js.php, which is actually a javascript file with some
> minor php preprocessing. is it possible to tell PDT that its a
> javascript file for purposes of code completion?
I would advise to use a different file extension (like .pjs or
something) and create a new content-type and file association for it.
You can associate both a JS editor and a PHP editor with it, and use the
"Open with" option to choose between them. Eclipse will remember your
choice the next time you open that file.
The problem with the .js.php extension is that eclipse apparently uses
"first best match" method to match file extensions, e.g. if you would
add .js.php to your file associations, the *.php will match first. I
think this could be reported as a bug, btw, since the best match should
be the pattern that is the longest, or even better: the most specific one.
You should of course be aware that if you 'd use another extension like
..pjs, it must be considered a php file by the webserver. You can do this
in Apache simply by adding a .htaccess file next to it, with a single line:
AddType .pjs application/x-httpd-php
HTH
|
|
|
Re: Chaning file type [message #26701 is a reply to message #26660] |
Fri, 08 June 2007 08:46 |
Eclipse User |
|
|
|
Originally posted by: omry.yadan.net
As you pointed out, changing the file extension involves configuring the
web server accordingly.
this is not something I am willing to do (my application is intended to
be as simple as possible to install, even if it makes my life a bit
harder).
what about explicitly setting the type of the file (similar to the way
Eclipse lets the user choose encoding on a per-file basis) ?
drm wrote:
>> I have a file.js.php, which is actually a javascript file with some
>> minor php preprocessing. is it possible to tell PDT that its a
>> javascript file for purposes of code completion?
>
> I would advise to use a different file extension (like .pjs or
> something) and create a new content-type and file association for it.
> You can associate both a JS editor and a PHP editor with it, and use the
> "Open with" option to choose between them. Eclipse will remember your
> choice the next time you open that file.
>
> The problem with the .js.php extension is that eclipse apparently uses
> "first best match" method to match file extensions, e.g. if you would
> add .js.php to your file associations, the *.php will match first. I
> think this could be reported as a bug, btw, since the best match should
> be the pattern that is the longest, or even better: the most specific one.
>
> You should of course be aware that if you 'd use another extension like
> .pjs, it must be considered a php file by the webserver. You can do this
> in Apache simply by adding a .htaccess file next to it, with a single line:
>
> AddType .pjs application/x-httpd-php
>
> HTH
>
>
|
|
|
|
Re: Changing file type [message #26780 is a reply to message #26740] |
Fri, 08 June 2007 10:28 |
Eclipse User |
|
|
|
Originally posted by: omry.yadan.net
> I don't think that is possible, but i'm not sure; at least I can't find it.
>
> Another alternative would be to add the Javascript editor to the *.php
> file type (Window->preferences->general->editors->file associations) and
> just use "open with".
>
That did the trick.
Eclipse remembers the editor associated with that particular file so it
works fine now.
Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.03752 seconds