本文整理了Java中org.eclipse.core.runtime.Assert.isTrue()
方法的一些代码示例,展示了Assert.isTrue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.isTrue()
方法的具体详情如下:
包路径:org.eclipse.core.runtime.Assert
类名称:Assert
方法名:isTrue
[英]Asserts that the given boolean is true
. If this is not the case, some kind of unchecked exception is thrown.
[中]断言给定的布尔值为true
。如果不是这样,则会引发某种未经检查的异常。
代码示例来源:origin: org.eclipse.core/runtime
private void assertInitialized() {
//avoid the Policy.bind if assertion is true
if (!initialized)
Assert.isTrue(false, Messages.meta_appNotInit);
}
代码示例来源:origin: org.eclipse.core/runtime
public Plugin(IPluginDescriptor descriptor) {
Assert.isNotNull(descriptor);
Assert.isTrue(!CompatibilityHelper.hasPluginObject(descriptor), NLS.bind(Messages.plugin_deactivatedLoad, this.getClass().getName(), descriptor.getUniqueIdentifier() + " is not activated")); //$NON-NLS-1$
this.descriptor = descriptor;
代码示例来源:origin: eclipse/eclipse.jdt.ls
/**
* Sets the granularity to use during the searches.
* <p>
* This method must be called before start searching. The default is a granularity of {@link #GRANULARITY_SEARCH_MATCH}.
*
* @param granularity The granularity to use. Must be one of the <code>GRANULARITY_XXX</code> constants.
*/
public final void setGranularity(final int granularity) {
Assert.isTrue(granularity == GRANULARITY_COMPILATION_UNIT || granularity == GRANULARITY_SEARCH_MATCH);
fGranularity= granularity;
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
public static void assertVisibility(int visibility){
Assert.isTrue( visibility == Modifier.PUBLIC ||
visibility == Modifier.PROTECTED ||
visibility == Modifier.NONE ||
visibility == Modifier.PRIVATE);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.core.resources
public Cache(int initialCapacity, int maximumCapacity, double threshold) {
Assert.isTrue(maximumCapacity >= initialCapacity, "maximum capacity < initial capacity"); //$NON-NLS-1$
Assert.isTrue(threshold >= 0 && threshold <= 1, "threshold should be between 0 and 1"); //$NON-NLS-1$
Assert.isTrue(initialCapacity > 0, "initial capacity must be greater than zero"); //$NON-NLS-1$
entries = new KeyedHashSet(initialCapacity);
this.maximumCapacity = maximumCapacity;
this.threshold = threshold;
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
public CopyResourceChange(IResource res, IContainer dest, INewNameQuery newNameQuery) {
Assert.isTrue(res instanceof IFile || res instanceof IFolder);
Assert.isTrue(dest instanceof IProject || dest instanceof IFolder);
fNewNameQuery= newNameQuery;
fSource= res;
fTarget= dest;
// Copy resource change isn't undoable and isn't used
// as a redo/undo change right now.
setValidationMethod(SAVE_IF_DIRTY);
}
代码示例来源:origin: org.eclipse.equinox/common
public IPath setDevice(String value) {
if (value != null) {
Assert.isTrue(value.indexOf(IPath.DEVICE_SEPARATOR) == (value.length() - 1), "Last character should be the device separator"); //$NON-NLS-1$
}
//return the receiver if the device is the same
if (value == device || (value != null && value.equals(device)))
return this;
return new Path(value, segments, separators);
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
protected ReplaceRewrite(ASTRewrite rewrite, ASTNode[] nodes) {
Assert.isNotNull(rewrite);
Assert.isNotNull(nodes);
Assert.isTrue(nodes.length > 0);
fRewrite= rewrite;
fToReplace= nodes;
fDescriptor= fToReplace[0].getLocationInParent();
if (nodes.length > 1) {
Assert.isTrue(fDescriptor instanceof ChildListPropertyDescriptor);
}
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
public String suggestNewMethodName(String oldMethodName, String oldTypeName, String newTypeName) {
Assert.isNotNull(oldMethodName);
Assert.isNotNull(oldTypeName);
Assert.isNotNull(newTypeName);
Assert.isTrue(oldMethodName.length() > 0);
Assert.isTrue(oldTypeName.length() > 0);
Assert.isTrue(newTypeName.length() > 0);
resetPrefixes();
return match(oldTypeName, newTypeName, oldMethodName);
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
private IResource getCommonResourceParent() {
Assert.isNotNull(fResources);
Assert.isTrue(fResources.length > 0);//safe - checked before
return fResources[0].getParent();
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
public GroupMemberFinder(InfixExpression groupRoot) {
super(true);
Assert.isTrue(isAssociativeInfix(groupRoot));
fGroupRoot = groupRoot;
fGroupRoot.accept(this);
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
private ChildListPropertyDescriptor getBodyDeclarationsProperty(ASTNode declaration) {
if (declaration instanceof AnonymousClassDeclaration) {
return AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY;
} else if (declaration instanceof AbstractTypeDeclaration) {
return ((AbstractTypeDeclaration) declaration).getBodyDeclarationsProperty();
}
Assert.isTrue(false);
return null;
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
public ChangeMethodSignatureProposal(String label, ICompilationUnit targetCU, ASTNode invocationNode,
IMethodBinding binding, ChangeDescription[] paramChanges, ChangeDescription[] exceptionChanges,
int relevance) {
super(label, CodeActionKind.QuickFix, targetCU, null, relevance);
Assert.isTrue(binding != null && Bindings.isDeclarationBinding(binding));
fInvocationNode= invocationNode;
fSenderBinding= binding;
fParameterChanges= paramChanges;
fExceptionChanges= exceptionChanges;
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
public static TypeReference createQualifiedReference(IJavaElement enclosingElement, int accuracy, int start, int length,
boolean insideDocComment, IResource resource, int simpleNameStart) {
Assert.isTrue(start < simpleNameStart && simpleNameStart < start + length);
return new TypeReference(enclosingElement, accuracy, start, length, insideDocComment, resource, simpleNameStart, null);
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
private static Change createDeleteChange(IResource resource) {
Assert.isTrue(! (resource instanceof IWorkspaceRoot));//cannot be done
Assert.isTrue(! (resource instanceof IProject)); //project deletion is handled by the workbench
return new DeleteResourceChange(resource.getFullPath(), true);
}
代码示例来源:origin: org.eclipse/org.eclipse.ui.workbench.texteditor
public void disconnect(IDocument document) {
Assert.isTrue(fRightDocument == document);
--fOpenConnections;
if (fOpenConnections == 0)
uninstall();
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
private static InfixExpression findGroupRoot(InfixExpression node) {
Assert.isTrue(isAssociativeInfix(node));
while (!isAGroupRoot(node)) {
ASTNode parent = node.getParent();
Assert.isNotNull(parent);
Assert.isTrue(isAssociativeInfix(parent));
Assert.isTrue(((InfixExpression) parent).getOperator() == node.getOperator());
node = (InfixExpression) parent;
}
return node;
}
代码示例来源:origin: org.eclipse/org.eclipse.ui.workbench.texteditor
public DocEquivalenceComparator(DocumentEquivalenceClass equivalenceClass, ILineRange range) {
fEquivalenceClass= equivalenceClass;
if (range == null) {
fLineOffset= 0;
fLines= fEquivalenceClass.getCount();
} else {
fLineOffset= range.getStartLine();
fLines= range.getNumberOfLines();
Assert.isTrue(fLineOffset >= 0);
Assert.isTrue(fLineOffset + fLines <= fEquivalenceClass.getCount());
}
}
代码示例来源:origin: eclipse/eclipse.jdt.ls
private boolean isMemberReferenceValidInClassInitialization(Name name) {
IBinding binding = name.resolveBinding();
Assert.isTrue(binding instanceof IVariableBinding || binding instanceof IMethodBinding);
if (name instanceof SimpleName) {
return Modifier.isStatic(binding.getModifiers());
} else {
Assert.isTrue(name instanceof QualifiedName);
return checkName(((QualifiedName) name).getQualifier());
}
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
@Override
public void documentAboutToBeChanged(DocumentEvent e) {
Assert.isTrue(e.getDocument() == fDocument);
fPreviousDocumentLength= e.getDocument().getLength();
fStartOffset= -1;
fEndOffset= -1;
fDeleteOffset= -1;
}
内容来源于网络,如有侵权,请联系作者删除!