Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed some deprecations/warnings #3314

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ private <T> void sleepWhile(Predicate<T> test, Provider<T> input, long timeOutIn
}

@Test public void testInferredMethodRenamed() throws Exception {
XtendFunction fooMethod = (XtendFunction) ((XtendClass)testHelper.xtendFile("Foo", "class Foo { def Foo foo() {this} }")
.getXtendTypes().get(0)).getMembers().get(0);
XtendFunction fooMethod = (XtendFunction) testHelper.xtendFile("Foo", "class Foo { def Foo foo() {this} }")
.getXtendTypes().get(0).getMembers().get(0);
IRenameStrategy renameStrategy = createRenameStrategy(fooMethod);
renameStrategy.applyDeclarationChange("bar", fooMethod.eResource().getResourceSet());
assertEquals("bar", fooMethod.getName());
Expand All @@ -146,8 +146,8 @@ private <T> void sleepWhile(Predicate<T> test, Provider<T> input, long timeOutIn
}

@Test public void testXtendConstructorIgnored() throws Exception {
XtendConstructor constructor = (XtendConstructor) ((XtendClass)testHelper.xtendFile("Foo", "class Foo { new() {} }")
.getXtendTypes().get(0)).getMembers().get(0);
XtendConstructor constructor = (XtendConstructor) testHelper.xtendFile("Foo", "class Foo { new() {} }")
.getXtendTypes().get(0).getMembers().get(0);
IRenameStrategy renameStrategy = createRenameStrategy(constructor);
assertNull(renameStrategy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ public static void makeCompliantFor(IJavaProject javaProject, JavaVersion javaVe
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, jreLevel);
options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED);
options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public static void makeJava8Compliant(IJavaProject javaProject) {
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED);
options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public static void makeJava8Compliant(IJavaProject javaProject) {
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED);
options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Change combineChanges(Change masterChange) {
visitCompositeChange((CompositeChange) masterChange, resource2textChange, otherChanges, editorsToSave);
CompositeChange compositeChange = new FilteringCompositeChange(masterChange.getName());
for (TextChange combinedTextChange : resource2textChange.values()) {
if(((MultiTextEdit) combinedTextChange.getEdit()).getChildrenSize() >0) {
if(combinedTextChange.getEdit().getChildrenSize() >0) {
if(combinedTextChange instanceof EditorDocumentChange) {
((EditorDocumentChange) combinedTextChange).setDoSave(editorsToSave.contains(((EditorDocumentChange) combinedTextChange).getEditor()));
compositeChange.add(combinedTextChange);
Expand Down Expand Up @@ -94,7 +94,7 @@ else if (sourceChange instanceof CompositeChange) {
MultiTextEdit combinedEdits = (MultiTextEdit) textChange.getEdit();
TextEdit newEdit = ((TextChange) sourceChange).getEdit().copy();
if (newEdit instanceof MultiTextEdit) {
for (TextEdit newTextEdit : ((MultiTextEdit) newEdit).getChildren()) {
for (TextEdit newTextEdit : newEdit.getChildren()) {
addIfNotDuplicate(combinedEdits, newTextEdit);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/**
* @author Sebastian Zarnekow - Initial contribution and API
*/
@SuppressWarnings("deprecation")
public class DummyTextViewer implements ITextViewer, ISelectionProvider {

private final ISelection selection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected void updateViewerInput() {
TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
Template template= data.getTemplate();
String name = template.getName();
TemplateContextType contextType = ((ContextTypeRegistry)getContextTypeRegistry()).getContextType(template.getContextTypeId());
TemplateContextType contextType = getContextTypeRegistry().getContextType(template.getContextTypeId());
if (contextType != null) {
String prefix =
"templates for " + grammarAccess.getGrammar().getName() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean
fIsNameModifiable= isNameModifiable;

List<String[]> contexts= Lists.newArrayList();
for (Iterator<TemplateContextType> it= Iterators.filter(((ContextTypeRegistry)registry).contextTypes(), TemplateContextType.class); it.hasNext();) {
for (Iterator<TemplateContextType> it= Iterators.filter(registry.contextTypes(), TemplateContextType.class); it.hasNext();) {
TemplateContextType type= it.next();
contexts.add(new String[] { type.getId(), type.getName() });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ public static void makeJava5Compliant(IJavaProject javaProject) {
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED);
options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE);
Expand All @@ -432,7 +431,6 @@ public static void makeJava8Compliant(IJavaProject javaProject) {
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED);
options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_LINE_NUMBER_ATTR, JavaCore.GENERATE);
options.put(JavaCore.COMPILER_SOURCE_FILE_ATTR, JavaCore.GENERATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected InputStream newTestGrammar() {
TextEdit edit = composer.endRecording();

assertTrue(edit instanceof MultiTextEdit);
TextEdit[] children = ((MultiTextEdit) edit).getChildren();
TextEdit[] children = edit.getChildren();
assertEquals(2, children.length);
assertMatches("'bar' | 'baz'", children[0]);
assertMatches("Bar: 'foo' ;", children[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testObjectReplacement() throws Exception {
TextEdit edit = composer.endRecording();

assertTrue(edit instanceof MultiTextEdit);
TextEdit[] children = ((MultiTextEdit) edit).getChildren();
TextEdit[] children = edit.getChildren();
assertEquals(2, children.length);
assertMatches("'bar' | 'baz'", children[0]);
assertMatches("Bar: 'foo';", children[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void setUp() throws Exception {
assertTrue(change1.getTextEdit() instanceof MultiTextEdit);
assertEquals(
3,
((MultiTextEdit) change0.getTextEdit()).getChildrenSize()
+ ((MultiTextEdit) change1.getTextEdit()).getChildrenSize());
change0.getTextEdit().getChildrenSize()
+ change1.getTextEdit().getChildrenSize());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ protected boolean isLikelyToBeValidProposal(INode lastCompleteNode, Iterable<Con
for (AbstractElement element: context.getFirstSetGrammarElements()) {
if (element instanceof Keyword) {
String keywordValue = ((Keyword) element).getValue();
String lastText = ((ILeafNode) lastCompleteNode).getText();
String lastText = lastCompleteNode.getText();
if (keywordValue.equals(lastText))
return true;
}
Expand Down Expand Up @@ -678,7 +678,7 @@ public String getPrefix(INode prefixNode) {
public String getNodeTextUpToCompletionOffset(INode currentNode) {
int startOffset = currentNode.getOffset();
int length = completionOffset - startOffset;
String nodeText = ((ILeafNode) currentNode).getText();
String nodeText = currentNode.getText();
String trimmedNodeText = length > nodeText.length() ? nodeText : nodeText.substring(0, length);
if (viewer.getDocument() != null /* testing */ && length >= 0) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected void setModel(XtextDocument document, String prefix, String editablePa
lock = new Object();
((ISynchronizable) document).setLockObject(lock);
}
((ISynchronizable) annotationModel).setLockObject(lock);
annotationModel.setLockObject(lock);
}
this.viewer.setDocument(document, annotationModel, prefix.length(), editablePart.length());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected void registerContextTypes(IGrammarAccess grammarAccess, Provider<Xtext
}
Collections.sort(allContextTypes);
for (XtextTemplateContextType templateContextType: allContextTypes) {
((ContextTypeRegistry) this).addContextType(templateContextType);
this.addContextType(templateContextType);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected static class EditorOpenerLabelProvider extends LabelProvider {

@Override
public Image getImage(Object element) {
return (Image) resourceManager.get(((FileOpener) element).getImageDescriptor());
return resourceManager.get(((FileOpener) element).getImageDescriptor());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public TreeVerificationBuilder hasChildren(int numChildren) {

public TreeVerificationBuilder child(int index) {
assertTrue("Index " + index + " out of bounds", currentFigure.getChildren().size() > index && index >= 0);
currentFigure = (IFigure) currentFigure.getChildren().get(index);
currentFigure = currentFigure.getChildren().get(index);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class GrammarTest extends AbstractXtextTests {
private AbstractRule checkConcreteImplRule(Grammar grammar, String ruleName) {
AbstractRule concreteRule = GrammarUtil.findRuleForName(grammar, ruleName);
assertNotNull(concreteRule);
EClassifier returnType = ((ParserRule)concreteRule).getType().getClassifier();
EClassifier returnType = concreteRule.getType().getClassifier();
String returnTypeName = getClassifierName(returnType);
assertEquals(ruleName, returnTypeName + "_Impl");
List<Assignment> assignments = GrammarUtil.containedAssignments(concreteRule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected Iterable<IResource> findResourcesContainingGenModels() {
@Override
public boolean visit(IResource resource) throws CoreException {
if (resource instanceof IFile) {
String fileExtension = ((IFile) resource).getFileExtension();
String fileExtension = resource.getFileExtension();
if ("genmodel".equals(fileExtension) || "xcore".equals(fileExtension)) {
filteredResources.add(resource);
}
Expand Down
Loading