Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tern Eclipse Javascript Support in PHP Files #411

Closed
RandyR34 opened this issue Mar 19, 2016 · 17 comments
Closed

Tern Eclipse Javascript Support in PHP Files #411

RandyR34 opened this issue Mar 19, 2016 · 17 comments
Milestone

Comments

@RandyR34
Copy link

Hi,
Is there a way to enable Tern javascript support for PHP files? Namely autocomplete with Tern's JQuery module.

Tern autocompletes fine with .html files (inside script block) and .js files.

However, php files with script block do not autocomplete at all.

Thanks.

@RandyR34 RandyR34 changed the title Tern Javascript Support in PHP Files Tern Eclipse Javascript Support in PHP Files Mar 19, 2016
@angelozerr
Copy link
Owner

If your PHP editor is based on JSDT for JavaScript, it should work, but never really tested. Which plugins do you use for PHP? I think http://www.zend.com/fr/products/studio works like this. @kaloyan-raev could you confirm us that tern works inside zend studio please?

@RandyR34
Copy link
Author

Thanks for the quick reply.

I installed Zend Studio trial just now to test it. Enabled JS support which installed Tern libraries. Same results (Tern code hinting works in .js file, but not in .php file inside script tag).

@angelozerr
Copy link
Owner

@kisaloyan-raev could you help me please about this issue. Thanks!

@kaloyan-raev
Copy link

@angelozerr Sorry, I missed the previous comments.

@mniewrzal Can you help here?

@mniewrzal
Copy link
Contributor

Hi,
it looks that CA is not working with combination PHP + HTML + JS (PDT/Zend Studio). Later I will take a look what is going on there.

@mniewrzal
Copy link
Contributor

Turns out that in tern.eclipse.ide.jsdt.ui proposal computer tern.eclipse.ide.jsdt.ui.contentassist.TernContentAssistProcessor needs additional content type org.eclipse.php.core.phpsource. I will prepare patch for this.

mniewrzal pushed a commit to mniewrzal/tern.java that referenced this issue Apr 27, 2016
Added content type to support mixed files (HTML+JS+PHP)
angelozerr added a commit that referenced this issue Apr 27, 2016
Tern Eclipse Javascript Support in PHP Files #411
@angelozerr angelozerr added this to the 1.2.0 milestone Apr 27, 2016
@angelozerr
Copy link
Owner

@rrefsland once https://opensagres.ci.cloudbees.com/job/tern.java/877/ will be finished, please try to install tern.java 1.2.0-SNAPSHOT https://github.com/angelozerr/tern.java/wiki/Installation-Update-Site

Thanks @mniewrzal for your job!

@RandyR34
Copy link
Author

Excellent.....will do. I'll try it out this weekend.

@RandyR34
Copy link
Author

RandyR34 commented May 1, 2016

I installed the updates to 1.2.0. It improved a little.

Ex: In a PHP file.....Starting out with "$" will popup JQuery (that's an improvement). But after the selector period "$()." no methods show.

In a javascript file, $(). will display all available methods.

@angelozerr
Copy link
Owner

@rrefsland @kaloyan-raev have you an idea?

@kaloyan-raev
Copy link

@mniewrzal could you take at this one too?

@mniewrzal
Copy link
Contributor

@rrefsland Can you try convert your project to javascript project? To do this select your project and from context menu choose Configure -> Convert to Javascript Project. After that I have result like on attached image.

screenshot from 2016-05-03 17-09-23

@angelozerr
Copy link
Owner

That's strange, it should work without converting your project to JavaScript project.

@mniewrzal
Copy link
Contributor

Problem is probably only with .php files. When I will be sure that this is a problem I will try to fix situation. Today I had only a moment to verify problem.

@RandyR34
Copy link
Author

RandyR34 commented May 4, 2016

[Edited comment, the reply via email with screenshots didn't quite work as expected.....]

Culprit was Eclipse adding an extra "<" in front of the script tag (along with an html comment inside by default).

Ex: This disabled Tern assist: <<script type="text/javascript">

Tern works fine with clean < script > tags.

Thanks guys.

@angelozerr
Copy link
Owner

@rrefsland if I understand your problem, when you have<!-- after <script type="javascript" >,, it breaks tern completion? If it that it's a bug with tern.java. To support completion tern.java extract JavaScript code from HTML with https://github.com/angelozerr/tern.java/blob/master/core/tern.core/src/tern/server/protocol/html/HtmlHelper.java#L50

It replaces HTML code with spaces and keep JS code and push this content to the tern server. I have not supported <!-- and perhaps tern doesn't support that.

To fix the problem, https://github.com/angelozerr/tern.java/blob/master/core/tern.core/src/tern/server/protocol/html/HtmlHelper.java#L50 should be improved to replace <!-- with spaces when it is after <script type="javascript" >

Any contribution are welcome!

@RandyR34
Copy link
Author

RandyR34 commented May 5, 2016

@angelozerr
Thanks for the explanation. It helped when I visited the link to extractJS(). The Tern library is so huge man....

Just to summarize:
Tern can handle <!-- --!> inside the script tags OK.

Tern does not handle a script tag with two <<. For example <<script type="text/javascript">. I'm not sure why Eclipse adds a default script tag with two <<. Who knows....Not a big deal.

Anyhow, case closed! I'll take a look and see if I can help.

@RandyR34 RandyR34 closed this as completed May 5, 2016
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

No branches or pull requests

4 participants