{"id":189168,"date":"2013-08-06T16:41:03","date_gmt":"2013-08-06T12:41:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=189168"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=189168","title":{"rendered":"<span class=\"post_title\">\u041f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f webstorm \u0438 \u0430\u0432\u0442\u043e-\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0435\u0435 \u0430\u0432\u0442\u043e-\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 IDE \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 IDEA. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a WebStorm \u0438\u043b\u0438 PhpStrom.<\/p>\n<p>  \u0423 \u043d\u0430\u0441 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 require.js. \u0418 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u0438 \u043a \u0442\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c \u0447\u0442\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043f\u0443\u0442\u0438 \u043a \u044d\u0442\u0438\u043c \u0444\u0430\u0439\u043b\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438 \u0438\u043b\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c.<br \/>  \u0418 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u0432\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438 \u0434\u043e \u0444\u0430\u0439\u043b\u043e\u0432.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043a\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u043a Idea \u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u043e <a href=\"http:\/\/habrahabr.ru\/post\/161877\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0445\u0430\u0431\u0440\u0430\u044e\u0437\u0435\u0440\u0430 <a href=\"http:\/\/habrahabr.ru\/users\/zenden2k\/\" class=\"user_link\">zenden2k<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043e\u043a \u0434\u043b\u044f kohana. \u041f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0435\u0451 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<p>  \u0420\u0435\u0448\u0438\u0432 \u0447\u0442\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u0442\u043e\u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u044f \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u043b\u0430\u0433\u0438\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<br \/>  \u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f PSI \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f javascript \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 Idea Community Edition, \u0430 \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0444\u0430\u0439\u043b\u0430 JS, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043a\u0438. \u041c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 Idea Ultimate EAP. \u0412 Idea UT \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f Javascript, \u0438 \u0442\u043e\u0433\u0434\u0430 \u0432 PSI Viewer (Tools -&gt;View PSI Structure) \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432\u044b\u0431\u043e\u0440 PSI \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f Javascript \u0444\u0430\u0439\u043b\u043e\u0432.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c6a\/924\/361\/c6a924361653afab4438e036ab35c219.png\" alt=\"image\"\/>  <\/div>\n<\/div>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0442\u0435\u043c \u0447\u0442\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 JetBrains \u0432\u044b\u043a\u0430\u0442\u0438\u043b\u0438 openapi \u0434\u043b\u044f PHP \u0438 JS, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0443\u0436\u0435 \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 PSI \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 JSLiteralExpression. \u041c\u043e\u0439 PsiReferenceContributor \u0441\u0442\u0430\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">RequirejsPsiReferenceContributor.java<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">package requirejs;  import com.intellij.lang.javascript.psi.JSLiteralExpression; import com.intellij.patterns.StandardPatterns; import com.intellij.psi.PsiReferenceContributor; import com.intellij.psi.PsiReferenceRegistrar;  public class RequirejsPsiReferenceContributor extends PsiReferenceContributor {     @Override     public void registerReferenceProviders(PsiReferenceRegistrar psiReferenceRegistrar) {         RequirejsPsiReferenceProvider provider = new RequirejsPsiReferenceProvider();          psiReferenceRegistrar.registerReferenceProvider(StandardPatterns.instanceOf(JSLiteralExpression.class), provider);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e PsiElement.class \u044f \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e JSLiteralExpression.class, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0434\u0440\u044f\u0434 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<br \/>  \u041d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c openapi \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0432 idea. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 Project Structure, \u0442\u0430\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c Libraries. \u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 + \u043d\u0430\u0434 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c Java \u0438 \u0432 \u043e\u0442\u043a\u0440\u044b\u0432\u0448\u0435\u043c\u0441\u044f \u043e\u043a\u043d\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0444\u0430\u0439\u043b\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0444\u0430\u0439\u043b &quot;\/path_to_webstrom\/plugins\/JavaScriptLanguage\/lib\/javascript-openapi.jar&quot;:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/a5b\/2d1\/135\/a5b2d1135d6eb207c6584173ecbf03a6.png\" alt=\"image\"\/><\/div>\n<\/div>\n<p>  \u041f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a Modules, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 Dependencies, \u0438 \u0442\u0430\u043c \u043d\u0430 \u043f\u0440\u043e\u0442\u0438\u0432 javascript-openapi \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c Scope \u043a\u0430\u043a Provided:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/828\/484\/ccf\/828484ccff3c777cbd4f5434286e8776.png\" alt=\"image\"\/><\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 IDE \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 openapi \u0434\u043b\u044f javascript.<\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c PsiReferenceProvider, \u0438\u0437\u0431\u0430\u0432\u0438\u0432 \u0435\u0433\u043e \u043e\u0442 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438, \u0432\u044b\u0448\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">RequirejsPsiReferenceProvider.java<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">package requirejs;  import com.intellij.ide.util.PropertiesComponent; import com.intellij.lang.javascript.psi.JSCallExpression; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.PsiReferenceProvider; import com.intellij.util.ProcessingContext; import org.jetbrains.annotations.NotNull;  public class RequirejsPsiReferenceProvider extends PsiReferenceProvider {     @NotNull     @Override     public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {         Project project = psiElement.getProject();          PropertiesComponent properties = PropertiesComponent.getInstance(project);         String webDirPrefString = properties.getValue(&quot;web_dir&quot;, &quot;webfront\/web&quot;);         VirtualFile webDir = project.getBaseDir().findFileByRelativePath(webDirPrefString);          if (webDir == null) {             return PsiReference.EMPTY_ARRAY;         }          try {             String path = psiElement.getText();             if (isRequireCall(psiElement)) {                 PsiReference ref = new RequirejsReference(psiElement, new TextRange(1, path.length() - 1), project, webDir);                 return new PsiReference[] {ref};             }         } catch (Exception ignored) {}          return new PsiReference[0];     }      public static boolean isRequireCall(PsiElement element) {         PsiElement prevEl = element.getParent();         if (prevEl != null) {             prevEl = prevEl.getParent();         }          if (prevEl != null) {             if (prevEl instanceof JSCallExpression) {                 try {                     if (prevEl.getChildren().length &gt; 1) {                         if (prevEl.getChildren()[0].getText().toLowerCase().equals(&quot;require&quot;)) {                             return true;                         }                     }                 } catch (Exception ignored) {}             }         }         return false;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438.<br \/>  \u0418 \u0432\u043e\u0442 \u0442\u0443\u0442 \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a \u0437\u0430\u0442\u044b\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u043e\u0447\u0435\u043d\u044c \u0441\u043a\u0443\u043f\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432 \u043a idea. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0444\u0430\u0439\u043b\u043e\u0432 \u043e\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u043a\u0430\u043a \u00abResource Root\u00bb, \u043d\u043e \u0443\u0432\u044b \u044f \u043d\u0435 \u0441\u043c\u043e\u0433 \u043d\u0430\u0439\u0442\u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u0431\u0440\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u0434\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0438\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u0430\u043a \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"http:\/\/habrahabr.ru\/users\/zenden2k\/\" class=\"user_link\">zenden2k<\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043f\u043e \u043f\u0443\u0442\u0438, \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u0423 \u043a\u043b\u0430\u0441\u0441\u0430 VirtualFile \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 findFileByRelativePath, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0443\u0442\u0438, \u0438 \u0438\u0449\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0444\u0430\u0439\u043b \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0438 \u0435\u0441\u0442\u044c \u0434\u0430, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u043a\u0430\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 VirtualFile \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u0430\u043a \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u0437\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 PsiElement, \u0432\u044b\u0440\u0435\u0437\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0435\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b. \u0415\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0435\u0433\u043e \u0432 \u0432\u0438\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 PsiElement. \u041c\u0435\u0442\u043e\u0434 resolve \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">RequirejsReverence.java::resolve()<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">    @Nullable     @Override     public PsiElement resolve() {         String path = element.getText();         path = path.replace(&quot;'&quot;, &quot;&quot;).replace(&quot;\\&quot;&quot;, &quot;&quot;);         if (path.startsWith(&quot;tpl!&quot;)) {             path = path.replace(&quot;tpl!&quot;, &quot;&quot;);         } else {             path = path.concat(&quot;.js&quot;);         }         if (path.startsWith(&quot;.\/&quot;)) {             path = path.replaceFirst(                     &quot;.&quot;,                     element                             .getContainingFile()                             .getVirtualFile()                             .getParent()                             .getPath()                             .replace(webDir.getPath(), &quot;&quot;)             );         }         VirtualFile targetFile = webDir.findFileByRelativePath(path);          if (targetFile != null) {             return PsiManager.getInstance(project).findFile(targetFile);         }          return null;     } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0432 \u044d\u0442\u043e \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a \u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e-\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0412 idea \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e-\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 getVariants \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 PsiReference, \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c CompletionContributor. \u042f \u0432 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043e\u0431\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430, \u043d\u043e \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u0432 CompletionContributor, \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0435 \u043d\u0430\u0448\u0451\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430.<br \/>  \u0414\u043b\u044f \u0430\u0432\u0442\u043e-\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, LoookupElement \u0438\u043b\u0438 PsiElement.<br \/>  \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u043e \u0442\u0443\u0442 \u043c\u0435\u043d\u044f \u0436\u0434\u0430\u043b \u0441\u044e\u0440\u043f\u0440\u0438\u0437. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c \u0447\u0442\u043e idea \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e \u0441\u043b\u0435\u0448\u0430\u043c\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0441\u043b\u0435\u0448\u0430 \u0432\u0441\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0441\u043b\u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u043b\u0435 \u0441\u043b\u0435\u0448\u0430, \u0442\u043e idea \u043d\u0435 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u0430\u043a \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0434\u043b\u044f \u0430\u0432\u0442\u043e-\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043d\u0435 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u0418 \u043d\u0430\u0439\u0442\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e-\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0441\u043e \u0441\u043b\u0435\u0448\u0430\u043c\u0438 \u0438\u043b\u0438 \u043a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043f\u0443\u0442\u044f\u043c\u0438 \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<br \/>  \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443.<br \/>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u0441\u0430\u043c\u043e\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 InsertHandler \u0438 \u0432 \u043d\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 handleInsert \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0410 \u0447\u0442\u043e \u0431\u044b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0443, \u0430 LookupElement, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c InsertHandler.<br \/>  \u0422\u0430\u043a \u0447\u0442\u043e \u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043b \u043a\u043b\u0430\u0441\u0441 LookupElement, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">RequirejsLookupElement.java<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">package requirejs;  import com.intellij.codeInsight.completion.InsertHandler; import com.intellij.codeInsight.completion.InsertionContext; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull;  public class RequirejsLookupElement extends LookupElement {     String path;     PsiElement element;     private InsertHandler&lt;LookupElement&gt; insertHandler = null;      public RequirejsLookupElement(String path, InsertHandler&lt;LookupElement&gt; insertHandler, PsiElement element) {         this.path = path;         this.insertHandler = insertHandler;         this.element = element;     }      public void handleInsert(InsertionContext context) {         if (this.insertHandler != null) {             this.insertHandler.handleInsert(context, this);         }     }      @NotNull     @Override     public String getLookupString() {         return path;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f InsertHandler \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">RequirejsInsertHandler.java<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">package requirejs;  import com.intellij.codeInsight.completion.InsertHandler; import com.intellij.codeInsight.completion.InsertionContext; import com.intellij.codeInsight.lookup.LookupElement;  public class RequirejsInsertHandler implements InsertHandler {     private static final RequirejsInsertHandler instance = new RequirejsInsertHandler();      @Override     public void handleInsert(InsertionContext insertionContext, LookupElement lookupElement) {         if (lookupElement instanceof RequirejsLookupElement) {             insertionContext.getDocument().replaceString(                     ((RequirejsLookupElement) lookupElement).element.getTextOffset() + 1,                     insertionContext.getTailOffset(),                     ((RequirejsLookupElement) lookupElement).path             );         }     }      public static RequirejsInsertHandler getInstance() {         return instance;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0421\u0443\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 handleInsert \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u043c\u044b \u0431\u0435\u0440\u0451\u043c lookupElement \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c PsiElement \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u0431\u044b\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0438 \u0432\u044b\u0431\u0440\u0430\u043d, \u0438\u0437 PsiElement \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0438\u0437 lookupElement.path \u0432\u0441\u044e \u0434\u043b\u0438\u043d\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043d\u043e \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u044f \u043d\u0430\u0439\u0442\u0438 \u043d\u0435 \u0441\u043c\u043e\u0433.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u043e\u0438\u0441\u043a \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u0438\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 LookupElement.<br \/>  \u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 RequirejsReference:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">RequirejsReference.java<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">package requirejs;  import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl; import com.intellij.openapi.vfs.newvfs.impl.VirtualFileImpl; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiManager; import com.intellij.psi.PsiReference; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;  import java.util.ArrayList;  public class RequirejsReference implements PsiReference {     PsiElement element;     TextRange textRange;     Project project;     VirtualFile webDir;      public RequirejsReference(PsiElement element, TextRange textRange, Project project, VirtualFile webDir) {         this.element = element;         this.textRange = textRange;         this.project = project;         this.webDir = webDir;     }      @Override     public PsiElement getElement() {         return this.element;     }      @Nullable     @Override     public PsiElement resolve() {         String path = element.getText();         path = path.replace(&quot;'&quot;, &quot;&quot;).replace(&quot;\\&quot;&quot;, &quot;&quot;);         if (path.startsWith(&quot;tpl!&quot;)) {             path = path.replace(&quot;tpl!&quot;, &quot;&quot;);         } else {             path = path.concat(&quot;.js&quot;);         }         if (path.startsWith(&quot;.\/&quot;)) {             path = path.replaceFirst(                     &quot;.&quot;,                     element                             .getContainingFile()                             .getVirtualFile()                             .getParent()                             .getPath()                             .replace(webDir.getPath(), &quot;&quot;)             );         }         VirtualFile targetFile = webDir.findFileByRelativePath(path);          if (targetFile != null) {             return PsiManager.getInstance(project).findFile(targetFile);         }          return null;     }      @Override     public String toString() {         return getCanonicalText();     }      @Override     public boolean isSoft() {         return false;     }      @NotNull     @Override     public Object[] getVariants() {         ArrayList&lt;String&gt; files = filterFiles(this.element);          ArrayList&lt;LookupElement&gt; completionResultSet = new ArrayList&lt;LookupElement&gt;();          for (int i = 0; i &lt; files.size(); i++) {             completionResultSet.add(                     new RequirejsLookupElement(                             files.get(i),                             RequirejsInsertHandler.getInstance(),                             this.element                     )             );         }          return completionResultSet.toArray();     }      protected ArrayList&lt;String&gt; getAllFilesInDirectory(VirtualFile directory) {         ArrayList&lt;String&gt; files = new ArrayList&lt;String&gt;();          VirtualFile[] childrens = directory.getChildren();         if (childrens.length != 0) {             for (int i = 0; i &lt; childrens.length; i++) {                 if (childrens[i] instanceof VirtualDirectoryImpl) {                     files.addAll(getAllFilesInDirectory(childrens[i]));                 } else if (childrens[i] instanceof VirtualFileImpl) {                     files.add(childrens[i].getPath().replace(webDir.getPath() + &quot;\/&quot;, &quot;&quot;));                 }             }         }          return files;     }      protected ArrayList&lt;String&gt; filterFiles (PsiElement element) {         String value = element.getText().replace(&quot;'&quot;, &quot;&quot;).replace(&quot;\\&quot;&quot;, &quot;&quot;).replace(&quot;IntellijIdeaRulezzz &quot;, &quot;&quot;);         Boolean tpl = value.startsWith(&quot;tpl!&quot;);         String valuePath = value.replaceFirst(&quot;tpl!&quot;, &quot;&quot;);          ArrayList&lt;String&gt; allFiles = getAllFilesInDirectory(webDir);         ArrayList&lt;String&gt; trueFiles = new ArrayList&lt;String&gt;();          String file;          for (int i = 0; i &lt; allFiles.size(); i++) {             file = allFiles.get(i);             if (file.startsWith(valuePath)) {                 if (tpl && file.endsWith(&quot;.html&quot;)) {                     trueFiles.add(&quot;tpl!&quot; + file);                 } else if (file.endsWith(&quot;.js&quot;)) {                     trueFiles.add(file.replace(&quot;.js&quot;, &quot;&quot;));                 }             }         }          return trueFiles;     }      @Override     public boolean isReferenceTo(PsiElement psiElement) {         return false;     }      @Override     public PsiElement bindToElement(@NotNull PsiElement psiElement) throws IncorrectOperationException {         throw new IncorrectOperationException();     }      @Override     public PsiElement handleElementRename(String s) throws IncorrectOperationException {         throw new IncorrectOperationException();     }      @Override     public TextRange getRangeInElement() {         return textRange;     }      @NotNull     @Override     public String getCanonicalText() {         return element.getText();     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u042f \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0438\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439, \u0438 \u0442\u0430\u043a \u0436\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u043c\u0435\u0442\u043e\u0434 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u0442\u0435\u043c\u043f\u043b\u0435\u0439\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e html, \u0430 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u044b js \u0444\u0430\u0439\u043b\u044b. \u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0435 \u0442\u0435\u043c\u043f\u043b\u0435\u0439\u0442\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c tpl!, \u0430 js \u0444\u0430\u0439\u043b\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f js.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451.<br \/>  \u0415\u0441\u0442\u044c \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0441\u043e\u0432\u0435\u0442\u044b \u043a\u0430\u043a \u043b\u0443\u0447\u0448\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0438\u0445 \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/189168\/\"> http:\/\/habrahabr.ru\/post\/189168\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0435\u0435 \u0430\u0432\u0442\u043e-\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 IDE \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 IDEA. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a WebStorm \u0438\u043b\u0438 PhpStrom.<\/p>\n<p>  \u0423 \u043d\u0430\u0441 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 require.js. \u0418 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u0438 \u043a \u0442\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c \u0447\u0442\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043f\u0443\u0442\u0438 \u043a \u044d\u0442\u0438\u043c \u0444\u0430\u0439\u043b\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438 \u0438\u043b\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c.<br \/>  \u0418 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u0432\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438 \u0434\u043e \u0444\u0430\u0439\u043b\u043e\u0432.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-189168","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/189168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=189168"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/189168\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=189168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=189168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=189168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}