当前位置: 首页>>代码示例>>Java>>正文


Java Assert.isTrue方法代码示例

本文整理汇总了Java中org.eclipse.core.runtime.Assert.isTrue方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.isTrue方法的具体用法?Java Assert.isTrue怎么用?Java Assert.isTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.runtime.Assert的用法示例。


在下文中一共展示了Assert.isTrue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rewriteAST

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel positionGroups) throws CoreException {
	final ASTRewrite rewrite = cuRewrite.getASTRewrite();
	VariableDeclarationFragment fragment = null;
	for (int i = 0; i < fNodes.length; i++) {
		final ASTNode node = fNodes[i];

		final AST ast = node.getAST();

		fragment = ast.newVariableDeclarationFragment();
		fragment.setName(ast.newSimpleName(NAME_FIELD));

		final FieldDeclaration declaration = ast.newFieldDeclaration(fragment);
		declaration.setType(ast.newPrimitiveType(PrimitiveType.LONG));
		declaration.modifiers().addAll(ASTNodeFactory.newModifiers(ast, Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL));

		if (!addInitializer(fragment, node)) {
			continue;
		}

		if (fragment.getInitializer() != null) {

			final TextEditGroup editGroup = createTextEditGroup(FixMessages.SerialVersion_group_description, cuRewrite);
			if (node instanceof AbstractTypeDeclaration) {
				rewrite.getListRewrite(node, ((AbstractTypeDeclaration) node).getBodyDeclarationsProperty()).insertAt(declaration, 0, editGroup);
			} else if (node instanceof AnonymousClassDeclaration) {
				rewrite.getListRewrite(node, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY).insertAt(declaration, 0, editGroup);
			} else if (node instanceof ParameterizedType) {
				final ParameterizedType type = (ParameterizedType) node;
				final ASTNode parent = type.getParent();
				if (parent instanceof ClassInstanceCreation) {
					final ClassInstanceCreation creation = (ClassInstanceCreation) parent;
					final AnonymousClassDeclaration anonymous = creation.getAnonymousClassDeclaration();
					if (anonymous != null) {
						rewrite.getListRewrite(anonymous, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY).insertAt(declaration, 0, editGroup);
					}
				}
			} else {
				Assert.isTrue(false);
			}

			addLinkedPositions(rewrite, fragment, positionGroups);
		}

		final String comment = CodeGeneration.getFieldComment(fUnit, declaration.getType().toString(), NAME_FIELD, "\n" /* StubUtility.getLineDelimiterUsed(fUnit) */);
		if (comment != null && comment.length() > 0 && !"/**\n *\n */\n".equals(comment)) {
			final Javadoc doc = (Javadoc) rewrite.createStringPlaceholder(comment, ASTNode.JAVADOC);
			declaration.setJavadoc(doc);
		}
	}
	if (fragment == null) {
		return;
	}

	positionGroups.setEndPosition(rewrite.track(fragment));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:57,代码来源:AbstractSerialVersionOperation.java

示例2: HydrographCompletionProposal

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
public HydrographCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition,
        Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
    Assert.isNotNull(replacementString);
    Assert.isTrue(replacementOffset >= 0);
    Assert.isTrue(replacementLength >= 0);
    Assert.isTrue(cursorPosition >= 0);

    fReplacementString = replacementString;
    fReplacementOffset = replacementOffset;
    fReplacementLength = replacementLength;
    fCursorPosition = cursorPosition;
    fImage = image;
    fDisplayString = displayString;
    fContextInformation = contextInformation;
    fAdditionalProposalInfo = additionalProposalInfo;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:HydrographCompletionProposal.java

示例3: addBreakpointToMap

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
private void addBreakpointToMap(IBreakpoint breakpoint) throws CoreException {
	Assert.isTrue(supportsBreakpoint(breakpoint) && breakpoint instanceof ILineBreakpoint);
	if (breakpoint instanceof ILineBreakpoint) {
		ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
		IResource resource = lineBreakpoint.getMarker().getResource();
		IPath location = resource.getLocation();
		String path = location.toOSString();
		String name = location.lastSegment();
		int lineNumber = lineBreakpoint.getLineNumber();

		Source source = new Source().setName(name).setPath(path);

		List<SourceBreakpoint> sourceBreakpoints = targetBreakpoints.computeIfAbsent(source,
				s -> new ArrayList<>());
		sourceBreakpoints.add(new SourceBreakpoint().setLine(lineNumber));
	}
}
 
开发者ID:tracymiranda,项目名称:dsp4e,代码行数:18,代码来源:DSPDebugTarget.java

示例4: deleteBreakpointFromMap

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
private void deleteBreakpointFromMap(IBreakpoint breakpoint) throws CoreException {
	Assert.isTrue(supportsBreakpoint(breakpoint) && breakpoint instanceof ILineBreakpoint);
	if (breakpoint instanceof ILineBreakpoint) {
		ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
		IResource resource = lineBreakpoint.getMarker().getResource();
		IPath location = resource.getLocation();
		String path = location.toOSString();
		String name = location.lastSegment();
		int lineNumber = lineBreakpoint.getLineNumber();
		for (Entry<Source, List<SourceBreakpoint>> entry : targetBreakpoints.entrySet()) {
			Source source = entry.getKey();
			if (Objects.equals(name, source.name) && Objects.equals(path, source.path)) {
				List<SourceBreakpoint> bps = entry.getValue();
				for (Iterator<SourceBreakpoint> iterator = bps.iterator(); iterator.hasNext();) {
					SourceBreakpoint sourceBreakpoint = (SourceBreakpoint) iterator.next();
					if (Objects.equals(lineNumber, sourceBreakpoint.line)) {
						iterator.remove();
					}
				}
			}
		}
	}
}
 
开发者ID:tracymiranda,项目名称:dsp4e,代码行数:24,代码来源:DSPDebugTarget.java

示例5: handleCoreException

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
 * Handles a core exception thrown during a testing environment operation
 */
private void handleCoreException(CoreException e) {
  e.printStackTrace();
  IStatus status = e.getStatus();
  String message = e.getMessage();
  if (status.isMultiStatus()) {
    MultiStatus multiStatus = (MultiStatus) status;
    IStatus[] children = multiStatus.getChildren();
    StringBuffer buffer = new StringBuffer();
    for (int i = 0, max = children.length; i < max; i++) {
      IStatus child = children[i];
      if (child != null) {
        buffer.append(child.getMessage());
        buffer.append(System.getProperty("line.separator"));//$NON-NLS-1$
        Throwable childException = child.getException();
        if (childException != null) {
          childException.printStackTrace();
        }
      }
    }
    message = buffer.toString();
  }
  Assert.isTrue(false, "Core exception in testing environment: " + message); //$NON-NLS-1$
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:27,代码来源:TestingEnvironment.java

示例6: duplicatePressed

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
 * Notifies that the Add button has been pressed.
 */
private void duplicatePressed() {
        setPresentsDefaultValue(false);
        int index = table.getSelectionIndex();
        int target = index + 1;

        if (index >= 0) {
                TableItem[] selection = table.getSelection();
                Assert.isTrue(selection.length == 1);
                String[] values = new String[columnNames.length];
                for (int j = 0; j < columnNames.length; j++) {
                        values[j] = selection[0].getText(j);
                }
                TableItem tableItem = new TableItem(table, SWT.NONE, target);
                tableItem.setText(values);
                table.setSelection(target);
        }
        selectionChanged();
}
 
开发者ID:ncleclipse,项目名称:ncl30-eclipse,代码行数:22,代码来源:TableFieldEditor.java

示例7: getRun

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
 * Returns a run based on a character.
 *
 * @param ch
 *            the character to test
 * @return the correct character given <code>ch</code>
 */
private Run getRun(char ch) {
	Run run;
	if (WHITESPACE.isValid(ch)) {
		run = WHITESPACE;
	} else if (DELIMITER.isValid(ch)) {
		run = DELIMITER;
	} else if (CAMELCASE.isValid(ch)) {
		run = CAMELCASE;
	} else if (OTHER.isValid(ch)) {
		run = OTHER;
	} else {
		Assert.isTrue(false);
		return null;
	}

	run.init();
	return run;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:JavaBreakIterator.java

示例8: getType

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
 * Returns the type node for the given declaration.
 *
 * @param declaration the declaration
 * @return the type node or <code>null</code> if the given declaration represents a type
 *         inferred parameter in lambda expression
 */
public static Type getType(VariableDeclaration declaration) {
	if (declaration instanceof SingleVariableDeclaration) {
		return ((SingleVariableDeclaration)declaration).getType();
	} else if (declaration instanceof VariableDeclarationFragment) {
		ASTNode parent= ((VariableDeclarationFragment)declaration).getParent();
		if (parent instanceof VariableDeclarationExpression) {
			return ((VariableDeclarationExpression)parent).getType();
		} else if (parent instanceof VariableDeclarationStatement) {
			return ((VariableDeclarationStatement)parent).getType();
		} else if (parent instanceof FieldDeclaration) {
			return ((FieldDeclaration)parent).getType();
		} else if (parent instanceof LambdaExpression) {
			return null;
		}
	}
	Assert.isTrue(false, "Unknown VariableDeclaration"); //$NON-NLS-1$
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:ASTNodes.java

示例9: isWhitespace

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
 * Returns <code>true</code> if the given sequence into the underlying text
 * represents whitespace, but not a delimiter, <code>false</code> otherwise.
 *
 * @param offset
 *            the offset
 * @param exclusiveEnd
 *            the end offset
 * @return <code>true</code> if the given range is whitespace
 */
private boolean isWhitespace(int offset, int exclusiveEnd) {
	if (exclusiveEnd == DONE || offset == DONE) {
		return false;
	}

	Assert.isTrue(offset >= 0);
	Assert.isTrue(exclusiveEnd <= getText().getEndIndex());
	Assert.isTrue(exclusiveEnd > offset);

	CharSequence seq = fIterator.fText;

	while (offset < exclusiveEnd) {
		char ch = seq.charAt(offset);
		if (!Character.isWhitespace(ch)) {
			return false;
		}
		if (ch == '\n' || ch == '\r') {
			return false;
		}
		offset++;
	}

	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:JavaWordIterator.java

示例10: storeRootFilename

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
    * Stores root file name in project preferences
    * @param project
    * @param rootFilename
    */
public static void storeRootFilename(IProject project, String rootFilename) {
	// If this condition does not hold, the subsequent code but also
	// AddModuleHandler will not work. The claim is that spec files are
	// always in the parent folder of the IProject.
	final IPath path = new Path(rootFilename);
	Assert.isTrue(ResourceHelper.isProjectParent(path.removeLastSegments(1), project),
			project.getLocation().toOSString() + " is *not* a subdirectory of " + rootFilename
					+ ". This is commonly caused by a symlink contained in the latter path.");
	// Store the filename *without* any path information, but prepend the
	// magical PARENT-1-PROJECT-LOC. It indicates that the file can be found
	// *one* level up (hence the "1") from the project location.
	// readProjectRootFile can later easily deduce the relative location of
	// the file.
	rootFilename = ResourceHelper.PARENT_ONE_PROJECT_LOC + path.lastSegment();
       IEclipsePreferences projectPrefs = getProjectPreferences(project);
       projectPrefs.put(IPreferenceConstants.P_PROJECT_ROOT_FILE, rootFilename);
       storePreferences(projectPrefs);        
   }
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:24,代码来源:PreferenceStoreHelper.java

示例11: suggestNewVariableName

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
public String suggestNewVariableName(String[] prefixes, String[] suffixes, String oldVariableName, String oldTypeName, String newTypeName) {

		Assert.isNotNull(prefixes);
		Assert.isNotNull(suffixes);
		Assert.isNotNull(oldVariableName);
		Assert.isNotNull(oldTypeName);
		Assert.isNotNull(newTypeName);
		Assert.isTrue(oldVariableName.length() > 0);
		Assert.isTrue(oldTypeName.length() > 0);
		Assert.isTrue(newTypeName.length() > 0);

		final String usedPrefix = findLongestPrefix(oldVariableName, prefixes);
		final String usedSuffix = findLongestSuffix(oldVariableName, suffixes);
		final String strippedVariableName = oldVariableName.substring(usedPrefix.length(), oldVariableName.length() - usedSuffix.length());

		String newVariableName = match(oldTypeName, newTypeName, strippedVariableName);
		return (newVariableName != null) ? usedPrefix + newVariableName + usedSuffix : null;
	}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:RenamingNameSuggestor.java

示例12: scanBackward

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
/**
 * Finds the highest position in <code>document</code> such that the position is &lt;=
 * <code>position</code> and &gt; <code>bound</code> and
 * <code>document.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
 * ch in <code>chars</code> and the position is in the default partition.
 *
 * @param document the document being modified
 * @param position the first character position in <code>document</code> to be considered
 * @param partitioning the document partitioning
 * @param bound the first position in <code>document</code> to not consider any more, with
 *            <code>scanTo</code> &gt; <code>position</code>
 * @param chars an array of <code>char</code> to search for
 * @return the highest position of one element in <code>chars</code> in (<code>bound</code>,
 *         <code>position</code>] that resides in a Java partition, or <code>-1</code> if none
 *         can be found
 */
private static int scanBackward(IDocument document, int position, String partitioning, int bound, char[] chars) {
	Assert.isTrue(bound >= -1);
	Assert.isTrue(position < document.getLength());

	Arrays.sort(chars);

	try {
		while (position > bound) {

			if (Arrays.binarySearch(chars, document.getChar(position)) >= 0
					&& isDefaultPartition(document, position, partitioning))
				return position;

			position--;
		}
	} catch (BadLocationException e) {}
	return -1;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:35,代码来源:SmartAutoEditStrategy.java

示例13: open

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public int open() {
	List<Object[]> selection = getInitialElementSelections();
	if (selection == null || selection.size() != fNumberOfPages) {
		setInitialSelections(new Object[fNumberOfPages]);
		selection = getInitialElementSelections();
	}

	Assert.isTrue(selection.size() == fNumberOfPages);

	return super.open();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:MultiElementListSelectionDialog.java

示例14: editorClosed

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
private void editorClosed(IEditorPart part) {
	if (part instanceof ITextEditor) {
		ICodeLensController controller = codeLensControllers.remove(part);
		if (controller != null) {
			controller.uninstall();
			Assert.isTrue(null == codeLensControllers.get(part),
					"An old ICodeLensController is not un-installed on Text Editor instance");
		}
	}
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:11,代码来源:EditorTracker.java

示例15: handle

import org.eclipse.core.runtime.Assert; //导入方法依赖的package包/类
void handle(Exception e) {
  if (e instanceof CoreException) {
    handleCoreException((CoreException) e);
  } else {
    e.printStackTrace();
    Assert.isTrue(false);
  }
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:9,代码来源:TestingEnvironment.java


注:本文中的org.eclipse.core.runtime.Assert.isTrue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。