锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="com.ebay.tools.vjet2.internal.debug.property.LaunchPropertyTester"
id="com.ebay.tools.vjet2.debug.property.launch"
namespace="com.ebay.tools.vjet2.debug"
properties="launchJS,launchHTML"
type="org.eclipse.core.runtime.IAdaptable">
</propertyTester>
</extension>
Specified class should be extends PropertyTester and implement related methods.
LaunchPropertyTester extends PropertyTester {
Others services register.
IFocusService focusService = (IFocusService) PlatformUI.getWorkbench() .getService(IFocusService.class); focusService.addFocusTracker(text, "textControlId");
All variables collected in ISources class, User can find related variables in this class.
鏂扮壒鎬т箣鍏細(xì)鏂板鍔?縐嶅惎鍔ㄧ晫闈紱
Interactive: A simulated log-in session 浣跨敤涓涓▼搴忕櫥闄嗙晫闈㈠惎鍔?br />
Browser: An embedded HTML browser 浣跨敤涓涓狧tml浣滀負(fù)鐧婚檰鐣岄潰
Extensible: A dynamic set of image contributions 浣跨敤涓寮犲浘鐗囦綔涓哄惎鍔ㄧ晫闈?br />
鍦ㄦ柊鐨凱DE涓彲浠ュ涓涓猵roduct閫夋嫨浣跨敤閭d竴縐嶅惎鍔ㄧ晫闈㈠惎鍔紝榪欎釜鏂板姛鑳界殑澧炲姞鏄潪甯告湁鎰忎箟鐨勶紝瀹冧嬌寰桼CP搴旂敤鏇村姞鐨勪漢鎬у寲錛屼笉鐢ㄥ啀鍦ㄧ郴緇熷惎鍔ㄤ腑寮瑰嚭瀵硅瘽妗嗕簡錛岃瀹㈡埛鏇村姞鏀懼績鐨勯夋嫨鍩轟簬RCP鐨勪駭鍝佷簡~
Eclipse3.4鍙戝竷 鏂扮壒鎬у睍紺?
|
涓婁竴綃囨枃绔?/font>鎴戜滑鐭ラ亾浜咵clipse寮瑰嚭鑿滃崟鐨勫熀鏈敤娉曘傚叾瀹濫clipse鐨勫脊鍑鴻彍鍗曞彲浠ョ敤鏉ュ仛寰堝鏂囩珷錛岀畝鍗曚竴鐐圭殑鏍規(guī)嵁鏂囦歡綾誨埆錛屾垜浠彲浠ヨ繘琛屼笉鍚岀殑鏂囦歡鎿嶄綔錛屾瘮濡侫nt鐨刡uild.xml鎴戜滑鍙互鐢ㄦ潵build錛孞ava鏂囦歡鎴戜滑鍙互鐢↗ava Editor鎵撳紑錛岃繖浜涘熀浜庢枃浠剁被鍨嬬殑鎿嶄綔鎴戜滑閮藉彲浠ュ緢瀹規(guī)槗鐨勫疄鐜般備絾鏄繕鏈変竴縐嶆儏鍐碉紝濡傛灉鏂囦歡綾誨瀷涓鏍鳳紝鎴戜滑鎯寵繘琛屼笉鍚岀殑鎿嶄綔錛岃鎬庝箞瀹炵幇鍛紵瀹為檯涓婅繖鏍風(fēng)殑搴旂敤寰堝錛屾瘮濡傚悓鏍鋒槸Java鏂囦歡錛屽惈鏈塵ain鏂規(guī)硶鐨凧ava鏂囦歡鏈塕un鍜孌ebug鐨勯夐」錛屽叾瀹冪殑閮芥病鏈夈傝繕鏈夌幇鍦ㄧ殑妗嗘灦閮芥槸鍩轟簬XML鏂囦歡榪涜閰嶇疆鐨勶紝濡傛灉涓涓」鐩嬌鐢ㄤ簡澶氫釜妗嗘灦錛屾垜浠庝箞鏍規(guī)嵁涓嶅悓鐨刋ML鏂囦歡榪涜妗嗘灦鐨勫尯鍒嗗憿錛熺瓟妗堝氨鏄痚nablement鐨則est銆?/font>
<!ELEMENT test EMPTY>
<!ATTLIST test
property CDATA #REQUIRED
args CDATA #IMPLIED
value CDATA #IMPLIED>
This element is used to evaluate the property state of the object in focus. The set of testable properties can be extended using the propery tester extension point. The test expression returns EvaluationResult.NOT_LOADED if teh property tester doing the actual testing isn't loaded yet.
姣斿鎴戜滑瑕佽鍚湁main鏂規(guī)硶鐨凧ava鏂囦歡瀹冪殑鍙抽敭寮瑰嚭鑿滃崟鍖呭惈涓涓澶栫殑閫夐」“This is main class”錛岄渶瑕佺紪鍐欏涓嬬殑Plugin.xml錛?/font>
鎴戜滑闇瑕佹嫻嬪湪褰撳墠鎯呭喌涓嬫槸鍚﹂渶瑕佹樉紺鴻繖涓彍鍗曢」錛屼嬌鐢ㄦ墿灞曠偣 org.eclipse.core.expressions.propertyTesters 錛?br />
<!ELEMENT propertyTester EMPTY>
<!ATTLIST propertyTester
id CDATA #REQUIRED
type CDATA #REQUIRED
namespace CDATA #REQUIRED
properties CDATA #REQUIRED
class CDATA #REQUIRED>
id - unique identifier for the property tester
type - the type to be extended by this property tester
namespace - a unique id determining the name space the properties are added to
properties - a comma separated list of properties provided by this property tester
class - the name of the class that implements the testing methods. The class must be public and extend org.eclipse.core.expressions.PropertyTester with a public 0-argument constructor.
榪欓噷鍙』娉ㄦ剰 propertyTester鐨刵amespace鍜宲roperties姝eソ瀵瑰簲test鐨刾roperty銆?br />
鑷充簬媯嫻嬬殑閫昏緫鎴戜滑鍦╝dvancedpopupmenus.popup.actions.VisablePropertyTester涓疄鐜幫紝榪欎釜綾誨繀欏葷戶鎵胯嚜org.eclipse.core.expressions.PropertyTester銆?/font>
鎴戜滑鍙鍒ゆ柇鎺ュ彈鐨凧ava鏂囦歡涓槸鍚﹀惈鏈塵ain鏂規(guī)硶錛屽鏋滄湁錛屽垯榪斿洖True錛屾病鏈夊垯榪斿洖False銆?br />
濡傛灉鎴戜滑鏄鎺ュ彈涓涓猈eb寮鍙戠殑閰嶇疆鏂囦歡錛屾垜浠彲浠ヨ繖鏍峰啓錛?/font>
娉ㄦ剰鍜屼笂涓涓緥瀛愪笉鍚岀殑鍦版柟錛宱bjectClass錛宯ameFileter鍜宼ype(鍦ㄤ笂涓涓緥瀛愪腑錛屾垜浠篃鍙互浣跨敤objectClass="org.eclipse.core.resources.IFile" nameFilter ="*.java" )錛岀浉搴旂殑鎴戜滑鐨刅isablePropertyTester綾諱篃瑕佸仛涓浜涙敼鍔細(xì)
榪欐牱鏍規(guī)嵁涓嶅悓鐨剎ml SystemID錛屾垜浠氨鑳藉鐭ラ亾鍒板簳榪欐槸鍝竴縐嶆鏋剁殑閰嶇疆鏂囦歡浜嗐?/font>
鏈涓嬮潰涓琛屾槸鍚姩鏃訛紝鏄劇ずMyEclipse鐨勫浘鐗囷紝濡傛灉娌℃湁榪欏彞璇濊繍琛?MyEclipse 6.0.1"蹇嵎鏂瑰紡錛屽垯浼?xì)鏄窘C篹clipse鐨勫惎鍔ㄧ敾闈紝鍏跺疄"MyEclipse 6.0.1"蹇嵎鏂瑰紡榪樻槸榪炴帴鐫eclipse.exe榪欎釜鎵ц紼嬪簭錛屽湪"MyEclipse 6.0.1"涓婄偣鍙抽敭錛岄夋嫨灞炴э紝鍦ㄧ洰鏍囬噷灝卞彲浠ョ湅鍒般?br />
絎?姝ワ細(xì)娉ㄥ唽MyEclipse
MyEclipse6.0鐨勬敞鍐屼竴瀹氳鏂紑緗戠粶錛屽惁鍒欒偗瀹氫笉鎴愬姛錛?br />
6.0.1GA娉ㄥ唽鐮?br />
Subscriber: administrator
Subscription Code: nLR7ZL-655342-54657656405281154
榪欓噷鏈変竴鐐瑰ぇ璞¤鎻愰啋澶у娉ㄦ剰錛屽鏋滀綘鐢?shù)鑴戜笂鐜板湪姝f湁鋴社敤鐨凪yEclipse錛屽氨鏄宸茬粡娉ㄥ唽浜嗭紝閭d箞鍦–:\Documents and Settings\"鑷繁鐨勭敤鎴峰悕" 鐩綍涓嬶紝浼?xì)鏈変竴涓?.myeclipse.properties"鏂囦歡錛岃繖鏃惰鍏堝浠芥鏂囦歡錛岀劧鍚庡垹闄ゅ畠錛屾柇寮緗戠粶錛屽啀鏉ユ敞鍐孧yEclipse6.0.1錛屾垚鍔熷悗濡備笅錛?br />
鍏朵腑createAST錛屽綋parse闇瑕佽緝闀挎椂闂存椂錛屽彲浠ラ噰鐢╟reateAST(new NullProgressMonitor())錛屽惁鍒欑洿鎺ヤ紶null鍗沖彲銆?/font>
recordModifications()鐢ㄤ簬璁板綍鑺傜偣鐨勫彉鍔紝姣斿淇敼銆佸垹闄ょ瓑錛屽綋闇瑕佸AST鏍?wèi)杩涜鍙樺姩鎿嶄綔鏃跺Q屽繀欏昏棰勫厛璋冪敤榪欎釜鏂規(guī)硶銆?/font>
姣旇緝閲嶈鐨勬槸錛氫竴涓狝ST鏍?wèi)涓婄殑鎵鏈夎妭鐐瑰繀欏婚兘灞炰簬璇ST銆備笉鍏佽鐩存帴灝嗗叾浠朅ST鏍?wèi)涓婄殑鑺傜傄?guī)坊鍔犺AST鏍?wèi)涓娿傚惁鍒欎細(xì)鎶涘嚭java.lang.IllegalArgumentException寮傚父銆傞』浣跨敤ASTNode.copySubtree(AST target, ASTNode node)榪斿洖涓涓洰鏍囨爲(wèi)鐨勬繁搴︽嫹璐濓紝鎵嶈兘榪涜娣誨姞鎿嶄綔銆備緥濡?
// package astexplorer;java 浠g爜
- PackageDeclaration packageDeclaration = ast.newPackageDeclaration();
- unit.setPackage(packageDeclaration);
- packageDeclaration.setName(ast.newSimpleName("astexplorer"));
// import org.eclipse.swt.SWT;
// import org.eclipse.swt.events.*;
// import org.eclipse.swt.graphics.*;
// import org.eclipse.swt.layout.*;
// import org.eclipse.swt.widgets.*;java 浠g爜
- for (int i = 0; i < IMPORTS.length; ++i) {
- ImportDeclaration importDeclaration = ast.newImportDeclaration();
- importDeclaration.setName(ast.newName(getSimpleNames(IMPORTS[i])));
- if (IMPORTS[i].indexOf("*") > 0)
- importDeclaration.setOnDemand(true);
- else
- importDeclaration.setOnDemand(false);
- unit.imports().add(importDeclaration);
- }
// public class SampleComposite extends Composite
java 浠g爜
- TypeDeclaration classType = ast.newTypeDeclaration();
- classType.setInterface(false);
- classType.setModifiers(Modifier.PUBLIC);
- classType.setName(ast.newSimpleName("SampleComposite"));
- classType.setSuperclass(ast.newSimpleName("Composite"));
- unit.types().add(classType);
List 4 鐢熸垚Constructor Declaration
// public SampleComposite(Composite parent,int style){}
java 浠g爜
- MethodDeclaration methodConstructor = ast.newMethodDeclaration();
- methodConstructor.setConstructor(true);
- methodConstructor.setModifiers(Modifier.PUBLIC);
- methodConstructor.setName(ast.newSimpleName("SampleComposite"));
- classType.bodyDeclarations().add(methodConstructor);
- // constructor parameters
- SingleVariableDeclaration variableDeclaration = ast.newSingleVariableDeclaration();
- variableDeclaration.setModifiers(Modifier.NONE);
- variableDeclaration.setType(ast.newSimpleType(ast.newSimpleName("Composite")));
- variableDeclaration.setName(ast.newSimpleName("parent"));
- methodConstructor.parameters().add(variableDeclaration);
- variableDeclaration = ast.newSingleVariableDeclaration();
- variableDeclaration.setModifiers(Modifier.NONE);
- variableDeclaration.setType(ast.newPrimitiveType(PrimitiveType.INT));
- variableDeclaration.setName(ast.newSimpleName("style"));
- methodConstructor.parameters().add(variableDeclaration);
- Block constructorBlock = ast.newBlock();
- methodConstructor.setBody(constructorBlock);
List 5 鐢熸垚Spuer Invocation
// super(parent,style)
java 浠g爜
- SuperConstructorInvocation superConstructorInvocation = ast.newSuperConstructorInvocation();
- constructorBlock.statements().add(superConstructorInvocation);
- Expression exp = ast.newSimpleName("parent");
- superConstructorInvocation.arguments().add(exp);
- superConstructorInvocation.arguments().add(ast.newSimpleName("style"));
List 6 鐢熸垚ClassInstanceCreation
// GridLayout gridLayout = new GridLayout();
java 浠g爜
- VariableDeclarationFragment vdf = ast.newVariableDeclarationFragment();
- vdf.setName(ast.newSimpleName("gridLayout"));
- ClassInstanceCreation cc = ast.newClassInstanceCreation();
- cc.setName(ast.newSimpleName("GridLayout"));
- vdf.setInitializer(cc);
- VariableDeclarationStatement vds = ast.newVariableDeclarationStatement(vdf);
- vds.setType(ast.newSimpleType(ast.newSimpleName("GridLayout")));
- constructBlock.statements().add(vds);
// Label label = new Label(this,SWT.NONE);
java 浠g爜
- VariableDeclarationFragment vdf = ast.newVariableDeclarationFragment();
- vdf.setName(ast.newSimpleName("label"));
- cc = ast.newClassInstanceCreation();
- cc.setName(ast.newSimpleName("Label"));
- cc.arguments().add(ast.newThisExpression());
- cc.arguments().add(ast.newName(getSimpleNames("SWT.NONE")));
- vdf.setInitializer(cc);
- VariableDeclarationStatement vds = ast.newVariableDeclarationStatement(vdf);
- vds.setType(ast.newSimpleType(ast.newSimpleName("Label")));
- constructBlock.statements().add(vds);
List 7鐢熸垚MethodInvocation
// setLayout(gridLayout);
java 浠g爜
- MethodInvocation mi = ast.newMethodInvocation();
- mi.setName(ast.newSimpleName("setLayout"));
- mi.arguments().add(ast.newSimpleName("gridLayout"));
- constructorBlock.statements().add(ast.newExpressionStatement(mi));
// label.setText("Press the button to close:");
java 浠g爜
- mi = ast.newMethodInvocation();
- mi.setExpression(ast.newSimpleName("label"));
- mi.setName(ast.newSimpleName("setText"));
- StringLiteral sl = ast.newStringLiteral();
- sl.setLiteralValue("Press the button to close:");
- mi.arguments().add(sl);
- constructorBlock.statements().add(ast.newExpressionStatement(mi));
// label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
java 浠g爜
- mi = ast.newMethodInvocation();
- mi.setExpression(ast.newSimpleName("label"));
- mi.setName(ast.newSimpleName("setLayoutData"));
- cc = ast.newClassInstanceCreation();
- cc.setName(ast.newSimpleName("GridData"));
- cc.arguments().add(ast.newName(getSimpleNames("GridData.HORIZONTAL_ALIGN_CENTER")));
- mi.arguments().add(cc);
- constructorBlock.statements().add(ast.newExpressionStatement(mi));
// Button button = new Button(this,SWT.PUSH);
java 浠g爜
- vdf = ast.newVariableDeclarationFragment();
- vdf.setName(ast.newSimpleName("button"));
- vds = ast.newVariableDeclarationStatement(vdf);
- vds.setType(ast.newSimpleType(ast.newSimpleName("Button")));
- constructorBlock.statements().add(vds);
- cc = ast.newClassInstanceCreation();
- cc.setName(ast.newSimpleName("Button"));
- vdf.setInitializer(cc);
- cc.arguments().add(ast.newThisExpression());
- cc.arguments().add(ast.newName(getSimpleNames("SWT.PUSH")));
// button.addSelectionListener(new SelectionAdapter() {});
java 浠g爜
- mi = ast.newMethodInvocation();
- constructorBlock.statements().add(ast.newExpressionStatement(mi));
- mi.setExpression(ast.newSimpleName("button"));
- mi.setName(ast.newSimpleName("addSelectionListener"));
- ClassInstanceCreation ci = ast.newClassInstanceCreation();
- ci.setName(ast.newSimpleName("SelectionAdapter"));
- mi.arguments().add(ci);
- AnonymousClassDeclaration cd = ast.newAnonymousClassDeclaration();
- ci.setAnonymousClassDeclaration(cd);
// public void setup(){super.setUp()}
- MethodDeclaration methodConstructor = ast.newMethodDeclaration();
methodConstructor.modifiers().add(
ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
methodConstructor.setName(ast.newSimpleName("setUp"));- Block constructorBlock = ast.newBlock();
methodConstructor.setBody(constructorBlock);- SuperMethodInvocation smi = ast.newSuperMethodInvocation();
smi.setName(ast.newSimpleName("setUp"));
ExpressionStatement es = ast.newExpressionStatement(smi);
constructorBlock.statements().add(es);- // set exception
List targetExNames = methodConstructor.thrownExceptions();
Name targetExName = ast.newName(Exception.class.getName());
targetExNames.add(targetExName);- methodConstructor.setJavadoc(JavaDocHelper.getJavaDoc(ast,
JavaDocHelper.setUpDoc, null, null));
classType.bodyDeclarations().add(methodConstructor);
package com.wipro.testtools.ui.internal.action;
import java.util.Iterator;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.internal.OpenPreferencesAction;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.actions.OpenPerspectiveDialogAction;
import org.eclipse.ui.internal.dialogs.SelectPerspectiveDialog;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.preference.IPreferencePage;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.swt.widgets.Shell;
public class OpenPreferencePages implements IWorkbenchWindowActionDelegate {
public OpenPreferencePages() {
super();
}
private IWorkbenchWindow workbenchWindow;
public void dispose() {
}
public void init(IWorkbenchWindow window) {
workbenchWindow = window;
}
public void run(IAction action) {
ts2();
}
private void ts2() {
// OpenPreferencesAction action = new OpenPreferencesAction();
// OpenPerspectiveDialogAction action = new
// OpenPerspectiveDialogAction(null);
// action.run();
String ourPreferenceDialog = "com.wipro.testtools.ui.preferences.SamplePreferencePage";
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, ourPreferenceDialog, new String[]{ourPreferenceDialog}, null);
dialog.open();
}
/**
*
*/
private void ts1() {
String PreferenceNodeId = "org.eclipse.ui.preferencePages.Workbench";
PreferenceDialogWrapper dialog = null;
PreferenceManager manager = WorkbenchPlugin.getDefault()
.getPreferenceManager();
if (manager != null) {
dialog = new PreferenceDialogWrapper(getShell(), manager);
dialog.create();
// WorkbenchHelp.setHelp(dialog.getShell(),
// IHelpContextIds.PREFERENCE_DIALOG);
for (Iterator iterator = manager.getElements(
PreferenceManager.PRE_ORDER).iterator(); iterator.hasNext();) {
IPreferenceNode node = (IPreferenceNode) iterator.next();
System.out.println(node.getId());
if (node.getId().equals(PreferenceNodeId)) {
dialog.showPage(node);
}
}
dialog.open();
}
}
public void selectionChanged(IAction action, ISelection selection) {
}
private Shell getShell() {
return DialogCheck.getShell();
}
}
class PreferenceDialogWrapper extends PreferenceDialog {
public PreferenceDialogWrapper(Shell parentShell, PreferenceManager manager) {
super(parentShell, manager);
super.setSelectedNodePreference("PreferenceNodeId");// this is added
}
public boolean showPage(IPreferenceNode node) {
return super.showPage(node);
}
public IPreferencePage getPage(IPreferenceNode node) {
if (node == null)
return null;
if (node.getPage() == null)
node.createPage();
if (node.getPage() == null)
return null;
return node.getPage();
}
}
class DialogCheck {
private DialogCheck() {
}
private static VerifyDialog _verifyDialog;
public static Shell getShell() {
Shell shell = WorkbenchPlugin.getDefault().getWorkbench()
.getActiveWorkbenchWindow().getShell();
_verifyDialog = new VerifyDialog(shell);
_verifyDialog.create();
return _verifyDialog.getShell();
}
}
class VerifyDialog extends TitleAreaDialog {
public VerifyDialog(Shell parent) {
super(parent);
}
}
鍏跺疄eclipse鎻愪緵浜嗚繖鏍風(fēng)殑API: See the TS2 Method:
Just two line codes. :(
CSS鎻掍歡錛?a >http://csseditor.sourceforge.net
JS鍜孉S鎻掍歡錛?a >http://sourceforge.net/projects/jseditor
XML鎻掍歡錛?a >http://xmlbuddy.com
姝e垯琛ㄨ揪寮忔祴璇曟彃浠訛細(xì)http://brosinski.com/stephan/archives/000028.php
XPath嫻嬭瘯鎻掍歡錛?a >http://www.purpletech.com/xpe/index.jsp
鏇村Eclipse鎻掍歡錛?a >http://eclipse-plugins.2y.net/eclipse/index.jsp
闂鎻愬嚭錛?
褰撴垜浠紪鍐欏畬浠g爜錛屽仛瀹屽崟鍏冩祴璇曠瓑鍚勭嫻嬭瘯鍚庡氨鎻愪氦姝e紡榪愯錛屽彧鑳界敱榪愯鐨勭郴緇熸潵媯嫻嬫垜浠唬鐮佹槸鍚︽湁闂浜嗭紝浠g爜涓殣钘忕殑閿欒鍦ㄧ郴緇熻繍琛岀殑榪囩▼涓鍙戠幇鍚庯紝鐒跺悗鍐嶆潵榪涜鐩稿簲鐨勪慨鏀癸紝閭d箞鍚庢湡淇敼鐨勪唬浠峰氨鐩稿綋楂樹簡銆?/p>
瑙e喅鏂規(guī)硶錛?/b>
鐜板湪鏈夊緢澶欽ava浠g爜鍒嗘瀽宸ュ叿錛孎indBugs涓紑婧愰」鐩綋涓殑涓涓紝瀹冨彲浠ュ府浣犳壘鍒頒唬鐮佷腑闅愯棌鐨勪竴浜涢敊璇紝鎻愬崌浣犵殑浠g爜鑳藉姏涓庣郴緇熷畨鍏ㄥ彲闈犳с?/p>
瀹夎
JDK錛?.5.0 浠巋ttp://java.sun.com涓婂幓涓嬭澆瀹夎
Eclipse錛?.1.1 浠巋ttp://www.eclipse.org 涓婂幓涓嬭澆瑙e帇
FindBugs錛?.9.4 浠巋ttp://findbugs.sourceforge.net/
瀹樻柟鐨勬枃妗?http://findbugs.sourceforge.net/manual/
Eclipse plugin for FindBugs version 0.0.17 浠?http://findbugs.sourceforge.net/downloads.html 涓嬭澆
鎻掍歡綆$悊鎶宸?/b>
鎻愮ず錛氭柊涓嬭澆鐨勬彃浠禤lugIn涓瀹氫笉瑕侀兘鏀懼湪鍘熷鐨凟clipse鐩綍涓嬪幓銆?/p>
姣斿錛欵:\OpenSource\Eclipse\PlugInsNew\
閭d箞灝卞湪%ECLIPSE_HOME%\PlugInsNew\鐩綍涓嬪緩绔媂YZ鐩綍錛岀洰褰曢噷闈㈡槸eclipse鐩綍錛宔clipse鐩綍鍖呭惈鏈塮eatures涓巔lugins涓や釜瀛愮洰褰曪紱緇撴瀯濡備笅鍥炬墍紺猴細(xì)
%ECLIPSE_HOME%\PlugInsNew\XYZ\eclipse\features
%ECLIPSE_HOME%\PlugInsNew\ XYZ\eclipse\plugins
鐒跺悗鍦?ECLIPSE_HOME%\links鐩綍閲屽緩绔嬩竴涓猉YZ.link鐨勬枃浠?
鍐呭濡傛槸錛歱ath=E:/OpenSource/Eclipse/PlugInsNew/XYZ灝變竴琛岃繖鏍風(fēng)殑璺緞鎸囩ず鑰屽凡銆?
褰撶劧錛岄噰鐢ㄧ浉瀵硅礬寰勬潵琛ㄧず鍙兘鏇寸洿瑙備竴浜涳紝鏂逛究榪涜鏂囦歡鏁翠綋縐誨姩鍜屽皬緇勫叏閮ㄦ垚鍛樼殑鍏變韓鍛藉悕鐢紝鐪佸緱縐誨姩鍚庤鏀瑰姩Link鏂囦歡閲岀殑緇濆璺緞鑰岃垂蹇冭垂鍔涖傜洿鎺ユ嫹璐濊繃鍘誨氨鍙互浣跨敤銆?
鍗砐YZ.link鏂囦歡鐨勫唴瀹瑰鏄細(xì)path=../PlugInsNew/XYZ
榪欐牱錛屽鏋滀綘涓嬭澆浜嗗涓彃浠跺氨鍙互濡傛硶鐐埗寤虹珛澶氫釜Link鏂囦歡錛屾兂鍔犺澆鍝釜鎻掍歡灝辨妸鍝釜鎻掍歡鐨凩ink鏂囦歡鏀懼埌%ECLIPSE_HOME%\links鐨勭洰褰曚腑鍗沖彲錛屼嬌鐢ㄤ笌綆$悊閮藉緢鏂逛究錛屽緩璁崈涓囦笉瑕佹斁鍦ㄩ粯璁ょ殑瀹夎鐩綍涓紱
濡傛灉浣犵殑%ECLIPSE_HOME%涓庢涓嶅悓錛岃淇敼XYZ.link鏂囦歡閲岀殑璺緞
鍒犻櫎%ECLIPSE_HOME%\links\XYZ.link鏂囦歡鍗沖彲
鍒犻櫎%ECLIPSE_HOME%\PlugInsNew\XYZ鏁翠釜鐩綍鍙婃枃浠?/p>
浣跨敤
閲嶆柊鍚姩Eclipse鍚庯紝鍦℉elp => About Eclipse SDK => Plug-in Details浣犲彲浠ョ湅鍒扮敱鈥淔indBugs Project鈥濇彁渚涚殑鈥淔indBugs Plug-in鈥濈増鏈?.0.17鎻掍歡錛屽涓嬪浘鎵紺猴細(xì)
FindBugs鐨勪嬌鐢ㄦ柟娉?/b>
FindBugs鏄竴涓彲浠ュ湪Java紼嬪簭涓彂鐜癇ugs鐨勭▼搴忋?
瀹冩槸涓撻棬鐢ㄦ潵瀵繪壘澶勪簬鈥淏ug Patterns鈥濆垪琛ㄤ腑鐨勪唬鐮佺殑銆?
Bug Patterns鎸囧緢鏈夊彲鑳芥槸閿欒鐨勪唬鐮佺殑瀹炰緥銆?/p>
鐩墠FindBugs鏈楂樼増鏈?.9.4錛屼笉榪囨洿鏂伴熷害寰堝揩鐨勶紝浣犲簲褰撶粡甯鎬笂鍘葷湅鐪嬫槸鍚︽湁鏂扮増鏈彂甯冦侲clipse plugin for FindBugs鏈楂樼増鏈?.0.17銆?/p>
緋葷粺瑕佹眰
浣跨敤FindBugs鑷沖皯闇瑕丣DK1.4.0浠ヤ笂鐗堟湰錛孎indBugs鏄鉤鍙扮嫭绔嬬殑錛屽彲浠ヨ繍琛屼簬GNU/Linux銆乄indows銆丮acOS X絳夊鉤鍙頒笂銆?/p>
榪愯FindBugs鑷沖皯闇瑕佹湁256 MB鍐呭瓨錛屽鏋滀綘瑕佸垎鏋愪竴涓緢澶х殑欏圭洰錛岄偅灝遍渶瑕佹洿鍔犲鐨勫唴瀛樹簡銆?/p>
FindBugs鐙珛榪愯鍜屼笌Ant緇撳悎鐨勮緇嗘搷浣滃氨涓嶄粙緇嶄簡錛屽彲浠ョ湅瀹樻柟鐨勬枃妗ttp://findbugs.sourceforge.net/manual/
鐙珛榪愯鐨勬晥鏋滃浘濡備笅錛?/p>
鎵撳紑Bug Details瑙嗗浘
Windows => Show View => Other鈥?=> FindBugs => BugDetails
鍦≒ackage Explorer鎴朜avigator瑙嗗浘涓紝閫変腑浣犵殑Java欏圭洰錛屽彸閿紝鍙互鐪嬪埌鈥淔ind Bugs鈥濊彍鍗曢」錛屽瓙鑿滃崟欏歸噷鏈夆淔ind Bugs鈥濆拰鈥淐lear Bug Markers鈥濅袱欏瑰唴瀹癸紝濡備笅鍥炬墍紺猴細(xì)
鎴戜滑寤虹珛涓涓畝鍗曠殑嫻嬭瘯鏂囦歡Test.java 鍐呭濡備笅錛?
public class Test { private String[] name; public String[] getName() { return name; } public void setName(String[] name) { this.name = name; } }
鎴戜滑鐐逛腑鈥淔ind Bugs鈥濓紝榪愯鏃朵細(xì)鍑虹幇濡備笅榪涘害妗嗭細(xì)
榪愯緇撴潫鍚庡彲浠ュ湪Problems涓湅鍒板鍔犱簡濡備笅鐨勮鍛婁俊鎭唴瀹?/p>
FindBugs榪愯鍚庣殑璀﹀憡淇℃伅鍐呭涓嶄粎鍦≒roblems瑙嗗浘涓樉紺猴紝鑰屼笖灝嗘爣璁板湪婧愪唬鐮佹爣璁版涓紝鍦ㄦ簮浠g爜緙栬緫鍣ㄤ腑鎴戜滑鍙互鐪嬪埌璀﹀憡鏍囪瘑錛屽涓嬪浘錛?
褰撳厜鏍囨寚鍚戜綘鐨勮鍛婁俊鎭殑浠g爜涓婇潰鏃訛紝灝變細(xì)鏈夌浉搴旂殑閿欒鎻愮ず淇℃伅錛屼笌Eclipse鏈韓鐨勯敊璇垨璀﹀憡淇℃伅鎻愮ず綾諱技銆?
閫変腑Problems瑙嗗浘閲屽嚭鐜扮殑鐩稿簲闂錛屽氨浼?xì)鍦ㄤ唬鐮伨~栬緫鍣ㄩ噷鍒囨崲鍒扮浉搴旂殑浠g爜涓婂幓錛屾柟渚挎牴鎹浉搴旂殑鎻愮ず淇℃伅榪涜浠g爜鐨勪慨鏀廣?
鍦≒roblems瑙嗗浘閲岋紝閫変腑鐩稿簲鐨勯棶棰樻潯鐩紝鍙抽敭錛屽湪寮瑰嚭鐨勮彍鍗曚腑錛屽彲浠ョ湅鍒扳淪how Bug Details鈥濓紝濡備笅鍥炬墍紺猴細(xì)
鐐逛腑瀹冿紝浼?xì)鍒囨崲鍒癇ug Details瑙嗗浘涓婂幓錛屾樉紺烘洿鍔犺緇嗙殑鎻愮ず淇℃伅銆?/p>
褰撶劧錛屽湪浠g爜緙栬緫紿楀彛涓紝鐐瑰嚮甯︽湁璀﹀憡鎻愮ず淇℃伅鐨勫浘鏍囨椂錛屼篃浼?xì)鑷姩鍒囨崲鍒癇ud Details紿楀彛鍘伙紝鏌ョ湅璇︾粏鐨勮鍛婁俊鎭紝濡備笅鍥炬墍紺恒?/p>
鏍規(guī)嵁榪欓噷璇︾粏鐨勪俊鎭紝浣犲彲浠ュ緱鍒癋indBugs涓轟粈涔堜細(xì)瀵逛綘鐨勪唬鐮佹姤璀﹀憡淇℃伅錛屽強鐩稿簲鐨勫鐞嗗姙娉曪紝鏍規(guī)嵁瀹冪殑鎻愮ず錛屼綘鍙互蹇熸柟渚垮湴榪涜浠g爜淇敼銆?/p>
鏍規(guī)嵁鎻愮ず錛屾垜浠皢浠g爜淇敼鎴愬涓嬶紝鍐嶈繍琛屽氨涓嶄細(xì)鎶ユ湁璀﹀憡淇℃伅浜嗐?/p>
public class Test { private String[] name; public String[] getName() { String[] temp = name; return temp; } public void setName(String[] name) { String[] temp = name; this.name = temp; } } 閰嶇疆FindBugs
閫夋嫨浣犵殑欏圭洰錛屽彸閿?=> Properties => FindBugs =>
鍙互閰嶇疆鐨勪俊鎭寘鎷涓婂浘鎵紺虹殑鍥涗釜閫夐」鐨勭浉鍏寵緗細(xì)
褰撴欏歸変腑鍚庯紝FindBugs灝嗕細(xì)鍦ㄤ綘淇敼Java綾繪椂鑷姩榪愯錛屽浣犺緗簡Eclipse鑷姩緙栬瘧寮鍏沖悗錛屽綋浣犱慨鏀瑰畬Java鏂囦歡淇濆瓨錛孎indBugs灝變細(xì)榪愯錛屽茍灝嗙浉搴旂殑淇℃伅鏄劇ず鍑烘潵銆?
褰撴欏規(guī)病鏈夐変腑錛屼綘鍙兘姣忔鍦ㄩ渶瑕佺殑鏃跺欒嚜宸卞幓榪愯FindBugs鏉ユ鏌ヤ綘鐨勪唬鐮併?
榪欎釜閫夋嫨欏規(guī)槸璁╀綘閫夋嫨鍝釜綰у埆鐨勪俊鎭繘琛屾樉紺猴紝鏈塋ow銆丮edium銆丠igh涓変釜閫夋嫨欏瑰彲浠ラ夋嫨錛屽緢綾諱技浜嶭og4J鐨勭駭鍒緗暒銆?姣斿錛?
浣犻夋嫨浜咹igh閫夋嫨欏癸紝閭d箞鍙湁鏄疕igh綰у埆鐨勬彁紺轟俊鎭墠浼?xì)琚槃·恒?
浣犻夋嫨浜哅edium閫夋嫨欏癸紝閭d箞鍙湁鏄疢edium鍜孒igh綰у埆鐨勬彁紺轟俊鎭墠浼?xì)琚槃·恒?
浣犻夋嫨浜哃ow閫夋嫨欏癸紝閭d箞鎵鏈夌駭鍒殑鎻愮ず淇℃伅閮戒細(xì)琚樉紺恒?/p>
鍦ㄨ繖閲屾槸涓浜涙樉紺築ug鍒嗙被鐨勯夋嫨錛?
Correctness鍏充簬浠g爜姝g‘鎬х浉鍏蟲柟闈㈢殑
Performance鍏充簬浠g爜鎬ц兘鐩稿叧鏂歸潰鐨?
Internationalization鍏充簬浠g爜鍥介檯鍖栫浉鍏蟲柟闈㈢殑
Multithreaded correctness鍏充簬浠g爜澶氱嚎紼嬫紜х浉鍏蟲柟闈㈢殑
Style鍏充簬浠g爜鏍峰紡鐩稿叧鏂歸潰鐨?/p>
Malicious code vulnerability鍏充簬鎭舵剰鐮村潖浠g爜鐩稿叧鏂歸潰鐨?
姣斿錛氬鏋滀綘鎶奡tyle鐨勬鏌ユ鍘繪帀涓嶉夋嫨涓畠錛岄偅涔堜笌Style鍒嗙被鐩稿叧鐨勮鍛婁俊鎭氨涓嶄細(xì)鏄劇ず浜嗐傚叾瀹冪殑綾諱技銆?/p>
鍦ㄨ繖閲屼綘鍙互閫夋嫨鎵瑕佽繘琛屾鏌ョ殑鐩稿叧鐨凚ug Pattern鏉$洰
鍙互浠嶣ug codes銆丏etector name銆丏etector description涓湅鍒扮浉搴旂殑鏄媯鏌ュ摢浜涙柟闈㈢殑鍐呭錛屼綘鍙互鏍規(guī)嵁闇瑕侀夋嫨鎴栧幓鎺夌浉搴旂殑 媯鏌ユ潯浠躲?
鎬葷粨
姝ゆ彃浠剁殑鍔熻兘寰堜笉閿欙紝鍙互甯姪鎴戜滑鎻愬崌Java浠g爜鐨勭紪鍐欒兘鍔涳紝鍐欏嚭鏇村姞瀹夊叏鍙潬鐨勪唬鐮併傚緩璁嬌鐢ㄦ垨鍔犲湪Ant閲岃繘琛屾寔緇瀯寤恒傜幇鍦紝浣犲彲浠ラ┈涓婃嬁鍑轟綘宸茬粡寮鍙戠殑涓涓」鐩紝媯鏌ヤ竴涓嬩綘鐨勪唬鐮佹湁娌℃湁闂浜嗐?/p>