Softbankのsecure.softbank.ne.jpがなくなってEnd-to-EndのSSLで気をつけるところ
携帯サイト閲覧時の重要なお知らせ
http://mb.softbank.jp/mb/information/details/101015.html
ということで微妙な仕様であったsecure.softbank.ne.jpがなくなりEnd-to-EndのSSLのみとなります。
この変更で独自ヘッダがすべて取得できなくなるのでx-jphone-msnameなどが取得できなくなり、機種判別をx-jphone-msnameで行っている場合などには機種が正常に取得できなくなってしまいます。
SSLでx-jphone-uidを利用している場合はそもそもやめたほうがよいでしょう。
(現状でも直接httpsページにアクセスすればEnd-to-EndのSSLとなり、x-jphone-uidを送ることができるため)
perl editor のpluginを作る コードアシスト すごく単純なもの
eclipseなんだしコードアシストは必須要件!
ただperlはコード上で変数がオブジェクトなのかはたまたなんのオブジェクトなのかの判断が難しい。
そこでctagsを利用し(5.7以降) キーワードファイルを作成しそれを元にコードアシストすることにする。
まずコードアシスト(ctrl+space)を押したときに候補となるリストを返却するクラスを実装する。
package com.appspot.charisoku30km.editor.perl.editors; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.CompletionProposal; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; public class PerlAssistProcessor implements IContentAssistProcessor { public PerlAssistProcessor(){ } //IContentAssistProcessorのメソッドの実装 //コードアシストの候補となるキーワード(ICompletionProposalオブジェクト)の配列を返します @Override public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { String currentWord = getCurrentWord(viewer.getDocument(), offset); CompletionProposal[] words = new CompletionProposal[1]; //現在の対象の文字列の長さと候補のワードの文字列の長さをから //置き換えるべき長さなどを設定しています。 words[0] = new CompletionProposal( "nurupo", offset - currentWord.length(), currentWord.length(), "nurupo".length() ); return words; } //現在対象となっている文字列を取得する private String getCurrentWord(IDocument document, int documentOffset) { StringBuffer currentWord = new StringBuffer(); char ch; try { for (int offset = documentOffset - 1 ; offset >=0 && !Character.isWhitespace(ch = document.getChar(offset)) ; offset--) { currentWord.insert(0, ch); } return currentWord.toString(); } catch (Exception e) { return null; } } @Override public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { // TODO Auto-generated method stub return null; } @Override public char[] getCompletionProposalAutoActivationCharacters() { // TODO Auto-generated method stub return null; } @Override public char[] getContextInformationAutoActivationCharacters() { // TODO Auto-generated method stub return null; } @Override public IContextInformationValidator getContextInformationValidator() { // TODO Auto-generated method stub return null; } @Override public String getErrorMessage() { // TODO Auto-generated method stub return null; } }
nurupoという文字列をアシスト候補として返却します。
次のSourceViewerConfigurationを継承し、このエディタ用のSourceViewerConfigurationを実装します。
package com.appspot.charisoku30km.editor.perl.editors; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.contentassist.ContentAssistant; import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; public class PerlConfiguration extends SourceViewerConfiguration { public PerlConfiguration() { } //コンテンツアシスト設定の実装 //デフォルトドキュメントの区画に対しPerlAssistProcessorを設定します。 //デフォルトドキュメントの区画は現在の実装ではコードのどこでもデフォルトドキュメントの区画となります。 public IContentAssistant getContentAssistant (ISourceViewer sourceViewer) { ContentAssistant assistant = new ContentAssistant(); PerlAssistProcessor processor = new PerlAssistProcessor(); assistant.setContentAssistProcessor(processor,IDocument.DEFAULT_CONTENT_TYPE); assistant.install(sourceViewer); return assistant; } }
コンテンツアシストの実装と設定クラスができたらPerlOreditorクラスにこの作成した設定クラスPerlConfigurationを設定してあげます
package com.appspot.charisoku30km.editor.perl.editors; import com.appspot.charisoku30km.editor.perl.editors.PerlConfiguration; import org.eclipse.ui.editors.text.TextEditor; public class PerlOreditor extends TextEditor { public PerlOreditor() { super(); setSourceViewerConfiguration(new PerlConfiguration()); } }
これで起動してctrl+spaceでnurupoと表示されたらOKだ!
perl editor のpluginを作る 基本エディタ
とりあえず何も機能もないエディタを作る
package com.appspot.charisoku30km.editor.perl.editors; import org.eclipse.ui.editors.text.TextEditor; public class PerlOreditor extends TextEditor { public PerlOreditor() { super(); } }
デフォルトのテキストエディタをとりあえず継承。
これを起動するるだけでエディタとして動く。
基本的な機能はこれに含まれているだろうからこれを肉付けしていく形で実装していく。
いらっとする
単語にある薄いリンクの線・・・
消したいよ どこから消すんだー
perl editor のpluginを作る 起動
ということで早速つくりはじめるよ!
eclipseは3.5.2を利用
色々プラグインはいってて移行がめんどいからね!
たぶん3.6でもうごくでしょ みたいなそんな感じ
New->Project->Other->Plugin Development->Plugin Project
で適当にwizardを進めて今回はedtiorのtemplateをつかっちゃうよ!
ちなみにtemplateではXMLEditorが出来上がるよ
これのソースを見て適当にいじっていくんだ!
ということでFinish!!
おお できた!XMLEditorができた!
完成だ!
ということでこのお話はおしまい^^
ってちがうよ!おじさんがほしいのはPerlだよ Perl
XMLじゃーないんだ!
まぁなにわともわれXML Editorを起動してみる
できたprojectにあるMETA-INF/MAINFEST.MFをクリックすると
なにやらでてくるのでそこにある
Launch an Eclipse Applicationを選択するとeclipseがもう一個起動してうごきだすぞ!
ただでさえ重いのにもういっこ動くなんてなんて素晴らしいんだ!
起動したあとprojectをつくってxmlファイルをつくって
さらにxmlファイルを作ったeditor(Sample XML Editor)で開くようにしないと
ためせないぞ!
ということで今回はここまで!
次からちゃんとつくる!
perl editor のpluginを作る はじまり
eclipseにperl editorのプラグインがいまいちよろしくないので自分でつくることにする
vimやEmacsは見なかったことにする ボクはeclipseが使いたい 使いたい
ためしたけど、んーーだったもの
・eclipse外部エディタのvim組み込み(gvimをプラグインを通してつかう
重すぎた 無理すぎた
・epic
syntax checkいらない レポジトリのファイルが多すぎておわらない
syntax checkいらないとおもってperlの設定をperl -v にするむなしさ
ということで自分でeditorをつくってみることにする。
ちなみにeclipse pluginなんてさわったことがない